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.DefaultFilterLinkShare - 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.<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 firsttag. 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:
In which: medium_type can be "audio", "image", "video", "news", "blog" and "mult".<meta name="medium" content="medium_type" />
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
Fields Modifier and Type Field Description static StringACTIVITY_LINK_PREVIEW_ENABLED_PROPERTY
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(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 tagStringgetDescription()gets descriptionList<String>getImages()gets 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.StringgetLink()gets provided linkStringgetMediaAlbum()gets mediaAlbum if provided in:StringgetMediaArtist()gets mediaArtist if provided in:StringgetMediaHeight()gets mediaHeight if provided in:org.exoplatform.commons.embedder.ExoMediagetMediaObject()get mediaObjectStringgetMediaSrc()gets mediaSrcStringgetMediaTitle()gets mediaTitle if provided in:StringgetMediaType()gets mediaType if provided in:StringgetMediaWidth()gets mediaWidth if provided in:StringgetMediumType()gets mediumTypeStringgetTitle()gets titlevoidsetDescription(String description)Set new value for description.voidsetTitle(String title)Set 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 tag-
Methods 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 Detail
-
ACTIVITY_LINK_PREVIEW_ENABLED_PROPERTY
public static final String ACTIVITY_LINK_PREVIEW_ENABLED_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getLink
public String getLink()
gets provided link- Returns:
- provided link
-
getTitle
public String getTitle()
gets title- Returns:
- title
-
setTitle
public void setTitle(String title)
Set new value for title.- Parameters:
title-
-
getDescription
public String getDescription()
gets description- Returns:
- description
-
setDescription
public void setDescription(String description)
Set new value for description.- Parameters:
description-
-
getMediumType
public String getMediumType()
gets mediumType- Returns:
- mediumType
-
getMediaSrc
public String getMediaSrc()
gets mediaSrc- Returns:
- mediaSrc
-
getMediaType
public String 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
public String getMediaTitle()
gets mediaTitle if provided in:<meta name="audio_title" content="audio_title_name" />
- Returns:
- mediaTitle
-
getMediaArtist
public String getMediaArtist()
gets mediaArtist if provided in:<meta name="audio_artist" content="audio_artist_name" />
- Returns:
- mediaArtist
-
getMediaAlbum
public String getMediaAlbum()
gets mediaAlbum if provided in:<meta name="audio_album" content="audio_album_name" />
- Returns:
- mediaAlbum
-
getMediaHeight
public String getMediaHeight()
gets mediaHeight if provided in:<meta name="video_height" content="video_height_value" />
- Returns:
- mediaHeight;
-
getMediaWidth
public String 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
public static LinkShare getInstance(String link) throws Exception
Gets LinkShare instance with specified link. The default lang = "en"- Parameters:
link-- Returns:
- LinkShare instance
- Throws:
Exception
-
getInstance
public static LinkShare getInstance(String link, String lang) throws Exception
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
-
-