mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-17 14:29:56 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
a9c3be2d75 | |||
5020fb4ecc | |||
241b8caa6b | |||
8e02bf6dc7 | |||
946bf9df5e | |||
d8b8037b3e | |||
d9bd567271 | |||
8ae2f529f7 | |||
88a78c7eef |
@ -76,7 +76,7 @@ self.OS.GUI =
|
||||
_courrier.osfail "Cannot read service script: #{srv} ", e, s
|
||||
|
||||
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)
|
||||
apps = []
|
||||
# search app by mimes
|
||||
@ -95,7 +95,7 @@ self.OS.GUI =
|
||||
|
||||
appsWithServices: () ->
|
||||
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
|
||||
|
||||
openWith: (it) ->
|
||||
|
@ -8,12 +8,16 @@
|
||||
<span if={data.shortcut} class = "shortcut">{data.shortcut}</span>
|
||||
</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 class="afx-corner-fix"></li>
|
||||
</ul>
|
||||
<script>
|
||||
this.items = opts.child || []
|
||||
if(opts.index != undefined)
|
||||
this.index = opts.index
|
||||
else
|
||||
this.index = -1
|
||||
var isRoot
|
||||
var lastChecked = undefined
|
||||
if(opts.rootid)
|
||||
@ -48,6 +52,7 @@
|
||||
self[k] = v
|
||||
self.update()
|
||||
}
|
||||
|
||||
self.root.push = function(e,u)
|
||||
{
|
||||
self.items.push(e)
|
||||
|
@ -150,6 +150,13 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
doc.replaceSelection ""
|
||||
, "Select image file", { mimes: ["image/.*"] }
|
||||
},
|
||||
{
|
||||
name:"Youtube",
|
||||
className: "fa fa-youtube",
|
||||
action: (e) ->
|
||||
doc = me.editor.codemirror.getDoc()
|
||||
doc.replaceSelection "[[youtube:]]"
|
||||
}
|
||||
"|",
|
||||
{
|
||||
name: "preview",
|
||||
@ -162,9 +169,11 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
@bloglist.set "onlistselect", (e) ->
|
||||
sel = me.bloglist.get "selected"
|
||||
return unless sel
|
||||
me.editor.value atob(sel.content)
|
||||
me.inputtags.value = sel.tags
|
||||
(me.find "blog-publish").set "swon", (if Number(sel.publish) then true else false)
|
||||
me.blogdb.get Number(sel.id), (r) ->
|
||||
me.error "Cannot fetch the entry content" if r.error
|
||||
me.editor.value atob(r.result.content)
|
||||
me.inputtags.value = r.result.tags
|
||||
(me.find "blog-publish").set "swon", (if Number(r.result.publish) then true else false)
|
||||
|
||||
@.bloglist.set "onitemclose", (e) ->
|
||||
me.openDialog "YesNoDialog", (b) ->
|
||||
@ -177,7 +186,10 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
, "Delete a post" ,
|
||||
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete this post ?" }
|
||||
return false
|
||||
|
||||
@bindKey "CTRL-S", () ->
|
||||
sel = me.tabbar.get "selidx"
|
||||
return unless sel is 2
|
||||
me.saveBlog()
|
||||
@on "vboxchange", () ->
|
||||
me.resizeContent()
|
||||
# USER TAB
|
||||
@ -311,14 +323,40 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
ctimestr: if sel then sel.ctimestr else d.toString()
|
||||
utime: d.timestamp()
|
||||
utimestr: d.toString()
|
||||
rendered: me.editor.options.previewRender(content).asBase64()
|
||||
rendered: me.process(me.editor.options.previewRender(content))
|
||||
publish: if ((@find "blog-publish").get "swon") then 1 else 0
|
||||
data.id = sel.id if sel
|
||||
|
||||
#save the data
|
||||
@blogdb.save data, (r) ->
|
||||
return me.error "Cannot save blog: #{r.error}" if r.error
|
||||
me.loadBlogs()
|
||||
|
||||
process: (text) ->
|
||||
# find video tag and rendered it
|
||||
embed = (id) ->
|
||||
return """
|
||||
<iframe
|
||||
class = "embeded-video"
|
||||
width="560" height="315"
|
||||
src="https://www.youtube.com/embed/#{id}"
|
||||
frameborder="0" allow="encrypted-media" allowfullscreen
|
||||
></iframe>
|
||||
"""
|
||||
re = /\[\[([^:]*):([^\]]*)\]\]/g
|
||||
replace = []
|
||||
while (found = re.exec text) isnt null
|
||||
replace.push found
|
||||
return text.asBase64() unless replace.length > 0
|
||||
ret = ""
|
||||
begin = 0
|
||||
for it in replace
|
||||
ret += text.substring begin, it.index
|
||||
ret += embed(it[2])
|
||||
begin = it.index + it[0].length
|
||||
ret += text.substring begin, text.length
|
||||
#console.log ret
|
||||
return ret.asBase64()
|
||||
|
||||
clearEditor:() ->
|
||||
@.editor.value ""
|
||||
@.inputtags.value = ""
|
||||
@ -330,13 +368,21 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
cond =
|
||||
order:
|
||||
ctime: "DESC"
|
||||
fields: [
|
||||
"id",
|
||||
"title",
|
||||
"ctimestr",
|
||||
"ctime",
|
||||
"utime",
|
||||
"utimestr"
|
||||
]
|
||||
@blogdb.find cond, (r) ->
|
||||
return me.notify "No post found: #{r.error}" if r.error
|
||||
console.log r.result
|
||||
for v in r.result
|
||||
v.text = v.title
|
||||
v.complex = true
|
||||
v.closable = true
|
||||
v.content = v.content.unescape()
|
||||
v.detail = [
|
||||
{ text: "Created: #{v.ctimestr}", class: "blog-dates" },
|
||||
{ text: "Updated: #{v.utimestr}", class: "blog-dates" }]
|
||||
|
@ -9,18 +9,54 @@ class RepositoryDialog extends this.OS.GUI.BaseDialog
|
||||
main: () ->
|
||||
me = @
|
||||
@list = @find "repo-list"
|
||||
ls = ({ text: v.name, iconclass: "fa fa-link", url: v.url
|
||||
} for v in @systemsetting.system.repositories)
|
||||
@url = @find "repo-url"
|
||||
@list.set "onlistselect", (e) ->
|
||||
($ me.url).html e.data.url
|
||||
@list.set "items", ls
|
||||
@list.set "onlistdbclick", (e) ->
|
||||
selidx = me.list.get "selidx"
|
||||
return unless selidx >= 0
|
||||
sel = me.systemsetting.system.repositories[selidx]
|
||||
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
|
||||
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 = """
|
||||
<afx-app-window data-id = "repository-dialog-win" apptitle="Repositories" width="250" height="250">
|
||||
<afx-vbox >
|
||||
<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-button data-id = "btadd" text = "[+]" data-width="30"></afx-button>
|
||||
<afx-button data-id = "btdel" text = "[-]" data-width="30"></afx-button>
|
||||
|
@ -7,12 +7,6 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
||||
me = @
|
||||
@installdir = @systemsetting.system.pkgpaths.user
|
||||
# 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.set "onlistselect", (e) ->
|
||||
return unless e.data
|
||||
@ -128,7 +122,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
||||
(d) ->
|
||||
return unless d
|
||||
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.systemsetting.system.packages[name] = undefined
|
||||
me._gui.refreshSystemMenu()
|
||||
|
Reference in New Issue
Block a user