Merge branch 'master' of https://github.com/lxsang/antos
This commit is contained in:
Xuan Sang LE 2018-03-07 10:57:05 +01:00
commit 5020fb4ecc
5 changed files with 63 additions and 18 deletions

View File

@ -76,7 +76,7 @@ self.OS.GUI =
_courrier.osfail "Cannot read service script: #{srv} ", e, s _courrier.osfail "Cannot read service script: #{srv} ", e, s
appsByMime: (mime) -> appsByMime: (mime) ->
metas = ( v for k, v of _OS.setting.system.packages when v.app ) metas = ( v for k, v of _OS.setting.system.packages when v and v.app )
mimes = ( m.mimes for m in metas when m) mimes = ( m.mimes for m in metas when m)
apps = [] apps = []
# search app by mimes # search app by mimes
@ -95,7 +95,7 @@ self.OS.GUI =
appsWithServices: () -> appsWithServices: () ->
o = {} o = {}
o[k] = v for k, v of _OS.setting.system.packages when v.services and v.services.length > 0 o[k] = v for k, v of _OS.setting.system.packages when v and v.services and v.services.length > 0
o o
openWith: (it) -> openWith: (it) ->

View File

@ -8,12 +8,16 @@
<span if={data.shortcut} class = "shortcut">{data.shortcut}</span> <span if={data.shortcut} class = "shortcut">{data.shortcut}</span>
</a> </a>
<afx-menu if={data.child != null && data.child.length > 0} child={data.child} onmenuselect = {data.onmenuselect} observable = {parent.root.observable} rootid = {parent.rid}></afx-menu> <afx-menu ref = "submenus" index = {i} if={data.child != null && data.child.length > 0} child={data.child} onmenuselect = {data.onmenuselect} observable = {parent.root.observable} rootid = {parent.rid}></afx-menu>
</li> </li>
<li class="afx-corner-fix"></li> <li class="afx-corner-fix"></li>
</ul> </ul>
<script> <script>
this.items = opts.child || [] this.items = opts.child || []
if(opts.index != undefined)
this.index = opts.index
else
this.index = -1
var isRoot var isRoot
var lastChecked = undefined var lastChecked = undefined
if(opts.rootid) if(opts.rootid)
@ -48,6 +52,7 @@
self[k] = v self[k] = v
self.update() self.update()
} }
self.root.push = function(e,u) self.root.push = function(e,u)
{ {
self.items.push(e) self.items.push(e)

View File

@ -150,6 +150,13 @@ class Blogger extends this.OS.GUI.BaseApplication
doc.replaceSelection "![](#{me._api.handler.shared}/#{r.result})" doc.replaceSelection "![](#{me._api.handler.shared}/#{r.result})"
, "Select image file", { mimes: ["image/.*"] } , "Select image file", { mimes: ["image/.*"] }
}, },
{
name:"Youtube",
className: "fa fa-youtube",
action: (e) ->
doc = me.editor.codemirror.getDoc()
doc.replaceSelection "[[youtube:]]"
}
"|", "|",
{ {
name: "preview", name: "preview",
@ -179,7 +186,10 @@ class Blogger extends this.OS.GUI.BaseApplication
, "Delete a post" , , "Delete a post" ,
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete this post ?" } { iconclass: "fa fa-question-circle", text: "Do you really want to delete this post ?" }
return false return false
@bindKey "CTRL-S", () ->
sel = me.tabbar.get "selidx"
return unless sel is 2
me.saveBlog()
@on "vboxchange", () -> @on "vboxchange", () ->
me.resizeContent() me.resizeContent()
# USER TAB # USER TAB

View File

@ -9,18 +9,54 @@ class RepositoryDialog extends this.OS.GUI.BaseDialog
main: () -> main: () ->
me = @ me = @
@list = @find "repo-list" @list = @find "repo-list"
ls = ({ text: v.name, iconclass: "fa fa-link", url: v.url @list.set "onlistdbclick", (e) ->
} for v in @systemsetting.system.repositories) selidx = me.list.get "selidx"
@url = @find "repo-url" return unless selidx >= 0
@list.set "onlistselect", (e) -> sel = me.systemsetting.system.repositories[selidx]
($ me.url).html e.data.url me.openDialog "PromptDialog", (e) ->
@list.set "items", ls m = e.match /\[([^\]]*)\]\s*(.*)/
return me.error "Wrong format: it should be [name] url" if not m or m.length isnt 3
sel.name = m[1]
sel.text = sel.name
sel.url = m[2]
me.refreshList()
, "Edit repository", { label: "Format : [name]url", value: "[#{e.data.text}] #{e.data.url}" }
(@find "btadd").set "onbtclick", (e) ->
me.openDialog "PromptDialog", (e) ->
m = e.match /\[([^\]]*)\]\s*(.*)/
return me.error "Wrong format: it should be [name] url" if not m or m.length isnt 3
me.systemsetting.system.repositories.push {
name: m[1],
url: m[2],
text: m[1],
i: me.systemsetting.system.repositories.length
}
me.refreshList()
, "Add repository", { label: "Format : [name]url" }
(@find "btdel").set "onbtclick", (e) ->
selidx = me.list.get "selidx"
return unless selidx >= 0
me.systemsetting.system.repositories.splice selidx, selidx
me.refreshList()
(@find "btquit").set "onbtclick", (e) -> me.quit()
@refreshList()
refreshList: () ->
ls = ({
text: v.name,
iconclass: "fa fa-link",
url: v.url,
complex: true,
detail: [{ text: v.url }]
} for v in @systemsetting.system.repositories)
@list.set "items", ls
onexit: (e) ->
@parent.repo.set "items", @systemsetting.system.repositories
@parent.dialog = undefined if @parent
RepositoryDialog.scheme = """ RepositoryDialog.scheme = """
<afx-app-window data-id = "repository-dialog-win" apptitle="Repositories" width="250" height="250"> <afx-app-window data-id = "repository-dialog-win" apptitle="Repositories" width="250" height="250">
<afx-vbox > <afx-vbox >
<afx-list-view data-id="repo-list"></afx-list-view> <afx-list-view data-id="repo-list"></afx-list-view>
<div data-id="repo-url" data-height="grow"></div>
<afx-hbox data-height = "30"> <afx-hbox data-height = "30">
<afx-button data-id = "btadd" text = "[+]" data-width="30"></afx-button> <afx-button data-id = "btadd" text = "[+]" data-width="30"></afx-button>
<afx-button data-id = "btdel" text = "[-]" data-width="30"></afx-button> <afx-button data-id = "btdel" text = "[-]" data-width="30"></afx-button>

View File

@ -7,12 +7,6 @@ class MarketPlace extends this.OS.GUI.BaseApplication
me = @ me = @
@installdir = @systemsetting.system.pkgpaths.user @installdir = @systemsetting.system.pkgpaths.user
# test repository # test repository
@systemsetting.system.repositories.push {
text: "Antos repository"
url: "https://os.localhost:9195/repo/packages.json"
name: "Antos repository"
selected:true
} if @systemsetting.system.repositories.length is 0
@repo = @find "repo" @repo = @find "repo"
@repo.set "onlistselect", (e) -> @repo.set "onlistselect", (e) ->
return unless e.data return unless e.data
@ -128,7 +122,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
(d) -> (d) ->
return unless d return unless d
app.path.asFileHandler().remove (r) -> app.path.asFileHandler().remove (r) ->
me.error "Cannot uninstall package: #{r.error}" if r.error return me.error "Cannot uninstall package: #{r.error}" if r.error
me.notify "Package uninstalled" me.notify "Package uninstalled"
me.systemsetting.system.packages[name] = undefined me.systemsetting.system.packages[name] = undefined
me._gui.refreshSystemMenu() me._gui.refreshSystemMenu()