### rss from usemod 1.0 $InterWikiMoniker = ''; # InterWiki moniker for this wiki. (for RSS) $SiteDescription = $SiteName; # Description of this wiki. (for RSS) $RssLogoUrl = ''; # Optional image for RSS feed $RssDays = 7; # Default number of days in RSS feed $RssTimeZone = 9; # Time Zone of Server (hour), 0 for GMT, 9 for Korea
### 패치를 위해 추가된 환경설정 변수 use vars qw( $UserGotoBar $UserGotoBar2 $UserGotoBar3 $UserGotoBar4 ... $InterWikiMoniker $SiteDescription $RssLogoUrl $RssDays $RssTimeZone ); ### ... ### 패치를 위해 추가된 내부 전역 변수 use vars qw(%RevisionTs $FS_lt $FS_gt $StartTime $Sec_Revision $Sec_Ts ... $QuotedFullUrl); ###
기존의 DoRc 함수가 인자를 받도록 바뀌었다. 0이면 rss, 1이면 기존 html 이다. 따라서 기존 코드에서 DoRc() 로 되어 있던 것들을 DoRc(1) 로 고친다. (0과 1을 반대로 했다면 안 고쳐도 되었을 텐데.. -_-)
sub DoBrowseRequest { ... &DoRc(1); ... }
sub BrowsePage { ... &DoRc(1); ... }
DoRc 함수를 인자에 따라 다르게 동작하도록 고친다. 아래에서 주석문에 rss 가 들어간 부분을 찾아서 고친다.
sub DoRc { ############### ### added by gypark ### rss from usemod1.0 my ($rcType) = @_; my $showHTML; ### ############### my ($fileData, $rcline, $i, $daysago, $lastTs, $ts, $idOnly); ... my $showbar = 0; ############### ### added by gypark ### rss from usemod1.0 if (0 == $rcType) { $showHTML = 0; } else { $showHTML = 1; } ### ############### ... $starttime = &GetParam("from", 0); ############### ### replaced by gypark ### rss from usemod1.0 # print "<h2>" . Ts('Updates since %s', &TimeToText($starttime)) # . "</h2>\n"; if ($showHTML) { print "<h2>" . Ts('Updates since %s', &TimeToText($starttime)) . "</h2>\n"; } ### ############### } else { $daysago = &GetParam("days", 0); $daysago = &GetParam("rcdays", 0) if ($daysago == 0); if ($daysago) { $starttime = $Now - ((24*60*60)*$daysago); ############### ### replaced by gypark ### rss from usemod1.0 # print "<h2>" . Ts('Updates in the last %s day' # . (($daysago != 1)?"s":""), $daysago) . "</h2>\n"; if ($showHTML) { print "<h2>" . Ts('Updates in the last %s day' . (($daysago != 1)?"s":""), $daysago) . "</h2>\n"; } ### ############### # Note: must have two translations (for "day" and "days") # Following comment line is for translation helper script # Ts('Updates in the last %s days', ''); } } if ($starttime == 0) { ############### ### replaced by gypark ### rss from usemod1.0 # $starttime = $Now - ((24*60*60)*$RcDefault); # print "<h2>" . Ts('Updates in the last %s day' # . (($RcDefault != 1)?"s":""), $RcDefault) . "</h2>\n"; if (0 == $rcType) { $starttime = $Now - ((24*60*60)*$RssDays); } else { $starttime = $Now - ((24*60*60)*$RcDefault); } if ($showHTML) { print "<h2>" . Ts('Updates in the last %s day' . (($RcDefault != 1)?"s":""), $RcDefault) . "</h2>\n"; } ### ############### # Translation of above line is identical to previous version } ############### ### pda clip by gypark } ### ############### # Read rclog data (and oldrclog data if needed) ($status, $fileData) = &ReadFile($RcFile); ... $lastTs++ if (($Now - $lastTs) > 5); # Skip last unless very recent $idOnly = &GetParam("rcidonly", ""); ############### ### replaced by gypark ### rss from usemod1.0 # if ($idOnly ne "") { if ($idOnly && $showHTML) { ### ############### print '<b>(' . Ts('for %s only', &ScriptLink($idOnly, $idOnly)) . ')</b><br>'; } ############### ### pda clip by gypark if (!($IsPDA)) { ### ############### ############### ### added by gypark ### rss from usemod1.0 if ($showHTML) { ### ############### foreach $i (@RcDays) { print " | " if $showbar; ... print " (". Ts('currently set to %s', &TimeToText($bookmark)). ")<br>\n"; } ### ############### ############### ### added by gypark ### rss from usemod1.0 } ### ############### ############### ### pda clip by gypark } ### ############### # Later consider a binary search? ... last if ($ts >= $starttime); } ############### ### replaced by gypark ### rss from usemod1.0 # if ($i == @fullrc) { if ($i == @fullrc && $showHTML) { ### ############### print '<br><strong>' . Ts('No updates since %s', &TimeToText($starttime)) . "</strong><br>\n"; } else { splice(@fullrc, 0, $i); # Remove items before index $i # Later consider an end-time limit (items older than X) ############### ### replaced by gypark ### rss from usemod1.0 # print &GetRcHtml(@fullrc); # } # print '<p>' . Ts('Page generated %s', &TimeToText($Now)), "<br>\n"; if (0 == $rcType) { print &GetRcRss(@fullrc); } else { print &GetRcHtml(@fullrc); } } if ($showHTML) { print '<p>' . Ts('Page generated %s', &TimeToText($Now)), "<br>\n"; } ### ############### }
기존의 GetOldPageLink 를 수정하고, 새로운 함수 GetOldPageParameters 를 추가한다.
############### ### replaced by gypark ### from usemod1.0 # sub GetOldPageLink { # my ($kind, $id, $revision, $name) = @_; # # if ($FreeLinks) { # $id = &FreeToNormal($id); # $name =~ s/_/ /g; # } # return &ScriptLink("action=$kind&id=$id&revision=$revision", $name); # } sub GetOldPageParameters { my ($kind, $id, $revision) = @_; $id = &FreeToNormal($id) if $FreeLinks; return "action=$kind&id=$id&revision=$revision"; } sub GetOldPageLink { my ($kind, $id, $revision, $name) = @_; $name =~ s/_/ /g if $FreeLinks; return &ScriptLink(&GetOldPageParameters($kind, $id, $revision), $name); } ### ###############
action=rss 이면 DoRss 를 부르게 한다.
sub DoOtherRequest { ... ### comment from Jof } elsif (($action eq "comments") || ($action eq "longcomments")) { &DoComments($id) if &ValidIdOrDie($id); ### rss from usemod1.0 } elsif ($action eq "rss") { &DoRss(); ### ############### } else { # Later improve error reporting &ReportError(Ts('Invalid action parameter %s', $action)); ... }
이제는 페이지를 저장할 때 rclog 화일에 페이지 revision 번호도 저장한다.
sub DoPostMain { # 원래 DoPost 였는데 코멘트 매크로 달면서 바뀌었다. ... # &WriteRcLog($id, $summary, $isEdit, $editTime, $user, $Section{'host'}); &WriteRcLog($id, $summary, $isEdit, $editTime, $user, $Section{'host'}, $Section{'revision'}); ### ... }
sub WriteRcLog { ############### ### replaced by gypark ### rss from usemod1.0 # my ($id, $summary, $isEdit, $editTime, $name, $rhost) = @_; my ($id, $summary, $isEdit, $editTime, $name, $rhost, $revision) = @_; ### ############### my ($extraTemp, %extra); %extra = (); $extra{'id'} = $UserID if ($UserID ne ""); $extra{'name'} = $name if ($name ne ""); ############### ### added by gypark ### 최근변경내역에 북마크 기능 도입 $extra{'tscreate'} = $Page{'tscreate'}; ### rss from usemod 1.0 $extra{'revision'} = $revision if ($revision ne ""); ############### $extraTemp = join($FS2, %extra); # The two fields at the end of a line are kind and extension-hash ... }
이하의 함수들은 통채로 추가.
DoRss 본체는 xml 헤더만 출력하고 DoRc(0) 을 부른다.
sub DoRss { print "Content-type: text/xml\n\n"; &DoRc(0); }
DoRc 는 인자 0 을 받았다면 GetRcRss 를 부른다.
sub GetRcRss { my ($rssHeader, $headList, $items); # Normally get URL from script, but allow override $FullUrl = $q->url(-full=>1) if ($FullUrl eq ""); $QuotedFullUrl = &QuoteHtml($FullUrl); $SiteDescription = &QuoteHtml($SiteDescription); my $ChannelAbout = &QuoteHtml($FullUrl . &ScriptLinkChar() . $ENV{QUERY_STRING}); $rssHeader = <<RSS ; <?xml version="1.0" encoding="$HttpCharset"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wiki="http://purl.org/rss/1.0/modules/wiki/" > <channel rdf:about="$ChannelAbout"> <title>${\(&QuoteHtml($SiteName))}</title> <link>${\($QuotedFullUrl . &QuoteHtml("?$RCName"))}</link> <description>${\(&QuoteHtml($SiteDescription))}</description> <wiki:interwiki> <rdf:Description link="$QuotedFullUrl"> <rdf:value>$InterWikiMoniker</rdf:value> </rdf:Description> </wiki:interwiki> <items> <rdf:Seq> RSS ($headList, $items) = &GetRc(0, @_); $rssHeader .= $headList; return <<RSS ; $rssHeader </rdf:Seq> </items> </channel> <image rdf:about="${\(&QuoteHtml($RssLogoUrl))}"> <title>${\(&QuoteHtml($SiteName))}</title> <url>$RssLogoUrl</url> <link>$QuotedFullUrl</link> </image> $items </rdf:RDF> RSS }
GetRcRss 는 다시 GetRc(0) 을 부른다. 또 DoRc 가 html 출력을 할 때는 GetRcHtml 을 부르는데 이녀석은 별 하는 일 없이 GetRc(1) 을 부른다. 0.92의 GetRcHtml 이 1.0 에서는 GetRc 로 바뀌고 인자에 따라 다르게 동작하게 한 건데... ext 버전에서는 GetRcHtml 이 워낙 많이 수정되어서 그냥 함수를 별개로 두기로 한다. 즉,
0.92 : HTML: DoRc ------> GetRcHtml 1.0 : RSS: --------+-> DoRc ---+---> GetRcRss ----------+-> GetRc ---------------+--> GetRssRcLine DoRc(0) | | GetRc(0) | (기존 GetRcHtml 수정) | | | | | | | | | | | | | HTML: --------+ +---> GetRcHtml ---------+ +--> GetHtmlRcLine DoRc(1) (이건 그냥 더미) GetRc(1) ext 버전 : RSS: --------+-> DoRc ---+---> GetRcRss ----------+-> GetRc ---------------+--> GetRssRcLine DoRc(0) | | GetRc(0) (1.0의 것을 사용) | | | | | | | | | | HTML: --------+ +---> GetRcHtml +--> GetHtmlRcLine DoRc(1) (기존 것 계속 사용) (결과적으로 사용되지 않음)따라서 GetRcHtml 과 GetRc 는 비슷한 코드가 반복된다. GetRc(1) 을 호출하는 부분이 없기 때문에 GetRc 에서 해당 경로를 죄다 삭제해 주면 좀 보기에 좋겠지만... 첫째로 귀찮고 둘째로 나중에 다시 필요해질지 모르니 그냥 두기로 함.
어쨌거나, 그래서 이것이 통채로 추가해 버린 GetRc 함수
sub GetRc { my $rcType = shift; my @outrc = @_; my ($rcline, $date, $newtop, $author, $inlist, $result); my ($showedit, $link, $all, $idOnly, $headItem, $item); my ($ts, $pagename, $summary, $isEdit, $host, $kind, $extraTemp); my ($rcchangehist, $tEdit, $tChanges, $tDiff); my ($headList, $historyPrefix, $diffPrefix); my %extra = (); my %changetime = (); my %pagecount = (); # Slice minor edits $showedit = &GetParam("rcshowedit", $ShowEdits); $showedit = &GetParam("showedit", $showedit); if ($showedit != 1) { my @temprc = (); foreach $rcline (@outrc) { ($ts, $pagename, $summary, $isEdit, $host) = split(/$FS3/, $rcline); if ($showedit == 0) { # 0 = No edits push(@temprc, $rcline) if (!$isEdit); } else { # 2 = Only edits push(@temprc, $rcline) if ($isEdit); } } @outrc = @temprc; } # Optimize param fetches out of main loop $rcchangehist = &GetParam("rcchangehist", 1); # Optimize translations out of main loop $tEdit = T('(edit)'); $tDiff = T('(diff)'); $tChanges = T('changes'); $diffPrefix = $QuotedFullUrl . &QuoteHtml("?action=browse\&diff=5\&id="); $historyPrefix = $QuotedFullUrl . &QuoteHtml("?action=history\&id="); foreach $rcline (@outrc) { ($ts, $pagename) = split(/$FS3/, $rcline); $pagecount{$pagename}++; $changetime{$pagename} = $ts; } $date = ""; $all = &GetParam("rcall", 0); $all = &GetParam("all", $all); $newtop = &GetParam("rcnewtop", $RecentTop); $newtop = &GetParam("newtop", $newtop); $idOnly = &GetParam("rcidonly", ""); $inlist = 0; $headList = ''; $result = ''; @outrc = reverse @outrc if ($newtop); foreach $rcline (@outrc) { ($ts, $pagename, $summary, $isEdit, $host, $kind, $extraTemp) = split(/$FS3/, $rcline); next if ((!$all) && ($ts < $changetime{$pagename})); next if (($idOnly ne "") && ($idOnly ne $pagename)); ### hide page next if (&PageIsHidden($pagename)); %extra = split(/$FS2/, $extraTemp, -1); if ($date ne &CalcDay($ts)) { $date = &CalcDay($ts); if (1 == $rcType) { # HTML # add date, properly closing lists first if ($inlist) { $result .= "</UL>\n"; $inlist = 0; } $result .= "<p><strong>" . $date . "</strong></p>\n"; if (!$inlist) { $result .= "<UL>\n"; $inlist = 1; } } } if (0 == $rcType) { # RSS ($headItem, $item) = &GetRssRcLine($pagename, $ts, $host, $extra{'name'}, $extra{'id'}, $summary, $isEdit, $pagecount{$pagename}, $extra{'revision'}, $diffPrefix, $historyPrefix); $headList .= $headItem; $result .= $item; } else { # HTML $result .= &GetHtmlRcLine($pagename, $ts, $host, $extra{'name'}, $extra{'id'}, $summary, $isEdit, $pagecount{$pagename}, $extra{'revision'}, $tEdit, $tDiff, $tChanges, $all, $rcchangehist); } } if (1 == $rcType) { $result .= "</UL>\n" if ($inlist); # Close final tag } return ($headList, $result); # Just ignore headList for HTML }
GetRc 함수 안에서 불려서 rss 출력의 각 라인을 생성하는 함수
sub GetRssRcLine { my ($pagename, $timestamp, $host, $userName, $userID, $summary, $isEdit, $pagecount, $revision, $diffPrefix, $historyPrefix) = @_; my ($itemID, $description, $authorLink, $author, $status, $importance, $date, $item, $headItem); # encode pagename for URL (ext1.88) my $encoded_pagename = &EncodeUrl($pagename); # Add to list of items in the <channel/> $itemID = $FullUrl . &ScriptLinkChar() . &GetOldPageParameters('browse', $encoded_pagename, $revision); $itemID = &QuoteHtml($itemID); $headItem = " <rdf:li rdf:resource=\"$itemID\"/>\n"; # Add to list of items proper. if (($summary ne "") && ($summary ne "*")) { $description = &QuoteHtml($summary); } $host = &QuoteHtml($host); $host =~ s/\d+$/xxx/; if ($userName) { $author = &QuoteHtml($userName); $authorLink = "link=\"$QuotedFullUrl?$author\""; } else { $author = $host; } $status = (1 == $revision) ? 'new' : 'updated'; $importance = $isEdit ? 'minor' : 'major'; $timestamp += $TimeZoneOffset; my ($sec, $min, $hour, $mday, $mon, $year) = localtime($timestamp); $year += 1900; $date = sprintf("%4d-%02d-%02dT%02d:%02d:%02d+%02d:00", $year, $mon+1, $mday, $hour, $min, $sec, ($TimeZoneOffset/(60*60) + $RssTimeZone)); $pagename = &QuoteHtml($pagename); # Write it out longhand $item = <<RSS ; <item rdf:about="$itemID"> <title>$pagename</title> <link>$QuotedFullUrl?$encoded_pagename</link> <description>$description</description> <dc:date>$date</dc:date> <dc:creator>$author</dc:creator> <dc:contributor> <rdf:Description wiki:host="$host" $authorLink> <rdf:value>$author</rdf:value> </rdf:Description> </dc:contributor> <wiki:status>$status</wiki:status> <wiki:importance>$importance</wiki:importance> <wiki:diff>$diffPrefix$encoded_pagename</wiki:diff> <wiki:version>$revision</wiki:version> <wiki:history>$historyPrefix$encoded_pagename</wiki:history> </item> RSS return ($headItem, $item); }
마찬가지로 GetRc 함수 안에서 불려서, html 출력의 각 라인을 생성하는 함수. 그렇지만 현재는 호출될 일이 없기 때문에 내용은 비워둔다. 호출되면 서버에러를 낸다.
sub GetHtmlRcLine { ### 현재는 사용되지 않음 die "GetHtmlRcLine -- must not be executed!!!"; }
ext1.65에서 추가로 수정된 부분. html 헤더에 RSS를 얻을 수 있는 URL을 넣어서 출력한다.
sub GetHtmlHeader { ... $html .= qq(<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$HttpCharset">\n); $html .= qq(<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">\n); # 이 아래 줄 추가 $html .= qq(<link rel="alternate" type="application/rss+xml" title="$SiteName" href="http://$ENV{SERVER_NAME}$ENV{SCRIPT_NAME}?action=rss">\n); $html .= qq(<script src="$JavaScript" language="javascript" type="text/javascript"></script>); ... }
오타 수정... DoRc 함수 안에 다음 줄이 오타가 있네요. 거의 호출되지 않는 부분이라 알아채지 못했었군요.
if ($idOnly && &showHTML) { 를 if ($idOnly && $showHTML) { 으로 (showHTML 앞의 & 를 $ 로) 고칠 것
/최근변경내역아이템갯수지정 패치를 적용하면 '최근 몇 개'의 엔트리를 출력할 지 지정할 수 있음.
ext1.54a - 출력 항목에 dc:creator 를 추가하고, wiki:diff 에는 diff=4 대신에 diff=5 가 출력되게 하였습니다. 로그인 한 사용자의 경우는 rss 리더에서 바로 diff 링크를 갈 경우 /북마크가 적용됩니다. (그런데 wiki:diff 항목을 지원하는 리더가 있는지 모르는 상태입니다 -_-)
ext1.65 - UseModWiki소스수정/라이브북마크 의 내용을 반영합니다. 제 홈페이지를 FireFox에서 볼 때 제대로 동작하는 것을 확인했습니다만, 안 되면 알려 주세요. 참고로 [RSS에 대한 잡담]도 읽어 볼만 하군요. 후자의 글에서 주장하는 "RSS는 미리 (정적으로) 생성되어 있어야 한다"는 말도 일리가 있긴 한데 언제 반영할지 모르겠습니다.
ext1.88
[Abilon]이라는 프로그램을 설치해서 써보고 있습니다만... author가 안나오니 좀 허전하군요. dc:creator 를 $author로 채워주면 잘 나옵니다. 그리고... description에 페이지 diff가 같이 나오게 할 수는 없을까요? 보통 description을 안 적기 마련인데 좀 휑하네요.
http://jof4002.net/?action=rss 땜빵으로 넣어봤습니다.
FireFox 에 라ㅤㅅㅠㅂ님이 적은 문제에 대해서 좀 시도를 해봤습니다만, 제가 Abilon을 안쓰기 때문에 [Blogline]에 대해서 해봤습니다.
1. item rdf:about에 대해서 URLEncode 를 호출해서 넣어주면 Bloglines에서는 잘 열립니다. 뭐. 아빌론에서도 되지 않을까 싶네요.
2. 그런데 그게 문제가 되는지 모르겠는데 현재 FireFox 에서 라이브 북마크를 보면 오히려 영어로 된 페이지 이름만 표시되고 있습니다.
현재 회사고, 회사에서는 FTP가 안되는 관계로 더이상 테스트 불가입니다. -_-;;;
그리고 페이지 내용에 대해 걸리는 링크가 제대로 안되는 문제는 보니 블록라인이 utf-8을 쓰고 있고, 한글을 utf-8로 처리해서 링크를 보내기 때문에 생기는 문제더군요. 뭐 이것도 URLEncode 를 불러주면 될 것 같습니다만, 매우 귀찮습니다.
올불로그나 블로그코리아나 RSS수집이 안되서 올블로그에서 테스트를 해보니 에러가 나는군요. 뭔가 문제가 있는지..
잘은 모르겠지만, 한RSS가 잘 해주고 있는 걸로봐서 올블로그가 이 버전의 RSS를 제대로 처리하지 못하는게 아닌가 생각됩니다. blog_rss 매크로의 출력과, 위키 자체의 action=rss 출력의 양식이 서로 다르거든요. 올블로그 쪽에 RSS주소를 알려주고 문의해 보시죠.
어디선가 괄호를 안닫은듯. 페이지가 이상하게 표시되요.
{{{#!vim perl }}} 에서 사용했던 source-highlight 패키지가 버전업이 되면서 출력이 바뀌어 버리는 바람에... -_-;;; 이 페이지 뿐 아니라 저렇게 소스 코드를 표시한 페이지들은 지금 난리가 아닙니다. ㅠ,.ㅠ
올블로그에 전체RSS등록하면, 한글이 깨져버리고 모노로그의 RSS를 등록하면 페이지가 제대로 표시가 되네요. 뭐가 차이가 나는 걸까요.