1 package org
.argeo
.cms
.ux
;
3 import org
.argeo
.api
.acr
.Content
;
4 import org
.argeo
.api
.acr
.ContentRepository
;
5 import org
.argeo
.api
.acr
.ContentSession
;
6 import org
.argeo
.api
.cms
.ux
.Cms2DSize
;
7 import org
.argeo
.api
.cms
.ux
.CmsView
;
8 import org
.argeo
.cms
.util
.CurrentSubject
;
10 /** Utilities around UX. */
11 public class CmsUxUtils
{
12 public static ContentSession
getContentSession(ContentRepository contentRepository
, CmsView cmsView
) {
13 return CurrentSubject
.callAs(cmsView
.getCmsSession().getSubject(), () -> contentRepository
.get());
16 public static String
getTitle(Content content
) {
17 return content
.getName().getLocalPart();
20 public static StringBuilder
imgBuilder(String src
, String width
, String height
) {
21 return new StringBuilder(64).append("<img width='").append(width
).append("' height='").append(height
)
22 .append("' src='").append(src
).append("'");
25 public static String
img(String src
, String width
, String height
) {
26 return imgBuilder(src
, width
, height
).append("/>").toString();
29 public static String
img(String src
, Cms2DSize size
) {
30 return img(src
, Integer
.toString(size
.width()), Integer
.toString(size
.height()));
34 private CmsUxUtils() {