1<#assign commonServiceApiService = serviceLocator.findService("es.juntadeandalucia.cma.global.common.services.api.CommonServiceApi")/>
2<#assign dlFileEntryLocalService=serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService") />
3<#assign assentEntryLocalService = serviceLocator.findService('com.liferay.asset.kernel.service.AssetEntryLocalService')/>
4<#assign formaterDate = commonServiceApiService.getFormatDate() />
5<#if locale=="en_GB">
6 <#assign formaterDate = formaterDate?replace("de", "of")/>
7</#if>
8<div style="display: block; position: fixed; left: 0px; right: 0px; top: 0px; bottom: 0px; background-color: white;z-index: 99;" id="hideAll"> </div>
9<#assign blogService = serviceLocator.findService("es.juntadeandalucia.cma.global.blogs.rating.service.BlogsRatingLocalService") />
10
11<section class="evr-blog">
12 <#assign URLb = themeDisplay.getPortalURL() + themeDisplay.getPathContext() + themeDisplay.getLayoutFriendlyURL(themeDisplay.getLayout()) + "/" />
13
14 <div class="evr-blog__title-container">
15 <span class="evr-blog__title"><@liferay.language key="cladt20.blogs.titulo.contenedor"/></span>
16 </div>
17 <#if entries?has_content>
18 <#list entries as curBlogEntry>
19
20 <#assign tituloURL = curBlogEntry.getUrlTitle()?replace("-", "+")>
21
22 <#assign resourcePrimKey = curBlogEntry.getPrimaryKey()/>
23 <#assign imageFileEntryId = curBlogEntry.getCoverImageFileEntryId()/>
24 <#assign imgBlog = "" />
25
26 <#if imageFileEntryId != 0>
27 <#assign cardImage = true />
28 <#assign assetEntry = assentEntryLocalService.getEntry("com.liferay.document.library.kernel.model.DLFileEntry", imageFileEntryId)/>
29 <#assign assetRenderer = assetEntry.assetRenderer />
30 <#assign imgBlog = assetRenderer.getURLDownload(themeDisplay) />
31 <#else>
32 <#assign cardImage = false />
33 </#if>
34
35 <#assign titulo = curBlogEntry.title />
36 <#assign texto = curBlogEntry.content />
37 <#assign resumen = curBlogEntry.getDescription() />
38
39 <div class="evr-blog__card" id="${curBlogEntry.getEntryId()}">
40 <#if cardImage>
41 <div class="evr-blog__card-fig-wrapper">
42 <div class="evr-blog__card-image" style="background-image: url(${imgBlog})"></div>
43 </div>
44 </#if>
45 <div class="evr-blog__card-text-container" >
46 <#if titulo?has_content>
47 <a class="evr-blog__card-title" href="${URLb}-/blogs/${curBlogEntry.getUrlTitle()}" title="${titulo}">${titulo}</a>
48 </#if>
49 <#if curBlogEntry.getDisplayDate()?has_content>
50 <span class="evr-blog__card-date">${dateUtil.getDate(curBlogEntry.getDisplayDate(), formaterDate, locale)}</span>
51 </#if>
52
53 <#if resumen?has_content>
54 <p class="evr-blog__card-text">${resumen}</p>
55 <#elseif texto?has_content>
56 <p class="evr-blog__card-text">${stringUtil.shorten(htmlUtil.stripHtml(texto), 400)}</p>
57 </#if>
58 </div>
59
60 <div class="evr-blog__card-icon-container">
61 <ul class="evr-blog__card-icons-rrss" style="padding-left: 20px;">
62 <#-- <li class="evr-blog__card-icon evr-blog__card-icon--more">
63 <button type="button" class="evr-blog__card-icon-button">
64 <figure class="evr-blog__card-icon-fig">
65 <img class="evr-blog__card-icon-img" src="${themeDisplay.getPathThemeImages()}/iconos_portal_SVG/icon_blog_puntos.svg" alt="Icono lista menú">
66 </figure>
67 </button>
68 </li> -->
69 <li class="evr-blog__card-icon evr-blog__card-icon--facebook">
70 <a href="http://www.facebook.com/sharer.php?u=${URLb}-/blogs/${curBlogEntry.getUrlTitle()}" role="button" class="evr-blog__card-icon-button" target="_blank">
71 <figure class="evr-blog__card-icon-fig">
72 <img class="evr-blog__card-icon-img" src="${themeDisplay.getPathThemeImages()}/iconos_portal_SVG/icon_blog_facebook.svg" alt="Icono Facebook">
73 </figure>
74 </a>
75 </li>
76 <li class="evr-blog__card-icon evr-blog__card-icon--linkedin">
77 <a href="https://www.linkedin.com/shareArticle?url=${URLb}-/blogs/${curBlogEntry.getUrlTitle()}&title=${curBlogEntry.getUrlTitle()}" role="button" class="evr-blog__card-icon-button" target="_blank">
78 <figure class="evr-blog__card-icon-fig">
79 <img class="evr-blog__card-icon-img" src="${themeDisplay.getPathThemeImages()}/iconos_portal_SVG/icon_blog_linkedin.svg" alt="Icono Linkedin">
80 </figure>
81 </a>
82 </li>
83 <#-- <li class="evr-blog__card-icon evr-blog__card-icon--pinterest">
84 <a href="https://pinterest.com/pin/create/bookmarklet/?url=${URLb}-/blogs/${curBlogEntry.getUrlTitle()}&description=${curBlogEntry.getUrlTitle()}" role="button" class="evr-blog__card-icon-button" target="_blank">
85 <figure class="evr-blog__card-icon-fig">
86 <img class="evr-blog__card-icon-img" src="${themeDisplay.getPathThemeImages()}/iconos_portal_SVG/icon_blog_pinterest.svg" alt="Icono Pinterest">
87 </figure>
88 </a>
89 </li> -->
90 <li class="evr-blog__card-icon evr-blog__card-icon--twitter">
91 <a href="https://twitter.com/intent/tweet?text=${tituloURL}&tw_p=tweetbutton&url=${URLb}-/blogs/${curBlogEntry.getUrlTitle()}" role="button" class="evr-blog__card-icon-button" target="_blank">
92 <figure class="evr-blog__card-icon-fig">
93 <img class="evr-blog__card-icon-img" src="${themeDisplay.getPathThemeImages()}/iconos_portal_SVG/icon_blog_twitter.svg" alt="Icono Twitter">
94 </figure>
95 </a>
96 </li>
97 </ul>
98 <div class="evr-blog__card-icons-feedback" style="display: block ruby;">
99 <#-- <div class="evr-blog__card-like-container">
100 <a href="https://twitter.com/intent/tweet?text=${tituloURL}&tw_p=tweetbutton&url=${URLb}-/blogs/${curBlogEntry.getUrlTitle()}" role="button" class="evr-blog__card-icon-button" target="_blank">
101 <figure class="evr-blog__card-like-icon-fig">
102 <img class="evr-blog__card-like-icon-img" src="${themeDisplay.getPathThemeImages()}/iconos_portal_SVG/icon_blog_heart.svg" alt="Icono like">
103 </figure>
104 </a>
105 <div class="evr-blog__card-like-counter">10</div>
106 </div> -->
107
108 <#if blogsPortletInstanceConfiguration.enableRatings()>
109 <div class="ratings">
110 <div class="taglib-ratings thumbs" id="${curBlogEntry.getEntryId()}ratingContainer">
111 <div class="liferay-rating-vote thumbrating" id="${curBlogEntry.getEntryId()}ratingThumb">
112 <div class="helper-clearfix rating-content thumbrating-content" id="${curBlogEntry.getEntryId()}rate">
113 <#if blogService.countByBlogEntryId(curBlogEntry.getEntryId()) == 0>
114 <#assign nuevoRating = blogService.addBlogsRating(curBlogEntry.getEntryId(), 0, 0)>
115 <#assign bRating = blogService.getBlogsRating(curBlogEntry.getEntryId())>
116 <#assign likes = bRating.getLikes()>
117 <#assign dislikes = bRating.getDislikes()>
118 <#assign updateLikes = likes + 1>
119 <#assign updateDislikes = dislikes + 1>
120
121 <a id="${curBlogEntry.getEntryId()?number}_likes" class="glyphicon glyphicon-thumbs-up rating-element rating-thumb-up rating-off" href="#" onclick='updateRating("${curBlogEntry.getEntryId()?number}", "${updateLikes?number}", "${dislikes?number}")' title="Valorar positivamente">${likes}</a>
122 <a id="${curBlogEntry.getEntryId()?number}_dislikes" class="glyphicon glyphicon-thumbs-down rating-element rating-thumb-down rating-off" href="#" onclick='updateRating("${curBlogEntry.getEntryId()?number}", "${likes?number}", "${updateDislikes?number}")' title="Valorar negativamente">${dislikes}</a>
123
124 <#elseif blogService.countByBlogEntryId(curBlogEntry.getEntryId()) == 1>
125 <#assign bRating = blogService.getBlogsRating(curBlogEntry.getEntryId())>
126 <#assign likes = bRating.getLikes()>
127 <#assign dislikes = bRating.getDislikes()>
128 <#assign updateLikes = likes + 1>
129 <#assign updateDislikes = dislikes + 1>
130
131 <a id="${curBlogEntry.getEntryId()?number}_likes" class="glyphicon glyphicon-thumbs-up rating-element rating-thumb-up rating-off" href="#" onclick='updateRating("${curBlogEntry.getEntryId()?number}", "${updateLikes?number}", "${dislikes?number}")' title="Valorar positivamente">${likes}</a>
132 <a id="${curBlogEntry.getEntryId()?number}_dislikes" class="glyphicon glyphicon-thumbs-down rating-element rating-thumb-down rating-off" href="#" onclick='updateRating("${curBlogEntry.getEntryId()?number}", "${likes?number}", "${updateDislikes?number}")' title="Valorar negativamente">${dislikes}</a>
133 </#if>
134 </div>
135 </div>
136 </div>
137 </div>
138 </#if>
139
140 <#if blogsPortletInstanceConfiguration.enableComments()>
141 <#assign viewCommentsPortletURL = renderResponse.createRenderURL() />
142
143 ${viewCommentsPortletURL.setParameter("mvcRenderCommandName", "/blogs/view_entry")}
144 ${viewCommentsPortletURL.setParameter("scroll", renderResponse.getNamespace() + "discussionContainer")}
145
146 <#if validator.isNotNull(curBlogEntry.getUrlTitle())>
147 ${viewCommentsPortletURL.setParameter("urlTitle", curBlogEntry.getUrlTitle())}
148 <#else>
149 ${viewCommentsPortletURL.setParameter("entryId", curBlogEntry.getEntryId()?string)}
150 </#if>
151
152 <div class="evr-blog__card-comment-container" style="padding-top: 9px;">
153 <a href="${viewCommentsPortletURL.toString()}">
154 <button type="button" class="evr-blog__card-comment-icon">
155 <figure class="evr-blog__card-comment-icon-fig" >
156 <img class="evr-blog__card-comment-icon-img" src="${themeDisplay.getPathThemeImages()}/iconos_portal_SVG/icon_blog_comentarios.svg" alt="Icono comentarios">
157 </figure>
158 </button>
159 </a>
160 </div>
161 </#if>
162 </div>
163 </div>
164 </div>
165 </#list>
166 </#if>
167</section>
168
169<script>
170
171 (function (factory) {
172 if (typeof define === 'function' && define.amd) {
173 // AMD (Register as an anonymous module)
174 define(['jquery'], factory);
175 } else if (typeof exports === 'object') {
176 // Node/CommonJS
177 module.exports = factory(require('jquery'));
178 } else {
179 // Browser globals
180 factory(jQuery);
181 }
182 }(function ($) {
183
184 var pluses = /\+/g;
185
186 function encode(s) {
187 return config.raw ? s : encodeURIComponent(s);
188 }
189
190 function decode(s) {
191 return config.raw ? s : decodeURIComponent(s);
192 }
193
194 function stringifyCookieValue(value) {
195 return encode(config.json ? JSON.stringify(value) : String(value));
196 }
197
198 function parseCookieValue(s) {
199 if (s.indexOf('"') === 0) {
200 // This is a quoted cookie as according to RFC2068, unescape...
201 s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
202 }
203
204 try {
205 // Replace server-side written pluses with spaces.
206 // If we can't decode the cookie, ignore it, it's unusable.
207 // If we can't parse the cookie, ignore it, it's unusable.
208 s = decodeURIComponent(s.replace(pluses, ' '));
209 return config.json ? JSON.parse(s) : s;
210 } catch(e) {}
211 }
212
213 function read(s, converter) {
214 var value = config.raw ? s : parseCookieValue(s);
215 return $.isFunction(converter) ? converter(value) : value;
216 }
217
218 var config = $.cookie = function (key, value, options) {
219
220 // Write
221
222 if (arguments.length > 1 && !$.isFunction(value)) {
223 options = $.extend({}, config.defaults, options);
224
225 if (typeof options.expires === 'number') {
226 var days = options.expires, t = options.expires = new Date();
227 t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
228 }
229
230 return (document.cookie = [
231 encode(key), '=', stringifyCookieValue(value),
232 options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
233 options.path ? '; path=' + options.path : '',
234 options.domain ? '; domain=' + options.domain : '',
235 options.secure ? '; secure' : ''
236 ].join(''));
237 }
238
239 // Read
240
241 var result = key ? undefined : {},
242 // To prevent the for loop in the first place assign an empty array
243 // in case there are no cookies at all. Also prevents odd result when
244 // calling $.cookie().
245 cookies = document.cookie ? document.cookie.split('; ') : [],
246 i = 0,
247 l = cookies.length;
248
249 for (; i < l; i++) {
250 var parts = cookies[i].split('='),
251 name = decode(parts.shift()),
252 cookie = parts.join('=');
253
254 if (key === name) {
255 // If second argument (value) is a function it's a converter...
256 result = read(cookie, value);
257 break;
258 }
259
260 // Prevent storing a cookie that we couldn't decode.
261 if (!key && (cookie = read(cookie)) !== undefined) {
262 result[name] = cookie;
263 }
264 }
265
266 return result;
267 };
268
269 config.defaults = {};
270
271 $.removeCookie = function (key, options) {
272 // Must not alter options, thus extending a fresh object...
273 $.cookie(key, '', $.extend({}, options, { expires: -1 }));
274 return !$.cookie(key);
275 };
276
277 }));
278
279 function updateRating(blogEntryId1, likes1, dislikes1) {
280
281
282 var cookieName = 'rating-' + blogEntryId1;
283 if(!$.cookie(cookieName)) {
284
285 Liferay.Service('/blogsrating.blogsrating/update-blogs-rating', {
286 blogEntryId: blogEntryId1,
287 likes: likes1,
288 dislikes: dislikes1
289 },
290 function(obj) {
291 //debugger;
292 var likes = document.getElementById(obj.blogEntryId + "_likes");
293 var dislikes = document.getElementById(obj.blogEntryId + "_dislikes");
294
295 //console.log(obj);
296 likes.text = obj.likes;
297 dislikes.text = obj.dislikes;
298 }
299 );
300
301 $.cookie(cookieName, "true");
302 window.location.hash = "#" + blogEntryId1;
303
304
305 } else {
306 alert('Ya has valorado esta entrada antes');
307
308 }
309 };
310
311 function hideBlog(){
312
313 var funcionalidades = document.getElementsByClassName('evr-header__bar-container');
314 var cabecera = document.getElementsByClassName('evr-header__container');
315 var categorizacion = document.getElementsByClassName('entry-title taglib-categorization-filter');
316 var rss = document.getElementsByClassName("subscribe");
317 //var enlaces = document.getElementById('p_p_id_com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_breakingNews4_');
318 var ocultarTodo = document.getElementById("hideAll");
319
320 //console.log(categorizacion.length);
321
322 //enlaces.parentNode.removeChild(enlaces);
323 ocultarTodo.parentNode.removeChild(ocultarTodo);
324
325 for (let i = 0; i < funcionalidades.length; i++) {
326 funcionalidades[i].parentNode.removeChild(funcionalidades[i]);
327 }
328
329 for (let j = 0; j < cabecera.length; j++) {
330 cabecera[j].parentNode.removeChild(cabecera[j]);
331 }
332
333 for (let k = 0; k < rss.length; k++) {
334 rss[k].parentNode.removeChild(rss[k]);
335 }
336
337 for (let x = 0; x < categorizacion.length; x++) {
338 categorizacion[x].parentNode.removeChild(categorizacion[x]);
339 }
340
341 };
342
343 $( window ).on( "load", hideBlog);
344</script>