4 slug_in_url = /([a-z0-9-]+)[/]?$/
5 slug_in_url.exec(url)[1]
8 constructor: (record) ->
12 wlurl = Readings.config.get 'wlurl'
14 <a href=\"reader.html?book_id=#{@id}\">
15 <img src=\"#{wlurl}#{@cover}\">
24 html = localStorage.getItem("html:#{@id}")
25 return not (html == null)
29 html = localStorage.getItem("html:#{@id}")
30 return $(html) if html
33 # fetches books content from WL
34 # and pass it to callback
36 $.ajax Readings.config.get "wlurl" + "/katalog/lektura/#{@slug}.html",
40 text = @mobilize_html text
41 localStorage.setItem("html:#{@id}", text)
43 @db.transaction (tx) =>
44 tx.executeSql "UPDATE _local = 1 WHERE id=?", [@id], (tx, rs) =>
47 throw Error "Error fetching book text slug=#{@slug}, #{er}"
49 mobilize_html: (html) ->
51 book_text = html.find("#book-id")
52 html.find("#download, #header, #themes").delete()
57 constructor: (record, @category) ->
58 $.extend(this, record)
61 "<li><a href=\"books.html?tag_id=#{@id}\">#{@name}</a></li>"
64 @sort_key[0].toUpperCase()
65 # if @category == 'author'
66 # # last word, first letter
67 # @name.split(' ').slice(-1)[0][0].toUpperCase()
69 # @name[0].toUpperCase()
73 # $.fn.Readings.BookList = (category, tag) ->
75 # $('[data-role=header] h1').text tag.name
76 # list = $('[data-role=listview]', this)
78 # url: "#{tag.href}books/"
79 # #url: Readings.config.get('wlurl') + "/api/#{category}"
83 # books = $.map data, (rec) -> new Readings.Book(rec)
85 # last_separator = null
86 # show_separator = !(category == 'authors')
89 # # throw a separator in for some categories
91 # separator = t.group()
92 # if last_separator != separator
93 # list.append "<li data-role=\"list-divider\">#{separator}</li>"
94 # last_separator = separator
96 # list.append b.render()
97 # list.listview 'refresh'