mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-11-20 04:08:20 +01:00
add modif
This commit is contained in:
parent
7c2cc7dc11
commit
46b048f221
@ -74,7 +74,7 @@
|
|||||||
|
|
||||||
createBook() {
|
createBook() {
|
||||||
var book, c1, c2, f1, f2, f3, f4, sec1, sec2, sec3;
|
var book, c1, c2, f1, f2, f3, f4, sec1, sec2, sec3;
|
||||||
book = new Book("home://test");
|
book = new Book("home://test", "mybook");
|
||||||
c1 = new BookletChapter(book, "Chapter one");
|
c1 = new BookletChapter(book, "Chapter one");
|
||||||
c2 = new BookletChapter(book, "Chapter two");
|
c2 = new BookletChapter(book, "Chapter two");
|
||||||
sec1 = new BookletSection(c1, "section 1 in c1");
|
sec1 = new BookletSection(c1, "section 1 in c1");
|
||||||
@ -173,9 +173,9 @@
|
|||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {}
|
save(apif) {}
|
||||||
|
|
||||||
remove() {}
|
remove(apif) {}
|
||||||
|
|
||||||
rename(newname) {}
|
rename(newname) {}
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ class BookletFolder extends BookletEntry
|
|||||||
constructor: (name) ->
|
constructor: (name) ->
|
||||||
super name
|
super name
|
||||||
|
|
||||||
save: () ->
|
save: (apif) ->
|
||||||
|
|
||||||
remove: () ->
|
remove: (apif) ->
|
||||||
|
|
||||||
rename: (newname) ->
|
rename: (newname) ->
|
||||||
|
|
||||||
@ -26,6 +26,7 @@ class Book extends BookletFolder
|
|||||||
super name
|
super name
|
||||||
@chapters = []
|
@chapters = []
|
||||||
@metaFile = "#{@path}/meta.json".asFileHandler()
|
@metaFile = "#{@path}/meta.json".asFileHandler()
|
||||||
|
@descFile = "#{@path}/book.md".asFileHandler()
|
||||||
|
|
||||||
addChapter: (chap) ->
|
addChapter: (chap) ->
|
||||||
chap.book = @
|
chap.book = @
|
||||||
@ -33,11 +34,26 @@ class Book extends BookletFolder
|
|||||||
|
|
||||||
size: () ->
|
size: () ->
|
||||||
return @chapters.length
|
return @chapters.length
|
||||||
|
|
||||||
|
save:(handle) ->
|
||||||
|
v.save handle for v in @chapters
|
||||||
|
me = @
|
||||||
|
if @dirty
|
||||||
|
if @descFile.dirty
|
||||||
|
@descFile.write "text/plain", (r) ->
|
||||||
|
handle.error __("Fail to save file {0}: {1}", me.descFile.path, r.error) if r.error
|
||||||
|
@metaFile.cache = @toc()
|
||||||
|
@metaFile.dirty = true
|
||||||
|
@metaFile.write "object", (r) ->
|
||||||
|
return handle.error __("Fail to write book meta: {0}", r.error)
|
||||||
|
me.markAsClean
|
||||||
|
handle.notify __("Book saved")
|
||||||
|
|
||||||
toc: () ->
|
toc: () ->
|
||||||
return {
|
return {
|
||||||
name: @name,
|
name: @name,
|
||||||
path: @path,
|
path: @path,
|
||||||
|
description: @descFile.path,
|
||||||
meta: @metaFile.path,
|
meta: @metaFile.path,
|
||||||
entries: v.toc() for v in @chapters
|
entries: v.toc() for v in @chapters
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class Booklet extends this.OS.GUI.BaseApplication
|
|||||||
@createBook()
|
@createBook()
|
||||||
|
|
||||||
createBook: () ->
|
createBook: () ->
|
||||||
book = new Book("home://test", "mybook", @)
|
book = new Book("home://test", "mybook")
|
||||||
c1 = new BookletChapter(book, "Chapter one")
|
c1 = new BookletChapter(book, "Chapter one")
|
||||||
c2 = new BookletChapter(book, "Chapter two")
|
c2 = new BookletChapter(book, "Chapter two")
|
||||||
sec1 = new BookletSection(c1, "section 1 in c1")
|
sec1 = new BookletSection(c1, "section 1 in c1")
|
||||||
|
Loading…
Reference in New Issue
Block a user