mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2025-07-12 22:03:29 +02:00
add new apps
This commit is contained in:
24
Booklet/build/debug/README.md
Normal file
24
Booklet/build/debug/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
# Booklet
|
||||
A tool for my online document hub
|
||||
|
||||
## Howto
|
||||
|
||||
1. Open the project.apj file with AntOSDK (simply double Click on it)
|
||||
2. Modify the UI in *assets/scheme.html*
|
||||
3. Modify application code in *coffees/main.coffee*
|
||||
4. Modify CSS style in *css/main.css*
|
||||
5. Other files need to be copied: put in to assets
|
||||
|
||||
## Set up build target
|
||||
|
||||
Click **Menu> Build > Build Option** or simply hit **ALT-Y**
|
||||
|
||||
In the build options dialog, add or remove files that need to be
|
||||
included into the build
|
||||
|
||||
Click **Save**
|
||||
|
||||
## Build application
|
||||
* To build: **Menu > Build > Build** or **ALT-C**
|
||||
* To build and run: **Menu > Build > Build and Run** or **CTRL-R**
|
||||
* To release: **Menu > Build > Build release** or **ALT-P**
|
324
Booklet/build/debug/main.js
Normal file
324
Booklet/build/debug/main.js
Normal file
@ -0,0 +1,324 @@
|
||||
(function() {
|
||||
var Book, Booklet, BookletChapter, BookletEntry, BookletFile, BookletFolder, BookletSection;
|
||||
|
||||
Booklet = class Booklet extends this.OS.GUI.BaseApplication {
|
||||
constructor(args) {
|
||||
super("Booklet", args);
|
||||
}
|
||||
|
||||
main() {
|
||||
this.initEditor();
|
||||
return this.resizeContent();
|
||||
}
|
||||
|
||||
initEditor() {
|
||||
var markarea, me;
|
||||
markarea = this.find("markarea");
|
||||
this.container = this.find("mycontainer");
|
||||
this.previewOn = false;
|
||||
this.currfile = "Untitled".asFileHandler();
|
||||
this.editormux = false;
|
||||
me = this;
|
||||
this.editor = new SimpleMDE({
|
||||
element: markarea,
|
||||
autofocus: true,
|
||||
tabSize: 4,
|
||||
indentWithTabs: true,
|
||||
toolbar: [
|
||||
"bold",
|
||||
"italic",
|
||||
"heading",
|
||||
"|",
|
||||
"quote",
|
||||
"code",
|
||||
"unordered-list",
|
||||
"ordered-list",
|
||||
"|",
|
||||
"link",
|
||||
"image",
|
||||
"table",
|
||||
"horizontal-rule",
|
||||
"|",
|
||||
{
|
||||
name: "preview",
|
||||
className: "fa fa-eye no-disable",
|
||||
action: function(e) {
|
||||
me.previewOn = !me.previewOn;
|
||||
return SimpleMDE.togglePreview(e);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
//if(self.previewOn) toggle the highlight
|
||||
//{
|
||||
// var container = self._scheme.find(self,"Text")
|
||||
// .$element.getElementsByClassName("editor-preview");
|
||||
// if(container.length == 0) return;
|
||||
// var codes = container[0].getElementsByTagName('pre');
|
||||
// codes.forEach(function(el){
|
||||
// hljs.highlightBlock(el);
|
||||
// });
|
||||
// //console.log(code);
|
||||
//}
|
||||
this.on("hboxchange", function(e) {
|
||||
return me.resizeContent();
|
||||
});
|
||||
this.bindKey("ALT-N", function() {
|
||||
return me.actionFile(`${me.name}-New`);
|
||||
});
|
||||
this.bindKey("ALT-O", function() {
|
||||
return me.actionFile(`${me.name}-Open`);
|
||||
});
|
||||
return this.createBook();
|
||||
}
|
||||
|
||||
createBook() {
|
||||
var book, c1, c2, f1, f2, f3, f4, sec1, sec2, sec3;
|
||||
book = new Book("home://test");
|
||||
c1 = new BookletChapter(book, "Chapter one");
|
||||
c2 = new BookletChapter(book, "Chapter two");
|
||||
sec1 = new BookletSection(c1, "section 1 in c1");
|
||||
sec2 = new BookletSection(c1, "section 2 in c1");
|
||||
sec3 = new BookletSection(c2, "section 1 in c2");
|
||||
f1 = new BookletFile(sec1);
|
||||
f2 = new BookletFile(sec2);
|
||||
f3 = new BookletFile(sec3);
|
||||
f4 = new BookletFile(sec1);
|
||||
return console.log(book.toc());
|
||||
}
|
||||
|
||||
resizeContent() {
|
||||
var cheight, children, statusbar, titlebar, toolbar;
|
||||
children = ($(this.container)).children();
|
||||
titlebar = (($(this.scheme)).find(".afx-window-top"))[0];
|
||||
toolbar = children[1];
|
||||
statusbar = children[4];
|
||||
cheight = ($(this.scheme)).height() - ($(titlebar)).height() - ($(toolbar)).height() - ($(statusbar)).height() - 40;
|
||||
return ($(children[2])).css("height", cheight + "px");
|
||||
}
|
||||
|
||||
menu() {
|
||||
var me, menu;
|
||||
me = this;
|
||||
menu = [
|
||||
{
|
||||
text: "__(File)",
|
||||
child: [
|
||||
{
|
||||
text: "__(New booklet)",
|
||||
dataid: `${this.name}-New`,
|
||||
shortcut: "A-N"
|
||||
},
|
||||
{
|
||||
text: "__(Open a booklet)",
|
||||
dataid: `${this.name}-Open`,
|
||||
shortcut: "A-O"
|
||||
}
|
||||
],
|
||||
onmenuselect: function(e) {
|
||||
return me.actionFile(e.item.data.dataid);
|
||||
}
|
||||
}
|
||||
];
|
||||
return menu;
|
||||
}
|
||||
|
||||
actionFile(e) {
|
||||
return console.log("Action file fired");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
me = @
|
||||
switch e
|
||||
when "#{@name}-Open"
|
||||
@openDialog "FileDiaLog", ( d, f ) ->
|
||||
me.open "#{d}/#{f}".asFileHandler()
|
||||
, __("Open file")
|
||||
|
||||
when "#{@name}-New"
|
||||
@currfile = "Untitled".asFileHandler()
|
||||
@currfile.cache = ""
|
||||
@editor.value("")
|
||||
*/
|
||||
Booklet.dependencies = ["mde/simplemde.min"];
|
||||
|
||||
this.OS.register("Booklet", Booklet);
|
||||
|
||||
BookletEntry = class BookletEntry {
|
||||
constructor(name1) {
|
||||
this.name = name1;
|
||||
this.markAsDirty();
|
||||
}
|
||||
|
||||
save() {}
|
||||
|
||||
remove() {}
|
||||
|
||||
markAsDirty() {
|
||||
return this.dirty = true;
|
||||
}
|
||||
|
||||
markAsClean() {
|
||||
return this.dirty = false;
|
||||
}
|
||||
|
||||
toc() {}
|
||||
|
||||
};
|
||||
|
||||
BookletFolder = class BookletFolder extends BookletEntry {
|
||||
constructor(name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
save() {}
|
||||
|
||||
remove() {}
|
||||
|
||||
rename(newname) {}
|
||||
|
||||
};
|
||||
|
||||
Book = class Book extends BookletFolder {
|
||||
constructor(path, name) {
|
||||
super(name);
|
||||
this.path = path;
|
||||
this.chapters = [];
|
||||
this.metaFile = `${this.path}/meta.json`.asFileHandler();
|
||||
}
|
||||
|
||||
addChapter(chap) {
|
||||
chap.book = this;
|
||||
return this.chapters.push(chap);
|
||||
}
|
||||
|
||||
size() {
|
||||
return this.chapters.length;
|
||||
}
|
||||
|
||||
toc() {
|
||||
var v;
|
||||
return {
|
||||
name: this.name,
|
||||
path: this.path,
|
||||
meta: this.metaFile.path,
|
||||
entries: (function() {
|
||||
var i, len, ref, results;
|
||||
ref = this.chapters;
|
||||
results = [];
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
results.push(v.toc());
|
||||
}
|
||||
return results;
|
||||
}).call(this)
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BookletChapter = class BookletChapter extends BookletFolder {
|
||||
constructor(book1, name) {
|
||||
super(name);
|
||||
this.book = book1;
|
||||
this.book.addChapter(this);
|
||||
this.sections = [];
|
||||
this.path = `${this.book.path}/${this.book.size()}`;
|
||||
this.metaFile = `${this.path}/meta.json`.asFileHandler();
|
||||
this.descFile = `${this.path}/chapter.md`.asFileHandler();
|
||||
}
|
||||
|
||||
addSection(sec) {
|
||||
sec.chapter = this;
|
||||
return this.sections.push(sec);
|
||||
}
|
||||
|
||||
size() {
|
||||
return this.sections.length;
|
||||
}
|
||||
|
||||
toc() {
|
||||
var v;
|
||||
return {
|
||||
name: this.name,
|
||||
path: this.path,
|
||||
meta: this.metaFile.path,
|
||||
description: this.descFile.path,
|
||||
entries: (function() {
|
||||
var i, len, ref, results;
|
||||
ref = this.sections;
|
||||
results = [];
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
results.push(v.toc());
|
||||
}
|
||||
return results;
|
||||
}).call(this)
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BookletSection = class BookletSection extends BookletFolder {
|
||||
constructor(chapter, name) {
|
||||
super(name);
|
||||
this.chapter = chapter;
|
||||
this.chapter.addSection(this);
|
||||
this.path = `${this.chapter.path}/${this.chapter.size()}`;
|
||||
this.files = [];
|
||||
this.descFile = `${this.path}/section.md`.asFileHandler();
|
||||
}
|
||||
|
||||
addFile(file) {
|
||||
file.section = this;
|
||||
return this.files.push(file);
|
||||
}
|
||||
|
||||
toc() {
|
||||
var v;
|
||||
return {
|
||||
name: this.name,
|
||||
path: this.path,
|
||||
description: this.descFile.path,
|
||||
entries: (function() {
|
||||
var i, len, ref, results;
|
||||
ref = this.files;
|
||||
results = [];
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
results.push(v.toc());
|
||||
}
|
||||
return results;
|
||||
}).call(this)
|
||||
};
|
||||
}
|
||||
|
||||
size() {
|
||||
return this.files.length;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BookletFile = class BookletFile extends BookletEntry {
|
||||
constructor(section) {
|
||||
super("");
|
||||
this.section = section;
|
||||
this.section.addFile(this);
|
||||
this.path = `${this.section.path}/${this.section.size()}.md`;
|
||||
this.handle = this.path.asFileHandler();
|
||||
}
|
||||
|
||||
getTitle() {}
|
||||
|
||||
toc() {
|
||||
return {
|
||||
name: this.name,
|
||||
path: this.path
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}).call(this);
|
13
Booklet/build/debug/package.json
Normal file
13
Booklet/build/debug/package.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"app":"Booklet",
|
||||
"name":"Booklet",
|
||||
"description":"",
|
||||
"info":{
|
||||
"author": "",
|
||||
"email": ""
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Other",
|
||||
"iconclass":"fa fa-adn",
|
||||
"mimes":["none"]
|
||||
}
|
9
Booklet/build/debug/scheme.html
Normal file
9
Booklet/build/debug/scheme.html
Normal file
@ -0,0 +1,9 @@
|
||||
<afx-app-window apptitle="Booklet" width="600" height="500" data-id="Booklet">
|
||||
<afx-hbox >
|
||||
<afx-tree-view data-id = "toc-ui" data-width="200"></afx-tree-view>
|
||||
<afx-resizer data-width="3"></afx-resizer>
|
||||
<div data-id = "mycontainer">
|
||||
<textarea data-id="markarea" ></textarea>
|
||||
</div>
|
||||
</afx-hbox>
|
||||
</afx-app-window>
|
Reference in New Issue
Block a user