4 # Readings jquery plugin dispatcher.
11 $.fn.Readings[meth].apply(this, args)
15 if Readings.initialized?
17 Readings.config = new Readings.Config
18 wlurl: 'http://readings.local'
25 show_filter: [ 'authors', 'themes' ]
26 show_dividers: [ 'authors', 'themes']
28 Readings.catalogue = new Readings.Catalogue().open()
29 Readings.initialized = true
31 $(document).on 'pageinit', '#page-categories' , (ev) ->
33 $('#list-categories').Readings 'CategoryList'
35 rcategory = /category=(\w+)/
36 rtag = /tag=([a-z0-9-]+)/
37 rtagid = /tag_id=([0-9]+)/
39 $(document).on 'pageinit', "#page-tags", (ev, ui) ->
40 category = rcategory.exec($(this).attr('data-url'))
42 category = category[1]
44 return $(this).Readings 'list',
46 # url: Readings.config.get('wlurl') + "/api/#{category}"
47 sql: "SELECT * FROM tag WHERE category=? ORDER BY sort_key"
49 filter: (Readings.config.get('show_filter').indexOf(category) >= 0)
50 mapper: (rec) -> new Readings.Tag(rec, category)
51 dividers: (Readings.config.get('show_dividers').indexOf(category) >= 0)
52 alert 'no category in query string'
54 $(document).on 'pageinit', '#page-books', (ev, ui) ->
55 tag_id_m = rtagid.exec($(this).attr('data-url'))
56 tag_id = tag_id_m[1] if tag_id_m?
58 tag = Readings.catalogue.withTag tag_id, (tag) =>
59 $(this).Readings 'list',
60 fetch: (cb) -> Readings.catalogue.withBooks(tag, cb)
62 dividers: (tag.category != 'author')