BrightSide Workbench Full Report + Source Code
org.turro.elephant.web.SocialNet Class Reference

Public Member Functions

 SocialNet (String url, String title, String description, Collection< RepositoryFile > files)
 
boolean hasImage ()
 
boolean hasLarge ()
 
void setImage (SocialImage image)
 
String getUrl ()
 
List< String > getMetas ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 34 of file SocialNet.java.

Constructor & Destructor Documentation

◆ SocialNet()

org.turro.elephant.web.SocialNet.SocialNet ( String  url,
String  title,
String  description,
Collection< RepositoryFile files 
)

Definition at line 39 of file SocialNet.java.

39  {
40  this.url = url;
41  this.title = title;
42  this.description = escape(description);
43  Repository repository = ElContextMap.getRoot().getRepository();
44  files.addAll(repository.getRepositoryFiles("*_def_social.png,*_def_social.jpg"));
45  SocialImageMap.initialize(this, files);
46  }
Here is the call graph for this function:

Member Function Documentation

◆ getMetas()

List<String> org.turro.elephant.web.SocialNet.getMetas ( )

Definition at line 64 of file SocialNet.java.

64  {
65  ArrayList<String> metas = new ArrayList<>();
66 
67  // Twitter card
68  if(!hasLarge()) {
69  metas.add("<meta name=\"twitter:card\" content=\"summary\">");
70  } else {
71  metas.add("<meta name=\"twitter:card\" content=\"summary_large_image\">"); // Twitter card
72  }
73  metas.add("<meta name=\"twitter:title\" content=\"" + escape(title) + "\"/>");
74  if(!Strings.isBlank(description)) {
75  metas.add("<meta name=\"twitter:description\" content=\"" + Strings.truncateAndWarn(description, 250) + "\"/>");
76  }
77  if(hasImage()) {
78  metas.add("<meta name=\"twitter:image\" content=\"" + ElephantContext.getServerBase("http") + image.getUrl() + "\"/>");
79  }
80 
81  // OpenGraph
82  metas.add("<meta property=\"og:site_name\" content=\"" + ElephantContext.getSiteName() + "\"/>");
83  metas.add("<meta property=\"og:type\" content=\"website\"/>");
84  metas.add("<meta property=\"og:url\" content=\"" + ElephantContext.getServerBase("http") + url + "\"/>");
85  metas.add("<meta property=\"og:title\" content=\"" + escape(title) + "\"/>");
86  if(!Strings.isBlank(description)) {
87  metas.add("<meta property=\"og:description\" content=\"" + Strings.truncateAndWarn(description, 250) + "\"/>");
88  }
89  if(hasImage()) {
90  metas.add("<meta property=\"og:image\" content=\"" + ElephantContext.getServerBase("http") + image.getUrl() + "\"/>");
91  }
92 
93  return metas;
94  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUrl()

String org.turro.elephant.web.SocialNet.getUrl ( )

Definition at line 60 of file SocialNet.java.

60  {
61  return url;
62  }
Here is the caller graph for this function:

◆ hasImage()

boolean org.turro.elephant.web.SocialNet.hasImage ( )

Definition at line 48 of file SocialNet.java.

48  {
49  return image != null && !image.isEmpty();
50  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasLarge()

boolean org.turro.elephant.web.SocialNet.hasLarge ( )

Definition at line 52 of file SocialNet.java.

52  {
53  return hasImage() && image.isLarge();
54  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setImage()

void org.turro.elephant.web.SocialNet.setImage ( SocialImage  image)

Definition at line 56 of file SocialNet.java.

56  {
57  this.image = image;
58  }
Here is the caller graph for this function:

The documentation for this class was generated from the following file: