N°2847 - Rollback fix on pages <base> URL tag (to much consequences)

Fixing the base URL tag on WebPage and derivated classes would require to migrate all extensions which use the add_linked_script / add_linked_stylesheet functions with a relative URL, which is almost all extensions. So the benefit isn't worth the workload.

Note: We could have migrate extensions by replacing "../images|js|css/xxx.yyy" with utils::GetAbsoluteUrlAppRoot()."images|js|css/xxx.yyy" to make them compatible with iTop 2.8 and previous versions. But as said before, much work.
This commit is contained in:
Molkobain
2020-07-17 21:01:04 +02:00
parent 8efd8008fc
commit ad379d3ef4
5 changed files with 46 additions and 39 deletions

View File

@@ -551,8 +551,8 @@ EOF
$oLayout->Render($oPage, $this->aCells, $bEditMode, $aExtraParams);
if (!$bEditMode)
{
$oPage->add_linked_script('js/dashlet.js');
$oPage->add_linked_script('js/dashboard.js');
$oPage->add_linked_script('../js/dashlet.js');
$oPage->add_linked_script('../js/dashboard.js');
}
}

View File

@@ -103,40 +103,40 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage
// TODO: Should we keep this? Makes no sense
//$this->add_header("Cache-control: no-cache");
// TODO: Add only what's necessary
$this->add_linked_stylesheet("css/jquery.treeview.css");
$this->add_linked_stylesheet("css/jquery-ui-timepicker-addon.css");
$this->add_linked_stylesheet("css/jquery.multiselect.css");
$this->add_linked_stylesheet("css/magnific-popup.css");
$this->add_linked_stylesheet("css/c3.min.css");
$this->add_linked_stylesheet("css/font-awesome/css/all.min.css");
$this->add_linked_stylesheet("js/ckeditor/plugins/codesnippet/lib/highlight/styles/obsidian.css");
$this->add_linked_stylesheet("../css/jquery.treeview.css");
$this->add_linked_stylesheet("../css/jquery-ui-timepicker-addon.css");
$this->add_linked_stylesheet("../css/jquery.multiselect.css");
$this->add_linked_stylesheet("../css/magnific-popup.css");
$this->add_linked_stylesheet("../css/c3.min.css");
$this->add_linked_stylesheet("../css/font-awesome/css/all.min.css");
$this->add_linked_stylesheet("../js/ckeditor/plugins/codesnippet/lib/highlight/styles/obsidian.css");
// TODO: Add only what's necessary
$this->add_linked_script('js/jquery.layout.min.js');
$this->add_linked_script('js/jquery.ba-bbq.min.js');
$this->add_linked_script("js/jquery.treeview.js");
$this->add_linked_script("js/date.js");
$this->add_linked_script("js/jquery-ui-timepicker-addon.js");
$this->add_linked_script("js/jquery-ui-timepicker-addon-i18n.min.js");
$this->add_linked_script("js/jquery.blockUI.js");
$this->add_linked_script("js/utils.js");
$this->add_linked_script("js/swfobject.js");
$this->add_linked_script("js/ckeditor/ckeditor.js");
$this->add_linked_script("js/ckeditor/adapters/jquery.js");
$this->add_linked_script("js/ckeditor/plugins/codesnippet/lib/highlight/highlight.pack.js");
$this->add_linked_script("js/jquery.qtip-1.0.min.js");
$this->add_linked_script('js/property_field.js');
$this->add_linked_script('js/icon_select.js');
$this->add_linked_script('js/raphael-min.js');
$this->add_linked_script('js/d3.js');
$this->add_linked_script('js/c3.js');
$this->add_linked_script('js/jquery.multiselect.js');
$this->add_linked_script('js/ajaxfileupload.js');
$this->add_linked_script('js/jquery.mousewheel.js');
$this->add_linked_script('js/jquery.magnific-popup.min.js');
$this->add_linked_script('js/moment-with-locales.min.js');
$this->add_linked_script('js/showdown.min.js');
$this->add_linked_script('js/newsroom_menu.js');
$this->add_linked_script('../js/jquery.layout.min.js');
$this->add_linked_script('../js/jquery.ba-bbq.min.js');
$this->add_linked_script("../js/jquery.treeview.js");
$this->add_linked_script("../js/date.js");
$this->add_linked_script("../js/jquery-ui-timepicker-addon.js");
$this->add_linked_script("../js/jquery-ui-timepicker-addon-i18n.min.js");
$this->add_linked_script("../js/jquery.blockUI.js");
$this->add_linked_script("../js/utils.js");
$this->add_linked_script("../js/swfobject.js");
$this->add_linked_script("../js/ckeditor/ckeditor.js");
$this->add_linked_script("../js/ckeditor/adapters/jquery.js");
$this->add_linked_script("../js/ckeditor/plugins/codesnippet/lib/highlight/highlight.pack.js");
$this->add_linked_script("../js/jquery.qtip-1.0.min.js");
$this->add_linked_script('../js/property_field.js');
$this->add_linked_script('../js/icon_select.js');
$this->add_linked_script('../js/raphael-min.js');
$this->add_linked_script('../js/d3.js');
$this->add_linked_script('../js/c3.js');
$this->add_linked_script('../js/jquery.multiselect.js');
$this->add_linked_script('../js/ajaxfileupload.js');
$this->add_linked_script('../js/jquery.mousewheel.js');
$this->add_linked_script('../js/jquery.magnific-popup.min.js');
$this->add_linked_script('../js/moment-with-locales.min.js');
$this->add_linked_script('../js/showdown.min.js');
$this->add_linked_script('../js/newsroom_menu.js');
$this->add_dict_entry('UI:FillAllMandatoryFields');
@@ -1138,6 +1138,13 @@ EOF
'aJsInlineLive' => $this->a_scripts,
];
// Base tag
// Note: We might consider to put the app_root_url parameter here, but that would need a BIG rework on iTop AND the extensions to replace all the "../images|js|css/xxx.yyy"...
if(!empty($this->a_base['href']))
{
$aData['aPage']['aMetadata']['sBaseUrl'] = $this->a_base['href'];
}
// Layouts
$aData['aLayouts'] = [
'sBanner' => $this->RenderBannerHtml(),
@@ -1163,8 +1170,6 @@ EOF
}
}
// Render final TWIG into global HTML
$oKpi = new ExecutionKPI();
$sHtml = TwigHelper::RenderTemplate($oTwigEnv, $aData, $sTemplateRelPath);

View File

@@ -2,7 +2,7 @@
{# TODO: Move this to a dedicated script file #}
{% if aBreadCrumbs.aWidgetOptions is defined %}
<script type="text/javascript" src="js/components/breadcrumbs.js"></script>
<script type="text/javascript" src="../js/components/breadcrumbs.js"></script>
<script type="text/javascript">
setTimeout(function(){
$('#{{ aBreadCrumbs.sId }}').breadcrumbs({{ aBreadCrumbs.aWidgetOptions|json_encode|raw }});

View File

@@ -37,7 +37,7 @@
</nav>
{# TODO: Move this to a dedicated script file #}
<script type="text/javascript" src="js/layouts/navigation-menu.js"></script>
<script type="text/javascript" src="../js/layouts/navigation-menu.js"></script>
<script type="text/javascript">
setTimeout(function(){
$('#{{ aNavigationMenu.sId }}').navigation_menu();

View File

@@ -5,7 +5,9 @@
{# This block can be used to add your own meta tags by extending the default template #}
{% block iboPageExtraMetas %}
{% endblock %}
<base href="{{ aPage.sAbsoluteUrlAppRoot }}">
{% if aPage.aMetadata.sBaseUrl is defined %}
<base href="{{ aPage.aMetadata.sBaseUrl }}">
{% endif %}
<title>{{ aPage.sTitle }}</title>
<link rel="shortcut icon" href="{{ aPage.sFaviconUrl|add_itop_version }}" />