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 = ...
print(data.content)
-- print(data.content)
local error_msg = {}
local iserror = false
for k,v in pairs(data.to) do
print("sent to:"..v)
local to = v
@ -11,7 +13,12 @@ for k,v in pairs(data.to) do
--print(cmd)
local r = os.execute(cmd)
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
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-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;"/>
<div data-id="editor-container">
<textarea name="content" data-id = "contentarea" />
</div>
<afx-hbox data-height = "35">
<div></div>
<afx-switch data 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-hbox>
</afx-vbox>
</afx-app-window>
<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

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

View File

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

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;
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 {
background-color: #333333;
font-size: 20px;
color: #929292;
afx-app-window[data-id="blogger-win"] afx-tab-container[data-id="tabcontainer"] afx-tab-bar afx-list-view > div.list-container > ul li{
font-size: 15px;
padding:0;
width: 100%;
border-radius: 0;
border:0;
margin: 0;
text-align: center;
}
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] > div > ul > li.selected{
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 {
background-color: #116cd6;
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-hbox{
margin-bottom: 5px;
margin-top: 5px;
}
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-label{
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-label i.label-text{
font-weight: bold;
}
afx-app-window[data-id="blogger-win"] afx-hbox.cv-side-bar-btn{
padding-left:3px;
padding-top:3px;
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 .lbl-header i.label-text{
font-weight: bold;
}
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;
text-align: center;
}
afx-app-window[data-id="blogger-cv-sec-win"] afx-hbox{
padding-left:5px;
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{
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > .list-container > ul .afx-cv-sec-title .label-text{
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 {
border: 2px solid #116cd6;
color: #414339;
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] afx-blogger-cvsection-item p {
padding: 0;
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;
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"] .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{
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .closable::before{
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;
}
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-weight: normal;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "blog-list"] > div.list-container > ul > li.selected .blog-dates{
color: white;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "blog-list"] > div.list-container > ul li.selected {
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-list-view data-id="tabbar" data-width="30"></afx-list-view>
<afx-vbox>
<afx-hbox data-id="user-container" data-height="100%">
<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>
@ -24,17 +24,19 @@
<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)"/>
<textarea name="shortbiblio" input-class = "user-input"/>
<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 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%">
<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 = "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-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>
@ -42,20 +44,23 @@
<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 = "3"/>
<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">
<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-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%">
<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>
<div data-id = "editor-container">
<textarea data-id="markarea" ></textarea>
@ -71,6 +76,7 @@
<div data-height="5"></div>
</afx-vbox>
</afx-hbox>
</afx-vbox>
</afx-tab-container>
</afx-hbox>
</afx-app-window>

View File

@ -7,12 +7,12 @@
<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" />
<textarea name="content" data-id = "contentarea" />
<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 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>

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;
"""
GraphEditor.dependencies = [
"ace/ace"
"os://scripts/ace/ace.js"
]
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",
"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",
"name": "LuaPlayground",