2007-10-15 16:44:40 -04:00
|
|
|
USING: sequences rss arrays concurrency kernel sorting
|
|
|
|
html.elements io assocs namespaces math threads vocabs html
|
2007-10-16 01:35:32 -04:00
|
|
|
furnace http.server.templating calendar math.parser splitting
|
2007-11-12 01:56:46 -05:00
|
|
|
continuations debugger system http.server.responders ;
|
2007-10-15 16:44:40 -04:00
|
|
|
IN: webapps.planet
|
|
|
|
|
|
|
|
TUPLE: posting author title date link body ;
|
|
|
|
|
|
|
|
: diagnostic write print flush ;
|
|
|
|
|
|
|
|
: fetch-feed ( pair -- feed )
|
|
|
|
second
|
|
|
|
dup "Fetching " diagnostic
|
2007-12-04 21:19:11 -05:00
|
|
|
dup download-feed feed-entries
|
2007-10-15 16:44:40 -04:00
|
|
|
swap "Done fetching " diagnostic ;
|
|
|
|
|
|
|
|
: fetch-blogroll ( blogroll -- entries )
|
|
|
|
#! entries is an array of { author entries } pairs.
|
|
|
|
dup [
|
|
|
|
[ fetch-feed ] [ error. drop f ] recover
|
2007-11-24 16:39:27 -05:00
|
|
|
] parallel-map
|
2007-10-15 16:44:40 -04:00
|
|
|
[ [ >r first r> 2array ] curry* map ] 2map concat ;
|
|
|
|
|
|
|
|
: sort-entries ( entries -- entries' )
|
|
|
|
[ [ second entry-pub-date ] compare ] sort <reversed> ;
|
|
|
|
|
|
|
|
: <posting> ( pair -- posting )
|
|
|
|
#! pair has shape { author entry }
|
|
|
|
first2
|
|
|
|
{ entry-title entry-pub-date entry-link entry-description }
|
|
|
|
get-slots posting construct-boa ;
|
|
|
|
|
|
|
|
: print-posting-summary ( posting -- )
|
|
|
|
<p "news" =class p>
|
|
|
|
<b> dup posting-title write </b> <br/>
|
|
|
|
"- " write
|
|
|
|
dup posting-author write bl
|
|
|
|
<a posting-link =href "more" =class a>
|
|
|
|
"Read More..." write
|
|
|
|
</a>
|
|
|
|
</p> ;
|
|
|
|
|
|
|
|
: print-posting-summaries ( postings -- )
|
|
|
|
[ print-posting-summary ] each ;
|
|
|
|
|
|
|
|
: print-blogroll ( blogroll -- )
|
|
|
|
<ul "description" =class ul>
|
|
|
|
[
|
|
|
|
<li> <a dup third =href a> first write </a> </li>
|
|
|
|
] each
|
|
|
|
</ul> ;
|
|
|
|
|
|
|
|
: format-date ( date -- string )
|
|
|
|
10 head "-" split [ string>number ] map
|
|
|
|
first3 0 0 0 0 <timestamp>
|
|
|
|
[
|
|
|
|
dup timestamp-day #
|
|
|
|
" " %
|
|
|
|
dup timestamp-month month-abbreviations nth %
|
|
|
|
", " %
|
|
|
|
timestamp-year #
|
|
|
|
] "" make ;
|
|
|
|
|
|
|
|
: print-posting ( posting -- )
|
|
|
|
<h2 "posting-title" =class h2>
|
|
|
|
<a dup posting-link =href a>
|
2007-10-29 01:17:02 -04:00
|
|
|
dup posting-title write-html
|
2007-10-15 16:44:40 -04:00
|
|
|
" - " write
|
|
|
|
dup posting-author write
|
|
|
|
</a>
|
|
|
|
</h2>
|
|
|
|
<p "posting-body" =class p> dup posting-body write-html </p>
|
|
|
|
<p "posting-date" =class p> posting-date format-date write </p> ;
|
|
|
|
|
|
|
|
: print-postings ( postings -- )
|
|
|
|
[ print-posting ] each ;
|
|
|
|
|
|
|
|
: browse-webapp-source ( vocab -- )
|
|
|
|
<a f >vocab-link browser-link-href =href a>
|
|
|
|
"Browse source" write
|
|
|
|
</a> ;
|
|
|
|
|
|
|
|
SYMBOL: default-blogroll
|
|
|
|
SYMBOL: cached-postings
|
|
|
|
|
|
|
|
: update-cached-postings ( -- )
|
|
|
|
default-blogroll get fetch-blogroll sort-entries
|
|
|
|
[ <posting> ] map
|
|
|
|
cached-postings set-global ;
|
|
|
|
|
|
|
|
: mini-planet-factor ( -- )
|
|
|
|
cached-postings get 4 head print-posting-summaries ;
|
|
|
|
|
|
|
|
: planet-factor ( -- )
|
2007-11-12 01:30:38 -05:00
|
|
|
serving-html [
|
2007-10-15 16:44:40 -04:00
|
|
|
"resource:extra/webapps/planet/planet.fhtml"
|
|
|
|
run-template-file
|
|
|
|
] with-html-stream ;
|
|
|
|
|
|
|
|
\ planet-factor { } define-action
|
|
|
|
|
|
|
|
{
|
2007-11-15 04:40:47 -05:00
|
|
|
{ "Berlin Brown" "http://factorlang-fornovices.blogspot.com/feeds/posts/default" "http://factorlang-fornovices.blogspot.com" }
|
2007-10-15 16:44:40 -04:00
|
|
|
{ "Chris Double" "http://www.bluishcoder.co.nz/atom.xml" "http://www.bluishcoder.co.nz/" }
|
|
|
|
{ "Elie Chaftari" "http://fun-factor.blogspot.com/feeds/posts/default" "http://fun-factor.blogspot.com/" }
|
|
|
|
{ "Doug Coleman" "http://code-factor.blogspot.com/feeds/posts/default" "http://code-factor.blogspot.com/" }
|
|
|
|
{ "Daniel Ehrenberg" "http://useless-factor.blogspot.com/feeds/posts/default" "http://useless-factor.blogspot.com/" }
|
2007-10-29 01:17:02 -04:00
|
|
|
{ "Kio M. Smallwood"
|
|
|
|
"http://sekenre.wordpress.com/feed/atom/"
|
|
|
|
"http://sekenre.wordpress.com/" }
|
2007-11-24 16:39:27 -05:00
|
|
|
{ "Phil Dawes" "http://www.phildawes.net/blog/category/factor/feed/atom" "http://www.phildawes.net/blog/" }
|
2007-10-15 16:44:40 -04:00
|
|
|
{ "Samuel Tardieu" "http://www.rfc1149.net/blog/tag/factor/feed/atom/" "http://www.rfc1149.net/blog/tag/factor/" }
|
|
|
|
{ "Slava Pestov" "http://factor-language.blogspot.com/atom.xml" "http://factor-language.blogspot.com/" }
|
|
|
|
} default-blogroll set-global
|
|
|
|
|
2007-10-24 02:24:26 -04:00
|
|
|
SYMBOL: last-update
|
|
|
|
|
2007-10-15 16:44:40 -04:00
|
|
|
: update-thread ( -- )
|
2007-10-24 02:24:26 -04:00
|
|
|
millis last-update set-global
|
|
|
|
[ update-cached-postings ] in-thread
|
2007-10-15 16:44:40 -04:00
|
|
|
10 60 * 1000 * sleep
|
|
|
|
update-thread ;
|
|
|
|
|
|
|
|
: start-update-thread ( -- )
|
|
|
|
[ update-thread ] in-thread ;
|
|
|
|
|
|
|
|
"planet" "planet-factor" "extra/webapps/planet" web-app
|
2007-11-21 04:19:32 -05:00
|
|
|
|
|
|
|
: merge-feeds ( feeds -- feed )
|
|
|
|
[ feed-entries ] map concat sort-entries ;
|
|
|
|
|
|
|
|
: planet-feed ( -- feed )
|
2007-12-04 21:19:11 -05:00
|
|
|
default-blogroll get [ second download-feed ] map merge-feeds
|
2007-11-21 04:19:32 -05:00
|
|
|
>r "[ planet-factor ]" "http://planet.factorcode.org" r> <entry>
|
2007-12-04 21:19:11 -05:00
|
|
|
feed>xml ;
|
2007-11-21 04:19:32 -05:00
|
|
|
|
|
|
|
: feed.xml planet-feed ;
|
|
|
|
|
|
|
|
\ feed.xml { } define-action
|