Class LinkShare
java.lang.Object
org.cyberneko.html.filters.DefaultFilter
org.exoplatform.social.service.rest.LinkShare
- All Implemented Interfaces:
org.apache.xerces.xni.parser.XMLComponent,org.apache.xerces.xni.parser.XMLDocumentFilter,org.apache.xerces.xni.parser.XMLDocumentSource,org.apache.xerces.xni.XMLDocumentHandler,org.cyberneko.html.HTMLComponent
public class LinkShare
extends org.cyberneko.html.filters.DefaultFilter
LinkShare - gets preview information of a link including:
- link
- title
- description
- images
- media (from popular sites: youtube, vimeo, flickr...) - low priority (NOT IMPLEMENTED YET)
This should be implemented from the client side to display preview and media player.
In order to provide this preview, always looks for the title of the page, a summary of the main content, and an image. Looks for preview information by the following priority:
1.
2. If title not found, then find in
Created by The eXo Platform SEA TODO: hoatle improvement: + scans description with MIN_CHARACTER + handles exception + parser more faster with and without scanning image tag, stop right when things got.
In order to provide this preview, always looks for the title of the page, a summary of the main content, and an image. Looks for preview information by the following priority:
1.
<meta name="title" content="page_title" />
<meta name="description" content="page_description" />
<link rel="image_src" href="image_source" />
2. If title not found, then find in
<title> tag.
If description not found, then find first tag. If no description, then return ""
If img_src not found, then find all images in page with max, min specified width + height
3.
To specify medium, use tag:
<meta name="medium" content="medium_type" />
In which: medium_type can be "audio", "image", "video", "news", "blog" and "mult".
Created by The eXo Platform SEA TODO: hoatle improvement: + scans description with MIN_CHARACTER + handles exception + parser more faster with and without scanning image tag, stop right when things got.
- Since:
- Oct 8, 2009
- Author:
- hoatle
- See Also:
-
- "http://activitystrea.ms/"
- "http://www.facebook.com/share_partners.php"
-
Field Summary
FieldsFields inherited from class org.cyberneko.html.filters.DefaultFilter
fDocumentHandler, fDocumentSource -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) filter method is called back when scanning meets the end of text in a tagvoidemptyElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs) this filter method is called back when scanning meets empty element tag Getting the image will use the following : 1- Meta tag with property og:image 2- Otherwise, link tag with image_src as Rel value 3- Otherwise the first image to get from the pagevoidendElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs) filter method is called back when scanning meets end element taggets descriptiongets images liststatic LinkSharegetInstance(String link) Gets LinkShare instance with specified link.static LinkSharegetInstance(String link, String lang) Gets LinkShare instance with link and lang specified.getLink()gets provided linkgets mediaAlbum if provided in:gets mediaArtist if provided in:gets mediaHeight if provided in:org.exoplatform.commons.embedder.ExoMediaget mediaObjectgets mediaSrcgets mediaTitle if provided in:gets mediaType if provided in:gets mediaWidth if provided in:gets mediumTypegetTitle()gets titlevoidsetDescription(String description) Set new value for description.voidSet new value for title.voidstartElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attrs, org.apache.xerces.xni.Augmentations augs) filter method is called back when scanning meets start element tagMethods inherited from class org.cyberneko.html.filters.DefaultFilter
comment, doctypeDecl, endCDATA, endDocument, endGeneralEntity, endPrefixMapping, getDocumentHandler, getDocumentSource, getFeatureDefault, getPropertyDefault, getRecognizedFeatures, getRecognizedProperties, ignorableWhitespace, merge, processingInstruction, reset, setDocumentHandler, setDocumentSource, setFeature, setProperty, startCDATA, startDocument, startDocument, startGeneralEntity, startPrefixMapping, textDecl, xmlDecl
-
Field Details
-
ACTIVITY_LINK_PREVIEW_ENABLED_PROPERTY
- See Also:
-
-
Method Details
-
getLink
gets provided link- Returns:
- provided link
-
getTitle
gets title- Returns:
- title
-
setTitle
Set new value for title.- Parameters:
title-
-
getDescription
gets description- Returns:
- description
-
setDescription
Set new value for description.- Parameters:
description-
-
getImages
gets images list- Returns:
- images
-
getMediumType
gets mediumType- Returns:
- mediumType
-
getMediaSrc
gets mediaSrc- Returns:
- mediaSrc
-
getMediaType
gets mediaType if provided in:<meta name="audio_type" content="Content-Type header field" />
or:<meta name="video_type" content="Content-Type header field" />
- Returns:
- mediaType
-
getMediaTitle
gets mediaTitle if provided in:<meta name="audio_title" content="audio_title_name" />
- Returns:
- mediaTitle
-
getMediaArtist
gets mediaArtist if provided in:<meta name="audio_artist" content="audio_artist_name" />
- Returns:
- mediaArtist
-
getMediaAlbum
gets mediaAlbum if provided in:<meta name="audio_album" content="audio_album_name" />
- Returns:
- mediaAlbum
-
getMediaHeight
gets mediaHeight if provided in:<meta name="video_height" content="video_height_value" />
- Returns:
- mediaHeight;
-
getMediaWidth
gets mediaWidth if provided in:<meta name="video_width" content="video_width_value" />
- Returns:
- mediaWidth
-
getMediaObject
public org.exoplatform.commons.embedder.ExoMedia getMediaObject()get mediaObject- Returns:
-
getInstance
Gets LinkShare instance with specified link. The default lang = "en"- Parameters:
link-- Returns:
- LinkShare instance
- Throws:
Exception
-
getInstance
Gets LinkShare instance with link and lang specified.- Parameters:
link-lang-- Returns:
- LinkShare instance
- Throws:
Exception
-
startElement
public void startElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attrs, org.apache.xerces.xni.Augmentations augs) filter method is called back when scanning meets start element tag- Specified by:
startElementin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
startElementin classorg.cyberneko.html.filters.DefaultFilter
-
endElement
public void endElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs) filter method is called back when scanning meets end element tag- Specified by:
endElementin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
endElementin classorg.cyberneko.html.filters.DefaultFilter
-
emptyElement
public void emptyElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs) this filter method is called back when scanning meets empty element tag Getting the image will use the following : 1- Meta tag with property og:image 2- Otherwise, link tag with image_src as Rel value 3- Otherwise the first image to get from the page- Specified by:
emptyElementin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
emptyElementin classorg.cyberneko.html.filters.DefaultFilter
-
characters
public void characters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) filter method is called back when scanning meets the end of text in a tag- Specified by:
charactersin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
charactersin classorg.cyberneko.html.filters.DefaultFilter
-