rss.t 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. # Copyright (C) 2006–2018 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. require './t/test.pl';
  16. package OddMuse;
  17. use Test::More tests => 135;
  18. use utf8; # tests contain UTF-8 characters and it matters
  19. AppendStringToFile($ConfigFile, "\$CommentsPrefix = 'Comments on ';\n");
  20. xpath_test(get_page('action=browse id=HomePage username=alex'),
  21. '//link[@rel="alternate"][@type="application/rss+xml"]'
  22. . '[@title="Follow-ups for alex"]'
  23. . '[@href="http://localhost/wiki.pl?action=rss;followup=alex"]');
  24. # make sure the right summary is shown
  25. update_page('big',
  26. 'A monk asked Seijo: "I understand that a Buddha who lived before '
  27. . 'recorded history sat in meditation for ten cycles of existence '
  28. . 'and could not realize the highest truth, and so could not become '
  29. . 'fully emancipated. Why was this so?',
  30. 'A Buddha Before History');
  31. test_page(get_page('action=rss full=1 diff=1'),
  32. 'A monk asked Seijo', 'A Buddha Before History', 'No diff available.');
  33. update_page('big',
  34. 'Seijo replied: "Your question is self-explanatory."',
  35. 'The first answer');
  36. test_page(get_page('action=rss full=1 diff=1'),
  37. '&lt;strong class="changes"&gt;A monk asked&lt;/strong&gt; Seijo', 'Seijo replied', 'The first answer');
  38. update_page('big',
  39. 'The monk asked: "Since the Buddha was meditating, '
  40. . 'why could he not fulfill Buddahood?"',
  41. 'A follow-up question');
  42. update_page('big', 'Seijo said: "He was not a Buddha."',
  43. 'The second answer', 1); # minor change
  44. # this diff ignores the minor change
  45. test_page(get_page('action=rss full=1 diff=1'),
  46. 'Seijo replied', 'The monk asked', 'A follow-up question');
  47. # this diff shows the minor change
  48. test_page(get_page('action=rss full=1 diff=2'),
  49. 'The monk asked', 'Seijo said', 'The second answer');
  50. # the order of pages and comment pages; the stripping of dates
  51. update_page('big', 'foo foo');
  52. update_page('2008-08-07_New_Hope', 'testing');
  53. update_page('2008-08-08', 'testing');
  54. update_page('2008-08-07_12h50_Forget_It', 'testing');
  55. update_page('Comments_on_2008-08-07_New_Hope', 'testing');
  56. test_page(get_page('action=rss full=1'),
  57. '<title>big</title>',
  58. '<title>New Hope</title>',
  59. '<title>12h50 Forget It</title>', # wrong
  60. '<title>2008-08-08</title>',
  61. '<title>Comments on New Hope</title>',
  62. '<description>&lt;div class="e-content" lang="en"&gt;&lt;p&gt;foo foo&lt;/p&gt;&lt;/div&gt;</description>');
  63. # no stripping of dates
  64. test_page(get_page('action=rss short=0'),
  65. '<title>big</title>',
  66. '<title>2008-08-07 New Hope</title>',
  67. '<title>2008-08-07 12h50 Forget It</title>',
  68. '<title>Comments on 2008-08-07 New Hope</title>');
  69. # changing $RssStrip to strip the hours in addition to the date
  70. AppendStringToFile($ConfigFile, "\$RssStrip = '^\\d\\d\\d\\d-\\d\\d-\\d\\d_(\\d\\d?h\\d\\d_)?';\n");
  71. test_page(get_page('action=rss'),
  72. '<title>New Hope</title>',
  73. '<title>Forget It</title>');
  74. # no more stripping
  75. AppendStringToFile($ConfigFile, "\$RssStrip = '';\n");
  76. test_page(get_page('action=rss'),
  77. '<title>2008-08-07 New Hope</title>',
  78. '<title>2008-08-07 12h50 Forget It</title>');
  79. # limiting the size of our RSS feed
  80. update_page('big', 'foo foo foo', '<mu>');
  81. test_page(get_page('action=rss'), '<description>&amp;lt;mu&amp;gt;</description>');
  82. test_page(get_page('action=rss full=1'), 'foo foo foo');
  83. test_page(get_page('action=rss full=1 diff=1'), '&lt;div class="diff"&gt;');
  84. update_page('big', 'x' x 49000);
  85. test_page(get_page('action=rss full=1'), 'xxxxxx');
  86. test_page(get_page('action=rss full=1 diff=1'), 'too big to send over RSS');
  87. update_page('big', 'x' x 55000, 'big edit');
  88. test_page_negative(get_page('action=rss full=1'), 'xxxxxx');
  89. test_page(get_page('action=rss full=1'), 'too big to send over RSS');
  90. update_page('big', "mee too\n" x 2 . 'x' x 55000);
  91. test_page(get_page('action=rss full=1'), 'too big to send over RSS');
  92. test_page(get_page('action=rss full=1 diff=1'), 'mee too', 'too big to send over RSS');
  93. # pagination
  94. my $interval = $RcDefault * 24 * 60 * 60;
  95. my $t1 = $Now - $interval;
  96. my $t2 = $Now - 2 * $interval;
  97. my $t3 = $Now - 3 * $interval;
  98. my $action1 = " from=$t2 upto=$t1";
  99. my $window1 = ";from=$t2;upto=$t1";
  100. my $window2 = ";from=$t3;upto=$t2";
  101. # make sure we start from a well-known point in time
  102. AppendStringToFile($ConfigFile, "push(\@MyInitVariables, sub { \$Now = '$Now' });\n");
  103. # check default RSS
  104. xpath_test(get_page('action=rss'),
  105. '//atom:link[@rel="self"][@href="http://localhost/wiki.pl?action=rss"]',
  106. '//atom:link[@rel="last"][@href="http://localhost/wiki.pl?action=rss"]',
  107. '//atom:link[@rel="previous"][@href="http://localhost/wiki.pl?action=rss' . $window1 . '"]');
  108. # check next page
  109. xpath_test(get_page('action=rss' . $action1),
  110. '//atom:link[@rel="self"][@href="http://localhost/wiki.pl?action=rss' . $window1 . '"]',
  111. '//atom:link[@rel="last"][@href="http://localhost/wiki.pl?action=rss"]',
  112. '//atom:link[@rel="previous"][@href="http://localhost/wiki.pl?action=rss' . $window2 . '"]');
  113. # check next page but with full pages
  114. xpath_test(get_page('action=rss full=1' . $action1),
  115. '//atom:link[@rel="self"][@href="http://localhost/wiki.pl?action=rss' . $window1 . ';full=1"]',
  116. '//atom:link[@rel="last"][@href="http://localhost/wiki.pl?action=rss;full=1"]',
  117. '//atom:link[@rel="previous"][@href="http://localhost/wiki.pl?action=rss' . $window2 . ';full=1"]');
  118. SKIP: {
  119. eval {
  120. require XML::RSS;
  121. };
  122. skip "XML::RSS not installed", 89 if $@;
  123. use Cwd;
  124. $dir = cwd;
  125. $uri = "file://$dir/t/feeds";
  126. $uri =~ s/ /%20/g; # for cygdrive stuff including spaces
  127. # some xpath tests
  128. update_page('RSS', "<rss $uri/heise.rdf>");
  129. $page = get_page('RSS');
  130. xpath_test($page, '//a[@title="999"][@href="http://www.heise.de/tp/deutsch/inhalt/te/15886/1.html"][text()="Berufsverbot für Mediendesigner?"]');
  131. test_page($page, split('\n',<<'EOT'));
  132. <div class="rss"><ul><li>
  133. Experimentell bestätigt:
  134. http://www.heise.de/tp/deutsch/inhalt/lis/15882/1.html
  135. Clash im Internet?
  136. http://www.heise.de/tp/deutsch/special/med/15787/1.html
  137. Die Einheit der Umma gegen die jüdische Weltmacht
  138. http://www.heise.de/tp/deutsch/special/ost/15879/1.html
  139. Im Krieg mit dem Satan
  140. http://www.heise.de/tp/deutsch/inhalt/co/15880/1.html
  141. Der dritte Mann
  142. http://www.heise.de/tp/deutsch/inhalt/co/15876/1.html
  143. Leicht neben dem Ziel
  144. http://www.heise.de/tp/deutsch/inhalt/mein/15867/1.html
  145. Wale sollten Nordkorea meiden
  146. http://www.heise.de/tp/deutsch/inhalt/co/15878/1.html
  147. Afghanistan-Krieg und Irak-Besatzung haben al-Qaida gestärkt
  148. http://www.heise.de/tp/deutsch/inhalt/co/15874/1.html
  149. Der mit dem Dinosaurier tanzt
  150. http://www.heise.de/tp/deutsch/inhalt/lis/15863/1.html
  151. Terroranschlag überschattet das Genfer Abkommen
  152. http://www.heise.de/tp/deutsch/special/ost/15873/1.html
  153. "Barwatch" in Kanada
  154. http://www.heise.de/tp/deutsch/inhalt/te/15871/1.html
  155. Die Türken kommen!
  156. http://www.heise.de/tp/deutsch/special/irak/15870/1.html
  157. Neue Regelungen zur Telekommunikationsüberwachung
  158. http://www.heise.de/tp/deutsch/inhalt/te/15869/1.html
  159. Ein Lied vom Tod
  160. http://www.heise.de/tp/deutsch/inhalt/kino/15862/1.html
  161. EOT
  162. # RSS 2.0
  163. update_page('RSS', "<rss $uri/flickr.xml>");
  164. test_page(get_page('RSS'),
  165. join('(.|\n)*', # verify the *order* of things.
  166. 'href="http://www.flickr.com/photos/broccoli/867118/"',
  167. 'href="http://www.flickr.com/photos/broccoli/867075/"',
  168. 'href="http://www.flickr.com/photos/seuss/864332/"',
  169. 'href="http://www.flickr.com/photos/redking/851171/"',
  170. 'href="http://www.flickr.com/photos/redking/851168/"',
  171. 'href="http://www.flickr.com/photos/redking/851167/"',
  172. 'href="http://www.flickr.com/photos/redking/851166/"',
  173. 'href="http://www.flickr.com/photos/redking/851165/"',
  174. 'href="http://www.flickr.com/photos/bibo/844085/"',
  175. 'href="http://www.flickr.com/photos/theunholytrinity/867312/"'),
  176. join('(.|\n)*',
  177. 'title="2004-10-14 09:34:47 "',
  178. 'title="2004-10-14 09:28:11 "',
  179. 'title="2004-10-14 05:08:17 "',
  180. 'title="2004-10-13 10:00:34 "',
  181. 'title="2004-10-13 10:00:30 "',
  182. 'title="2004-10-13 10:00:27 "',
  183. 'title="2004-10-13 10:00:25 "',
  184. 'title="2004-10-13 10:00:22 "',
  185. 'title="2004-10-12 23:38:14 "',
  186. 'title="2004-10-10 10:09:06 "'),
  187. join('(.|\n)*',
  188. '>The Hydra<',
  189. '>The War On Hydra<',
  190. '>Nation Demolished<',
  191. '>Drummers<',
  192. '>Death<',
  193. '>Audio Terrorists<',
  194. '>Crowds<',
  195. '>Assholes<',
  196. '>iraq_saddam03<',
  197. '>brudermann<'));
  198. update_page('RSS', "<rss $uri/kensanata.xml>");
  199. test_page(get_page('RSS'), split('\n',<<'EOT'));
  200. Fania All Stars - Bamboleo
  201. http://www.audioscrobbler.com/music/Fania\+All\+Stars/_/Bamboleo
  202. EOT
  203. update_page('RSS', "<rss $uri/linuxtoday.rdf>");
  204. test_page(get_page('RSS'), split('\n',<<'EOT'));
  205. PRNewswire: Texas Software Startup, Serenity Systems, Advises Business Users to Get Off Windows
  206. http://linuxtoday.com/story.php3\?sn=9443
  207. LinuxPR: MyDesktop Launches Linux Software Section
  208. http://linuxtoday.com/story.php3\?sn=9442
  209. LinuxPR: Franklin Institute Science Museum Chooses Linux
  210. http://linuxtoday.com/story.php3\?sn=9441
  211. Yellow Dog Linux releases updated am-utils
  212. http://linuxtoday.com/story.php3\?sn=9440
  213. LinuxPR: LinuxCare Adds Laser5 Linux To Roster of Supported Linux Distributions
  214. http://linuxtoday.com/story.php3\?sn=9439
  215. EOT
  216. update_page('RSS', "<rss $uri/fm.rdf>");
  217. test_page(get_page('RSS'), split('\n',<<'EOT'));
  218. Xskat 3.1
  219. http://freshmeat.net/news/1999/09/01/936224942.html
  220. Java Test Driver 1.1
  221. http://freshmeat.net/news/1999/09/01/936224907.html
  222. WaveLAN/IEEE driver 1.0.1
  223. http://freshmeat.net/news/1999/09/01/936224545.html
  224. macfork 1.0
  225. http://freshmeat.net/news/1999/09/01/936224336.html
  226. QScheme 0.2.2
  227. http://freshmeat.net/news/1999/09/01/936223755.html
  228. CompuPic 4.6 build 1018
  229. http://freshmeat.net/news/1999/09/01/936223729.html
  230. eXtace 1.1.16
  231. http://freshmeat.net/news/1999/09/01/936223709.html
  232. GTC 0.3
  233. http://freshmeat.net/news/1999/09/01/936223686.html
  234. RocketJSP 0.9c
  235. http://freshmeat.net/news/1999/09/01/936223646.html
  236. Majik 3D 0.0/M3
  237. http://freshmeat.net/news/1999/09/01/936223622.html
  238. EOT
  239. update_page('RSS', "<rss $uri/rss1.0.rdf>");
  240. test_page(get_page('RSS'), split('\n',<<'EOT'));
  241. GTKeyboard 0.85
  242. http://freshmeat.net/news/1999/06/21/930003829.html
  243. EOT
  244. # Note, cannot identify BayleShanks as author in the mb.rdf
  245. update_page('RSS', "<rss $uri/mb.rdf $uri/community.rdf>");
  246. test_page(get_page('RSS'), split('\n',<<'EOT'));
  247. MeatBall:LionKimbro
  248. 2003-10-24T22:49:33\+06:00
  249. CommunityWiki:RecentNearChanges
  250. http://www.usemod.com/cgi-bin/mb.pl\?LionKimbro
  251. 2003-10-24T21:02:53\+00:00
  252. unified rc for here and meatball
  253. <span class="contributor"><span> \. \. \. \. </span>AlexSchroeder</span>
  254. http://www.emacswiki.org/cgi-bin/community\?action=browse;id=RecentNearChanges;revision=1
  255. EOT
  256. # Have multiple, separate feeds on a page.
  257. update_page('RSS', "One:\n\n<rss $uri/mb.rdf>\n\nTwo:\n\n<rss $uri/community.rdf>");
  258. test_page(get_page('RSS'), split('\n',<<'EOT'));
  259. LionKimbro
  260. 2003-10-24T22:49:33\+06:00
  261. RecentNearChanges
  262. http://www.usemod.com/cgi-bin/mb.pl\?LionKimbro
  263. 2003-10-24T21:02:53\+00:00
  264. unified rc for here and meatball
  265. <span class="contributor"><span> \. \. \. \. </span>AlexSchroeder</span>
  266. http://www.emacswiki.org/cgi-bin/community\?action=browse;id=RecentNearChanges;revision=1
  267. EOT
  268. # Have multiple, separate feeds on a page, in a long table
  269. add_module('tables-long.pl');
  270. update_page('RSS', qq"Everything in a long table.
  271. <table/mainpage a/third, b/third, c/third>
  272. a: Fire Engineering Training
  273. b: Fire Engineering LODDs
  274. c: Irons & Ladders
  275. a:
  276. <rss 3 $uri/mb.rdf>
  277. b:
  278. <rss 3 $uri/community.rdf>
  279. c:
  280. <rss 3 $uri/rss1.0.rdf>
  281. ----
  282. ");
  283. test_page(get_page('RSS'), split('\n',<<'EOT'));
  284. reply to Scott's comment \(need threading!\)
  285. reply to sunir
  286. WikiEmigration is the way to go
  287. unified rc for here and meatball
  288. see newpage if you have a namepage on MeatballWiki
  289. GTKeyboard is a graphical keyboard that
  290. EOT
  291. }