4 module(..., package
.seeall
)
9 <div id="disqus_thread"></div>
10 <script type="text/javascript">
11 /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
12 var disqus_shortname = 'rubberbytes'; // required: replace example with your forum shortname
14 // The following are highly recommended additional parameters. Remove the slashes in front to use.
15 var disqus_identifier = "$id";
16 var disqus_url = "http://rubberbytes.nfshost.com/$id";
19 var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
20 dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
21 (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
24 <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
25 <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
29 local blog_template
= [=[
36 $do_entries[[<li><a href="?p=$id">$name</a></li>]]
40 local entry_template
= [=[
48 local function pages_in_order(sputnik
)
49 local pages
= sputnik
.saci
:get_nodes_by_prefix
'blog'
51 for id
,page
in pairs(pages
) do
54 table.sort(res
,function(p1
,p2
) return (p1
.creation_time
or '') < (p2
.creation_time
or '') end)
58 local wiki
= require("sputnik.actions.wiki")
59 function actions
.show_blog(node
, request
, sputnik
)
60 -- XXX: Falta el cas on no hi ha cap subpàgina...
61 -- i documentar una mica això
62 local pages
= pages_in_order(sputnik
)
63 local most_recent
= sputnik
:get_node(table.remove(pages
, 1).id
)
65 most_recent
= sputnik
:decorate_node(most_recent
)
66 most_recent
= sputnik
:activate_node(most_recent
)
68 node
.title
= most_recent
.title
:gsub('blog/','')
69 node
.inner_html
= cosmo
.f(blog_template
) {
70 disqs
= cosmo
.f(disqs_tpl
){ id
= most_recent
.id
},
71 most_recent
= most_recent
.actions
.show_content(most_recent
, request
, sputnik
),
72 do_entries
= function()
73 for _
, page
in ipairs(pages
) do
76 name
= page
.title
:gsub('blog/',''),
82 return node
.wrappers
.default(node
, request
, sputnik
)
85 function actions
.show_blog_entry(node
, request
, sputnik
)
86 node
.title
= node
.title
:gsub('blog/', '')
87 node
.inner_html
= cosmo
.f(entry_template
) {
88 disqs
= cosmo
.f(disqs_tpl
){ id
= node
.id
},
89 entry_content
= node
.actions
.show_content(node
, request
, sputnik
)
92 return node
.wrappers
.default(node
, request
, sputnik
)
93 -- return wiki.actions.show(node, request, sputnik)
96 function actions
.rss(node
, request
, sputnik
)
97 local pages
= pages_in_order(sputnik
)
100 return cosmo
.f(node
.templates
.RSS
){
101 title
= "Recent Updates to Rubberbytes Blog",
102 channel_url
= "http://" .. sputnik
.config
.DOMAIN
.. sputnik
:make_url(node
.id
),
104 for i
, page
in ipairs(pages
) do
105 page
= sputnik
:decorate_node(page
)
106 page
= sputnik
:activate_node(page
)
108 local last_edit
= sputnik
:get_history(page
.id
, 1)[0]
111 link
= "http://" .. sputnik
.config
.DOMAIN
.. sputnik
:make_url(page
.id
),
112 title
= page
.title
:gsub('blog/',''),
113 ispermalink
= "false",
115 pub_date
= sputnik
:format_time_RFC822(page
.creation_time
), --sputnik:format_time_RFC822(last_edit.timestamp),
116 author
= "Joan Arnaldich",
117 summary
= sputnik
:escape(page
.actions
.show_content(page
, request
, sputnik
))
121 }, "application/rss+xml"
125 function actions
.save_page(node
, request
, sputnik
)
126 if not node
.creation_time
then
128 params
.author
= request
.user
129 params
.creation_time
= os
.time()
130 node
= sputnik
:update_node_with_params(node
, params
)