rss.t 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. # Copyright (C) 2006–2015 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 => 126;
  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;p&gt;foo foo&lt;/p&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. SKIP: {
  94. eval {
  95. require XML::RSS;
  96. };
  97. skip "XML::RSS not installed", 89 if $@;
  98. use Cwd;
  99. $dir = cwd;
  100. $uri = "file://$dir/t/feeds";
  101. $uri =~ s/ /%20/g; # for cygdrive stuff including spaces
  102. # some xpath tests
  103. update_page('RSS', "<rss $uri/heise.rdf>");
  104. $page = get_page('RSS');
  105. xpath_test($page, '//a[@title="999"][@href="http://www.heise.de/tp/deutsch/inhalt/te/15886/1.html"][text()="Berufsverbot für Mediendesigner?"]');
  106. test_page($page, split('\n',<<'EOT'));
  107. <div class="rss"><ul><li>
  108. Experimentell bestätigt:
  109. http://www.heise.de/tp/deutsch/inhalt/lis/15882/1.html
  110. Clash im Internet?
  111. http://www.heise.de/tp/deutsch/special/med/15787/1.html
  112. Die Einheit der Umma gegen die jüdische Weltmacht
  113. http://www.heise.de/tp/deutsch/special/ost/15879/1.html
  114. Im Krieg mit dem Satan
  115. http://www.heise.de/tp/deutsch/inhalt/co/15880/1.html
  116. Der dritte Mann
  117. http://www.heise.de/tp/deutsch/inhalt/co/15876/1.html
  118. Leicht neben dem Ziel
  119. http://www.heise.de/tp/deutsch/inhalt/mein/15867/1.html
  120. Wale sollten Nordkorea meiden
  121. http://www.heise.de/tp/deutsch/inhalt/co/15878/1.html
  122. Afghanistan-Krieg und Irak-Besatzung haben al-Qaida gestärkt
  123. http://www.heise.de/tp/deutsch/inhalt/co/15874/1.html
  124. Der mit dem Dinosaurier tanzt
  125. http://www.heise.de/tp/deutsch/inhalt/lis/15863/1.html
  126. Terroranschlag überschattet das Genfer Abkommen
  127. http://www.heise.de/tp/deutsch/special/ost/15873/1.html
  128. "Barwatch" in Kanada
  129. http://www.heise.de/tp/deutsch/inhalt/te/15871/1.html
  130. Die Türken kommen!
  131. http://www.heise.de/tp/deutsch/special/irak/15870/1.html
  132. Neue Regelungen zur Telekommunikationsüberwachung
  133. http://www.heise.de/tp/deutsch/inhalt/te/15869/1.html
  134. Ein Lied vom Tod
  135. http://www.heise.de/tp/deutsch/inhalt/kino/15862/1.html
  136. EOT
  137. # RSS 2.0
  138. update_page('RSS', "<rss $uri/flickr.xml>");
  139. test_page(get_page('RSS'),
  140. join('(.|\n)*', # verify the *order* of things.
  141. 'href="http://www.flickr.com/photos/broccoli/867118/"',
  142. 'href="http://www.flickr.com/photos/broccoli/867075/"',
  143. 'href="http://www.flickr.com/photos/seuss/864332/"',
  144. 'href="http://www.flickr.com/photos/redking/851171/"',
  145. 'href="http://www.flickr.com/photos/redking/851168/"',
  146. 'href="http://www.flickr.com/photos/redking/851167/"',
  147. 'href="http://www.flickr.com/photos/redking/851166/"',
  148. 'href="http://www.flickr.com/photos/redking/851165/"',
  149. 'href="http://www.flickr.com/photos/bibo/844085/"',
  150. 'href="http://www.flickr.com/photos/theunholytrinity/867312/"'),
  151. join('(.|\n)*',
  152. 'title="2004-10-14 09:34:47 "',
  153. 'title="2004-10-14 09:28:11 "',
  154. 'title="2004-10-14 05:08:17 "',
  155. 'title="2004-10-13 10:00:34 "',
  156. 'title="2004-10-13 10:00:30 "',
  157. 'title="2004-10-13 10:00:27 "',
  158. 'title="2004-10-13 10:00:25 "',
  159. 'title="2004-10-13 10:00:22 "',
  160. 'title="2004-10-12 23:38:14 "',
  161. 'title="2004-10-10 10:09:06 "'),
  162. join('(.|\n)*',
  163. '>The Hydra<',
  164. '>The War On Hydra<',
  165. '>Nation Demolished<',
  166. '>Drummers<',
  167. '>Death<',
  168. '>Audio Terrorists<',
  169. '>Crowds<',
  170. '>Assholes<',
  171. '>iraq_saddam03<',
  172. '>brudermann<'));
  173. update_page('RSS', "<rss $uri/kensanata.xml>");
  174. test_page(get_page('RSS'), split('\n',<<'EOT'));
  175. Fania All Stars - Bamboleo
  176. http://www.audioscrobbler.com/music/Fania\+All\+Stars/_/Bamboleo
  177. EOT
  178. update_page('RSS', "<rss $uri/linuxtoday.rdf>");
  179. test_page(get_page('RSS'), split('\n',<<'EOT'));
  180. PRNewswire: Texas Software Startup, Serenity Systems, Advises Business Users to Get Off Windows
  181. http://linuxtoday.com/story.php3\?sn=9443
  182. LinuxPR: MyDesktop Launches Linux Software Section
  183. http://linuxtoday.com/story.php3\?sn=9442
  184. LinuxPR: Franklin Institute Science Museum Chooses Linux
  185. http://linuxtoday.com/story.php3\?sn=9441
  186. Yellow Dog Linux releases updated am-utils
  187. http://linuxtoday.com/story.php3\?sn=9440
  188. LinuxPR: LinuxCare Adds Laser5 Linux To Roster of Supported Linux Distributions
  189. http://linuxtoday.com/story.php3\?sn=9439
  190. EOT
  191. update_page('RSS', "<rss $uri/fm.rdf>");
  192. test_page(get_page('RSS'), split('\n',<<'EOT'));
  193. Xskat 3.1
  194. http://freshmeat.net/news/1999/09/01/936224942.html
  195. Java Test Driver 1.1
  196. http://freshmeat.net/news/1999/09/01/936224907.html
  197. WaveLAN/IEEE driver 1.0.1
  198. http://freshmeat.net/news/1999/09/01/936224545.html
  199. macfork 1.0
  200. http://freshmeat.net/news/1999/09/01/936224336.html
  201. QScheme 0.2.2
  202. http://freshmeat.net/news/1999/09/01/936223755.html
  203. CompuPic 4.6 build 1018
  204. http://freshmeat.net/news/1999/09/01/936223729.html
  205. eXtace 1.1.16
  206. http://freshmeat.net/news/1999/09/01/936223709.html
  207. GTC 0.3
  208. http://freshmeat.net/news/1999/09/01/936223686.html
  209. RocketJSP 0.9c
  210. http://freshmeat.net/news/1999/09/01/936223646.html
  211. Majik 3D 0.0/M3
  212. http://freshmeat.net/news/1999/09/01/936223622.html
  213. EOT
  214. update_page('RSS', "<rss $uri/rss1.0.rdf>");
  215. test_page(get_page('RSS'), split('\n',<<'EOT'));
  216. GTKeyboard 0.85
  217. http://freshmeat.net/news/1999/06/21/930003829.html
  218. EOT
  219. # Note, cannot identify BayleShanks as author in the mb.rdf
  220. update_page('RSS', "<rss $uri/mb.rdf $uri/community.rdf>");
  221. test_page(get_page('RSS'), split('\n',<<'EOT'));
  222. MeatBall:LionKimbro
  223. 2003-10-24T22:49:33\+06:00
  224. CommunityWiki:RecentNearChanges
  225. http://www.usemod.com/cgi-bin/mb.pl\?LionKimbro
  226. 2003-10-24T21:02:53\+00:00
  227. unified rc for here and meatball
  228. <span class="contributor"><span> \. \. \. \. </span>AlexSchroeder</span>
  229. http://www.emacswiki.org/cgi-bin/community\?action=browse;id=RecentNearChanges;revision=1
  230. EOT
  231. # Have multiple, separate feeds on a page.
  232. update_page('RSS', "One:\n\n<rss $uri/mb.rdf>\n\nTwo:\n\n<rss $uri/community.rdf>");
  233. test_page(get_page('RSS'), split('\n',<<'EOT'));
  234. LionKimbro
  235. 2003-10-24T22:49:33\+06:00
  236. RecentNearChanges
  237. http://www.usemod.com/cgi-bin/mb.pl\?LionKimbro
  238. 2003-10-24T21:02:53\+00:00
  239. unified rc for here and meatball
  240. <span class="contributor"><span> \. \. \. \. </span>AlexSchroeder</span>
  241. http://www.emacswiki.org/cgi-bin/community\?action=browse;id=RecentNearChanges;revision=1
  242. EOT
  243. # Have multiple, separate feeds on a page, in a long table
  244. add_module('tables-long.pl');
  245. update_page('RSS', qq"Everything in a long table.
  246. <table/mainpage a/third, b/third, c/third>
  247. a: Fire Engineering Training
  248. b: Fire Engineering LODDs
  249. c: Irons & Ladders
  250. a:
  251. <rss 3 $uri/mb.rdf>
  252. b:
  253. <rss 3 $uri/community.rdf>
  254. c:
  255. <rss 3 $uri/rss1.0.rdf>
  256. ----
  257. ");
  258. test_page(get_page('RSS'), split('\n',<<'EOT'));
  259. reply to Scott's comment \(need threading!\)
  260. reply to sunir
  261. WikiEmigration is the way to go
  262. unified rc for here and meatball
  263. see newpage if you have a namepage on MeatballWiki
  264. GTKeyboard is a graphical keyboard that
  265. EOT
  266. }