Use "resource_path" TALES extension to get resource URL
authorThierry Florac <thierry.florac@onf.fr>
Tue, 16 May 2017 11:05:57 +0200
changeset 78 70361525c66b
parent 77 a6c8b6a420f7
child 79 5726318eeb90
Use "resource_path" TALES extension to get resource URL
src/pyams_content/shared/common/zmi/dashboard.py
src/pyams_content/shared/common/zmi/templates/header.pt
src/pyams_content/shared/common/zmi/templates/review-comments.pt
--- a/src/pyams_content/shared/common/zmi/dashboard.py	Tue May 16 11:05:23 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/dashboard.py	Tue May 16 11:05:57 2017 +0200
@@ -39,6 +39,7 @@
 from hypatia.catalog import CatalogQuery
 from hypatia.query import And, Or, Eq, Any
 from pyams_catalog.query import CatalogResultSet
+from pyams_content.skin import pyams_content
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.container import ContainerView
 from pyams_skin.page import DefaultPageHeaderAdapter
@@ -47,6 +48,7 @@
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
 from pyams_utils.date import format_datetime, SH_DATETIME_FORMAT
+from pyams_utils.fanstatic import get_resource_path
 from pyams_utils.list import unique
 from pyams_utils.property import cached_property
 from pyams_utils.registry import get_utility
@@ -428,10 +430,11 @@
         oid = ISequentialIdInfo(item).hex_oid
         icon_class = 'fa fa-fw fa-star{0}'.format('' if oid in (self.profile.favorites or ()) else '-o')
         return '<i data-ams-plugins="pyams_content" ' \
-            'data-ams-plugin-pyams_content-src="/--static--/pyams_content/js/pyams_content{{MyAMS.devext}}.js" ' \
+            'data-ams-plugin-pyams_content-src="{path}" ' \
             'data-ams-click-handler="PyAMS_content.profile.switchFavorite" data-ams-stop-propagation="true" ' \
             'data-sequence-oid="{oid}" ' \
             'class="{icon_class}"></i>'.format(
+                path=get_resource_path(pyams_content),
                 oid=oid,
                 title=self.request.localizer.translate(self.icon_hint),
                 icon_class=icon_class)
--- a/src/pyams_content/shared/common/zmi/templates/header.pt	Tue May 16 11:05:23 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/templates/header.pt	Tue May 16 11:05:57 2017 +0200
@@ -19,10 +19,10 @@
 		<span class="bold content-title" tal:content="i18n:context.title">Title</span> |
 		<span class="content-owner" i18n:translate="">by <i18n:var name="owner" tal:content="view.owner" /></span>
 		<i data-ams-plugins="pyams_content"
-		   data-ams-plugin-pyams_content-src="/--static--/pyams_content/js/pyams_content{MyAMS.devext}.js"
 		   data-ams-click-handler="PyAMS_content.profile.switchFavorite"
 		   data-ams-hint-gravity="w" title="Add/remove from favorites" i18n:attributes="title"
 		   tal:attributes="class 'fa fa-star{0} txt-color-blue hint opaque align-middle padding-left-10 padding-bottom-5'.format('' if view.favorite_content else '-o');
+						   data-ams-plugin-pyams_content-src extension:resource_path('pyams_content.skin:pyams_content');
 						   data-sequence-oid view.hex_oid;"></i><br />
 		<span class="content-version" tal:content="string:V${view.version_id}">Version</span> =
 		<span class="content-state" tal:content="structure view.state">state</span> |
--- a/src/pyams_content/shared/common/zmi/templates/review-comments.pt	Tue May 16 11:05:23 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/templates/review-comments.pt	Tue May 16 11:05:57 2017 +0200
@@ -1,7 +1,7 @@
 <div class="ams-widget comments" i18n:domain="pyams_content"
 	 data-ams-plugins="pyams_content"
-	 data-ams-plugin-pyams_content-src="/--static--/pyams_content/js/pyams_content{MyAMS.devext}.js"
-	 data-ams-plugin-pyams_content-css="/--static--/pyams_content/css/pyams_content{MyAMS.devext}.css"
+	 tal:attributes="data-ams-plugin-pyams_content-src extension:resource_path('pyams_content.skin:pyams_content');
+					 data-ams-plugin-pyams_content-css extension:resource_path('pyams_content.skin:pyams_content_css');"
 	 data-ams-plugin-pyams_content-async="false"
 	 data-ams-callback="PyAMS_content.review.initComments">
 	<header>