Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
VaiTon authored Mar 11, 2023
0 parents commit 8d82ae1
Show file tree
Hide file tree
Showing 14 changed files with 267 additions and 0 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build and Deploy
on:
push:
branches: main
pull_request:
branches: main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

env:
REGEX_INCLUDE: "\\.(pdf|link|txt)$"

jobs:
build:
name: Build pdfs out of tex,md and various doc files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Install tex
run: |
sudo apt update
sudo apt install texlive-latex-extra texlive-lang-italian texlive-lang-english texlive-fonts-recommended texlive-bibtex-extra texlive-science texlive-xetex
- name: Install format conversion tools
run: |
sudo apt install libreoffice
wget https://github.com/jgm/pandoc/releases/download/2.18/pandoc-2.18-linux-amd64.tar.gz -O /tmp/pandoc.tar.gz
tar xfz /tmp/pandoc.tar.gz -C /tmp
sudo mv /tmp/pandoc-*/bin/* /usr/bin
- name: Recursively compile tex files
run: ./.github/workflows/rec "*\.tex$" "xelatex -pdf"

- name: Recursively compile (doc|ppt)x? files
run: ./.github/workflows/rec "*\.(doc|ppt)x?$" "libreoffice --headless --convert-to pdf --outdir ."

- name: Recursively compile md files
run: ./.github/workflows/rec "*\.md$" ${GITHUB_WORKSPACE}/.github/workflows/md2pdf

- name: Generate build artifact
uses: actions/upload-artifact@v2
with:
name: build-result
path: .

statik:
name: Generate the static listing
runs-on: ubuntu-latest
needs: build
steps:
- name: Download compiled files
uses: actions/download-artifact@v2
with:
name: build-result

- name: Install go
uses: actions/setup-go@v3
with:
go-version: ">=1.18.0"

- name: Install statik
run: go install github.com/lucat1/statik@latest

- name: Update packages and install rsync
run: sudo apt install rsync

- name: Generate static directory listing
run: $(go env GOPATH)/bin/statik -page .github/workflows/page.gohtml -l -b "https://${{ github.event.repository.owner.name }}.github.io/${{ github.event.repository.name }}/" -i "$REGEX_INCLUDE" site

- name: Generate site artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v2
with:
name: statik-build
path: ./site

deploy:
name: Deploy to Github Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: statik
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download static site artifact
uses: actions/download-artifact@v2
with:
name: statik-build
path: site
- name: Setup Pages
uses: actions/configure-pages@v1
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@main
63 changes: 63 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Lint file names
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
check:
name: Check file names
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: csunibo/lint-filenames@v1.3.2
name: Lint file names under ./appunti
with:
path: "./appunti"
pattern: '^(\.gitkeep|([a-z0-9]+(-[a-z0-9]+)*\.[a-zA-Z]+))$'
recursive: "true"
- uses: csunibo/lint-filenames@v1.3.2
name: Lint file names under ./dispense
with:
path: "./dispense"
pattern: '^(\.gitkeep|(\d+(-[a-z0-9]+)+\.[a-zA-Z]+))$'
recursive: "true"
- uses: csunibo/lint-filenames@v1.3.2
name: Lint file names under ./esercizi
with:
path: "./esercizi"
pattern: '^(\.gitkeep|([a-z0-9]+(-[a-z0-9]+)*\.[a-zA-Z]+))$'
recursive: "true"
- uses: csunibo/lint-filenames@v1.3.2
name: Lint file names under ./lavagne
with:
path: "./lavagne"
pattern: '^(\.gitkeep|(\d{4}-\d{2}-\d{2}(-[a-z0-9]+)+\.[a-zA-Z]+))$'
recursive: "true"
- uses: csunibo/lint-filenames@v1.3.2
name: Lint file names under ./libri
with:
path: "./libri"
pattern: '^(\.gitkeep|([a-z0-9]+(-[a-z0-9]+)*\.[a-zA-Z]+))$'
recursive: "true"
- uses: csunibo/lint-filenames@v1.3.2
name: Lint file names under ./lucidi
with:
path: "./lucidi"
pattern: '^(\.gitkeep|(\d+(-[a-z0-9]+)+\.[a-zA-Z]+))$'
recursive: "true"
- uses: csunibo/lint-filenames@v1.3.2
name: Lint file names under ./prove
with:
path: "./prove"
pattern: '^(\.gitkeep)|((scritto|totale|parziale\d|orale(\d?)|progetto(\d?))-\d{4}(-\d{2}-\d{2})?(-[a-z0-9]+)?-(testo|soluzione)(-[a-z0-9]+)?\.[a-zA-Z0-9]+)$'
recursive: "true"
- uses: csunibo/lint-filenames@v1.3.2
name: Lint file names under ./varie
with:
path: "./varie"
pattern: '^(\.gitkeep|([a-z0-9]+(-[a-z0-9]+)*\.[a-zA-Z]+))$'
recursive: "true"
3 changes: 3 additions & 0 deletions .github/workflows/md2pdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -ex

pandoc --pdf-engine=xelatex -t pdf $1 -o ${1%.md}.pdf
38 changes: 38 additions & 0 deletions .github/workflows/page.gohtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width">
<meta property="og:title" content="{{ .Root.URL.Path }}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ .Root.URL }}" />
<meta property="og:image" content="/img/unibo512.png" />
<meta property="og:site_name" content="CSUnibo" />
<style>{{ .Stylesheet }}</style>
<title>Index of {{ .Root.URL.Path }}</title>
<!-- icons -->
<link rel=icon href="/img/unibo32.ico" sizes="32x32" type="image/x-icon">
<link rel=icon href="/img/unibo128.ico" sizes="128x128" type="image/x-icon">
<link rel=icon href="/img/unibo180.ico" sizes="180x180" type="image/x-icon">
<link rel=icon href="/img/unibo192.ico" sizes="192x192" type="image/x-icon">
</head>
<body>
<h1>
Index of <a href="https://csunibo.github.io/">csunibo</a>/{{ range $i,$p := .Parts }}<a href="{{ $p.URL }}">{{ $p.Name }}</a>/{{ end }}
</h1>
<hr>
<div class="g">
{{ range $i,$d := .Root.Directories }}
<a href="{{ $d.URL }}" class="d">{{ $d.Name }}</a>
<p>{{ $d.ModTime.Format "02 Jan 06 15:04 MST" }}</p>
<p>{{ $d.Size }}</p>
{{ end }}
{{ range $i,$f := .Root.Files }}
<a href="{{ $f.URL }}">{{ $f.Name }}</a>
<p>{{ $f.ModTime.Format "02 Jan 06 15:04 MST" }}</p>
<p>{{ $f.Size }}</p>
{{ end }}
</div>
<hr>
<p>Generated by <a href="https://github.com/lucat1/statik">statik</a> on {{ .Today.Format "02 Jan 06 15:04 MST" }}</p>
</body>
</html>
11 changes: 11 additions & 0 deletions .github/workflows/rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh -ex

# The chaining of find and grep was deemded necessary due to find's lack of a
# proper regex implementation in find. Also note that on linux find does not
# support -E like on BSDs.
for file in $(find . | grep -E "$1"); do
back=$PWD
cd $(dirname $file)
$2 $(basename $file)
cd $back
done
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# \<Insegnamento\>

Una raccolta di risorse per l'insegnamento di \<Insegnamento\> del Corso di
Laurea in Informatica.

## Presentazione

[Questo sito](https://csunibo.github.io/<insegnamento>) elenca staticamente
i contenuti della raccolta. Qui, documenti e presentazioni con estensione
`.md`, `.tex`, `.doc`, `.docx`, `.ppt` o `.pptx` sono automaticamente
convertiti in formato PDF.

## Contribuire

Si può contribuire al progetto tramite una [_pull request_](https://docs.github.com/en/enterprise-server@3.1/pull-requests).
La seguente tabella elenca gli identificativi validi per le cartelle a livello
radice. Ciascun contenuto deve essere collocato nella cartella che meglio lo
descrive e avere un nome accettato dalla relativa espressione regolare, qualora
essa sia specificata.

| Identificativo | Espressione regolare accettante i nomi dei contenuti | Esempi |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
| `appunti` | `[a-z0-9]+(-[a-z0-9]+)*\.[a-zA-Z]+` | `notion-di-mario-modulo2.link`, `glossario.tex` |
| `dispense` | `\d+(-[a-z0-9]+)+\.[a-zA-Z]+` | `00-introduzione.pdf`, `01-fondamenti-del-calcolo.txt` |
| `esercizi` | `[a-z0-9]+(-[a-z0-9]+)*\.[a-zA-Z]+` | `eserciziario-del-tutor.pdf`, `esercitazione-2022-05-10.tex`, `esercizio-1-12.c` |
| `lavagne` | `\d{4}-\d{2}-\d{2}(-[a-z0-9]+)+\.[a-zA-Z]+` | `2022-02-21-presentazione.pdf`, `2022-02-22-modelli-di-calcolo.png` |
| `libri` | `[a-z0-9]+(-[a-z0-9]+)*\.[a-zA-Z]+` | `fioresi-morigi-introduzione-all-algebra-lineare.pdf` |
| `lucidi` | `\d+(-[a-z0-9]+)+\.[a-zA-Z]+` | `00-introduzione.pptx`, `01-fondamenti-del-calcolo.pdf` |
| `prove` | `(scritto\|totale\|parziale\d\|orale(\d?)\|progetto(\d?))-\d{4}(-\d{2}-\d{2})?(-[a-z0-9]+)?-(testo\|soluzione)(-[a-z0-9]+)?\.[a-zA-Z0-9]+` | `parziale2-testo-2022-05-24-b.pdf`, `totale-soluzione-2022-05-31-incompleto.pdf`, `orale-testo-2022-06-08.md` |
| `varie` | `[a-z0-9]+(-[a-z0-9]+)*\.[a-zA-Z]+` | `calcolatore-in-rete.link`, `utile-contenitore-docker.link`, `veloce-script.sh` |

Non sono ammessi:

1. collegamenti pubblicitari o che puntano a risorse esterne non gratuite;
1. programmi in formato binario;
1. contenuti duplicati;
1. risorse non rilevanti per l'insegnamento in questione.
Empty file added appunti/.gitkeep
Empty file.
Empty file added dispense/.gitkeep
Empty file.
Empty file added esercizi/.gitkeep
Empty file.
Empty file added lavagne/.gitkeep
Empty file.
Empty file added libri/.gitkeep
Empty file.
Empty file added lucidi/.gitkeep
Empty file.
Empty file added prove/.gitkeep
Empty file.
Empty file added varie/.gitkeep
Empty file.

0 comments on commit 8d82ae1

Please sign in to comment.