Revamped edit quick reference
[papyrus.git] / papyrus.php
blobdd3a449b3881b9772db28b3427b24c981f46c83a
1 <?php if (!defined('PmWiki')) exit();
3 /* PAPYRUS skin for PmWiki
4 Copyright 2019 Said Achmiz
6 Version: 2019-01-28-2
8 More info at these URLs:
10 * https://www.pmwiki.org/wiki/Skins/Papyrus
11 * https://www.pmwiki.org/wiki/Profiles/SaidAchmiz
13 The Papyrus skin includes:
15 * papyrus.php (skin script file)
16 * papyrus.css (style sheet)
17 * papyrus.jpg (background pattern)
18 * papyrus.tmpl (skin template)
19 * ReadMe.txt (instructions & info)
22 global $FmtPV;
23 $FmtPV['$SkinName'] = '"Papyrus"';
24 $FmtPV['$SkinVersion'] = '"2019-01-28-2"';
26 ## Append the modification time to the URL as a GET parameter; this should be ignored
27 ## by the web server, but is seen as part of the unique URL of the remote resource by
28 ## the browser; when it changes (because the attachment has been modified), the
29 ## browser will see that it doesn’t have a cached version of the resource under the
30 ## new URL, and will retrieve the updated version.
31 $filepath = "$SkinDir/papyrus.css";
32 $path = "$SkinDirUrl/papyrus.css";
33 $versioned_path = $path . "?v=" . filemtime($filepath);
35 global $VersionedAssetsReattachFileExtension;
36 if ($VersionedAssetsReattachFileExtension == true) {
37 ## Re-attach the file extension.
38 preg_match("/\\.[^\\.]+$/", $path, $matches);
39 $versioned_path .= $matches[0];
42 global $HTMLHeaderFmt;
43 $HTMLHeaderFmt[] = "<link rel='stylesheet' type='text/css' href='$versioned_path' />\n";
45 ## Define a custom PageStore for bundled pages.
46 class PapyrusPageStore extends PageStore {
47 function pagefile($pagename) {
48 global $FarmD;
49 $dfmt = $this->dirfmt;
50 if ($pagename > '') {
51 $pagename = str_replace('/', '.', $pagename);
52 if ($dfmt == dirname(__FILE__).'/wikilib.d/{$FullName}')
53 return $this->PFE(dirname(__FILE__)."/wikilib.d/$pagename");
54 if ($dfmt == '$FarmD/pub/skins/papyrus/wikilib.d/{$FullName}')
55 return $this->PFE("$FarmD/pub/skins/papyrus/wikilib.d/$pagename");
57 return $this->PFE(FmtPageName($dfmt, $pagename));
60 global $WikiLibDirs, $RecipeInfo;
61 $PageStorePath = dirname(__FILE__).'/wikilib.d/{$FullName}';
62 $where = count($WikiLibDirs);
63 if ($where > 1) $where--;
64 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.
65 array_splice($WikiLibDirs, $where, 0, array(new PapyrusPageStore($PageStorePath)));
67 ## Label the body element with a class indicating the current page action.
68 global $HTMLFooterFmt, $action;
69 $HTMLFooterFmt[] = "<script type='text/javascript'>document.querySelector('body').classList.add('action-{$action}');</script>";
71 ## Enable the (:notitlegroup:) and (:titlegroup:) directives.
72 Markup('notitlegroup', 'directives', '/\\(:notitlegroup:\\)/i', function ($m) {
73 global $HTMLStylesFmt;
74 $HTMLStylesFmt['papyrus-title-group'] = "#pageTitle .title-group { display: none; }";
75 });
76 Markup('titlegroup', 'directives', '/\\(:titlegroup:\\)/i', function ($m) {
77 global $HTMLStylesFmt;
78 $HTMLStylesFmt['papyrus-title-group'] = "";
79 });