UseModWiki소스수정/하위페이지링크변경 페이지의 소스 보기
마지막으로 [b]
-- Loading page list... --
내용출력
로그인[l]
Diary
[f]
최근변경내역
[r]
페이지목록[i]
횡설수설[2]
게시판[3]
링크
수정할 수 없습니다: UseModWiki소스수정/하위페이지링크변경 는 읽기 전용 페이지입니다.
== # 링크 변경 시
"/페이지이름"
형태의 하위페이지 링크도 변경 == 관리자 메뉴에서 페이지 이름을 변경하거나 링크를 변경할 때, "/하위페이지" 형태로만 되어 있는 링크가 제대로 변환되지 않는 문제 해결. 예를 들어 A페이지의 [[하위페이지]]로 A/a가 있을 때, A페이지나 A페이지의 하위페이지에서는 "[[/a]]"라고 링크를 할 수 있다. 이 때, A/a 페이지 이름을 A/b 페이지로 변경할 경우, "A/a"형태의 링크는 "A/b"로 잘 변경되지만, "/a"라고만 되어 있는 형태의 링크는 변경되지 않은채 남아 있었다. 이 문제를 해결하는 패치. * 필수 요구 사항: 없음 * 선택 요구 사항: 없음 === # 부작용 === 없을 것 같음... === # wiki.pl 수정 === 페이지 이름 변경을 수행하기 전에 역링크 목록을 만드는 루틴에서, "/하위페이지" 형태의 링크를 "메인페이지/하위페이지" 형태로 복원하여 같이 처리. {{{#!vim perl sub BuildLinkIndexPage { ... %seen = (); foreach $link (@links) { ### 링크변경 개선 - "/하위페이지" 형태의 링크도 변경 - 아래 세 줄 추가 if ( $link =~ m!^/! ) { $link = (split('/',$page))[0] . $link; } ### if (defined($LinkIndex{$link})) { if (!$seen{$link}) { ... } }}} .kp 파일의 내용에 있는 링크를 수정하는 루틴 수정 {{{#!vim perl sub RenameKeepText { ... if (!defined($tempSection{'keepts'})) { return; } ### 링크변경 개선 - "/하위페이지" 형태의 링크도 변경 - 이 단락 추가 my ( $old_main, $old_sub ) = split("/", $old); my ( $new_main, $new_sub ) = split("/", $new); my $old_new_same_main = ( $old_main eq $new_main ); my ( $page_main, $page_sub) = split("/", $page); my $old_page_same_main = ( $old_main eq $page_main ); ### # First pass: optimize for nothing changed $changed = 0; foreach (@kplist) { %tempSection = split(/$FS2/, $_, -1); $sectName = $tempSection{'name'}; if ($sectName =~ /^(text_)/) { %Text = split(/$FS3/, $tempSection{'data'}, -1); $newText = &SubstituteTextLinks($old, $new, $Text{'text'}); ### 링크변경 개선 - "/하위페이지" 형태의 링크도 변경 - 이 단락 추가 if ( $old_page_same_main && $old_sub ) { if ( $old_new_same_main && $new_sub ) { $newText = &SubstituteTextLinks("/$old_sub", "/$new_sub", $newText); } else { $newText = &SubstituteTextLinks("/$old_sub", $new, $newText); } } ### $changed = 1 if ($Text{'text'} ne $newText); } # Later add other section types? (maybe) } return if (!$changed); # No sections changed open (OUT, ">$fname") or return; foreach (@kplist) { %tempSection = split(/$FS2/, $_, -1); $sectName = $tempSection{'name'}; if ($sectName =~ /^(text_)/) { %Text = split(/$FS3/, $tempSection{'data'}, -1); $newText = &SubstituteTextLinks($old, $new, $Text{'text'}); ### 링크변경 개선 - "/하위페이지" 형태의 링크도 변경 - 이 단락 추가 if ( $old_page_same_main && $old_sub ) { if ( $old_new_same_main && $new_sub ) { $newText = &SubstituteTextLinks("/$old_sub", "/$new_sub", $newText); } else { $newText = &SubstituteTextLinks("/$old_sub", $new, $newText); } } ### $Text{'text'} = $newText; $tempSection{'data'} = join($FS3, %Text); print OUT $FS1, join($FS2, %tempSection); } else { print OUT $FS1, $_; } } close(OUT); } }}} .db 파일의 텍스트를 수정하는 루틴 개선 {{{#!vim perl sub RenameTextLinks { ... $old =~ s/_/ /g; $new =~ s/_/ /g; ### 링크변경 개선 - "/하위페이지" 형태의 링크도 변경 - 이 단락 추가 my ( $old_main, $old_sub ) = split("/", $old); my ( $new_main, $new_sub ) = split("/", $new); my $old_new_same_main = ( $old_main eq $new_main ); ### # Note: the LinkIndex must be built prior to this routine return if (!defined($LinkIndex{$oldCanonical})); @pageList = split(' ', $LinkIndex{$oldCanonical}); foreach $page (@pageList) { ### 링크변경 개선 - "/하위페이지" 형태의 링크도 변경 - 이 단락 추가 my ( $page_main, $page_sub) = split("/", $page); my $old_page_same_main = ( $old_main eq $page_main ); ### $changed = 0; &OpenPage($page); foreach $section (keys %Page) { if ($section =~ /^text_/) { &OpenSection($section); %Text = split(/$FS3/, $Section{'data'}, -1); $oldText = $Text{'text'}; $newText = &SubstituteTextLinks($old, $new, $oldText); ### 링크변경 개선 - "/하위페이지" 형태의 링크도 변경 - 이 단락 추가 if ( $old_page_same_main && $old_sub ) { if ( $old_new_same_main && $new_sub ) { $newText = &SubstituteTextLinks("/$old_sub", "/$new_sub", $newText); } else { $newText = &SubstituteTextLinks("/$old_sub", $new, $newText); } } ### if ($oldText ne $newText) { $Text{'text'} = $newText; $Section{'data'} = join($FS3, %Text); $Page{$section} = join($FS2, %Section); $changed = 1; } } elsif ($section =~ /^cache_diff/) { $oldText = $Page{$section}; $newText = &SubstituteTextLinks($old, $new, $oldText); ### 링크변경 개선 - "/하위페이지" 형태의 링크도 변경 - 이 단락 추가 if ( $old_page_same_main && $old_sub ) { if ( $old_new_same_main && $new_sub ) { $newText = &SubstituteTextLinks("/$old_sub", "/$new_sub", $newText); } else { $newText = &SubstituteTextLinks("/$old_sub", $new, $newText); } } ### if ($oldText ne $newText) { $Page{$section} = $newText; $changed = 1; } } # Later: add other text-sections (categories) here } ... } }}} === # 추가 업데이트 내역 === === # 사용자 의견 ===
---- [[위키위키분류]]
UseModWiki소스수정/하위페이지링크변경
페이지로 돌아가기 |
다른 수정본 보기