-
Notifications
You must be signed in to change notification settings - Fork 75
Add end-to-end example installation script #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RidaAyed
wants to merge
17
commits into
mfg92:master
Choose a base branch
from
RidaAyed:CreateExampleSiteScript
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4b9e906
Add shell script and according readme part
RidaAyed 2f1a91d
adapt curl command, add (expanded) script content
RidaAyed 90d01a1
fix bash command
RidaAyed 2ae496c
fixed typo
RidaAyed 7ac7b22
del duplicated command
RidaAyed 3ed645f
Explain if then statement
RidaAyed b7fcc9e
Comment out and echo the command at the same time
RidaAyed 3fac4dd
One theme's enough
RidaAyed 9251e69
Use mysite as default sitename, don't say hugo where it's obvious
RidaAyed cfa112a
Add path to hugo bin as argument
RidaAyed 305e07e
Minor typo
RidaAyed 3bc7a02
Consider script's working directory
RidaAyed 3f317ed
Explicit's better than implicit; Be quiet about a failed kill
RidaAyed 22e3e31
Close elseif
RidaAyed d449b14
use one line to echo to rm evaluation
RidaAyed f05d0ef
use git submodule add instead of git clone
RidaAyed 54d29e1
Merge branch 'master' into CreateExampleSiteScript
RidaAyed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| #!/bin/sh | ||
| if [ -z "$1" ] | ||
| #If first argument is empty set "/tmp" as working directory | ||
| then | ||
| OUT_DIR=/tmp | ||
| else | ||
| #Else set first argument as working directory | ||
| OUT_DIR=`pwd`"/$1" | ||
| fi | ||
| if [ -z "$2" ] | ||
| #If second argument is empty set "hugo" as sitename | ||
| then | ||
| SITE=mysite | ||
| else | ||
| #Else set second argument as sitename | ||
| SITE=$2 | ||
| fi | ||
| if [ -z "$3" ] | ||
| #If third argument is empty set "hugo" as path | ||
| then | ||
| HUGOPATH=hugo | ||
| else | ||
| #Else set third argument as path | ||
| HUGOPATH=$3 | ||
| fi | ||
|
|
||
| echo "Check if $OUT_DIR does not exist" | ||
| if [ ! -d "$OUT_DIR" ] | ||
| then | ||
| echo "Directory $1 DOES NOT exists. You can create it using: mkdir $1" | ||
| exit 9999 # die with error code 9999 | ||
| fi | ||
|
|
||
| echo "Working directory is $OUT_DIR" | ||
|
|
||
| echo "Sitename is $SITE" | ||
| cd $OUT_DIR | ||
|
|
||
| echo "Kill any running hugo server" | ||
| sudo killall --quiet --signal SIGKILL hugo | ||
|
|
||
| echo "Remove any remnants from previous tests by \ | ||
| uncommenting this line in the script or run it manually:" | ||
| echo `sudo rm --recursive --force --verbose $SITE` | ||
|
|
||
| echo "Generate a new site" | ||
| $HUGOPATH new site $SITE | ||
|
|
||
| echo "Get a lightweight theme" | ||
| cd $OUT_DIR/$SITE | ||
|
RidaAyed marked this conversation as resolved.
|
||
| git init | ||
| git submodule add https://github.com/de-souza/hugo-flex.git themes/hugo-flex | ||
|
|
||
| echo "Add the theme to the site's config" | ||
|
|
||
| echo 'theme = "hugo-flex"' >> config.toml | ||
|
|
||
| echo "Create a first post" | ||
| $HUGOPATH new posts/my-first-post.md | ||
|
|
||
| echo "Show what has been created" | ||
| cat ~$OUT_DIR/$SITE/content/posts/my-first-post.md | ||
|
|
||
| echo "Add the word 'foobar' and some others to the post" | ||
| printf '# foobar\nbar\n- lorem\n- ipsum' >> $OUT_DIR/$SITE/content/posts/my-first-post.md | ||
|
|
||
| echo "Start hugo server and build $SITE" | ||
| nohup $HUGOPATH server --buildDrafts & | ||
|
|
||
| echo "Do a test: \ | ||
| Wait some time for hugo to generate the server, \ | ||
| then get the website and assert it contains the word foo in it's html source \ | ||
| by grepping it in the html source \ | ||
| (you might have to do this manually if $SITE is cluttering your terminal" | ||
| sleep 3s | ||
|
|
||
| echo `curl -s http://localhost:1313/ | grep 'foobar'` | ||
|
|
||
| echo "Kill any running hugo server" | ||
| sudo killall --quiet --signal SIGKILL hugo | ||
|
|
||
| echo "Remove any remnants from previous tests by \ | ||
| uncommenting this line in the script or run it manually:" | ||
| echo `sudo rm --recursive --force --verbose $OUT_DIR/$SITE/themes/hugo-shortcode-gallery` | ||
|
|
||
| echo "Cloning the hugo-shortcode-gallery git repository into $OUT_DIR/$SITE/themes." | ||
| git submodule add https://github.com/mfg92/hugo-shortcode-gallery.git themes/hugo-shortcode-gallery | ||
|
|
||
| echo "Adding this theme to $OUT_DIR/$SITE/config.toml using GNU sed" | ||
|
|
||
| echo `sed --debug -i 's/"hugo-flex"/\["hugo-flex", "hugo-shortcode-gallery"\]/' $OUT_DIR/$SITE/config.toml` | ||
|
|
||
| echo "Adding the gallery to the navigation in $OUT_DIR/$SITE/config.toml" | ||
| printf " | ||
| [[menu.nav]] | ||
| name = '"Gallery"' | ||
| url = '"gallery/"' | ||
| weight = 1 | ||
| " >> $OUT_DIR/$SITE/config.toml | ||
|
|
||
| echo "Create the gallery and images folder" | ||
| mkdir --parents $OUT_DIR/$SITE/content/gallery/images | ||
|
|
||
| echo "Create the index.md in the gallery folder" | ||
| cd $OUT_DIR/$SITE | ||
| $HUGOPATH new /gallery/index.md | ||
|
|
||
| echo "Check content of index.md" | ||
| cat $OUT_DIR/$SITE/content/gallery/index.md | ||
|
|
||
| echo "Download some images into gallery/images" | ||
| cd $OUT_DIR/$SITE/content/gallery/images | ||
| wget --no-verbose https://raw.githubusercontent.com/mfg92/hugo-shortcode-gallery/example_site/example_site/content/gallery/images/2020-06-18-_MG_9066.jpg | ||
| wget --no-verbose https://raw.githubusercontent.com/mfg92/hugo-shortcode-gallery/example_site/example_site/content/gallery/images/2020-07-26-_MG_3439.jpg | ||
|
|
||
| echo "Adding the shortcode to index.md" | ||
| printf 'Here is an example gallery: | ||
|
|
||
| {{< gallery | ||
| match="images/*" | ||
| showExif="true" | ||
| sortOrder="desc" | ||
| loadJQuery="true" | ||
| embedPreview="true" | ||
| >}}' >> $OUT_DIR/$SITE/content/gallery/index.md | ||
|
|
||
| echo "cd into $OUT_DIR/$SITE and build the site" | ||
| cd $OUT_DIR/$SITE | ||
| nohup $HUGOPATH server --buildDrafts & | ||
|
|
||
| echo "Do a test: \ | ||
| Wait some time for hugo to generate the server, \ | ||
| then visit the gallery and assert it contains the string 'jpg', \ | ||
| by grepping it in the html source \ | ||
| (you might have to do this manually if hugo is cluttering your terminal" | ||
| sleep 3s | ||
|
|
||
| echo `curl -s http://localhost:1313/gallery/ | grep 'jpg'` | ||
|
|
||
| echo "Visit http://localhost:1313/gallery/ using your default browser" | ||
| xdg-open http://localhost:1313/gallery/ | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.