| 1 |
#?SuikaWikiConfig/2.0 |
| 2 |
|
| 3 |
Plugin: |
| 4 |
@Name: WikiLinking |
| 5 |
@Description: |
| 6 |
@@@: Wiki hyperlinking support |
| 7 |
@@lang:en |
| 8 |
@License: %%GPL%% |
| 9 |
@Author: |
| 10 |
@@Name: |
| 11 |
@@@@: Wakaba |
| 12 |
@@@lang:ja |
| 13 |
@@@script:Latn |
| 14 |
@@Mail[list]: w@suika.fam.cx |
| 15 |
@Date.RCS: $Date: 2003/10/30 07:45:10 $ |
| 16 |
|
| 17 |
PluginConst: |
| 18 |
@NS_XHTML1: |
| 19 |
http://www.w3.org/1999/xhtml |
| 20 |
@NS_XHTML2: |
| 21 |
http://www.w3.org/2002/06/xhtml2 |
| 22 |
@NS_XLINK: |
| 23 |
http://www.w3.org/1999/xlink |
| 24 |
@NS_HLINK: |
| 25 |
http://www.w3.org/2002/06/hlink |
| 26 |
|
| 27 |
FormattingRule: |
| 28 |
@Category[list]: |
| 29 |
view |
| 30 |
view-resource |
| 31 |
form-input |
| 32 |
@Name: link-to-wikipage |
| 33 |
@Description: |
| 34 |
@@@: |
| 35 |
Creating "from" anchor field of a link whose "to" is a WikiPage |
| 36 |
@@lang: en |
| 37 |
@Parameter: |
| 38 |
@@Name: base-page |
| 39 |
@@Type: WikiName |
| 40 |
@@Default: (current) |
| 41 |
@@Description: |
| 42 |
@@@@:Base WikiName (Relative WikiName is resolved with) |
| 43 |
@@@lang:en |
| 44 |
@Parameter: |
| 45 |
@@Name: hreflang |
| 46 |
@@Type: |
| 47 |
HTML4:LanguageCode |
| 48 |
@@Default:(none) |
| 49 |
@@Description: |
| 50 |
@@@@:(Human) language the linked WikiPage written in |
| 51 |
@@@lang:en |
| 52 |
@Parameter: |
| 53 |
@@Name: hreftype |
| 54 |
@@Type: |
| 55 |
HTML4:ContentType |
| 56 |
@@Default:(none) |
| 57 |
@@Description: |
| 58 |
@@@@:Media type the linked WikiPage provided with |
| 59 |
@@@lang:en |
| 60 |
@Parameter: |
| 61 |
@@Name:label |
| 62 |
@@Type:CDATA |
| 63 |
@@Default:(auto) |
| 64 |
@@Description: |
| 65 |
@@@@:Source anchor label |
| 66 |
@@@lang:en |
| 67 |
@Parameter: |
| 68 |
@@Name: mode |
| 69 |
@@Type: WikiMode |
| 70 |
@@Default:(default) |
| 71 |
@@Description: |
| 72 |
@@@@:Mode of the Wiki linked to |
| 73 |
@@@lang:en |
| 74 |
@Parameter: |
| 75 |
@@Name: page |
| 76 |
@@Type: WikiName |
| 77 |
@@Default: (current) |
| 78 |
@@Description: |
| 79 |
@@@@:WikiPage linked to |
| 80 |
@@@lang:en |
| 81 |
@Parameter: |
| 82 |
@@Name: page-anchor-name |
| 83 |
@@Type: |
| 84 |
XML:ID |
| 85 |
@@Default: (none) |
| 86 |
@@Description: |
| 87 |
@@@@:Identifier in the WikiPage linked to |
| 88 |
@@@lang:en |
| 89 |
@Parameter: |
| 90 |
@@Name: page-anchor-no |
| 91 |
@@Type: |
| 92 |
SGML:NUMBER |
| 93 |
@@Default: (none) |
| 94 |
@@Description: |
| 95 |
@@@@:Numeral anchor index in the WikiPage linked to |
| 96 |
@@@lang:en |
| 97 |
@Parameter: |
| 98 |
@@Name: page-title |
| 99 |
@@Type:CDATA |
| 100 |
@@Default:(auto) |
| 101 |
@@Description: |
| 102 |
@@@@:Title of the WikiPage linked to |
| 103 |
@@@lang:en |
| 104 |
@Parameter: |
| 105 |
@@Name: rel |
| 106 |
@@Type: |
| 107 |
HTML4:LinkTypes |
| 108 |
@@Default:(none) |
| 109 |
@@Description: |
| 110 |
@@@@:Link relationships |
| 111 |
@@@lang:en |
| 112 |
@Parameter: |
| 113 |
@@Name: rev |
| 114 |
@@Type: |
| 115 |
HTML4:LinkTypes |
| 116 |
@@Default:(none) |
| 117 |
@@Description: |
| 118 |
@@@@:Link relationship (reverse) |
| 119 |
@@@lang:en |
| 120 |
@Parameter: |
| 121 |
@@Name: up-to-date |
| 122 |
@@Type: boolean |
| 123 |
@@Default: "0" |
| 124 |
@@Description: |
| 125 |
@@@@:Appends random "up-to-date" parameter to the URI reference |
| 126 |
@@@lang:en |
| 127 |
@Parameter: |
| 128 |
@@Name: with-lm |
| 129 |
@@Type: boolean |
| 130 |
@@Default:"0" |
| 131 |
@@Description: |
| 132 |
@@@@:Appends "last-modified" parameter to the URI reference |
| 133 |
@@@lang:en |
| 134 |
@Formatting: |
| 135 |
__ATTRNODE:%page_title__; |
| 136 |
__ATTRTEXT:%class__; |
| 137 |
__ATTRNODE:%label__; |
| 138 |
__ATTRTEXT:%page__;__ATTRTEXT:%base_page__;__ATTRTEXT:%page_anchor_no__; |
| 139 |
__ATTRTEXT:%with_lm__;__ATTRTEXT:%up_to_date__; |
| 140 |
__ATTRTEXT:%page_anchor_name__; |
| 141 |
__ATTRTEXT:%hreflang__;__ATTRTEXT:%hreftype__; |
| 142 |
__ATTRTEXT:%mode__; |
| 143 |
__ATTRTEXT:%rel__;__ATTRTEXT:%rev__; |
| 144 |
__FUNCPACK__->to_wikipage_in_html ({ |
| 145 |
label => ($p->{label}), |
| 146 |
} => { |
| 147 |
base => [split m#//#, ($p->{base_page}||$o->{page})], |
| 148 |
page_name_relative => [split m#//#, $p->{page}], |
| 149 |
page_anchor_no => $p->{page_anchor_no}, |
| 150 |
page_anchor_name => $p->{page_anchor_name}, |
| 151 |
page_title => $p->{page_title}, |
| 152 |
wiki_mode => $p->{mode}, |
| 153 |
_with_lm => $p->{with_lm}, |
| 154 |
_up_to_date => $p->{up_to_date}, |
| 155 |
-hreflang => $p->{hreflang}, |
| 156 |
-hreftype => $p->{type}, |
| 157 |
}, { |
| 158 |
o => $o, |
| 159 |
parent => $p->{-parent}, |
| 160 |
-rel => $p->{rel}, |
| 161 |
-rev => $p->{rev}, |
| 162 |
}); |
| 163 |
|
| 164 |
FormattingRule: |
| 165 |
@Category[list]: page-link |
| 166 |
@Name: link-to-it |
| 167 |
@Description: |
| 168 |
@@@: |
| 169 |
Source anchor |
| 170 |
@@lang: en |
| 171 |
@Parameter: |
| 172 |
@@Name: class |
| 173 |
@@Type: |
| 174 |
HTML4:class |
| 175 |
@@Default: (none) |
| 176 |
@@Description: |
| 177 |
@@@@: Class names |
| 178 |
@@@lang:en |
| 179 |
@Parameter: |
| 180 |
@@Name: description |
| 181 |
@@Type: CDATA |
| 182 |
@@Default: (none) |
| 183 |
@@Description: |
| 184 |
@@@@: Description of the anchor or link |
| 185 |
@@@lang:en |
| 186 |
@Parameter: |
| 187 |
@@Name: label |
| 188 |
@@Type: CDATA |
| 189 |
@@Default: "" |
| 190 |
@@Description: |
| 191 |
@@@@: Source anchor label (content) |
| 192 |
@@@lang:en |
| 193 |
@Formatting: |
| 194 |
__ATTRNODE:%label__; |
| 195 |
__ATTRTEXT:%class__; |
| 196 |
__ATTRTEXT:%description__; |
| 197 |
my $A = $p->{-parent}->append_new_node (type => '#element', |
| 198 |
namespace_uri => $NS_XHTML1, |
| 199 |
local_name => 'a'); |
| 200 |
$A->set_attribute (href => $o->{link}->{dest}->{uri}); |
| 201 |
|
| 202 |
$A->append_node ($p->{label}, node_or_text => 1); |
| 203 |
$A->set_attribute (title => $p->{description}) if $p->{description}; |
| 204 |
my @class = split /\s+/, $p->{class}; |
| 205 |
if (substr ($o->{link}->{dest}->{uri}, 0, length ($o->uri ('wiki'))) |
| 206 |
eq $o->uri ('wiki')) { |
| 207 |
push @class, 'wiki'; ## Link to the page within the Wiki |
| 208 |
} |
| 209 |
$A->set_attribute (class => join ' ', @class) if @class; |
| 210 |
|
| 211 |
$A->set_attribute (rel => $o->{link}->{option}->{-rel}) |
| 212 |
if $o->{link}->{option}->{-rel}; |
| 213 |
$A->set_attribute (rev => $o->{link}->{option}->{-rev}) |
| 214 |
if $o->{link}->{option}->{-rev}; |
| 215 |
|
| 216 |
$A->set_attribute (hreflang => $o->{link}->{dest}->{-lang}) |
| 217 |
if $o->{link}->{dest}->{-lang}; |
| 218 |
$A->set_attribute (type => $o->{link}->{dest}->{-type}) |
| 219 |
if $o->{link}->{dest}->{-type}; |
| 220 |
|
| 221 |
FormattingRule: |
| 222 |
@Category[list]: page-link |
| 223 |
@Name: link-base-page-name |
| 224 |
@Description: |
| 225 |
@@@: Base WikiPage name |
| 226 |
@@lang: en |
| 227 |
@Formatting: |
| 228 |
$p->{-parent}->append_text (join '//', @{$o->{link}->{dest}->{base}}); |
| 229 |
|
| 230 |
FormattingRule: |
| 231 |
@Category[list]: page-link |
| 232 |
@Name: link-dest-anchor-no |
| 233 |
@Description: |
| 234 |
@@@: Anchor number in the WikiPage linked to, if specified |
| 235 |
@@lang: en |
| 236 |
@Formatting: |
| 237 |
$p->{-parent}->append_text ($o->{link}->{dest}->{page_anchor_no}); |
| 238 |
|
| 239 |
FormattingRule: |
| 240 |
@Category[list]: page-link |
| 241 |
@Name: if-linked-wikipage-exist |
| 242 |
@Description: |
| 243 |
@@@: If or if not linked WikiPage exists, then |
| 244 |
@@lang: en |
| 245 |
@Formatting: |
| 246 |
my $page = $o->{link}->{dest}->{page}; |
| 247 |
my $rule; |
| 248 |
if ($o->{wiki}->{db}->exist (content => $page)) { |
| 249 |
$rule = __ATTRTEXT:%true__; |
| 250 |
} else { |
| 251 |
$rule = __ATTRTEXT:%false__; |
| 252 |
} |
| 253 |
SuikaWiki::Plugin->formatter ('page-link') |
| 254 |
->replace ($rule, param => $o, -parent => $p->{-parent}); |
| 255 |
|
| 256 |
|
| 257 |
FormattingRule: |
| 258 |
@Category[list]: page-link |
| 259 |
@Name: if-link-has-dest-anchor-no |
| 260 |
@Description: |
| 261 |
@@@: If or if the link has destination numeral anchor |
| 262 |
@@lang: en |
| 263 |
@Formatting: |
| 264 |
my $rule; |
| 265 |
if ($o->{link}->{dest}->{page_anchor_no}) { |
| 266 |
$rule = __ATTRTEXT:%true__; |
| 267 |
} else { |
| 268 |
$rule = __ATTRTEXT:%false__; |
| 269 |
} |
| 270 |
SuikaWiki::Plugin->formatter ('page-link') |
| 271 |
->replace ($rule, param => $o, -parent => $p->{-parent}); |
| 272 |
|
| 273 |
FormattingRule: |
| 274 |
@Category[list]: page-link |
| 275 |
@Name:-bare-text |
| 276 |
@Formatting: |
| 277 |
$p->{-parent}->append_text ($p->{-bare_text}); |
| 278 |
|
| 279 |
Function: |
| 280 |
@Name: to_wikipage_in_html |
| 281 |
@Description: |
| 282 |
@@@:Make a link to the WikiPage (in HTML) |
| 283 |
@@lang:en |
| 284 |
@Main: |
| 285 |
my (undef, $src => $dest, $opt) = @_; |
| 286 |
#$dest->{page_name} = SuikaWiki::Plugin::WikiNamespace->resolve_relative_name |
| 287 |
# ($dest->{base} => $dest->{page_name_relative}); |
| 288 |
$dest->{page_name} = $dest->{page_name_relative}; |
| 289 |
$dest->{uri} = SuikaWiki::Plugin->_uri_wiki_page ## TODO: use formal API |
| 290 |
(join (q#//#, @{$dest->{page_name}}), |
| 291 |
mode => $dest->{wiki_mode}, |
| 292 |
anchor => $dest->{page_anchor_no}, up_to_date => $dest->{_up_to_date}, |
| 293 |
with_lm => $dest->{_with_lm}, |
| 294 |
add_param => $dest->{page_anchor_name}?"#$dest->{page_anchor_name}":''); |
| 295 |
|
| 296 |
local $opt->{o}->{link} = { |
| 297 |
src => $src, |
| 298 |
dest => $dest, |
| 299 |
option => $opt, |
| 300 |
}; |
| 301 |
$src->{label} = SuikaWiki::Plugin->resource ('Link:toWikiPage:SourceLabel') |
| 302 |
unless defined $src->{label}; |
| 303 |
SuikaWiki::Plugin->formatter ('page-link') |
| 304 |
->replace ($src->{label}, param => $opt->{o}, -parent => $opt->{parent}); |
| 305 |
|