pub enum LinkType {
Direct,
Page,
Interwiki,
Anchor,
TableOfContents,
}Variants§
Direct
This URL was specified directly.
For instance, as a raw URL, or a single-bracket link.
Page
This URL was specified by specifying a particular Wikijump page.
This variant comes from triple-bracket links.
Interwiki
This URL was generated via interwiki substitution.
Anchor
This URL points to an anchor elsewhere on this page.
TableOfContents
This URL points to entries on a page in a table of contents.
Implementations§
source§impl LinkType
impl LinkType
sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
Examples found in repository?
src/render/html/element/link.rs (line 57)
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
pub fn render_link(
ctx: &mut HtmlContext,
link: &LinkLocation,
label: &LinkLabel,
target: Option<AnchorTarget>,
ltype: LinkType,
) {
info!("Rendering link '{:?}' (type {})", link, ltype.name());
let handle = ctx.handle();
// Add to backlinks
ctx.add_link(link);
let url = normalize_link(link, ctx.handle());
let target_value = match target {
Some(target) => target.html_attr(),
None => "",
};
let css_class = match link {
LinkLocation::Url(url) if url == "javascript:;" => "wj-link-anchor",
LinkLocation::Url(url) if url.starts_with('#') => "wj-link-anchor",
LinkLocation::Url(url) if url.starts_with('/') => "wj-link-internal",
LinkLocation::Url(_) => "wj-link-external",
LinkLocation::Page(page) => {
if ctx.page_exists(page) {
"wj-link-internal"
} else {
"wj-link-internal wj-link-missing"
}
}
};
let interwiki_class = if ltype == LinkType::Interwiki {
" wj-link-interwiki"
} else {
""
};
let site = ctx.info().site.as_ref().to_string();
let mut tag = ctx.html().a();
tag.attr(attr!(
"href" => &url,
"target" => target_value; if target.is_some(),
"class" => "wj-link " css_class interwiki_class,
"data-link-type" => ltype.name(),
));
// Add <a> internals, i.e. the link name
handle.get_link_label(&site, link, label, |label| {
tag.contents(label);
});
}Trait Implementations§
source§impl<'de> Deserialize<'de> for LinkType
impl<'de> Deserialize<'de> for LinkType
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl IntoEnumIterator for LinkType
impl IntoEnumIterator for LinkType
type Iterator = LinkTypeIter
fn iter() -> LinkTypeIter ⓘ
source§impl PartialEq<LinkType> for LinkType
impl PartialEq<LinkType> for LinkType
impl Copy for LinkType
impl Eq for LinkType
impl StructuralEq for LinkType
impl StructuralPartialEq for LinkType
Auto Trait Implementations§
impl RefUnwindSafe for LinkType
impl Send for LinkType
impl Sync for LinkType
impl Unpin for LinkType
impl UnwindSafe for LinkType
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer