Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
README.org 10.67 KiB

Course homepage for TATA54, elementary number theory

Convert from org-mode, deploy to gitlab

This repo is supposed to use a gitlab CI script to run emacs in batch on incoming org-mode files, converting them to html files, placed in the top-level public directory. At the moment, I run the emacs script locally.

Homepage url

The pages are available at https://jansn19.gitlab-pages.liu.se/tata54-kurshemsida/

The yaml file for Gitlab CI

Third attempt

No automatic CI pipeline build of html,

image: busybox

pages:
  stage: deploy
  script:
  - echo 'Nothing to do...'
  artifacts:
    paths:
    - public
    expire_in: 1 day
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

Third attempt stopped working <2024-06-01 Sat>

Fourth attempt

image: alpine:latest

pages:
  stage: deploy
  script:
  - echo 'Inget att utföra...'
  artifacts:
    paths:
    - public
    expire_in: 1 day
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

Did not work either, back to previous

publish.el script

;; publish.el --- Publish org-mode project on Gitlab Pages
;; Author: Rasmus, modified by Jan Snellman

(add-to-list 'load-path "/usr/share/emacs/site-lisp")

(defun get-latest-org ()
  "Download the latest Org if the shipped version is too old."
  (let* ((default-directory "/tmp/")
         (org-dir "/tmp/org-mode/")
         (dev-url "https://code.orgmode.org/bzg/org-mode/archive/master.tar.gz")
         (htmlize-url "https://raw.githubusercontent.com/hniksic/emacs-htmlize/master/htmlize.el")
         (devp (zerop (shell-command (concat "wget -q --spider " dev-url)))))
    (unless (file-directory-p org-dir)
      (url-copy-file
       (if devp dev-url "https://orgmode.org/org-latest.tar.gz")
       "org.tar.gz" t)
      (shell-command "tar xfz org.tar.gz;"))
    (unless (file-exists-p (concat org-dir "lisp/org-loaddefs.el"))
      (shell-command (concat (concat "cd " org-dir ";")
                             "make autoloads")))
    (unless (featurep 'htmlize)
      (url-copy-file htmlize-url (concat org-dir "lisp/htmlize.el") t))
    (add-to-list 'load-path (concat org-dir "lisp/"))
    (add-to-list 'load-path (concat org-dir "contrib/lisp/"))))

;; If you need the latest version of Org run this command
;; (get-latest-org)

;; You can also install Org via package.el.

;; (setq package-selected-packages '(org))
;; (package-initialize)
;; (package-install-selected-packages)

(require 'org)
(require 'ox-publish)

;; Disable time-stamps
;; (setq org-publish-use-timestamps-flag nil)

(setq user-full-name "Jan Snellman")
(setq user-mail-address "jan.snellman@liu.se")

(setq org-export-with-section-numbers nil
      org-export-with-smart-quotes t
      org-export-with-toc nil)

(setq org-html-divs '((preamble "header" "top")
                      (content "main" "content")
                      (postamble "footer" "postamble"))
      org-html-container-element "section"
      org-html-metadata-timestamp-format "%Y-%m-%d"
      org-html-checkbox-type 'html
      org-html-html5-fancy t
      org-html-doctype "html5")

(defvar site-attachments (regexp-opt '("jpg" "jpeg" "gif" "png" "svg"
                                       "ico" "cur" "css" "js" "woff" "html" "pdf")))

(defvar site-images (regexp-opt '("jpg" "jpeg" "gif" "png" "svg"
                                  "ico" )))


(setq org-publish-project-alist
      '(("tata54-org"
         :base-directory "./homepage"
         :base-extension "org"
         :recursive t
         :publishing-function org-html-publish-to-html
         :publishing-directory "./public"
         :exclude "public/"
         :auto-sitemap t
         :sitemap-filename "sitemap.org"
         :sitemap-title "Kurshemsida"
         :sitemap-file-entry-format "%d *%t*"
         :html-head-extra "<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\"/>"
         :auto-preamble nil
         :html-preamble "<div id=\"navbar\" style =\"text-align: center;\">
              <a href='https://liu.se'>LiU</a> -
              <a href='https://liu.se/organisation/liu/mai'>MAI</a> -
              <a href='https://liu.se/organisation/liu/mai'>Grundutbildning</a> -
              <a href='https://courses.mai.liu.se/Lists/html/'>Kurser</a> -
              <a href='index.html'>TATA54</a></div>"
         :sitemap-style list
         :sitemap-sort-files anti-chronologically)

        ;; ("tata54-static"
        ;;  :base-directory "./homepage"
        ;;  :exclude "public/"
        ;;  :base-extension site-attachments
        ;;  :publishing-directory "./public"
        ;;  :publishing-function org-publish-attachment
        ;;  :recursive t)

        ("tata54-literature"
         :base-directory "./homepage/literature"
         :exclude "public/"
         :base-extension "pdf"
         :publishing-directory "./public/literature"
         :publishing-function org-publish-attachment
         :recursive t)

        ("tata54-exams"
         :base-directory "./homepage/exams"
         :exclude "public/"
         :base-extension "pdf"
         :publishing-directory "./public/exams"
         :publishing-function org-publish-attachment
         :recursive t)

        ("tata54-lectures"
         :base-directory "./homepage/lectures"
         :exclude "public/"
         :base-extension "pdf"
         :publishing-directory "./public/lectures"
         :publishing-function org-publish-attachment
         :recursive t)

        ("tata54-labs"
         :base-directory "./homepage/labs"
         :exclude "public/"
         :base-extension "html\\|ipynb"
         :publishing-directory "./public/labs"
         :publishing-function org-publish-attachment
         :recursive t)

        ("tata54-images"
         :base-directory "./homepage/img"
         :exclude "public/"
         :base-extension  "png\\|svg\\|jpg\\|jpeg"
         :publishing-directory "./public/img"
         :publishing-function org-publish-attachment
         :recursive t)


        ("tata54" :components ("tata54-org"
                               "tata54-literature"
                               "tata54-exams"
                               "tata54-lectures"
                               "tata54-labs"
                               "tata54-images"))))

build.sh

#!/bin/sh
emacs --batch --no-init-file --load publish.el --funcall org-publish-all

Styling

At the moment we use a modified version of org-html-themes by Fabrice Niessen to provide the css and styling. There is an update_theme.sh which can be run after the org file describing the theme has been modified.