Compare commits

...

3 Commits

Author SHA1 Message Date
Collin J. Doering d02d329bbc
TODO.org: Move Archive section to the top and add a new TODO item 2021-12-18 21:12:31 -05:00
Collin J. Doering 6b1129aa1a
TODO.org: Mark completed, but forgotten tasks and create Archive heading 2021-12-18 20:44:29 -05:00
Collin J. Doering 9171aa88ad
Replace broken piwiki analytics with self-hosted plausible
* templates/partials/analytics.html: Upon a client load of the website, determine which site
they are viewing (dev, staging, production) and setup plausible analytics appropriately.

* templates/default.html: Remove non-functional piwiki script reference and replace with a
reference to the new partial template for analytics

* src/site.hs (main): Remove remnant of application cache support

* js/default.js: Remove unneeded analytics code specific to piwiki. No additions were made here in support of plausible

* TODO.org: Mark associated TODO item DONE
2021-12-18 20:37:59 -05:00
5 changed files with 84 additions and 73 deletions

View File

@ -1,32 +1,71 @@
#+TITLE: blog-rekahsoft-ca TODO's
#+AUTHOR: Collin J. Doering
* DONE Remove the use of application cache now that most major browsers are pulling support
* Archive :ARCHIVE:
** DONE Remove the use of application cache now that most major browsers are pulling support
CLOSED: [2021-11-28 Sun 10:43]
:PROPERTIES:
:ARCHIVE_TIME: 2021-12-18 Sat 20:36
:END:
- State "DONE" from "TODO" [2021-11-28 Sun 10:43]
** DONE Fix analytics (pywiki is no longer in use, find and use something else)
CLOSED: [2021-12-18 Sat 20:31]
:PROPERTIES:
:ARCHIVE_TIME: 2021-12-18 Sat 20:36
:END:
- Note taken on [2021-12-18 Sat 20:31] \\
Decided to use [[https://github.com/plausible/analytics][Plausible]], self hosted on my single use AWS ec2.
- State "DONE" from "TODO" [2021-12-18 Sat 20:31]
** DONE Fix rendering of mathjax
CLOSED: [2021-12-18 Sat 20:33]
:PROPERTIES:
:ARCHIVE_TIME: 2021-12-18 Sat 20:36
:END:
- State "DONE" from "TODO" [2021-12-18 Sat 20:33]
** DONE Setup automated deployment from ci
CLOSED: [2021-12-18 Sat 20:33]
:PROPERTIES:
:ARCHIVE_TIME: 2021-12-18 Sat 20:36
:END:
- State "DONE" from "TODO" [2021-12-18 Sat 20:33]
** CANCELED Use separate file for terraform backend
CLOSED: [2021-12-18 Sat 20:33]
:PROPERTIES:
:ARCHIVE_TIME: 2021-12-18 Sat 20:36
:END:
- State "CANCELED" from "TODO" [2021-12-18 Sat 20:33] \\
No need. Embedding the backend into main.tf is file for the time being
Used to be: +Add missing terraform backend files to repository+, however this was not true.
The backend is just embedded in [[./infra/main.tf][infra/main.tf]].
** DONE Build the site as a guix package output of ~blog-rekahsoft-ca~
CLOSED: [2021-12-18 Sat 20:34]
:PROPERTIES:
:ARCHIVE_TIME: 2021-12-18 Sat 20:36
:END:
- State "DONE" from "TODO" [2021-12-18 Sat 20:34]
* TODO [#A] Invalid page urls load as the home page
Eg. https://blog.rekahsoft.ca/this-is-not-a-valid-page.html will show the home page, and
retain this url. However, it should show a page not found page.
* TODO The image full screen features does not work on initial page loads and requires going to at least one other page :bug:
See:
- [[file:js/default.js::// Add fullscreen functionality to inline-images and figures][Fullscreen image onclik functionality is added in the router upon content loading, which doesn't occur on the intial page load]]
* TODO Completely replace all references to stack
* TODO Fix analytics (pywiki is no longer in use, find and use something else)
* DOING Completely replace all references to stack
- State "DOING" from "TODO" [2021-12-18 Sat 20:33]
* TODO Modernize javascript in [[file:js/default.js][js/default.js]]
* TODO Allow posts (and pages?) to be written in org-mode
See:
- https://github.com/jaspervdj/hakyll/issues/700
- https://turbomack.github.io/posts/2016-12-21-org-mode-in-hakyll.html
* TODO Fix rendering of mathjax
* TODO Use javascript/css sources from guix packages instead of vendoring them or using them from the internet
- [ ] jQuery
- [ ] mathjax
- [ ] skeleton
* TODO Setup automated deployment from ci
* TODO Use separate file for terraform backend
Used to be: +Add missing terraform backend files to repository+, however this was not true.
The backend is just embedded in [[./infra/main.tf][infra/main.tf]].
* TODO Figure out fast workflow for modifying haskell sources without rebuilding guix package
*** TODO [[./clay][clay sources]]
*** TODO [[./src][hakell sources]]
@ -34,8 +73,14 @@ The backend is just embedded in [[./infra/main.tf][infra/main.tf]].
See: http://blog.tpleyer.de/posts/2019-04-21-external-code-inclusion-with-hakyll.html
* TODO Ensure [[./blog-rekahsoft-ca.cabal][blog-rekahsoft-ca.cabal]] is usable with cabal and has the correct dependencies
* TODO Build the site as a guix package output of ~blog-rekahsoft-ca~
* TODO Invalid page urls load as the home page
* TODO Add a way to submit commits on articles
Eg. https://blog.rekahsoft.ca/this-is-not-a-valid-page.html will show the home page, and
retain this url. However, it should show a page not found page.
See:
- https://posativ.org/isso/
- https://remark42.com/
- Another option is to use the fediverse as a source of comments:
https://news.ycombinator.com/item?id=25570268
* TODO Proxy analytics traffic through same domain to avoid adblockers
See: https://plausible.io/docs/proxy/introduction

View File

@ -27,9 +27,6 @@
/*global jQuery, MathJax*/
//------------------------
// Global array for processing piwik analytics commands
var _paq = _paq || [];
(function ($, mj) {
"use strict";
@ -196,49 +193,6 @@ var _paq = _paq || [];
return spec;
}()),
analytics = (function () {
var inited = false,
spec = {
trackPageView: trackPageView,
debugEnable: function () {
init();
}
};
function trackPageView (href) {
if (inited) {
_paq.push(["setDocumentTitle", document.domain + href]);
_paq.push(["trackPageView"]);
}
}
function init() {
if (!inited) {
_paq.push(["setDoNotTrack", true]);
_paq.push(["enableLinkTracking"]);
_paq.push(["setTrackerUrl", "//analytics.rekahsoft.ca/piwik.php"]);
_paq.push(["setSiteId", 1]);
inited = true;
}
}
// Initialize piwik.js when site is initially loaded
router.onInit(function () {
if (document.domain != "localhost") {
init();
trackPageView('/');
}
});
// Track page views with piwik each time the url changes
router.onChange(function (url, dta) {
trackPageView(url);
});
return spec
}()),
site = (function () {
var status = (function () {
var messages = [],

View File

@ -151,9 +151,7 @@ main = hakyllWith myConfig $ do
paginateContext paginatedTaggedPosts pageNum <>
constField "tag" tag <>
listField "posts" (taggedPostCtx tags) (return posts)
indexCtx = if pageNum <= 2
then appCacheCtx <> navCtx
else navCtx
indexCtx = navCtx
makeItem ""
>>= loadAndApplyTemplate "templates/tag-page.html" ctx
@ -186,9 +184,7 @@ main = hakyllWith myConfig $ do
let ctx = taggedPostCtx tags <>
paginateContext paginatedPosts pageNum <>
listField "posts" (taggedPostCtx tags) (return posts)
indexCtx = if pageNum <= 2
then appCacheCtx <> navCtx
else navCtx
indexCtx = navCtx
makeItem ""
>>= loadAndApplyTemplate "templates/pages/blog.html" ctx
@ -215,7 +211,7 @@ main = hakyllWith myConfig $ do
listField "posts" (taggedPostCtx tags) (return posts) <>
tagCloudField "tagCloud" 65 135 tags <>
defaultContext
indexCtx = navCtx <> appCacheCtx
indexCtx = navCtx
sectionCtx <- getResourceBody >>= genSectionContext
pg <- loadSnapshot (fromFilePath pageTemplate) "original"
@ -286,9 +282,6 @@ postCtx = dateField "date" "%B %e, %Y" <>
taggedPostCtx :: Tags -> Context String
taggedPostCtx tags = tagsField "tags" tags <> postCtx
appCacheCtx :: Context String
appCacheCtx = constField "appcache" "true"
pageWeight :: (Functor f, MonadMetadata f) => Item a -> f Int
pageWeight i = fmap (maybe 0 read) $ getMetadataField (itemIdentifier i) "weight"

View File

@ -24,9 +24,7 @@
</head>
<body>
<!-- Piwik -->
<script type="text/javascript" async defer src="//analytics.rekahsoft.ca/piwik.js"></script>
<noscript><img src="//analytics.rekahsoft.ca/piwik.php?idsite=1" style="border:0;display:none;" alt="" /></noscript>
$partial("templates/partials/analytics.html")$
$partial("templates/partials/logo-banner.html")$
$partial("templates/partials/nav.html")$

View File

@ -0,0 +1,21 @@
<script>
var ref = document.createElement("script");
ref.setAttribute("type", "text/javascript");
var script = "https://analytics.rekahsoft.ca/js/plausible.js";
switch (window.location.hostname) {
case "www.blog.rekahsoft.ca":
ref.setAttribute("data-domain", "blog.rekahsoft.ca");
break;
case "www.blog.staging.rekahsoft.ca":
ref.setAttribute("data-domain", "blog.staging.rekahsoft.ca");
break;
default:
script = "https://analytics.rekahsoft.ca/js/plausible.exclusions.local.js";
ref.setAttribute("data-domain", "localhost:3000");
ref.setAttribute("data-exclude", "localhost:3000");
}
ref.setAttribute("src", script);
document.getElementsByTagName("head")[0].appendChild(ref)
</script>