Quick Install

Hanya satu perintah yang anda butuhkan untuk membuat website baru.

After Dark termasuk skrip instalasi portabel untuk pengaturan cepat:

themes/after-dark/bin/install
Perluas untuk melihat skrip
  1#!/bin/sh
  2
  3#
  4# Copyright (C) 2019  Josh Habdas <jhabdas@protonmail.com>
  5#
  6# This file is part of After Dark.
  7#
  8# After Dark is free software: you can redistribute it and/or modify
  9# it under the terms of the GNU Affero General Public License as published
 10# by the Free Software Foundation, either version 3 of the License, or
 11# (at your option) any later version.
 12#
 13# After Dark is distributed in the hope that it will be useful,
 14# but WITHOUT ANY WARRANTY; without even the implied warranty of
 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16# GNU Affero General Public License for more details.
 17#
 18# You should have received a copy of the GNU Affero General Public License
 19# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 20#
 21
 22validate_hugo () {
 23   # Exit with error if hugo is not installed
 24   if ! hash hugo 2>/dev/null ; then
 25     echo "Error: After Dark requires Hugo version 0.44 or greater" >&2; exit 1
 26   fi
 27
 28   # Exit with error if not minimum required hugo version
 29   re="v(0\d*\.([4-9][4-9]|[5-9])|[1-9]).*"
 30   if ! hugo version | grep -qE "$re" ; then
 31      echo "Error: After Dark requires Hugo version 0.44 or greater" >&2; exit 1
 32   fi
 33}
 34
 35create_site_dir () {
 36   SITE_DIR="flying-toasters"
 37   if [ "$1" != "" ] ; then
 38      SITE_DIR="$1"
 39   fi
 40
 41   SITE_DIR_ABS="$PWD/$SITE_DIR"
 42   mkdir -p "$SITE_DIR"
 43}
 44
 45create_site () {
 46   echo "Creating a new Hugo site ..."
 47   hugo new site "$SITE_DIR" 1>/dev/null
 48   cd "$SITE_DIR" || exit 1
 49}
 50
 51download_theme () {
 52   echo "Downloading the latest version of After Dark ..."
 53   LATEST_META=$(wget -qO - https://registry.npmjs.org/after-dark/latest)
 54   vers=$(echo "$LATEST_META" | egrep -o "\"version\".*[^,]*," | cut -d ',' -f1 | cut -d ':' -f2 | tr -d '" ')
 55   mkdir -p themes/after-dark
 56   wget -qO - https://registry.npmjs.org/after-dark/-/after-dark-"$vers".tgz | tar --strip-components=1 -xz -C themes/after-dark
 57   echo "Version $vers downloaded to $SITE_DIR/themes/after-dark"
 58}
 59
 60download_module () {
 61   [ -z "$1" ] && { echo "Error: Attempt to download undefined module" >&2; exit 1; }
 62   echo "Downloading $1 module for After Dark ..."
 63   meta=$(wget -qO - https://registry.npmjs.org/"$1"/latest)
 64   vers=$(echo "$meta" | egrep -o "\"version\".*[^,]*," | cut -d ',' -f1 | cut -d ':' -f2 | tr -d '" ')
 65   mkdir -p themes/"$1"
 66   wget -qO - https://registry.npmjs.org/"$1"/-/"$1"-"$vers".tgz | tar --strip-components=1 -xz -C themes/"$1"
 67   echo "Version $vers downloaded to $SITE_DIR/themes/$1"
 68}
 69
 70configure_theme () {
 71   echo "Configuring basic After Dark theme settings ..."
 72   tee "config.toml" > /dev/null <<TOML
 73baseurl = "https://domain.example" # Controls base URL sitewide
 74languageCode = "en-US" # Controls site language
 75title = "After Dark" # Homepage title and page title suffix
 76paginate = 11 # Number of posts to show before paginating
 77copyright = "Copyright &copy; Copyright Owner. Licensed under <a target=\"_blank\" rel=\"external noopener license\" href=\"https://creativecommons.org/licenses/by-nd/4.0/\">CC-BY-ND-4.0</a>." # Optional, remove to suppress copyright notices
 78
 79# Controls default theme and theme components
 80theme = [
 81  "fractal-forest", # OBSD
 82  "after-dark" # AGPL-3.0-or-later
 83]
 84
 85disableLiveReload = false # Optional, set true to disable live reload
 86enableRobotsTXT = true # Suggested, enable robots.txt file
 87
 88pygmentsCodefences = true # Suggested, highlight fenced code blocks
 89pygmentsUseClasses = true # Required for custom syntax highlighting
 90
 91sectionPagesMenu = "main" # Enable menu system for lazy bloggers
 92footnoteReturnLinkContents = "↩" # Provides a nicer footnote return link
 93
 94[params]
 95  description = "" # Suggested, controls default description meta
 96  author = "" # Optional, controls author name display on posts
 97  hide_author = false # Optional, set true to hide author name on posts
 98  disable_csp = false # Optional, set true to disable content security policy
 99  images = [
100    "https://source.unsplash.com/collection/983219/2000x1322"
101  ] # Suggested, controls default Open Graph images
102
103[params.layout.menu.main]
104  hidden = true # Optional, set false or remove to show section menu
105
106[params.layout.footer]
107  hidden = false # Optional, set true to hide footer
108
109[params.modules.fractal_forest]
110  enabled = true # Optional, set false to disable module
111  decoders = ["bpgdec8a"] # Optional, 8-bit javascript decoder with animation
112TOML
113}
114
115update_archetypes () {
116   echo "Updating the default content archetype ..."
117   rm -f archetypes/default.md
118   cp themes/after-dark/archetypes/default.md archetypes
119}
120
121create_welcome_post () {
122   echo "Creating welcome post ..."
123   hugo new post/welcome.md 1>/dev/null
124}
125
126serve_site () {
127   echo "Starting site server ..."
128   hugo serve --buildDrafts --navigateToChanged --port 1313 1>/dev/null &
129}
130
131generate_help_docs () {
132   echo "Generating help documentation ..."
133   THEME_PATH=themes/after-dark
134   meta_path="$THEME_PATH"/data/npm
135   mkdir -p "$meta_path" && echo "$LATEST_META" | tr '\r\n' ' ' > "$meta_path"/latest.json
136   cd "$THEME_PATH"/docs && mkdir themes && ln -s ../.. "$THEME_PATH"
137   hugo new validate.md --kind validate 1>/dev/null
138}
139
140serve_help () {
141   echo "Starting help server ..."
142   hugo serve --disableLiveReload --port 1414 1>/dev/null &
143}
144
145set -e
146
147echo "Welcome to the After Dark quick installer. Press CTRL-C at any time to abort."
148
149validate_hugo
150create_site_dir "$1"
151create_site
152download_theme
153update_archetypes
154download_module "fractal-forest"
155configure_theme
156create_welcome_post
157serve_site
158generate_help_docs
159serve_help
160
161YELLOW='\033[0;33m'
162NC='\033[0m'
163
164printf "${YELLOW}Installation successful!${NC}\n"
165echo "Site created in $SITE_DIR_ABS"
166echo "Site server started at http://localhost:1313/"
167echo "To stop it run \"kill \$(ps aux | awk '/[h]ugo.*1313/ {print \$2}')\"."
168echo "Help server started at http://localhost:1414/"
169echo "To stop and restart it run \"./themes/after-dark/bin/help\"."
170echo "Thank you for choosing After Dark."

Silahkan instal Hugo 0.44 atau yang lebih besar sebelum menjalankan skrip.

Skrip telah diuji pada Debian, BusyBox dan Darwin, dan seharusnya juga dapat bekerja di bawah Alpine, Ubuntu, Docker dan Windows melalui Cmder tanpa ketergantungan tambahan.

Warning: selalu periksa skrip yang diunduh dari internet sebelum menjalankannya secara lokal. Jika anda memilih untuk tidak menjalankan skrip Unduh secara manual.

Jalankan skrip sesuka anda. Berikut adalah metode yang memungkinkan:

  1. Unduh dan kirim ke sh secara langsung:

    wget -qO - https://go.habd.as/after-dark | sh

    (Cojones not included.)

  2. Unduh di file baru, chmod dan jalankan:

    curl -O https://cdn.jsdelivr.net/npm/after-dark@latest/bin/install && \
    chmod +x install && ./install

    (It’s safe if it comes from a CDN, amirite?)

  3. Dari kanonik git klon:

    # sumber klon dan ubah ke direktori sumber git klon https://git.habd.as/comfusion/after-dark.git && cd "$_"
    
    # gunakan npm cli untuk mendapatkan hash rilis
    echo "${$(npm run integrity)#*sha512-}"
    
    # jalankan instal cepat setelah memvalidasi
    ./bin/install

    (Release Hashes may be used for code validation.)

Skrip harus selesai dalam 5-10 detik sehingga menghasilkan sampel situs dan dokumen bantuan:

After Dark screenshots
After Dark Quick Install running to completion in Terminal on macOS Mojave.

Konfigurasi multi situs

After Dark memungkingkan menjalankan manajemen multi situs dari satu instalasi. Untuk mengelola beberapa website gunakan -c dan -d bendera untuk menentukan konten dan tujuan direktori secara berurutan.

Misalnya, untuk mengahasilkan situs audio menggunakan instalasi After Dark saat ini, buat skrip yang dapat dieksekusi untuk menghasilkan situs tersebut:

flying-toasters/bin/gen-audio-site
#!/bin/sh
hugo -c sites/audio -d public/static.domain.example

Dimana audio berisi konten untuk situs itu:

├── layouts
├── sites
│   └── audio
│       ├── audiobooks
│       │   ├── gaining-currency.md
│       │   └── the-power-of-now.md
│       └── clips
│           └── war-of-the-worlds.md
├── static

Dan public berisi folder untuk setiap situs:

public
└── static.domain.example
    ├── categories
    │   └── index.xml
    ├── audiobooks
    │   └── index.html
    ├── clips
    │   └── index.html
    ├── css
    ├── index.html
    ├── index.xml
    ├── js
    ├── sitemap.xml
    └── tags
        └── index.xml

Dan buat skrip lain untuk menyajikan konten untuk diedit:

flying-toasters/bin/serve-audio-site
#!/bin/sh
hugo -c sites/audio

Setiap subdirektori public kemudian menjadi website yang independen dan dapat disebarkan serta salinan persisnya disimpan untuk konten tujuan yang dihasilkan.

Tip: Untuk jenis fleksibiltas tambahan hugo --help dan modifikasi skrip anda menggunakan --theme dan --config flags.

Multi situs sangat cocok untuk mempertahankan tampilan dan rasa yang konsisten di berbagai domain asal sekaligus membatasi kebutuhan untuk menjalankannya Upgrade Script untuk setiap situs.