Skip to content

Commit

Permalink
DONE: #38 Override display.tpl
Browse files Browse the repository at this point in the history
  • Loading branch information
madi-nuralin committed Jul 1, 2024
1 parent f2de8cb commit 423cff9
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 74 deletions.
56 changes: 38 additions & 18 deletions MaterialThemePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,32 @@ public function init() {
]);

$request = Application::get()->getRequest();
$templateManager = TemplateManager::getManager($request);

$templateManager->unregisterPlugin('block', 'material_button_primary');
$templateManager->registerPlugin('block', 'material_button_primary', [$this, 'smartyMaterialButtonPrimary'], false);

$templateManager->unregisterPlugin('block', 'material_label');
$templateManager->registerPlugin('block', 'material_label', [$this, 'smartyMaterialLabel'], false);

$templateManager->unregisterPlugin('block', 'material_select');
$templateManager->registerPlugin('block', 'material_select', [$this, 'smartyMaterialSelect'], false);

$templateManager->unregisterPlugin('function', 'material_input');
$templateManager->registerPlugin('function', 'material_input', [$this, 'smartyMaterialInput']);

$templateManager->unregisterPlugin('function', 'material_checkbox');
$templateManager->registerPlugin('function', 'material_checkbox', [$this, 'smartyMaterialCheckbox']);

$templateManager->unregisterPlugin('function', 'material_select_date_a11y');
$templateManager->registerPlugin('function', 'material_select_date_a11y', [$this, 'smartyMaterialSelectDateA11y']);
$templateManager = TemplateManager::getManager($request);
$templateManager->assign('jquery', $this->getJqueryPath($request));
$templateManager->assign('jqueryUI', $this->getJqueryUIPath($request));

$plugins = [
'material_button_primary' => ['block', 'smartyMaterialButtonPrimary'],
'material_label' => ['block', 'smartyMaterialLabel'],
'material_select' => ['block', 'smartyMaterialSelect'],
'material_input' => ['function', 'smartyMaterialInput'],
'material_checkbox' => ['function', 'smartyMaterialCheckbox'],
'material_select_date_a11y' => ['function', 'smartyMaterialSelectDateA11y']
];

foreach ($plugins as $key => $value) {
$templateManager->unregisterPlugin($value[0], $key);
$templateManager->registerPlugin($value[0], $key, [$this, $value[1]], false);
}

// Load primary stylesheet
$this->addStyle('stylesheet', 'styles/dist/output.css');

// Load alpinejs for this theme
$this->addScript('alpinejs', 'js/alpinejs@3.x.x/dist/cdn.min.js');
$this->addScript('mainjs', 'js/main.js');

// Add navigation menu areas for this theme
$this->addMenuArea(['primary', 'user']);
}
Expand Down Expand Up @@ -149,6 +149,26 @@ public function getDescription() {
return __('plugins.themes.material.description');
}

/**
* Get the jquery path
*
* @return string
*/
public function getJqueryPath($request) {
$min = Config::getVar('general', 'enable_minified') ? '.min' : '';
return $request->getBaseUrl() . '/lib/pkp/lib/vendor/components/jquery/jquery' . $min . '.js';
}

/**
* Get the jqueryUI path
*
* @return string
*/
public function getJqueryUIPath($request) {
$min = Config::getVar('general', 'enable_minified') ? '.min' : '';
return $request->getBaseUrl() . '/lib/pkp/lib/vendor/components/jqueryui/jquery-ui' . $min . '.js';
}

public function smartyMaterialButtonPrimary($params, $content, $smarty, &$repeat) {
$default = "";
$default .= " rounded-full";
Expand Down
62 changes: 6 additions & 56 deletions styles/dist/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -1464,11 +1464,6 @@ input:focus {
margin-right: auto;
}

.my-8 {
margin-top: 2rem;
margin-bottom: 2rem;
}

.-mb-56 {
margin-bottom: -14rem;
}
Expand All @@ -1493,10 +1488,6 @@ input:focus {
margin-bottom: 1rem;
}

.ml-0 {
margin-left: 0px;
}

.ml-2 {
margin-left: 0.5rem;
}
Expand Down Expand Up @@ -1782,6 +1773,12 @@ input:focus {
margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
}

.space-x-4 > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0;
margin-right: calc(1rem * var(--tw-space-x-reverse));
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
}

.space-y-2 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0;
margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));
Expand Down Expand Up @@ -1826,10 +1823,6 @@ input:focus {
border-radius: 1rem;
}

.rounded-3xl {
border-radius: 1.5rem;
}

.rounded-full {
border-radius: 9999px;
}
Expand Down Expand Up @@ -1858,11 +1851,6 @@ input:focus {
border-right-width: 1px;
}

.border-gray-300 {
--tw-border-opacity: 1;
border-color: rgb(209 213 219 / var(--tw-border-opacity));
}

.border-slate-100 {
--tw-border-opacity: 1;
border-color: rgb(241 245 249 / var(--tw-border-opacity));
Expand All @@ -1876,11 +1864,6 @@ input:focus {
background-color: rgb(10 16 31 / 0.8);
}

.bg-amber-50 {
--tw-bg-opacity: 1;
background-color: rgb(255 251 235 / var(--tw-bg-opacity));
}

.bg-blue-300 {
--tw-bg-opacity: 1;
background-color: rgb(147 197 253 / var(--tw-bg-opacity));
Expand Down Expand Up @@ -2029,10 +2012,6 @@ input:focus {
padding: 1rem;
}

.p-6 {
padding: 1.5rem;
}

.p-px {
padding: 1px;
}
Expand Down Expand Up @@ -2345,12 +2324,6 @@ input:focus {
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}

.shadow-sm {
--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}

.shadow-xl {
--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);
Expand Down Expand Up @@ -2615,12 +2588,6 @@ input:focus {
outline-offset: 2px;
}

.focus\:ring:focus {
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
}

.focus\:ring-blue-200:focus {
--tw-ring-opacity: 1;
--tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
Expand All @@ -2646,10 +2613,6 @@ input:focus {
--tw-ring-color: rgb(186 230 253 / var(--tw-ring-opacity));
}

.focus\:ring-opacity-50:focus {
--tw-ring-opacity: 0.5;
}

.focus-visible\:outline-2:focus-visible {
outline-width: 2px;
}
Expand Down Expand Up @@ -2795,11 +2758,6 @@ input:focus {
display: none;
}

:is(.dark .dark\:border-gray-500) {
--tw-border-opacity: 1;
border-color: rgb(107 114 128 / var(--tw-border-opacity));
}

:is(.dark .dark\:border-slate-800) {
--tw-border-opacity: 1;
border-color: rgb(30 41 59 / var(--tw-border-opacity));
Expand Down Expand Up @@ -2830,10 +2788,6 @@ input:focus {
background-color: rgb(30 41 59 / var(--tw-bg-opacity));
}

:is(.dark .dark\:bg-slate-800\/60) {
background-color: rgb(30 41 59 / 0.6);
}

:is(.dark .dark\:bg-slate-900) {
--tw-bg-opacity: 1;
background-color: rgb(15 23 42 / var(--tw-bg-opacity));
Expand Down Expand Up @@ -2882,10 +2836,6 @@ input:focus {
--tw-ring-inset: inset;
}

:is(.dark .dark\:ring-slate-300\/10) {
--tw-ring-color: rgb(203 213 225 / 0.1);
}

:is(.dark .dark\:ring-slate-700) {
--tw-ring-opacity: 1;
--tw-ring-color: rgb(51 65 85 / var(--tw-ring-opacity));
Expand Down
1 change: 1 addition & 0 deletions templates/frontend/components/headerSection.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
text-blue-300
text-sky-300
text-orange-300
dark:bg-gray-800
"></div>


Expand Down
71 changes: 71 additions & 0 deletions templates/plugins/generic/pdfJsViewer/templates/display.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{**
* plugins/generic/pdfJsViewer/templates/display.tpl
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* Embedded viewing of a PDF galley.
*}
<!DOCTYPE html>
<html lang="{$currentLocale|replace:"_":"-"}" xml:lang="{$currentLocale|replace:"_":"-"}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={$defaultCharset|escape}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{translate key="article.pageTitle" title=$title|escape}</title>

{load_header context="frontend" headers=$headers}
{load_stylesheet context="frontend" stylesheets=$stylesheets}
{load_script context="frontend" scripts=$scripts}
<script type="text/javascript" src="{$jquery}"></script>
<script type="text/javascript" src="{$jqueryUI}"></script>
</head>
<body class="pkp_page_{$requestedPage|escape} pkp_op_{$requestedOp|escape}">

{* Header wrapper *}
<header class="flex justify-between space-x-4 px-2 py-1 text-sm">

<a href="{$parentUrl}" class="return">
<span class="pkp_screen_reader">
{if $parent instanceOf Issue}
{translate key="issue.return"}
{else}
{translate key="article.return"}
{/if}
</span>
</a>

<a href="{$parentUrl}" class="title">
{$title|escape}
</a>

<a href="{$pdfUrl}" class="download" download>
<span class="label">
{translate key="common.download"}
</span>
</a>

</header>

<script type="text/javascript">
// Creating iframe's src in JS instead of Smarty so that EZProxy-using sites can find our domain in $pdfUrl and do their rewrites on it.
$(document).ready(function() {ldelim}
var urlBase = "{$pluginUrl}/pdf.js/web/viewer.html?file=";
var pdfUrl = {$pdfUrl|json_encode:JSON_UNESCAPED_SLASHES};
$("#pdfCanvasContainer > iframe").attr("src", urlBase + encodeURIComponent(pdfUrl));
{rdelim});
</script>

<div id="pdfCanvasContainer" class="galley_view{if !$isLatestPublication} galley_view_with_notice{/if}">
{if !$isLatestPublication}
<div class="galley_view_notice">
<div class="galley_view_notice_message" role="alert">
{$datePublished}
</div>
</div>
{/if}
<iframe src="" width="100%" height="100%" style="min-height: 500px;" title="{$galleyTitle}" allowfullscreen webkitallowfullscreen></iframe>
</div>
{call_hook name="Templates::Common::Footer::PageFooter"}
</body>
</html>

0 comments on commit 423cff9

Please sign in to comment.