Nicole Sharp's Website

From NikkiWiki
Jump to navigation Jump to search

Notes on the development of Nicole Sharp's Website.

PHP

PHP version

PHP info

<?php

phpinfo();

/*
https://www.php.net/manual/function.phpinfo
Personal Homepage Hypertext Preprocessor Info (PHPINFO) for Nicole Sharp's Website.
2024-06-07 Nicole Sharp
https://www.nicolesharp.net/
Unless otherwise noted, content on Nicole Sharp's Website is available under the Creative Commons Attribution-ShareAlike 4.0 International Public License.
https://creativecommons.org/licenses/by-sa/4.0/
*/

?>

PHP initialization

date.timezone = (America/New_York)
; https://help.dreamhost.com/hc/articles/217185277/
; https://www.php.net/manual/timezones.america.php
zend_extension = opcache.so ; https://help.dreamhost.com/hc/articles/216660668/
; https://help.dreamhost.com/hc/articles/214894037/
; DreamHost Personal Homepage Hypertext Preprocessor Initialization Run Commands (PHPRC) for Nicole Sharp's Website.
; 2024-06-07 Nicole Sharp
; https://www.nicolesharp.net/
; Unless otherwise noted, content on Nicole Sharp's Website is available under the Creative Commons Attribution-ShareAlike 4.0 International Public License.
; https://creativecommons.org/licenses/by-sa/4.0/

PHP timezone

PHP caching

MediaWiki

MediaWiki requirements

MediaWiki version

MediaWiki download

MediaWiki installation

MediaWiki shortlinks

ARTICLEPATH HTACCESS

RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
# https://www.mediawiki.org/wiki/manual:short_URL/Apache
# Apache Hypertext Transfer Protocol Server Access (HTACCESS) for Nicole Sharp's Website.
# 2024-06-07 Nicole Sharp
# https://www.nicolesharp.net/
# Unless otherwise noted, content on Nicole Sharp's Website is available under the Creative Commons Attribution-ShareAlike 4.0 International Public License.
# https://creativecommons.org/licenses/by-sa/4.0/

ARTICLEPATH LOCALSETTINGS

$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1"; ## https://www.mediawiki.org/wiki/short_URLs_on_Apache

MediaWiki timezone

$wgLocaltimezone = "America/New_York"; ## https://www.mediawiki.org/wiki/timezone
## https://www.php.net/manual/timezones.america.php

HitCounter

wfLoadExtension( 'HitCounters' );
$wgGroupPermissions['sysop']['hitcounter-exempt'] = false;
## https://www.mediawiki.org/wiki/HitCounter

HeadScript

wfLoadExtension( 'HeadScript' );
$wgHeadScriptCode = <<<'START_END_MARKER'
<meta name="author" content="Nicole Sharp" />
<script type="text/javascript" src="/matomo.js" defer="defer" data-cite="https://www.matomo.org/" data-title="Matomo Analytics"></script>
<script type="text/javascript" src="https://www.googletagmanager.com/gtag/js?id=G-J2SZ5TVE3E" defer="defer" data-title="Google Tag Manager"></script>
<script type="text/javascript" src="/google.js" defer="defer" data-cite="https://analytics.google.com/" data-title="Google Analytics"></script>
<script type="text/javascript" src="/microsoft.js" defer="defer" data-cite="https://clarity.microsoft.com/" data-title="Microsoft Clarity"></script>
<script type="text/javascript" src="/yandex.js" defer="defer" data-cite="https://metrica.yandex.com/" data-title="Yandex Metrica"></script>
START_END_MARKER;
## https://www.mediawiki.org/wiki/HeadScript

MediaWiki linkfollowing

$wgNoFollowLinks = false; ## https://www.mediawiki.org/wiki/NoFollowLinks

MediaWiki favicon

$wgFavicon = "/favicon.gif"; ## https://www.mediawiki.org/wiki/$wgFavicon

$wgLogos = [
	'1x' => "$wgResourceBasePath/resources/assets/NikkiWiki.gif",
	'icon' => "$wgResourceBasePath/resources/assets/NikkiWiki.gif",
];

WikiSEO

wfLoadExtension( 'WikiSEO' );
$wgWikiSeoEnableAutoDescription = true;
$wgTwitterSiteHandle = '@nicolesharp100'; ## https://www.twitter.com/nicolesharp100/
## https://www.mediawiki.org/wiki/WikiSEO

MediaWiki uploads

USEINSTANTCOMMONS

$wgUseInstantCommons = false;
## https://www.mediawiki.org/wiki/InstantCommons
## https://www.mediawiki.org/wiki/UseInstantCommons

UPLOADDIRECTORY

$wgUploadDirectory = "{$IP}/uploads"; ## https://www.mediawiki.org/wiki/UploadDirectory
$wgUploadPath = "{$wgScriptPath}/uploads"; ## https://www.mediawiki.org/wiki/UploadPath
$wgHashedUploadDirectory = false; ## https://www.mediawiki.org/wiki/HashedUploadDirectory
## https://www.mediawiki.org/wiki/uploads

FOREIGNFILEREPOS

$wgForeignFileRepos[] = [
	'class' => ForeignAPIRepo::class,
	'name' => 'commonswiki', # Must be a distinct name.
	'apibase' => 'https://commons.wikimedia.org/w/api.php',
	'hashLevels' => 0,
	'fetchDescription' => true, # Optional.
	'descriptionCacheExpiry' => 43200, # 12 hours, optional (values are in seconds).
	'apiMetadataExpiry' => 14400, # 4 hours, optional.  Consider increasing for better performance.
	'apiThumbCacheExpiry' => 86400, # 24 hours, optional, but required for local thumb caching.
];

$wgForeignFileRepos[] = [
	'class' => ForeignAPIRepo::class,
	'name' => 'enwikipedia',
	'apibase' => 'https://en.wikipedia.org/w/api.php',
	'hashLevels' => 0,
	'fetchDescription' => true,
	'descriptionCacheExpiry' => 43200,
	'apiMetadataExpiry' => 14400,
	'apiThumbCacheExpiry' => 86400,
];

## https://www.mediawiki.org/wiki/ForeignFileRepos

MediaWiki highlighting

Pygments

## wfLoadExtension( 'SyntaxHighlight_GeSHi' ); ## https://www.mediawiki.org/wiki/SyntaxHighlight

HighlightJS

wfLoadExtension( 'Highlightjs_Integration' ); ## https://www.mediawiki.org/wiki/Extension:Highlightjs_Integration
HighlightJS update
  1. Minified JavaScripts and CSS (cascading stylesheets) are only available on the CDN Release.  Only use the stable branch CDN Releases for updating HighlightJS.
  2. Disable HighlightJS and then rename "/w/extensions/Highlightjs_Integration/highlight/" to "/w/extensions/Highlightjs_Integration/highlight-old/".
  3. Rename "cdn-release-11-stable/build" to "cdn-release-11-stable/highlight".
  4. Upload the new "highlight" directory to "/w/extensions/Highlightjs_Integration/".
  5. There should exist subdirectories corresponding to "/w/extensions/Highlightjs_Integration/highlight/styles/" and "/w/extensions/Highlightjs_Integration/highlight-old/styles/".
  6. Re-enable HighlightJS.
HighlightJS configuration
{
    "name": "highlight.js integration",
    "version": "2.2",
    "author": [
        "[https://www.mediawiki.org/wiki/User:NikusPokus Nikus Pokus]",
        "[https://github.com/kuenzign Nathan Kuenzig]",
        "[https://github.com/jakeman95 jakeman95]"
    ],
    "url": "https://www.mediawiki.org/wiki/Extension:Highlightjs_Integration",
    "license-name": "AGPL-3.0",
    "description": "Allows to use the client-side syntax highlighter [https://highlightjs.org highlight.js] in MediaWiki",
    "type": "other",
    "require": {
        "MediaWiki": ">= 1.39"
    },
    "Hooks": {
        "ParserFirstCallInit": [
            "HighlightjsIntegration::onParserFirstCallInit"
        ],
        "BeforePageDisplay": [
            "HighlightjsIntegration::onBeforePageDisplay"
        ]
    },
    "AutoloadClasses": {
        "HighlightjsIntegration": "HighlightjsIntegration.class.php"
    },
    "ResourceModules": {
        "ext.HighlightjsIntegration": {
            "scripts": [
                "highlight/highlight.min.js",
                "init.js",
                "highlight/languages/apache.min.js"
            ],
            "styles": [
                "custom.css",
                "highlight/styles/stackoverflow-light.min.css"
            ],
            "targets": [
                "desktop",
                "mobile"
            ]
        }
    },
    "ResourceFileModulePaths": {
        "localBasePath": ""
    },
    "config": {
        "HighlightTags": [
            "syntaxhighlight",
            "source"
        ],
        "LangMapping": {
            "tsql": "sql",
            "mysql": "sql",
            "vb": "vbscript",
            "vba": "vbscript",
            "xaml": "xml",
            "mediawiki": "markdown",
            "asp": "html"
        }
    },
    "manifest_version": 1
}
HighlightJS languages

The following language codes are the same for both HighlightJS and Pygments.  This allows copying the <syntaxhighlight> element and attributes from HighlightJS-based NikkiWiki to Pygments-based Wikimedia wikis.

apache CONF, HTACCESS
css CSS
html HTM, HTML
ini INI, PHPRC
js JS
json JSON
php PHP
text TXT

MediaWiki caching

MAINCACHETYPE

## https://www.mediawiki.org/wiki/performance
$wgMainCacheType = CACHE_ANYTHING; ## https://www.mediawiki.org/wiki/MainCacheType

CACHEDIRECTORY

$wgCacheDirectory = "$IP/cache"; ## https://www.mediawiki.org/wiki/$wgCacheDirectory

Matomo

Matomo Plugins

  1. "Force SSL [Secure Sockets Layer]" (Matomo)
  2. "Security Info" (Matomo)
  3. "Tracking Spam Protection" (Matomo)
  4. "Provider" (Matomo)
  5. "IP2Location [Internet Protocol 2 Location]" (Matomo)
  6. "IP2Proxy" (Matomo)
  7. "Bandwidth" (Matomo)
  8. "Tasks Timetable" (Matomo)
  9. "Device Detector Cache" (Matomo)

Matomo Geolocation

DBIP

  • DBIP (Database Internet Protocol) Location Database: https://download.db-ip.com/free/dbip-city-lite-2024-06.mmdb.gz
  • DBIP ISP (Internet Service Provider) Database: https://download.db-ip.com/free/dbip-asn-lite-2024-06.mmdb.gz
  • Needs to be updated monthly (not weekly).  DBIP is not as accurate as IP2Location, so use IP2Location instead.

IP2Location

IP2Location download
  • "IP2Location Lite"
  • Use IPv6 DB11 for IP2Location and IPv6 PX11 for IP2Proxy.  The IPv6 database will also include the IPv4 database.
  • IP2Location Database Path: "/home/klppbrtl/nicolesharp.net/matomo/misc/IP2LOCATION-LITE-DB11.IPV6.BIN".
  • IP2Proxy Database Path: "/home/klppbrtl/nicolesharp.net/matomo/misc/IP2PROXY-LITE-PX11.BIN".
  • Local database needs to be manually updated every month.  Otherwise use API (Application Programming Interface) Key.
IP2Location API
  • "IP2Location IO [Input/Output]"
  • Two different online accounts have to be registered for IP2Location Lite versus IP2Location IO.
  • API Key is limited to 30,000 queries per month.

Matomo Tracking

var _paq = window._paq = window._paq || [];
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(["setCookieDomain", "*.nicolesharp.net"]);
_paq.push(["setDomains", ["*.nicolesharp.net"]]);
_paq.push(["setDoNotTrack", true]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://www.nicolesharp.net/matomo/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();

/*
https://www.matomo.org/
Matomo Analytics JavaScript (JS) for Nicole Sharp's Website.
2024-06-07 Nicole Sharp and Matomo
https://www.nicolesharp.net/
https://www.matomo.org/
Unless otherwise noted, content on Nicole Sharp's Website is available under the Creative Commons Attribution-ShareAlike 4.0 International Public License.
https://creativecommons.org/licenses/by-sa/4.0/
*/