Minor fix to PmTOC styling
[papyrus.git] / papyrus.php
blobd8466c49c484c033829583785c41c55f0503bc35
1 <?php if (!defined('PmWiki')) exit();
2 /* Papyrus skin for PmWiki
3 Copyright 2017-2022 Said Achmiz
5 https://www.pmwiki.org/wiki/Skins/Papyrus
6 */
8 global $FmtPV;
9 $FmtPV['$SkinName'] = '"Papyrus"';
10 $FmtPV['$SkinVersion'] = '"2022-03-04"';
12 ## Append the modification time to the URL as a GET parameter; this should be ignored
13 ## by the web server, but is seen as part of the unique URL of the remote resource by
14 ## the browser; when it changes (because the attachment has been modified), the
15 ## browser will see that it doesn’t have a cached version of the resource under the
16 ## new URL, and will retrieve the updated version.
17 $filepath = "$SkinDir/papyrus.css";
18 $path = "$SkinDirUrl/papyrus.css";
19 $versioned_path = $path . "?v=" . filemtime($filepath);
21 global $VersionedAssetsReattachFileExtension;
22 if ($VersionedAssetsReattachFileExtension == true) {
23 ## Re-attach the file extension.
24 preg_match("/\\.[^\\.]+$/", $path, $matches);
25 $versioned_path .= $matches[0];
28 global $HTMLHeaderFmt;
29 $HTMLHeaderFmt[] = "<link rel='stylesheet' type='text/css' href='$versioned_path' />\n";
31 ## Define a custom PageStore for bundled pages.
32 class PapyrusPageStore extends PageStore {
33 function pagefile($pagename) {
34 global $FarmD;
35 $dfmt = $this->dirfmt;
36 if ($pagename > '') {
37 $pagename = str_replace('/', '.', $pagename);
38 if ($dfmt == dirname(__FILE__).'/wikilib.d/{$FullName}')
39 return $this->PFE(dirname(__FILE__)."/wikilib.d/$pagename");
40 if ($dfmt == '$FarmD/pub/skins/papyrus/wikilib.d/{$FullName}')
41 return $this->PFE("$FarmD/pub/skins/papyrus/wikilib.d/$pagename");
43 return $this->PFE(FmtPageName($dfmt, $pagename));
46 global $WikiLibDirs, $RecipeInfo;
47 $PageStorePath = dirname(__FILE__).'/wikilib.d/{$FullName}';
48 $where = count($WikiLibDirs);
49 if ($where > 1) $where--;
50 if ($RecipeInfo['Sisterly']['Version'] != '') $where--; // If Sisterly is enabled, then the last PageStore is the SisterStore, not the PmWiki stuff. So we have to insert at an index 1 less.
51 array_splice($WikiLibDirs, $where, 0, array(new PapyrusPageStore($PageStorePath)));
53 ## Label the body element with a class indicating the current page action.
54 global $HTMLFooterFmt, $action;
55 $HTMLFooterFmt[] = "<script type='text/javascript'>document.querySelector('body').classList.add('action-{$action}');</script>";
57 ## Enable the (:notitlegroup:) and (:titlegroup:) directives.
58 Markup('notitlegroup', 'directives', '/\(:notitlegroup:\)/i', function ($m) {
59 global $HTMLStylesFmt;
60 $HTMLStylesFmt['papyrus-title-group'] = "#pageTitle .title-group { display: none; }";
61 });
62 Markup('titlegroup', 'directives', '/\(:titlegroup:\)/i', function ($m) {
63 global $HTMLStylesFmt;
64 $HTMLStylesFmt['papyrus-title-group'] = "";
65 });