| -11,64 +9,27 |
| * 사용법 : |
| ** 이 패치를 적용하면, 기존에 "This page is read-only (이 페이지는 수정이 불가능합니다)" 라고 나오던 자리에 "View text of this page (페이지 소스 보기)" 란 링크가 나온다. 이 링크를 클릭하면 페이지 소스를 볼 수 있다. |
| ** 마우스를 더블 클릭했을 때 역시, 페이지 수정 권한이 있는지 여부에 따라서 자동으로 편집 창 또는 소스 보기 창을 띄워준다. (따라서 [[/마우스더블클릭]] 패치는 더 이상 유용하지 않다) |
| ** wiki.pl?action=view&id=페이지이름[&revision=리비전번호] 의 형식으로 직접 호출할 수도 있다. |
| *** revision 번호 파라메터를 생략하면 현재 버전을 보여준다. |
|
| * 부작용 : 테스트하는 동안에는 별다른 문제가 발견되지는 않았다. |
|
| * 소스 수정 |
| : 마우스 더블 클릭을 처리하는 부분 |
| {{{perl |
| : [[/마우스더블클릭]] 패치에서 편집 권한이 있을 때만 더블 클릭이 통하게 했던 것을 되돌림 |
| {{{#!vim perl |
| sub GetHtmlHeader { |
| ... |
| if ($bgcolor ne '') { |
| $bodyExtra = qq( BGCOLOR="$bgcolor"); |
| } |
| ############### |
| ### replaced by gypark |
| ### #EXTERN |
| # added luke |
| # if ($ClickEdit) { |
| # if ($FreeLinks) { |
| # $id = &FreeToNormal($id); |
| # } |
| # $bodyExtra .= qq(ondblclick="location.href='$ScriptName?action=edit&id=$id'"); |
| # } |
| # end |
|
| if (&GetParam('InFrame','') ne '') { |
| $html .= qq(<base target="_parent">\n); |
| } else { |
| if ($ClickEdit) { |
| if ($FreeLinks) { |
| $id = &FreeToNormal($id); |
| } |
| ### 아래의 세 줄이 새로 수정된 부분이다 |
| my $action = "view"; |
| $action = "edit" if (&UserCanEdit($id,0)); |
| $bodyExtra .= qq(ondblclick="location.href='$ScriptName?action=$action&id=$id'"); |
| ### 여기까지 |
| } |
| } |
|
| ### |
| ############### |
|
| # Insert any other body stuff (like scripts) into $bodyExtra here |
| # (remember to add a space at the beginning to separate from prior text) |
| $html .= "</HEAD><BODY $bodyExtra>\n"; |
| return $html; |
| $bodyExtra .= qq(ondblclick="location.href='$ScriptName?action=edit&id=$id'"); # 뒤에 있던 if 문 제거 |
| ... |
| } |
| }}} |
|
| : 편집 가이드 수정 |
| {{{perl |
| : 편집 가이드에서 기존에는 읽기 전용이라고 메시지만 나왔던 것을 링크가 걸리도록 수정 |
| {{{#!vim perl |
| sub GetEditGuide { |
| ... |
| if (&UserCanEdit($id, 0)) { |
| if ($rev ne '') { |
| $result .= &GetOldPageLink('edit', $id, $rev, |
| Ts('Edit revision %s of this page', $rev)); |
| Ts('Edit revision %s of this page', $rev)); |
| } else { |
| $result .= &GetEditLink($id, T('Edit text of this page')); |
| } |
| -91,69 +52,52 |
| } |
| }}} |
|
| : redirect 나 extern 을 사용한 페이지의 상단의 안내문에 있는 페이지 링크도 마찬가지로 view 또는 edit 를 결정한다. [[/EXTERN명령어]] 패치와 섞여 있으니 주의. |
| {{{perl |
| sub GetHeader { |
| ... |
| ############### |
| ### replaced by gypark |
| ### #EXTERN |
| # if ($oldId ne '') { |
| # $result .= $q->h3('(' . Ts('redirected from %s', |
| # &GetEditLink($oldId, $oldId)) . ')'); |
| # } |
|
| my $topMsg = ""; |
| if ($oldId ne '') { |
| ### view action 추가 by gypark |
| # $topMsg .= '('.Ts('redirected from %s',&GetEditLink($oldId, $oldId)).') '; |
| my $oldpagelink = &GetViewLink($oldId, $oldId); |
| $oldpagelink = &GetEditLink($oldId, $oldId) if (&UserCanEdit($oldId)); |
| $topMsg .= '('.Ts('redirected from %s',$oldpagelink).') '; |
| } |
| if (&GetParam('InFrame','') eq '1') { |
| ### view action 추가 by gypark |
| # $topMsg .= '('.Ts('%s includes external page',&GetEditLink($id,$id)).')'; |
| my $oldpagelink = &GetViewLink($id, $id); |
| $oldpagelink = &GetEditLink($id, $id) if (&UserCanEdit($id)); |
| $topMsg .= '('.Ts('redirected from %s',$oldpagelink).') '; |
| } |
| $result .= $q->h3($topMsg) if (($oldId ne '') || (&GetParam('InFrame','') eq '1')); |
| ### |
| ############### |
| ... |
| } |
| }}} |
| : DoEdit 함수를 고쳐 준다. 주석문을 참조하여 바뀐 곳을 찾아서 고쳐 줄 것. 중간 중간에 보면 원래의 코드를 if 문으로 둘러싼 부분들이 있다. 앞뒤 괄호가 맞게 추가되는지 잘 살피지 않으면 나중에 에러가 날 수 있으니 주의 |
| {{{#!vim perl |
| sub DoEdit { |
| my ($id, $isConflict, $oldTime, $newText, $preview) = @_; |
| my ($header, $editRows, $editCols, $userName, $revision, $oldText); |
| my ($summary, $isEdit, $pageTime); |
|
| : action=view 로 불렀을 때 동작시키는 부분 |
| {{{perl |
| sub DoOtherRequest { |
| ... |
| if ($action eq "edit") { |
| &DoEdit($id, 0, 0, "", 0) if &ValidIdOrDie($id); |
| ############### |
| ### added by gypark |
| ### "view" action 추가 |
| } elsif ($action eq "view") { |
| &DoView($id); |
| ### view action 추가 |
| my $canEdit = &UserCanEdit($id,1); |
| ### |
| ############### |
| } elsif ($action eq "unlock") { |
| &DoUnlock(); |
| ... |
| } |
| }}} |
|
| : 다음의 두 함수를 통채로 추가한다. |
| {{{perl |
| ############### |
| ### commented by gypark |
| ### view action 추가 |
| sub DoView { |
| my ($id) = @_; |
| my ($header, $viewRows, $viewCols, $revision, $pageSource); |
| # if (!&UserCanEdit($id, 1)) { |
| # print &GetHeader("", T('Editing Denied'), ""); |
| # if (&UserIsBanned()) { |
| # print T('Editing not allowed: user, ip, or network is blocked.'); |
| # print "<p>"; |
| # print T('Contact the wiki administrator for more information.'); |
| # } else { |
| ### 수정 불가를 알리는 메세지에, 사이트 제목이 아니라 |
| ### 해당 페이지명이 나오도록 수정 |
| # print Ts('Editing not allowed: %s is read-only.', $SiteName); |
| # print Ts('Editing not allowed: %s is read-only.', $id); |
| # } |
| # print &GetCommonFooter(); |
| # return; |
| # } |
| ### |
| ############### |
|
| # Consider sending a new user-ID cookie if user does not have one |
| &OpenPage($id); |
| &OpenDefaultText(); |
| $header = Ts('Viewing %s', $id); |
| $pageTime = $Section{'ts'}; |
| $header = Ts('Editing %s', $id); |
| ############### |
| ### added by gypark |
| ### view action 추가 |
| $header = Ts('Viewing %s', $id) if (!$canEdit); |
| ### |
| ############### |
| # Old revision handling |
| $revision = &GetParam('revision', ''); |
| $revision =~ s/\D//g; # Remove non-numeric chars |
| -164,45 +108,137 |
| # Later look for better solution, like error message? |
| } else { |
| &OpenKeptRevision($revision); |
| $header = Ts('Viewing revision %s of', $revision) . " $id"; |
| $header = Ts('Editing revision %s of', $revision) . " $id"; |
| ############### |
| ### added by gypark |
| ### view action 추가 |
| $header = Ts('Viewing revision %s of', $revision) . " $id" if (!$canEdit); |
| ### |
| ############### |
| } |
| } |
| $pageSource = $Text{'text'}; |
| $viewRows = &GetParam("editrows", 20); |
| $viewCols = &GetParam("editcols", 65); |
|
| $oldText = $Text{'text'}; |
| if ($preview && !$isConflict) { |
| $oldText = $newText; |
| } |
| $editRows = &GetParam("editrows", 20); |
| $editCols = &GetParam("editcols", 65); |
| print &GetHeader('', &QuoteHtml($header), ''); |
| if ($revision ne '') { |
| ############### |
| ### added by gypark |
| ### view action 추가 |
| if (!$canEdit) { |
| if (&UserIsBanned()) { |
| print T('Editing not allowed: user, ip, or network is blocked.'); |
| print "<p>"; |
| print T('Contact the wiki administrator for more information.'); |
| } else { |
| print Ts('Editing not allowed: %s is read-only.', $id); |
| } |
| print "<br>\n"; |
| } |
| ### |
| ############### |
| ############### |
| ### replaced by gypark |
| ### view action 추가 |
| # if ($revision ne '') { |
| if ($canEdit && ($revision ne '')) { |
| ### |
| ############### |
| print "\n<b>" |
| . Ts('Viewing old revision %s.', $revision) |
| . '</b><br>' |
| . Ts('Editing old revision %s.', $revision) . " " |
| . T('Saving this page will replace the latest revision with this text.') |
| . '</b><br>' |
| } |
| print $q->textarea(-class=>'view', -accesskey=>'i', -name=>'text', |
| -default=>$pageSource, -rows=>$viewRows, -columns=>$viewCols, |
| -override=>1, -style=>'width:100%', -wrap=>'virtual', |
| -readonly=>'true'); |
| print "<br>"; |
|
| print "<hr class='footer'>\n"; |
| print Ts('Return to %s' , &GetPageLink($id)) . " | "; |
| print &GetHistoryLink($id, T('View other revisions')) . "<br>\n"; |
| print &GetMinimumFooter(); |
| ############### |
| ### replaced by gypark |
| ### view action 추가 |
| # if ($isConflict) { |
| if ($canEdit && $isConflict) { |
| ### |
| ############### |
| $editRows -= 10 if ($editRows > 19); |
| print "\n<H1>" . T('Edit Conflict!') . "</H1>\n"; |
| ... |
| var w = window.open(s, "Help", "width=500,height=400, resizable=1, scrollbars=1"); |
| w.focus(); |
| } |
| //--> |
| </script> |
| |; |
|
| sub GetViewLink { |
| my ($id, $name) = @_; |
| ############### |
| ### added by gypark |
| ### view action 추가 |
| if ($canEdit) { |
| ### |
| ############### |
| print T('Editing Help :') . " "; |
| ############### |
| ### replaced by gypark |
| ### 도움말 별도의 화일로 분리 |
|
| if ($FreeLinks) { |
| $id = &FreeToNormal($id); |
| $name =~ s/_/ /g; |
| # print &HelpLink(1, T('Make Page')) . " | "; |
| # ... |
| # print &HelpLink(5, T('Emoticon')) . "<br>\n"; |
| use vars qw(@HelpItem); |
| require mod_edithelp; |
|
| foreach (0 .. $#HelpItem) { |
| print &HelpLink($_, T("$HelpItem[$_]")); |
| print " | " if ($_ ne $#HelpItem); |
| } |
| print "<br>\n"; |
| ### |
| ############### |
| ############### |
| ### added by gypark |
| ### view action 추가 |
| } |
| return &ScriptLink("action=view&id=$id", $name); |
| } |
|
| ### 통채로 추가한 함수들의 끝 |
| ### |
| ############### |
|
| &DoWikiRequest() if ($RunCGI && ($_ ne 'nocgi')); # Do everything. |
| ############### |
| ### replaced by gypark |
| ### 편집모드에 들어갔을때 포커스가 편집창에 있도록 한다 |
| # print &GetFormStart(); |
| print &GetFormStart("form_edit"); |
| ### |
| ############### |
| ############### |
| ### added by gypark |
| ### view action 추가 |
| if ($canEdit) { |
| ### |
| ############### |
| print &GetHiddenValue("title", $id), "\n", |
| &GetHiddenValue("oldtime", $pageTime), "\n", |
| &GetHiddenValue("oldconflict", $isConflict), "\n"; |
| if ($revision ne "") { |
| print &GetHiddenValue("revision", $revision), "\n"; |
| } |
| print &GetTextArea('text', $oldText, $editRows, $editCols); |
| $summary = &GetParam("summary", "*"); |
| ... |
| &GetTextArea('newtext', $newText, $editRows, $editCols), |
| "<p>\n"; |
| } |
| ### added by gypark |
| ### view action 추가 |
| } else { |
| print $q->textarea(-class=>'view', -accesskey=>'i', -name=>'text', |
| -default=>$oldText, -rows=>$editRows, -columns=>$editCols, |
| -override=>1, -style=>'width:100%', -wrap=>'virtual', |
| -readonly=>'true'); |
| } |
| ### |
| ############### |
| print "<hr class='footer'>\n"; |
| if ($preview) { |
| ... |
| print &GetMinimumFooter(); |
| } |
| }}} |
|
| == Notes == |