adapt Blogger to the new api

This commit is contained in:
Xuan Sang LE 2020-05-23 20:09:01 +02:00
parent e810eb4a14
commit 7c70cf4d15
81 changed files with 1932 additions and 453 deletions

View File

@ -1,11 +0,0 @@
coffee_files = dialogs.coffee main.coffee
jsfiles = katex/katex.js katex/auto-render.js
cssfiles = main.css katex/katex.css
copyfiles = scheme.html cvsection.html package.json katex/fonts api/sendmail.lua sendmail.html
PKG_NAME=Blogger
include ../pkg.mk

4
Blogger/README.md Normal file
View File

@ -0,0 +1,4 @@
# Blogger
Blackend for my blog at
"katex/fonts",

View File

@ -1,6 +1,8 @@
local data = ... local data = ...
print(data.content) -- print(data.content)
local error_msg = {}
local iserror = false
for k,v in pairs(data.to) do for k,v in pairs(data.to) do
print("sent to:"..v) print("sent to:"..v)
local to = v local to = v
@ -11,7 +13,12 @@ for k,v in pairs(data.to) do
--print(cmd) --print(cmd)
local r = os.execute(cmd) local r = os.execute(cmd)
if not r then if not r then
print("Cannot send mail to: "..v) iserror = true
table.insert(error_msg, v)
print("Unable to send mail to: "..v)
end end
end end
return "Email sent" local result = {}
result.error = iserror
result.result = error_msg
return result

View File

@ -0,0 +1,4 @@
# Blogger
Blackend for my blog at
"katex/fonts",

View File

@ -0,0 +1,32 @@
<afx-app-window data-id = "blogger-cv-sec-win" apptitle="Porforlio section" width="450" height="400">
<afx-vbox >
<div data-height="5"></div>
<afx-hbox data-height = "30" >
<afx-label data-width= "70" text = "__(Title)"></afx-label>
<input type = "text" name="title" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30" >
<afx-label text = "__(Subtitle)" data-width= "70"></afx-label>
<input type = "text" name="subtitle" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30" >
<afx-label text = "__(Location)" data-width= "70"></afx-label>
<input type = "text" name="location" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30" >
<afx-label text = "__(From)" data-width= "70"></afx-label>
<input type = "text" name="start" input-class = "user-input"/>
<afx-label text = "To:" style="text-align:center;" data-width= "70"></afx-label>
<input type = "text" name="end" input-class = "user-input"/>
</afx-hbox>
<afx-label data-height = "30" text = "Content" style = "margin-left:5px;"></afx-label>
<div data-id="editor-container">
<textarea name="content" data-id = "contentarea" ></textarea>
</div>
<afx-hbox data-height = "35">
<div></div>
<afx-switch data-id = "section-publish" data-width="30"></afx-switch>
<afx-button iconclass = "fa fa-save" data-id = "bt-cv-sec-save" data-width="60" text = "__(Save)"></afx-button>
</afx-hbox>
</afx-vbox>
</afx-app-window>

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

View File

@ -0,0 +1 @@
uォZ

1088
Blogger/build/debug/main.css Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
{
"app":"Blogger",
"name":"Blogging application",
"description":"Backend manager for blogging",
"info":{
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.6-a",
"category":"Internet",
"iconclass":"fa fa-book",
"mimes":["none"]
}

View File

@ -0,0 +1,82 @@
<afx-app-window data-id = "blogger-win" apptitle="Blogger" width="600" height="500">
<afx-hbox >
<afx-tab-container data-id = "tabcontainer" dir = "row" tabbarwidth= "22">
<afx-hbox data-id="user-container" data-height="100%" iconclass="fa fa-user-circle">
<afx-vbox>
<afx-hbox data-height = "30">
<afx-label data-width= "70" text = "__(Full name)"></afx-label>
<input type = "text" name="fullname" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "__(Address)" data-width= "70"></afx-label>
<input type = "text" name="address" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "__(Phone)" data-width= "70"></afx-label>
<input type = "text" name="Phone" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "__(Email)" data-width= "70"></afx-label>
<input type = "text" name="email" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "__(Url)" data-width= "70"></afx-label>
<input type = "text" name="url" input-class = "user-input"/>
</afx-hbox>
<afx-label data-height = "30" text = "__(Short biblio)"></afx-label>
<textarea name="shortbiblio" input-class = "user-input"></textarea>
<afx-hbox data-height = "35">
<div></div>
<afx-button iconclass = "fa fa-save" data-id = "bt-user-save" data-width="60" text = "__(Save)"></afx-button>
</afx-hbox>
</afx-vbox>
</afx-hbox>
<afx-hbox data-id="cv-container" data-height="100%" iconclass="fa fa-info-circle">
<div data-width="5"></div>
<afx-vbox data-width="150" min-width="100">
<afx-label class="lbl-header" data-height = "23" text = "__(Categories)" iconclass = "fa fa-bars"></afx-label>
<afx-tree-view data-id = "cv-list" ></afx-tree-view>
<afx-hbox data-height="30" class = "cv-side-bar-btn">
<afx-button data-id = "cv-cat-add" data-width = "25" text = "" iconclass = "fa fa-plus-circle"></afx-button>
<afx-button data-id = "cv-cat-del" data-width = "25" text = "" iconclass = "fa fa-minus-circle"></afx-button>
<afx-button data-id = "cv-cat-edit" data-width = "25" text = "" iconclass = "fa fa-pencil-square-o"></afx-button>
</afx-hbox>
</afx-vbox>
<afx-resizer data-width = "2"></afx-resizer>
<afx-vbox>
<afx-list-view data-id = "cv-sec-list" ></afx-list-view>
<afx-hbox data-height="30" class = "cv-side-bar-btn">
<afx-label data-id = "cv-sec-status"></afx-label>
<afx-button data-id = "cv-sec-add" data-width = "25" text = "" iconclass = "fa fa-plus-circle"></afx-button>
<afx-button data-id = "cv-sec-edit" data-width = "25" text = "" iconclass = "fa fa-pencil-square-o"></afx-button>
<afx-button data-id = "cv-sec-move" data-width = "25" text = "" iconclass = "fa fa-exchange"></afx-button>
</afx-hbox>
</afx-vbox>
<div data-width="5"></div>
</afx-hbox>
<afx-hbox data-id = "blog-container" data-height="100%" iconclass="fa fa-book">
<afx-list-view data-id = "blog-list" min-width="100" data-width="200"></afx-list-view>
<afx-resizer data-width = "3"></afx-resizer>
<afx-vbox>
<div data-id = "editor-container">
<textarea data-id="markarea" ></textarea>
</div>
<afx-label text = "__(Tags)" style="font-weight:bold;" data-height="25" ></afx-label>
<afx-hbox data-height="25">
<input type = "text" data-id = "input-tags" />
<div data-width="5"></div>
<afx-switch data data-id = "blog-publish" data-width="30"></afx-switch>
<div data-width="5"></div>
</afx-hbox>
<div data-height="5"></div>
</afx-vbox>
</afx-hbox>
</afx-tab-container>
</afx-hbox>
</afx-app-window>

View File

@ -0,0 +1,20 @@
<afx-app-window data-id = "blogger-send-mail-win" apptitle="Send mail" width="500" height="400" resizable = "false">
<afx-hbox>
<afx-menu data-width="150" data-id="email-list"></afx-menu>
<afx-resizer data-width="3"></afx-resizer>
<div data-width="5"></div>
<afx-vbox >
<div data-height="5"></div>
<afx-label data-height="20" text = "__(Title)"></afx-label>
<input type = "text" data-height="20" name="title" data-id = "mail-title"/>
<afx-label data-height = "20" text = "Content" ></afx-label>
<textarea name="content" data-id = "contentarea" ></textarea>
<div data-height="5"></div>
<afx-hbox data-height = "30">
<div></div>
<afx-button iconclass = "fa fa-paper-plane" data-id = "bt-sendmail" data-width="60" text = "__(Send)"></afx-button>
</afx-hbox>
</afx-vbox>
<div data-width="5"></div>
</afx-hbox>
</afx-app-window>

View File

@ -0,0 +1,24 @@
local data = ...
-- print(data.content)
local error_msg = {}
local iserror = false
for k,v in pairs(data.to) do
print("sent to:"..v)
local to = v
local from = "From: xsang.le@gmail.com\n"
local suject = "Subject: " .. data.title .. "\n"
local content = data.content.."\n"
local cmd = 'echo "' .. utils.escape(from .. suject .. content) .. '"| sendmail ' .. to
--print(cmd)
local r = os.execute(cmd)
if not r then
iserror = true
table.insert(error_msg, v)
print("Unable to send mail to: "..v)
end
end
local result = {}
result.error = iserror
result.result = error_msg
return result

Binary file not shown.

View File

@ -1,32 +1,32 @@
<afx-app-window data-id = "blogger-cv-sec-win" apptitle="Porforlio section" width="450" height="400"> <afx-app-window data-id = "blogger-cv-sec-win" apptitle="Porforlio section" width="450" height="400">
<afx-vbox > <afx-vbox >
<div data-height="5"></div> <div data-height="5"></div>
<afx-hbox data-height = "30" > <afx-hbox data-height = "30" >
<afx-label data-width= "70" text = "__(Title)"></afx-label> <afx-label data-width= "70" text = "__(Title)"></afx-label>
<input type = "text" name="title" input-class = "user-input"/> <input type = "text" name="title" input-class = "user-input"/>
</afx-hbox> </afx-hbox>
<afx-hbox data-height = "30" > <afx-hbox data-height = "30" >
<afx-label text = "__(Subtitle)" data-width= "70"></afx-label> <afx-label text = "__(Subtitle)" data-width= "70"></afx-label>
<input type = "text" name="subtitle" input-class = "user-input"/> <input type = "text" name="subtitle" input-class = "user-input"/>
</afx-hbox> </afx-hbox>
<afx-hbox data-height = "30" > <afx-hbox data-height = "30" >
<afx-label text = "__(Location)" data-width= "70"></afx-label> <afx-label text = "__(Location)" data-width= "70"></afx-label>
<input type = "text" name="location" input-class = "user-input"/> <input type = "text" name="location" input-class = "user-input"/>
</afx-hbox> </afx-hbox>
<afx-hbox data-height = "30" > <afx-hbox data-height = "30" >
<afx-label text = "__(From)" data-width= "70"></afx-label> <afx-label text = "__(From)" data-width= "70"></afx-label>
<input type = "text" name="start" input-class = "user-input"/> <input type = "text" name="start" input-class = "user-input"/>
<afx-label text = "To:" style="text-align:center;" data-width= "70"></afx-label> <afx-label text = "To:" style="text-align:center;" data-width= "70"></afx-label>
<input type = "text" name="end" input-class = "user-input"/> <input type = "text" name="end" input-class = "user-input"/>
</afx-hbox> </afx-hbox>
<afx-label data-height = "30" text = "Content" style = "margin-left:5px;"/> <afx-label data-height = "30" text = "Content" style = "margin-left:5px;"></afx-label>
<div data-id="editor-container"> <div data-id="editor-container">
<textarea name="content" data-id = "contentarea" /> <textarea name="content" data-id = "contentarea" ></textarea>
</div> </div>
<afx-hbox data-height = "35"> <afx-hbox data-height = "35">
<div></div> <div></div>
<afx-switch data data-id = "section-publish" data-width="30"></afx-switch> <afx-switch data-id = "section-publish" data-width="30"></afx-switch>
<afx-button iconclass = "fa fa-save" data-id = "bt-cv-sec-save" data-width="60" text = "__(Save)"/> <afx-button iconclass = "fa fa-save" data-id = "bt-cv-sec-save" data-width="60" text = "__(Save)"></afx-button>
</afx-hbox> </afx-hbox>
</afx-vbox> </afx-vbox>
</afx-app-window> </afx-app-window>

View File

@ -17,141 +17,151 @@
#along with this program. If not, see https://www.gnu.org/licenses/. #along with this program. If not, see https://www.gnu.org/licenses/.
class BloggerCategoryDialog extends this.OS.GUI.BasicDialog class BloggerCategoryDialog extends this.OS.GUI.BasicDialog
constructor: () -> constructor: () ->
super "BloggerCategoryDialog", { super "BloggerCategoryDialog"
tags: [
{ tag: "afx-label", att: "data-height = '20', text = 'Pick a parent'" }, main: () ->
{ tag: "afx-tree-view" }, super.main()
{ tag: "afx-label", att: "data-height = '20', text = 'Category name'" }, @tree = @find "tree"
{ tag: "input", att: "type = 'text' data-height = '20'" } @txtinput = @find "txtinput"
],
width: 200, (@find "bt-ok").set "onbtclick", (e) =>
height: 300, sel = @tree.get "selectedItem"
resizable: true, return @notify __("Please select a parent category") unless sel
buttons: [ seldata = sel.get "data"
{ val = @txtinput.value
label: "0k", return @notify __("Please enter category name") if val is "" and not @data.selonly
onclick: (d) -> return @notify __("Parent can not be the category itself") if @data.cat and @data.cat.id is seldata.id
sel = (d.find "content1").get "selectedItem" @handle { p: seldata, value: val } if @handle
return d.notify __("Please select a parent category") unless sel @quit()
val = (d.find "content3").value
return d.notify __("Please enter category name") if val is "" and not d.data.selonly (@find "bt-cancel").set "onbtclick", (e) =>
return d.notify __("Parent can not be the category itself") if d.data.cat and d.data.cat.id is sel.id @quit()
d.handler { p: sel, value: val } if d.handler if @data and @data.tree
d.quit() if @data and @data.cat
}, @txtinput.value = @data.cat.name
{ if @data.cat.pid is "0"
label: "Cancel", seldata = @data.tree
onclick: (d) -> d.quit() else
} seldata = @findDataByID @data.cat.pid, @data.tree.nodes
], seldata.selected = true if seldata
filldata: (d) -> @tree.set "data", @data.tree
return unless d.data @tree.expandAll()
#console.log d.data # TODO set selected category name
tree = d.find "content1"
tree.set "data", d.data.tree if d.data.tree findDataByID: (id, list) ->
if d.data.cat for data in list
it = (tree.find "id", d.data.cat.pid)[0] return data if data.id is id
tree.set "selectedItem", it if data.nodes
(d.find "content3").value = d.data.cat.name @findDataByID id, data.nodes
#(d.find "content0").set "text", d.data.label return undefined
#(d.find "content1").value = d.data.value if d.data.value
xtra: (d) -> BloggerCategoryDialog.scheme = """
$( d.find "content3" ).keyup (e) -> <afx-app-window width='300' height='400'>
(d.find "bt0").trigger() if e.which is 13 <afx-vbox>
} <afx-label text="__(Pick a parent)" data-height="25" class="lbl-header" ></afx-label>
<afx-tree-view data-id="tree" ></afx-tree-view>
<afx-label text="__(Category name)" data-height="25" class="lbl-header" ></afx-label>
<input type="text" data-height="25" data-id = "txtinput"/ >
<div data-height = '30' style=' text-align:right;padding:3px;'>
<afx-button data-id = "bt-ok" text = "__(Ok)"></afx-button>
<afx-button data-id = "bt-cancel" text = "__(Cancel)"></afx-button>
</div>
</afx-vbox>
</afx-app-window>
"""
# This dialog is use for cv section editing # This dialog is use for cv section editing
class BloggerCVSectionDiaglog extends this.OS.GUI.BaseDialog class BloggerCVSectionDiaglog extends this.OS.GUI.BasicDialog
constructor: () -> constructor: (parent) ->
super "BloggerCVSectionDiaglog" file = "#{parent.meta().path}/cvsection.html".asFileHandle()
super "BloggerCVSectionDiaglog", file
init: () ->
@render "#{@path()}/cvsection.html"
main: () -> main: () ->
me = @ super.main()
@scheme.set "apptitle", @title
@editor = new SimpleMDE @editor = new SimpleMDE
element: @find "contentarea" element: @find "contentarea"
status: false status: false
toolbar: false toolbar: false
($ (@select '[class = "CodeMirror-scroll"]')[0]).css "min-height", "50px" ($ (@select '[class = "CodeMirror-scroll"]')[0]).css "min-height", "50px"
($ (@select '[class="CodeMirror cm-s-paper CodeMirror-wrap"]')[0]).css "min-height", "50px" ($ (@select '[class="CodeMirror cm-s-paper CodeMirror-wrap"]')[0]).css "min-height", "50px"
@on "vboxchange", () -> inputs = @select "[input-class='user-input']"
me.resizeContent() (($ v).val @data.section[v.name] for v in inputs ) if @data and @data.section
@editor.value @data.section.content if @data and @data.section
inputs = me.select "[input-class='user-input']" (@find "section-publish").set "swon", (if @data and @data.section and Number(@data.section.publish) then true else false)
(($ v).val me.data[v.name] for v in inputs ) if me.data (@find "bt-cv-sec-save").set "onbtclick", (e) =>
@editor.value me.data.content if me.data and me.data.content
(me.find "section-publish").set "swon", (if Number(me.data.publish) then true else false)
(@find "bt-cv-sec-save").set "onbtclick", (e) ->
data = {} data = {}
console.log inputs
data[v.name] = ($ v).val() for v in inputs data[v.name] = ($ v).val() for v in inputs
data.content = me.editor.value() data.content = @editor.value()
return me.notify __("Title or content must not be blank") if data.title is "" and data.content is "" return @notify __("Title or content must not be blank") if data.title is "" and data.content is ""
#return me.notify "Content must not be blank" if data.content is "" #return @notify "Content must not be blank" if data.content is ""
data.id = me.data.id if me.data and me.data.id data.id = @data.section.id if @data and @data.section
if (me.find "section-publish").get "swon" val = (@find "section-publish").get "swon"
if val is true
data.publish = 1 data.publish = 1
else else
data.publish = 0 data.publish = 0
@handle data if @handle
@quit()
@on "vboxchange", () => @resizeContent()
@resizeContent()
me.handler data if me.handler
me.quit()
me.resizeContent()
resizeContent: () -> resizeContent: () ->
container = @find "editor-container" container = @find "editor-container"
children = ($ container).children() children = ($ container).children()
cheight = ($ container).height() - 30 cheight = ($ container).height() - 30
($ children[1]).css("height", cheight + "px") ($ children[1]).css("height", cheight + "px")
# this dialog is for send mail
class BloggerSendmailDiaglog extends this.OS.GUI.BaseDialog
constructor: () ->
super "BloggerCVSectionDiaglog"
init: () -> # this dialog is for send mail
@render "#{@path()}/sendmail.html" class BloggerSendmailDiaglog extends this.OS.GUI.BasicDialog
@subdb = new @.parent._api.DB("subscribers") constructor: (parent) ->
file = "#{parent.meta().path}/sendmail.html".asFileHandle()
super "BloggerSendmailDiaglog", file
main: () -> main: () ->
# get db super.main()
me = @ @subdb = new @.parent._api.DB("subscribers")
@maillinglist = @find "email-list" @maillinglist = @find "email-list"
title = (new RegExp "^#+(.*)\n", "g").exec @data.content title = (new RegExp "^#+(.*)\n", "g").exec @data.content
(@find "mail-title").value = title[1] (@find "mail-title").value = title[1]
content = (@data.content.substring 0, 500) + "..." content = (@data.content.substring 0, 500) + "..."
(@find "contentarea").value = BloggerSendmailDiaglog.template.format @data.id, content, @data.id (@find "contentarea").value = BloggerSendmailDiaglog.template.format @data.id, content
@subdb.find {}, (d) -> @subdb.find {}
return me.error __("Cannot fetch subscribers data: {0}", d.error) if d.error .then (d) =>
for v in d.result for v in d
v.text = v.name v.text = v.name
v.switch = true v.switch = true
v.checked = true v.checked = true
@maillinglist.set "items", d
.catch (e) =>
@error __("Cannot fetch subscribers data: {0}", e.toString()), e
me.maillinglist.set "items", d.result (@find "bt-sendmail").set "onbtclick", (e) =>
items = @maillinglist.get "items"
(@find "bt-sendmail").set "onbtclick", (e) ->
items = me.maillinglist.get "items"
emails = [] emails = []
emails.push v.email for v in items when v.checked is true for v in items
return me.notify __("No email selected") if emails.length is 0 if v.checked is true
console.log v.email
emails.push v.email
return @notify __("No email selected") if emails.length is 0
# send the email # send the email
data = data =
path: "#{me.parent.path()}/sendmail.lua", path: "#{@parent.path()}/sendmail.lua",
parameters: parameters:
to: emails, to: emails,
title: (me.find "mail-title").value, title: (@find "mail-title").value,
content: (me.find "contentarea").value content: (@find "contentarea").value
me._api.post "system/apigateway", data, (d) -> @_api.apigateway data, false
me.notify "Sendmail: {0}".format d .then (d) =>
me.quit() return @notify __("Unable to send mail to: {0}", d.result.join(", ")) if d.error
, (e, s) -> @quit()
console.log e .catch (e) =>
me.error __("Error sending mail: {0}", e.responseText) console.log e
@error __("Error sending mail: {0}", e.toString()), e
@ -166,7 +176,7 @@ Xuan Sang LE has just published a new post on his blog: https://blog.lxsang.me/p
Read the full article via: Read the full article via:
https://blog.lxsang.me/post/id/{2} https://blog.lxsang.me/post/id/{0}
You receive this email because you have been subscribed to his blog. You receive this email because you have been subscribed to his blog.

View File

@ -20,122 +20,156 @@ class Blogger extends this.OS.GUI.BaseApplication
super "Blogger", args super "Blogger", args
main: () -> main: () ->
me = @
@tabbar = @find "tabbar"
@containers = [
@find("user-container"),
@find("cv-container"),
@find("blog-container")
]
@user = {} @user = {}
@cvlist = @find "cv-list" @cvlist = @find "cv-list"
@cvlist.set "ontreeselect", (d) -> @cvlist.set "ontreeselect", (d) =>
me.CVSectionByCID Number(d.id) return unless d
data = d.data.item.get "data"
@CVSectionByCID Number(data.id)
@inputtags = @.find "input-tags" @inputtags = @.find "input-tags"
@bloglist = @find "blog-list" @bloglist = @find "blog-list"
@seclist = @find "cv-sec-list"
@userdb = new @_api.DB("user") @userdb = new @_api.DB("user")
@cvcatdb = new @_api.DB("cv_cat") @cvcatdb = new @_api.DB("cv_cat")
@cvsecdb = new @_api.DB("cv_sections") @cvsecdb = new @_api.DB("cv_sections")
@blogdb = new @_api.DB("blogs") @blogdb = new @_api.DB("blogs")
@tabbar.set "onlistselect", (e) ->
($ el).hide() for el in me.containers
me.fetchData e.idx
($ me.containers[e.idx]).show()
me.trigger "calibrate"
@tabbar.set "items", [
{ iconclass: "fa fa-user-circle", selected: true },
{ iconclass: "fa fa-info-circle" },
{ iconclass: "fa fa-book" }
]
(@find "bt-user-save").set "onbtclick", (e) ->
me.saveUser()
(@find "cv-cat-add").set "onbtclick", (e) -> @tabcontainer = @find "tabcontainer"
me.openDialog new BloggerCategoryDialog(), @tabcontainer.set "ontabselect", (e) =>
(d) -> @fetchData e.data.container.aid()
c =
name: d.value,
pid: d.p.id,
publish: 1
me.cvcatdb.save c, (r) ->
me.error __("Cannot add new category") if r.error
me.refreshCVCat()
#update the list
, __("Add category"), { tree: me.cvlist.get "data" } (@find "bt-user-save").set "onbtclick", (e) =>
@saveUser()
(@find "cv-cat-edit").set "onbtclick", (e) -> (@find "cv-cat-add").set "onbtclick", (e) =>
cat = me.cvlist.get "selectedItem" @fetchCVCat().then (tree) =>
@openDialog(new BloggerCategoryDialog(), {
title: __("Add category"),
tree: tree
}).then (d) =>
c =
name: d.value,
pid: d.p.id,
publish: 1
@cvcatdb.save c
.then (r) =>
@refreshCVCat()
.catch (e) => @error __("Cannot add new category"), e
.catch (e) => @error e.toString(), e
.catch (e) => @error __("Unable to fetch categories"), e
(@find "cv-cat-edit").set "onbtclick", (e) =>
sel = @cvlist.get "selectedItem"
return unless sel
cat = sel.get "data"
return unless cat return unless cat
me.openDialog new BloggerCategoryDialog(), (d) -> @fetchCVCat().then (tree) =>
c = @openDialog(new BloggerCategoryDialog(), {
id: cat.id, title: __("Edit category"),
publish: cat.publish, tree: tree, cat: cat
pid: d.p.id, }).then (d) =>
name: d.value c =
id: cat.id,
publish: cat.publish,
pid: d.p.id,
name: d.value
me.cvcatdb.save c, (r) -> @cvcatdb.save c
return me.error __("Cannot Edit category") if r.error .then (r) =>
me.refreshCVCat() @refreshCVCat()
, __("Edit category"), { tree: (me.cvlist.get "data"), cat: cat } .catch (e) =>
@error __("Cannot Edit category"), e
.catch (e) => @error __("Unable to fetch categories"), e
(@find "cv-cat-del").set "onbtclick", (e) -> (@find "cv-cat-del").set "onbtclick", (e) =>
cat = me.cvlist.get "selectedItem" sel = @cvlist.get "selectedItem"
return unless sel
cat = sel.get "data"
return unless cat return unless cat
me.openDialog "YesNoDialog", @openDialog("YesNoDialog", {
(d) -> title: __("Delete category") ,
return unless d iconclass: "fa fa-question-circle",
me.deleteCVCat cat text: __("Do you really want to delete: {0}?", cat.name)
, __("Delete category") , }).then (d) =>
{ iconclass: "fa fa-question-circle", text: __("Do you really want to delete: {0}?", cat.name) } return unless d
@deleteCVCat cat
.catch (e) => @error e.toString(), e
(@find "cv-sec-add").set "onbtclick", (e) -> (@find "cv-sec-add").set "onbtclick", (e) =>
cat = me.cvlist.get "selectedItem" sel = @cvlist.get "selectedItem"
return me.notify __("Please select a category") unless cat and cat.id isnt 0 return unless sel
me.openDialog new BloggerCVSectionDiaglog(), (d) -> cat = sel.get "data"
return @notify __("Please select a category") unless cat and cat.id isnt "0"
@openDialog(new BloggerCVSectionDiaglog(@), {
title: __("New section entry for {0}", cat.name)
}).then (d) =>
d.cid = Number cat.id d.cid = Number cat.id
d.start = Number d.start d.start = Number d.start
d.end = Number d.end d.end = Number d.end
d.publish = 1 # d.publish = 1
me.cvsecdb.save d, (r) -> @cvsecdb.save d
return me.error __("Cannot save section: {0}", r.error) if r.error .then (r) =>
me.CVSectionByCID Number(cat.id) @CVSectionByCID Number(cat.id)
.catch (e) => @error __("Cannot save section: {0}", e.toString()), e
, __("New section entry for {0}", cat.name), null (@find "cv-sec-move").set "onbtclick", (e) =>
sel = (@find "cv-sec-list").get "selectedItem"
return @notify __("Please select a section to move") unless sel
sec = sel.get "data"
(@find "cv-sec-move").set "onbtclick", (e) -> @fetchCVCat().then (tree) =>
sec = (me.find "cv-sec-list").get "selected" @openDialog(new BloggerCategoryDialog(),{
return me.notify __("Please select a section to move") unless sec title: __("Move to"),
tree: tree,
selonly: true
}).then (d) =>
c =
id: sec.id,
cid: d.p.id
me.openDialog new BloggerCategoryDialog(), (d) -> @cvsecdb.save c
c = .then (r) =>
id: sec.id, @CVSectionByCID(sec.cid)
cid: d.p.id (@find "cv-sec-list").unselect()
.catch (e) => @error __("Cannot move section"), e
me.cvsecdb.save c, (r) -> (@find "cv-sec-edit").set "onbtclick", (e) =>
return me.error __("Cannot move section") if r.error sel = (@find "cv-sec-list").get "selectedItem"
me.CVSectionByCID(sec.cid) return @notify __("Please select a section to edit") unless sel
(me.find "cv-sec-list").set "selected", -1 sec = sel.get "data"
, __("Move to"), { tree: (me.cvlist.get "data"), selonly: true } @openDialog(new BloggerCVSectionDiaglog(@), {
title: __("Modify section entry"),
(@find "cv-sec-edit").set "onbtclick", (e) -> section: sec
sec = (me.find "cv-sec-list").get "selected" }).then (d) =>
return me.notify __("Please select a section to edit") unless sec
me.openDialog new BloggerCVSectionDiaglog(), (d) ->
d.cid = Number sec.cid d.cid = Number sec.cid
d.start = Number d.start d.start = Number d.start
d.end = Number d.end d.end = Number d.end
#d.publish = Number sec.publish #d.publish = Number sec.publish
me.cvsecdb.save d, (r) -> @cvsecdb.save d
return me.error __("Cannot save section: {0}", r.error) if r.error .then (r) =>
me.CVSectionByCID Number(sec.cid) @CVSectionByCID Number(sec.cid)
.catch (e) => return @error __("Cannot save section: {0}", e.toString()), e
, __("Modify section entry"), sec @seclist .set "onitemclose", (e) =>
return unless e
data = e.data.item.get "data"
console.log data
@openDialog("YesNoDialog", {
iconclass: "fa fa-question-circle",
text: __("Do you really want to delete: {0}?", data.title)
}).then (b) =>
return unless b
@cvsecdb.delete data.id
.then (r) =>
@seclist.remove e.data.item
.catch (e) => @error __("Cannot delete the section: {0}", e.toString()), e
return false
@editor = new SimpleMDE @editor = new SimpleMDE
element: me.find "markarea" element: @find "markarea"
autofocus: true autofocus: true
tabSize: 4 tabSize: 4
indentWithTabs: true indentWithTabs: true
@ -143,15 +177,15 @@ class Blogger extends this.OS.GUI.BaseApplication
{ {
name: __("New"), name: __("New"),
className: "fa fa-file", className: "fa fa-file",
action: (e) -> action: (e) =>
me.bloglist.set "selected", -1 @bloglist.unselect()
me.clearEditor() @clearEditor()
}, },
{ {
name: __("Save"), name: __("Save"),
className: "fa fa-save", className: "fa fa-save",
action: (e) -> action: (e) =>
me.saveBlog() @saveBlog()
} }
, "|", "bold", "italic", "heading", "|", "quote", "code", , "|", "bold", "italic", "heading", "|", "quote", "code",
"unordered-list", "ordered-list", "|", "link", "unordered-list", "ordered-list", "|", "link",
@ -159,121 +193,149 @@ class Blogger extends this.OS.GUI.BaseApplication
{ {
name: "image", name: "image",
className: "fa fa-file-image-o", className: "fa fa-file-image-o",
action: (e) -> action: (e) =>
me.openDialog "FileDiaLog", (d, n, p) -> @openDialog("FileDialog", {
p.asFileHandler().publish (r) -> title: __("Select image file"),
return me.error __("Cannot export file for embedding to text") if r.error mimes: ["image/.*"]
doc = me.editor.codemirror.getDoc() }).then (d) =>
doc.replaceSelection "![](#{me._api.handler.shared}/#{r.result})" d.file.path.asFileHandle().publish()
, __("Select image file"), { mimes: ["image/.*"] } .then (r) =>
doc = @editor.codemirror.getDoc()
doc.replaceSelection "![](#{@_api.handle.shared}/#{r.result})"
.catch (e) => @error __("Cannot export file for embedding to text"), e
}, },
{ {
name:"Youtube", name:"Youtube",
className: "fa fa-youtube", className: "fa fa-youtube",
action: (e) -> action: (e) =>
doc = me.editor.codemirror.getDoc() doc = @editor.codemirror.getDoc()
doc.replaceSelection "[[youtube:]]" doc.replaceSelection "[[youtube:]]"
} }
"|", "|",
{ {
name: __("Preview"), name: __("Preview"),
className: "fa fa-eye no-disable", className: "fa fa-eye no-disable",
action: (e) -> action: (e) =>
me.previewOn = !me.previewOn @previewOn = !@previewOn
SimpleMDE.togglePreview e SimpleMDE.togglePreview e
#/console.log me.select ".editor-preview editor-preview-active" #/console.log @select ".editor-preview editor-preview-active"
renderMathInElement me.find "editor-container" renderMathInElement @find "editor-container"
}, },
"|", "|",
{ {
name: __("Send mail"), name: __("Send mail"),
className: "fa fa-paper-plane", className: "fa fa-paper-plane",
action: (e) -> action: (e) =>
sel = me.bloglist.get "selected" sel = @bloglist.get "selectedItem"
return me.error __("No post selected") unless sel return @error __("No post selected") unless sel
me.openDialog new BloggerSendmailDiaglog(), (d) -> data = sel.get "data"
@openDialog(new BloggerSendmailDiaglog(@), {
title: __("Send mail"),
content: @editor.value(),
id: data.id
})
.then (d) ->
console.log "test" console.log "test"
, __("Send mail"), { content: me.editor.value(), id: sel.id }
} }
] ]
@bloglist.set "onlistselect", (e) -> @bloglist.set "onlistselect", (e) =>
sel = me.bloglist.get "selected" el = @bloglist.get "selectedItem"
return unless el
sel = el.get "data"
return unless sel return unless sel
me.blogdb.get Number(sel.id), (r) -> @blogdb.get Number(sel.id)
me.error __("Cannot fetch the entry content") if r.error .then (r) =>
me.editor.value atob(r.result.content) @editor.value atob(r.content)
me.inputtags.value = r.result.tags @inputtags.value = r.tags
(me.find "blog-publish").set "swon", (if Number(r.result.publish) then true else false) (@find "blog-publish").set "swon", (if Number(r.publish) then true else false)
.catch (e) =>
@error __("Cannot fetch the entry content"), e
@.bloglist.set "onitemclose", (e) -> @bloglist.set "onitemclose", (e) =>
me.openDialog "YesNoDialog", (b) -> return unless e
el = e.data.item
data = el.get "data"
@openDialog("YesNoDialog", {
title: __("Delete a post"),
iconclass: "fa fa-question-circle",
text: __("Do you really want to delete this post ?")
}).then (b) =>
return unless b return unless b
me.blogdb.delete e.item.item.id, (r) -> @blogdb.delete data.id
return me.error __("Cannot delete: {0}", r.error) if r.error .then (r) =>
me.bloglist.remove e.item.item, true @bloglist.remove el
me.bloglist.set "selected", -1 @bloglist.unselect()
me.clearEditor() @clearEditor()
, __("Delete a 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 @bindKey "CTRL-S", () =>
me.saveBlog() sel = @tabcontainer.get "selectedTab"
@on "vboxchange", () -> return unless sel and sel.container.aid() is "blog-container"
me.resizeContent() @saveBlog()
@on "vboxchange", () =>
@resizeContent()
@resizeContent()
@loadBlogs()
# @fetchData 0
# USER TAB # USER TAB
fetchData: (idx) -> fetchData: (idx) ->
me = @
switch idx switch idx
when 0 #user info when "user-container" #user info
@userdb.get null, (d) -> @userdb.get null
return me.error __("Cannot fetch user data") if d.error .then (d) =>
me.user = d.result[0] @user = d[0]
inputs = me.select "[input-class='user-input']" inputs = @select "[input-class='user-input']"
($ v).val me.user[v.name] for v in inputs ($ v).val @user[v.name] for v in inputs
when 1 # category .catch (e) => @error __("Cannot fetch user data"), e
when "cv-container" # category
@refreshCVCat() @refreshCVCat()
else else
@loadBlogs() @loadBlogs()
saveUser:() -> saveUser:() ->
me = @
inputs = @select "[input-class='user-input']" inputs = @select "[input-class='user-input']"
@user[v.name] = ($ v).val() for v in inputs @user[v.name] = ($ v).val() for v in inputs
return @notify __("Full name must be entered") if not @user.fullname or @user.fullname is "" return @notify __("Full name must be entered") if not @user.fullname or @user.fullname is ""
#console.log @user #console.log @user
@userdb.save @user, (r) -> @userdb.save @user
return me.error __("Cannot save user data") if r.error .then (r) =>
return me.notify __("User data updated") return @notify __("User data updated")
.catch (e) => return @error __("Cannot save user data"), e
# PORFOLIO TAB # PORFOLIO TAB
refreshCVCat: () -> refreshCVCat: () ->
me = @ @fetchCVCat().then (data) =>
data = @cvlist.set "data", data
name: "Porfolio", @cvlist.expandAll()
id:0, .catch (e) => @error __("Unable to load categories"), e
nodes: []
cnd =
order:
name: "ASC"
@cvcatdb.find cnd, (d) ->
if d.error
me.cvlist.set "data", data
return me.notify __("Cannot fetch CV categories")
me.fetchCVCat d.result, data, "0"
me.cvlist.set "data", data
#it = (me.cvlist.find "pid", "2")[0]
#me.cvlist.set "selectedItem", it
fetchCVCat: (table, data, id) -> fetchCVCat: () ->
new Promise (resolve, reject) =>
data =
name: "Porfolio",
id:"0",
nodes: []
cnd =
order:
name: "ASC"
@cvcatdb.find cnd
.then (d) =>
@catListToTree d, data, "0"
resolve data
.catch (e) -> reject __e e
#it = (@cvlist.find "pid", "2")[0]
#@cvlist.set "selectedItem", it
catListToTree: (table, data, id) ->
result = (v for v in table when v.pid is id) result = (v for v in table when v.pid is id)
return data.nodes = null if result.length is 0 return data.nodes = null if result.length is 0
for v in result for v in result
v.nodes = [] v.nodes = []
@fetchCVCat table, v, v.id @catListToTree table, v, v.id
#v.nodes = null if v.nodes.length is 0 #v.nodes = null if v.nodes.length is 0
data.nodes.push v data.nodes.push v
@ -287,59 +349,42 @@ class Blogger extends this.OS.GUI.BaseApplication
cond = ({ "=": { cid: v } } for v in ids) cond = ({ "=": { cid: v } } for v in ids)
# delete all content # delete all content
@cvsecdb.delete { "or": cond }, (r) -> @cvsecdb.delete({ "or": cond }).then (r) =>
return me.error __("Cannot delete all content of: {0} [{1}]", cat.name, r.error) if r.error
cond = ({ "=": { id: v } } for v in ids) cond = ({ "=": { id: v } } for v in ids)
me.cvcatdb.delete { "or": cond }, (re) -> @cvcatdb.delete({ "or": cond }).then (re) =>
return me.error __("Cannot delete the category: {0} [{1}]", cat.name, re.error) if re.error @refreshCVCat()
me.refreshCVCat() @seclist.set "data", []
.catch (e) =>
@error __("Cannot delete the category: {0} [{1}]", cat.name, e.toString()), e
.catch (e) =>
@error __("Cannot delete all content of: {0} [{1}]", cat.name, e.toString()), e
CVSectionByCID: (cid) -> CVSectionByCID: (cid) ->
me = @
cond = cond =
exp: exp:
"=": "=":
cid: cid cid: cid
order: order:
start: "DESC" start: "DESC"
@cvsecdb.find cond, (d) -> @cvsecdb.find(cond).then (d) =>
return me.notify __("Section list is empty, please add one") if d.error
v.text = v.title for v in d.result
items = [] items = []
$(me.find "cv-sec-status").html __("Found {0} sections", d.result.length) (@find "cv-sec-status").set "text", __("Found {0} sections", d.length)
for v in d.result for v in d
v.text = v.title v.closable = true
v.complex = true v.tag = "afx-blogger-cvsection-item"
v.start = Number(v.start) v.start = Number(v.start)
v.end = Number(v.end) v.end = Number(v.end)
v.detail = [] v.start = undefined if v.start < 1000
v.detail.push { text: v.subtitle, class: "cv-subtitle" } if v.subtitle isnt "" v.end = undefined if v.end < 1000
if v.start isnt 0 and v.end isnt 0
v.detail.push { text: "#{v.start} - #{v.end}", class: "cv-period" }
else
v.detail.push { text: "", class: "cv-period" }
v.detail.push { text: v.location, class: "cv-loc" } if v.location isnt ""
#v.detail.push { text: v.end } if v.end isnt 0
v.closable = true
v.detail.push { text: v.content, class: "cv-content" }
items.push v items.push v
el = me.find "cv-sec-list" @seclist.set "data", items
el.set "onitemclose", (e) -> .catch (e) => @error e.toString(), e
me.openDialog "YesNoDialog", (b) ->
return unless b
me.cvsecdb.delete e.item.item.id, (r) ->
return me.error __("Cannot delete the section: {0}", r.error) if r.error
el.remove e.item.item, true
, __("Delete section") ,
{ iconclass: "fa fa-question-circle", text: __("Do you really want to delete: {0}?",e.item.item.text) }
return false
el.set "items", items
# blog # blog
saveBlog: () -> saveBlog: () ->
me = @ sel = undefined
sel = @bloglist.get "selected" selel = @bloglist.get "selectedItem"
sel = selel.get "data" if selel
tags = @inputtags.value tags = @inputtags.value
content = @editor.value() content = @editor.value()
title = (new RegExp "^#+(.*)\n", "g").exec content title = (new RegExp "^#+(.*)\n", "g").exec content
@ -354,13 +399,14 @@ class Blogger extends this.OS.GUI.BaseApplication
ctimestr: if sel then sel.ctimestr else d.toString() ctimestr: if sel then sel.ctimestr else d.toString()
utime: d.timestamp() utime: d.timestamp()
utimestr: d.toString() utimestr: d.toString()
rendered: me.process(me.editor.options.previewRender(content)) rendered: @process(@editor.options.previewRender(content))
publish: if ((@find "blog-publish").get "swon") then 1 else 0 publish: if ((@find "blog-publish").get "swon") then 1 else 0
data.id = sel.id if sel data.id = sel.id if sel
#save the data #save the data
@blogdb.save data, (r) -> @blogdb.save data
return me.error __("Cannot save blog: {0}", r.error) if r.error .then (r) =>
me.loadBlogs() @loadBlogs()
.catch (e) => @error __("Cannot save blog: {0}", e.toString()), e
process: (text) -> process: (text) ->
# find video tag and rendered it # find video tag and rendered it
@ -394,8 +440,9 @@ class Blogger extends this.OS.GUI.BaseApplication
(@.find "blog-publish").set "swon", false (@.find "blog-publish").set "swon", false
# load blog # load blog
loadBlogs: () -> loadBlogs: () ->
me = @ selidx = -1
selidx = @bloglist.get "selidx" el = @bloglist.get "selectedItem"
selidx = $(el).index()
cond = cond =
order: order:
ctime: "DESC" ctime: "DESC"
@ -407,21 +454,17 @@ class Blogger extends this.OS.GUI.BaseApplication
"utime", "utime",
"utimestr" "utimestr"
] ]
@blogdb.find cond, (r) -> @blogdb.find cond
return me.notify __("No post found: {0}", r.error) if r.error .then (r) =>
for v in r.result v.tag = "afx-blogger-post-item" for v in r
v.text = v.title @bloglist.set "data", r
v.complex = true if selidx isnt -1
v.closable = true @bloglist.set "selected", selidx
v.detail = [ else
{ text: __("Created: {0}", v.ctimestr), class: "blog-dates" }, @clearEditor()
{ text: __("Updated: {0}", v.utimestr), class: "blog-dates" }] @bloglist.set "selected", -1
me.bloglist.set "items", r.result .catch (e) => @error __("No post found: {0}", e.toString()), e
if selidx isnt -1
me.bloglist.set "selected", selidx
else
me.clearEditor()
me.bloglist.set "selected", -1
resizeContent: () -> resizeContent: () ->
container = @find "editor-container" container = @find "editor-container"
children = ($ container).children() children = ($ container).children()
@ -430,6 +473,10 @@ class Blogger extends this.OS.GUI.BaseApplication
statusbar = children[4] statusbar = children[4]
cheight = ($ @scheme).height() - ($ titlebar).height() - ($ toolbar).height() - ($ statusbar).height() - 90 cheight = ($ @scheme).height() - ($ titlebar).height() - ($ toolbar).height() - ($ statusbar).height() - 90
($ children[2]).css("height", cheight + "px") ($ children[2]).css("height", cheight + "px")
Blogger.singleton = true Blogger.singleton = true
Blogger.dependencies = [ "mde/simplemde.min" ] Blogger.dependencies = [
"os://scripts/mde/simplemde.min.js",
"os://scripts/mde/simplemde.min.css"
]
this.OS.register "Blogger", Blogger this.OS.register "Blogger", Blogger

View File

@ -1,94 +1,92 @@
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] { afx-app-window[data-id="blogger-win"] afx-tab-container[data-id="tabcontainer"] afx-tab-bar afx-list-view > div.list-container {
padding: 0; padding: 0;
margin: 0; margin: 0;
background-color: #333333; border-right: 1px solid #292929;
} }
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] > div > ul > li { afx-app-window[data-id="blogger-win"] afx-tab-container[data-id="tabcontainer"] afx-tab-bar afx-list-view > div.list-container > ul li{
background-color: #333333; font-size: 15px;
font-size: 20px; padding:0;
color: #929292; width: 100%;
border-radius: 0;
border:0;
margin: 0;
text-align: center;
} }
afx-app-window[data-id="blogger-win"] afx-tab-container[data-id="tabcontainer"] afx-tab-bar afx-list-view > div.list-container > ul li.selected {
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] > div > ul > li.selected{ background-color: #116cd6;
color:white; color:white;
} }
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] {
padding: 10px; afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-label i.label-text{
}
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-hbox{
margin-bottom: 5px;
margin-top: 5px;
}
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-label{
font-weight: bold; font-weight: bold;
} }
afx-app-window[data-id="blogger-win"] afx-hbox.cv-side-bar-btn{
padding-left:3px; afx-app-window .lbl-header i.label-text{
padding-top:3px; font-weight: bold;
background-color: #f6F6F6;
border-top: 1px solid #cbcbcb;
color:#414339;
}
afx-app-window[data-id="blogger-win"] afx-resizer{
border-left: 1px solid #cbcbcb;
background-color: transparent;
} }
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="cv-container"] afx-label.cat-header{ afx-app-window[data-id="blogger-win"] afx-hbox[data-id="cv-container"] afx-label.cat-header{
background-color: #f6F6F6;
border-bottom: 1px solid #cbcbcb; border-bottom: 1px solid #cbcbcb;
text-align: center; text-align: center;
} }
afx-app-window[data-id="blogger-cv-sec-win"] afx-hbox{
padding-left:5px; afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > .list-container > ul .afx-cv-sec-title .label-text{
padding-right:5px;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > div.list-container > ul > li{
padding-bottom: 10px;
padding-top:10px;
/*border-bottom: 1px solid #cbcbcb;*/
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > div.list-container > ul afx-label{
font-weight: bold; font-weight: bold;
} }
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > div.list-container > ul >li:nth-child(odd){
background-color: white; afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] afx-blogger-cvsection-item afx-label {
display: block;
} }
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > div.list-container > ul > li.selected { afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] afx-blogger-cvsection-item p {
border: 2px solid #116cd6; padding: 0;
color: #414339; margin: 0;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] afx-blogger-cvsection-item .afx-cv-sec-period,
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] afx-blogger-cvsection-item .afx-cv-sec-loc {
text-align: right;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] afx-blogger-cvsection-item afx-cv-sec-content{
text-align: justify;
overflow-wrap: break-word;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > div.list-container > ul li.selected {
border: 1px solid #116cd6;
background-color: transparent; background-color: transparent;
border-radius: 5px; border-radius: 5px;
} }
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > div.list-container > ul > li.selected ul.complex-content li{
color: #414339; afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .closable::before{
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-content{
text-align: justify;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-period, .cv-loc{
text-align: right;
clear: both;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-subtitle{
font-style: italic;
float:left;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] i.closable::before{
content: "\f014"; content: "\f014";
font-size: 15px; font-size: 14px;
} }
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "blog-list"] > div.list-container > ul afx-label{ afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .period-end::before{
content: "-";
}
afx-app-window[data-id ='blogger-win'] .editor-toolbar{
background-color: white;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "blog-list"] > div.list-container > ul li afx-label {
display: block;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "blog-list"] > div.list-container > ul .afx-blogpost-title .label-text{
font-weight: bold; font-weight: bold;
} }
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "blog-list"] > div.list-container > ul .blog-dates{ afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "blog-list"] > div.list-container > ul .blog-dates .label-text{
font-size: 10px; font-size: 10px;
font-weight: normal;
} }
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "blog-list"] > div.list-container > ul > li.selected .blog-dates{ afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "blog-list"] > div.list-container > ul li.selected {
color: white; background-color: #116cd6;
color:white;
} }

16
Blogger/project.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "Blogger",
"root": "home://workspace/antosdk-apps/Blogger",
"css": ["main.css", "katex/katex.css"],
"javascripts": ["katex/katex.js", "katex/auto-render.js"],
"coffees": ["main.coffee", "dialogs.coffee", "tags.coffee"],
"copies": [
"scheme.html",
"cvsection.html",
"api/sendmail.lua",
"sendmail.html",
"package.json",
"README.md",
"katex/fonts"
]
}

View File

@ -1,8 +1,8 @@
<afx-app-window data-id = "blogger-win" apptitle="Blogger" width="500" height="500"> <afx-app-window data-id = "blogger-win" apptitle="Blogger" width="600" height="500">
<afx-hbox > <afx-hbox >
<afx-list-view data-id="tabbar" data-width="30"></afx-list-view> <afx-tab-container data-id = "tabcontainer" dir = "row" tabbarwidth= "22">
<afx-vbox>
<afx-hbox data-id="user-container" data-height="100%"> <afx-hbox data-id="user-container" data-height="100%" iconclass="fa fa-user-circle">
<afx-vbox> <afx-vbox>
<afx-hbox data-height = "30"> <afx-hbox data-height = "30">
<afx-label data-width= "70" text = "__(Full name)"></afx-label> <afx-label data-width= "70" text = "__(Full name)"></afx-label>
@ -24,17 +24,19 @@
<afx-label text = "__(Url)" data-width= "70"></afx-label> <afx-label text = "__(Url)" data-width= "70"></afx-label>
<input type = "text" name="url" input-class = "user-input"/> <input type = "text" name="url" input-class = "user-input"/>
</afx-hbox> </afx-hbox>
<afx-label data-height = "30" text = "__(Short biblio)"/> <afx-label data-height = "30" text = "__(Short biblio)"></afx-label>
<textarea name="shortbiblio" input-class = "user-input"/> <textarea name="shortbiblio" input-class = "user-input"></textarea>
<afx-hbox data-height = "35"> <afx-hbox data-height = "35">
<div></div> <div></div>
<afx-button iconclass = "fa fa-save" data-id = "bt-user-save" data-width="60" text = "__(Save)"/> <afx-button iconclass = "fa fa-save" data-id = "bt-user-save" data-width="60" text = "__(Save)"></afx-button>
</afx-hbox> </afx-hbox>
</afx-vbox> </afx-vbox>
</afx-hbox> </afx-hbox>
<afx-hbox data-id="cv-container" data-height="100%">
<afx-hbox data-id="cv-container" data-height="100%" iconclass="fa fa-info-circle">
<div data-width="5"></div>
<afx-vbox data-width="150" min-width="100"> <afx-vbox data-width="150" min-width="100">
<afx-label class = "cat-header" data-height = "23" text = "__(Categories)" iconclass = "fa fa-bars"></afx-label> <afx-label class="lbl-header" data-height = "23" text = "__(Categories)" iconclass = "fa fa-bars"></afx-label>
<afx-tree-view data-id = "cv-list" ></afx-tree-view> <afx-tree-view data-id = "cv-list" ></afx-tree-view>
<afx-hbox data-height="30" class = "cv-side-bar-btn"> <afx-hbox data-height="30" class = "cv-side-bar-btn">
<afx-button data-id = "cv-cat-add" data-width = "25" text = "" iconclass = "fa fa-plus-circle"></afx-button> <afx-button data-id = "cv-cat-add" data-width = "25" text = "" iconclass = "fa fa-plus-circle"></afx-button>
@ -42,20 +44,23 @@
<afx-button data-id = "cv-cat-edit" data-width = "25" text = "" iconclass = "fa fa-pencil-square-o"></afx-button> <afx-button data-id = "cv-cat-edit" data-width = "25" text = "" iconclass = "fa fa-pencil-square-o"></afx-button>
</afx-hbox> </afx-hbox>
</afx-vbox> </afx-vbox>
<afx-resizer data-width = "3"/> <afx-resizer data-width = "2"></afx-resizer>
<afx-vbox> <afx-vbox>
<afx-list-view data-id = "cv-sec-list" ></afx-list-view> <afx-list-view data-id = "cv-sec-list" ></afx-list-view>
<afx-hbox data-height="30" class = "cv-side-bar-btn"> <afx-hbox data-height="30" class = "cv-side-bar-btn">
<div data-id = "cv-sec-status"></div> <afx-label data-id = "cv-sec-status"></afx-label>
<afx-button data-id = "cv-sec-add" data-width = "25" text = "" iconclass = "fa fa-plus-circle"></afx-button> <afx-button data-id = "cv-sec-add" data-width = "25" text = "" iconclass = "fa fa-plus-circle"></afx-button>
<afx-button data-id = "cv-sec-edit" data-width = "25" text = "" iconclass = "fa fa-pencil-square-o"></afx-button> <afx-button data-id = "cv-sec-edit" data-width = "25" text = "" iconclass = "fa fa-pencil-square-o"></afx-button>
<afx-button data-id = "cv-sec-move" data-width = "25" text = "" iconclass = "fa fa-exchange"></afx-button> <afx-button data-id = "cv-sec-move" data-width = "25" text = "" iconclass = "fa fa-exchange"></afx-button>
</afx-hbox> </afx-hbox>
</afx-vbox> </afx-vbox>
<div data-width="5"></div>
</afx-hbox> </afx-hbox>
<afx-hbox data-id = "blog-container" data-height="100%">
<afx-list-view data-id = "blog-list" min-width="100" data-width="150"></afx-list-view>
<afx-resizer data-width = "3"/> <afx-hbox data-id = "blog-container" data-height="100%" iconclass="fa fa-book">
<afx-list-view data-id = "blog-list" min-width="100" data-width="200"></afx-list-view>
<afx-resizer data-width = "3"></afx-resizer>
<afx-vbox> <afx-vbox>
<div data-id = "editor-container"> <div data-id = "editor-container">
<textarea data-id="markarea" ></textarea> <textarea data-id="markarea" ></textarea>
@ -71,6 +76,7 @@
<div data-height="5"></div> <div data-height="5"></div>
</afx-vbox> </afx-vbox>
</afx-hbox> </afx-hbox>
</afx-vbox>
</afx-tab-container>
</afx-hbox> </afx-hbox>
</afx-app-window> </afx-app-window>

View File

@ -7,12 +7,12 @@
<div data-height="5"></div> <div data-height="5"></div>
<afx-label data-height="20" text = "__(Title)"></afx-label> <afx-label data-height="20" text = "__(Title)"></afx-label>
<input type = "text" data-height="20" name="title" data-id = "mail-title"/> <input type = "text" data-height="20" name="title" data-id = "mail-title"/>
<afx-label data-height = "20" text = "Content" /> <afx-label data-height = "20" text = "Content" ></afx-label>
<textarea name="content" data-id = "contentarea" /> <textarea name="content" data-id = "contentarea" ></textarea>
<div data-height="5"></div> <div data-height="5"></div>
<afx-hbox data-height = "30"> <afx-hbox data-height = "30">
<div></div> <div></div>
<afx-button iconclass = "fa fa-paper-plane" data-id = "bt-sendmail" data-width="60" text = "__(Send)"/> <afx-button iconclass = "fa fa-paper-plane" data-id = "bt-sendmail" data-width="60" text = "__(Send)"></afx-button>
</afx-hbox> </afx-hbox>
</afx-vbox> </afx-vbox>
<div data-width="5"></div> <div data-width="5"></div>

60
Blogger/tags.coffee Normal file
View File

@ -0,0 +1,60 @@
Ant = this
class CVSectionListItemTag extends this.OS.GUI.tag["afx-list-item-proto"]
constructor: (r, o) ->
super r, o
__data__: (v) ->
return unless v
nativel = ["content", "start", "end" ]
@set "closable", v.closable
for k, el of @refs
if v[k] and v[k] isnt ""
if nativel.includes k
$(el).text v[k]
else
el.set "text", v[k]
__selected: (v) ->
@get("data").selected = v
itemlayout: () ->
{ el: "div", children: [
{ el: "afx-label", ref: "title", class: "afx-cv-sec-title" },
{ el: "afx-label", ref: "subtitle", class: "afx-cv-sec-subtitle" },
{ el: "p", ref: "content", class: "afx-cv-sec-content" },
{ el: "p", class: "afx-cv-sec-period", children: [
{ el: "i", ref: "start" },
{ el: "i", ref: "end", class: "period-end" }
] },
{ el: "afx-label", ref: "location", class: "afx-cv-sec-loc" }
] }
this.OS.GUI.define "afx-blogger-cvsection-item", CVSectionListItemTag
class BlogPostListItemTag extends this.OS.GUI.tag["afx-list-item-proto"]
constructor: (r, o) ->
super r, o
__data__: (v) ->
return unless v
v.closable = true
@set "closable", v.closable
@refs.title.set "text", v.title
@refs.ctimestr.set "text", __("Created: {0}", v.ctimestr)
@refs.utimestr.set "text", __("Updated: {0}", v.utimestr)
__selected: (v) ->
@get("data").selected = v
itemlayout: () ->
{ el: "div", children: [
{ el: "afx-label", ref: "title", class: "afx-blogpost-title" },
{ el: "afx-label", ref: "ctimestr", class: "blog-dates" },
{ el: "afx-label", ref: "utimestr", class: "blog-dates" },
] }
this.OS.GUI.define "afx-blogger-post-item", BlogPostListItemTag

View File

@ -259,6 +259,6 @@ graph TD;
C-->D; C-->D;
""" """
GraphEditor.dependencies = [ GraphEditor.dependencies = [
"ace/ace" "os://scripts/ace/ace.js"
] ]
this.OS.register "GraphEditor", GraphEditor this.OS.register "GraphEditor", GraphEditor

View File

@ -1 +0,0 @@
{"name":"GraphEditor","root":"home://workspace/GraphEditor","css":["css/main.css"],"javascripts":["javascripts/svg-pan-zoom.js","javascripts/mermaidAPI.min.js"],"coffees":["coffees/main.coffee"],"copies":["assets/scheme.html","package.json","README.md"]}

8
GraphEditor/project.json Normal file
View File

@ -0,0 +1,8 @@
{
"name": "GraphEditor",
"root": "home://workspace/antosdk-apps/GraphEditor",
"css": ["css/main.css"],
"javascripts": ["javascripts/svg-pan-zoom.js", "javascripts/mermaidAPI.min.js"],
"coffees": ["coffees/main.coffee"],
"copies": ["assets/scheme.html", "package.json", "README.md"]
}

View File

@ -17,6 +17,15 @@
"version": "0.0.2-a", "version": "0.0.2-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ActivityMonitor/build/release/ActivityMonitor.zip" "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ActivityMonitor/build/release/ActivityMonitor.zip"
}, },
{
"pkgname": "Blogger",
"name": "Blogging application",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Blogger/README.md",
"category": "Internet",
"author": "Xuan Sang LE",
"version": "0.0.6-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Blogger/build/release/Blogger.zip"
},
{ {
"pkgname": "LuaPlayground", "pkgname": "LuaPlayground",
"name": "LuaPlayground", "name": "LuaPlayground",