[ 新規 | 編集 | 差分 ] [ 検索 | 一覧 | FrontPage ] [ 履歴 (RSS) | 差分履歴 (RSS) ] [ ログイン ]
【PR】Amazon | SL-C3000 | SL-C1000(3/18発売!) | SL-C860 | SL-6000W | SL-6000L | SL-6000N

WalWiki/カスタマイズ/エイリアス定義

編集

[alias link definition]

編集

セクションへのリンクを適用していた場合には今回修正した新しい実装にしないとこの機能がうまく動かないので注意して下さい。

関連するカスタマイズ

編集

グローバル変数定義

編集
my $AliasLinkName = 'AliasLinkName';                        # yakty add [alias link definition]
my %aliaslink;                                              # yakty add [alias link definition]
my %alias_link_list;                                        # yakty add [alias link definition]

main()内の変更

編集
sub main {
    open(LOG, ">>${modifier_dir_data}/log.txt") if ($walrus_debugging >= 2);    # Walrus add [for debug]
    &init_resource;
    &check_modifiers;
    &open_db;
    &init_InterWikiName;  # yakty add [alias link definition]
    &init_AntennaSite;    # yakty add [alias link definition]
    &init_AliasLink;      # yakty add [alias link definition]
    &init_form;
    #&init_InterWikiName; # yakty del [alias link definition]
    #&init_AntennaSite;   # yakty del [alias link definition]
    if ($command_do{$form{mycmd}}) {
        &{$command_do{$form{mycmd}}};
    } else {
        &do_FrontPage;
    }
    &close_db;
    close LOG if ($walrus_debugging >= 2);                                      # Walrus add [for debug]
}

init_form()内の変更

編集
    my $query = &decode($ENV{QUERY_STRING});
    if ($page_command{$query}) {
        $form{mycmd} = $page_command{$query};
        $form{mypage} = $query;
    # yakty del [alias link definition] start
    #} elsif ($query =~ /^($wiki_name)$/) {
    #    $form{mycmd} = 'read';
    #    $form{mypage} = $1;
    # yakty del [alias link definition] end
    } elsif ($database{$query}) {
        $form{mycmd} = 'read';
        $form{mypage} = $query;
    #} # yakty del [alias link definition]
    # yakty add [alias link definition] start
    } elsif ($aliaslink{$query} and $database{$aliaslink{$query}}) {
        $form{mycmd} = 'read';
        $form{mypage} = $aliaslink{$query};
    }
    # yakty add [alias link definition] end

make_link()内の変更

編集
    my $name         = $chunk;
    my $escapedchunk = &escape($chunk);
    my $escapedname  = &escape($name);
    my $cookedchunk  = &encode($chunk);
    #if ($form{mypage} ne $InterWikiName and $chunk !~ /^$embedded_name$/) {                                         # yakty del [alias link definition]
    if ($form{mypage} ne $InterWikiName and $chunk !~ /^$embedded_name$/ and $form{mypage} ne $AliasLinkName) {      # yakty add [alias link definition]
        ($name, $chunk) = ($1, $2) if ($chunk =~ /^\[\[(\S+) (\S+)\]\]$/);
        ($name, $chunk) = (&unarmor_name($name), &unarmor_name($chunk));
        } elsif ($page_command{$chunk}) {
            return qq(<a title="$escapedchunk" href="$url_cgi?$cookedchunk$part">$escapedchunk</a>);  # yakty add [link to part]
            #return qq(<a title="$escapedchunk" href="$url_cgi?$cookedchunk">$escapedchunk</a>);      # yakty del [link to part]
        # yakty add [alias link definition] start
        } elsif (defined $aliaslink{$chunk}) {
            #return &make_link(&armor_name($name . " " . $aliaslink{$chunk}));                        # yakty del [link to part]
            return &make_link("[[$name $aliaslink{$chunk}$part]]");                                   # yakty add [link to part]
        # yakty add [alias link definition] end
        } else {
            return qq($escapedchunk<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit&amp;mypage=$cookedchunk">$editchar</a>);
        }
    }
}

print_editform()内の変更

編集
        $content = &text_to_html($content, toc=>0);                   # Walrus add [additional edit info]
        $content =~ s/\$INTERWIKILIST/&make_interwiki_list()/ge;      # Walrus add [additional edit info]
        $content =~ s/\$ANTENNASITELIST/&make_antennasite_list()/ge;  # Walrus add [additional edit info]
        $content =~ s/\$ALIASLINKLIST/&make_aliaslink_list()/ge;      # yakty add [alias link definition]
        print $content;                                               # Walrus add [additional edit info]

init_AliasLink()追加

編集
# yakty add [alias link definition] start
sub init_AliasLink
{
    my $content = $database{$AliasLinkName};
    while ($content =~ /(\[\[(\S+) (\S+)\]\])/g) {
        my ($link, $name, $page) = ($1, $2, $3);
        next if(&is_exist_page($name));
        $link = $page if($page =~ /^(https?|ftp):[^\?]+\.(gif|png|jpe?g)$/ and $use_autoimg);
        if($page =~ /^$interwiki_name$/ and $interwiki{$1}) {
            my ($remoteurl, $localname) = ($interwiki{$1}, $2);
            $remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $localname)/e;
            $remoteurl = &decode($remoteurl);
            $link = $remoteurl if ($remoteurl =~ /^(https?|ftp):[^\?]+\.(gif|png|jpe?g)$/ and $use_autoimg);
        }
        $aliaslink{$name} = $page;
        $name = &armor_name($name);
        $alias_link_list{$name} = &make_link($link);
        $alias_link_list{"[[$name]]"} = $alias_link_list{$name} if($name ne "[[$name]]");
    }
}
# yakty add [alias link definition] end

make_aliaslink_list()追加

編集
# yakty add [alias link definition] start
sub make_aliaslink_list {
    my @sites;
    foreach my $key (sort {uc($a) cmp uc($b)} (keys(%aliaslink))) {
        push(@sites, sprintf(qq(&quot;<span title="%s">%s</a>&quot;), &escape($aliaslink{$key}), &escape($key)));
    }
    return join(', ', @sites);
}
# yakty add [alias link definition] end

inline()内の変更

編集
            !
#               &make_link($1)                  # Walrus del [link cache]
#                (defined($link_cache{$1})) ? $link_cache{$1} : (length($_ = &make_link($1)) < 1024) ? ($link_cache{$1} = $_) : $_ # Walrus add [link cache] # yakty del [make cached link]
                &make_cachedlink($1)            # yakty add [make cached link]
            !gex;

make_cachedlink()内の変更

編集
# yakty add [make cached link] start
sub make_cachedlink {
    my ($page) = @_;
    my $link;
    if(defined($link_cache{$page})){
        return $link_cache{$page};
    # yakty add [alias link definition] start
    } elsif(&is_exist_page($page)){
        $link = &make_link($page);
    } elsif(defined($alias_link_list{$page})) {
        $link = $alias_link_list{$page};
    # yakty add [alias link definition] end
    # yakty add [auto link] start
    } elsif(defined($auto_link_list{$page})) {
        $link = $auto_link_list{$page};
    # yakty add [auto link] end
    } else {
        $link = &make_link($page);
    }
    if(length($link) < 1024
            and $page ne $embed_comment         # yakty add [multi comment]
            and $page ne $embed_rcomment){      # yakty add [multi comment]
        $link_cache{$page} = $link;
    }
    return $link;
}
# yakty add [make cached link] end

03154