Merge pull request #1 from johnbintz/updates

Get Hugo 0.69.0 working, other updates
This commit is contained in:
John Bintz 2020-04-10 10:11:10 -04:00 committed by GitHub
commit d80ef5df18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 3384 additions and 2383 deletions

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
10

View File

@ -16,7 +16,7 @@ end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Base on the Sandstorm snapshots of the official Debian 8 (jessie) box.
config.vm.box = "debian/contrib-stretch64"
config.vm.box_version = "9.3.0"
config.vm.box_version = ">= 0"
if Vagrant.has_plugin?("vagrant-vbguest") then
# vagrant-vbguest is a Vagrant plugin that upgrades

View File

@ -21,5 +21,5 @@ fi
cd /opt/app
cp post-receive /var/git/.git/hooks
caddy &
NODE_ENV=production HOME=/tmp npm start
npm start

File diff suppressed because it is too large Load Diff

View File

@ -17,11 +17,11 @@ const pkgdef :Spk.PackageDefinition = (
# This manifest is included in your app package to tell Sandstorm
# about your app.
appTitle = (defaultText = "Hugo"),
appTitle = (defaultText = "Hugo (new)"),
appVersion = 3, # Increment this for every release.
appVersion = 4, # Increment this for every release.
appMarketingVersion = (defaultText = "0.20.7-sandstorm3"),
appMarketingVersion = (defaultText = "0.69.0-sandstorm"),
# Human-readable representation of appVersion. Should match the way you
# identify versions of your app in documentation and marketing.
@ -242,6 +242,8 @@ const myCommand :Spk.Manifest.Command = (
# Note that this defines the *entire* environment seen by your app.
(key = "PATH", value = "/usr/local/bin:/usr/bin:/bin"),
(key = "SANDSTORM", value = "1"),
(key = "HOME", value = "/var"),
(key = "NODE_ENV", value = "production"),
# Export SANDSTORM=1 into the environment, so that apps running within Sandstorm
# can detect if $SANDSTORM="1" at runtime, switching UI and/or backend to use
# the app's Sandstorm-specific integration code.

View File

@ -5,6 +5,9 @@
set -euo pipefail
export HUGO_VERSION=0.69.0
export NODE_VERSION=10
apt-get update
apt-get install -y git
@ -14,9 +17,9 @@ apt-get install -y git
if [ ! -e /usr/local/bin/capnp ] ; then
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -q clang autoconf pkg-config libtool
cd /tmp
if [ ! -e capnproto ]; then git clone https://github.com/sandstorm-io/capnproto; fi
if [ ! -e capnproto ]; then git clone https://github.com/capnproto/capnproto; fi
cd capnproto
git checkout f73ac9f6667d7b87c395d23f3753dde63937cf00
git checkout master
cd c++
autoreconf -i
./configure
@ -33,7 +36,7 @@ fi
cp /opt/app/sandstorm-integration/bin/getPublicId /usr/local/bin
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | sudo -E bash -
apt-get install -y nodejs
npm install -g yarn
@ -41,16 +44,6 @@ apt-get install -y python-pip asciidoctor
pip install pygments
cd /tmp
wget https://github.com/gohugoio/hugo/releases/download/v0.49.2/hugo_0.49.2_Linux-64bit.deb -O hugo.deb
wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.deb -O hugo.deb
dpkg -i hugo.deb
rm hugo.deb
# cd /tmp
# wget https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz -O go.tar.gz
# tar xfz go.tar.gz
# mv go /usr/local
# rm go.tar.gz
wget "https://caddyserver.com/download/build?os=linux&arch=amd64&features=filemanager%2Chugo" -O /tmp/caddy.tar.gz
cd /tmp
tar xfz caddy.tar.gz
mv caddy /usr/local/bin
rm caddy.tar.gz

View File

@ -1,3 +1,27 @@
# V0 (2016-10-10)
## V0 (2016-10-10)
* Initial release.
* Initial release.
## 0.69.0 (2020-04-10)
The "I can't stand Hugo 0.20.something anymore" release.
### Enhancements
* Upgrade Hugo to 0.69.0
* Remove Caddy & admin interface for now
* This never quite worked right for me and direct support for
Hugo management was [dropped during Caddy 2 development](https://caddy.community/t/new-old-plugin-http-filebrowser/5103).
Bringing back Caddy would require a bit more work than I'm able to put into
it for this release.
* Update NodeJS to 10 and `yarn upgrade` all transitive dependencies
### Workarounds
* For some reason the `getPublicId` script causes some part of Cap'n Proto to
crash the grain when executed, specifically as the script is exiting.
I've tried everything I know to have it not do that, but ended up with a
terrible workaround: capture the stdout of the script to a file as it
executes and memoize the output based on the session ID parameter.
For my single-person Sandstorm server, this seems fine. I would love help
figuring this out.

View File

@ -1,7 +0,0 @@
127.0.0.1:8001
errors stderr
log stdout
hugo /var/git {
allow_commands false
after_save "/opt/app/commit-on-save {path}"
}

View File

@ -1,34 +1,36 @@
Hugo Sandstorm package
===========================
# Hugo Sandstorm package
This is the [Sandstorm](https://sandstorm.io) package of [Hugo](https://gohugo.io/).
The version of Hugo in this build is 0.69.0.
![Hugo screenshot](.sandstorm/app-graphics/screenshot2.png "Hugo administration view in Sandstorm")
## Development
# How to
The package is done with [vagrant-spk](https://github.com/sandstorm-io/vagrant-spk), a tool designed to help app developers package apps for [Sandstorm](https://sandstorm.io).
The package is built with [vagrant-spk](https://github.com/sandstorm-io/vagrant-spk),
a tool designed to help app developers package apps for [Sandstorm](https://sandstorm.io).
You can follow the below mentioned steps to make your own package or to contribute.
## Prerequisites
### Prerequisites
You will need to install:
- [Vagrant](https://www.vagrantup.com/)
- [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
- Git
* [Vagrant](https://www.vagrantup.com/)
* [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
* Git
## Step by Step
```
git clone https://github.com/sandstorm-io/vagrant-spk
git clone https://github.com/ndarilek/hugo-sandstorm
git clone https://github.com/johnbintz/hugo-sandstorm
export PATH=$(pwd)/vagrant-spk:$PATH
cd hugo-sandstorm
vagrant-spk vm up
vagrant-spk dev
```
visit [http://local.sandstorm.io:6080/](http://local.sandstorm.io:6080/) in a web browser
Visit [http://local.sandstorm.io:6080/](http://local.sandstorm.io:6080/) in a web browser.
Note: when you want to fork this repo and create actual app packages for the app store you would need either the original app key or create a new one and make your own version of the app.
Note: when you want to fork this repo and create actual app packages for the app
store you would need either the original app key or
[create a new one and make your own version of the app](https://docs.sandstorm.io/en/latest/developing/publishing-apps/).

View File

@ -1,5 +0,0 @@
#!/bin/sh
cd /var/git
git add $1
git commit $1 -m "Saved $1 via administrative interface."
/var/git/.git/hooks/post-receive

View File

@ -1,3 +1,3 @@
Introducing [Hugo](https://gohugo.io), a new idea for making website creation simple again. Hugo works flexibly with many formats, and is ideal for blogs, docs, portfolios and much more. Hugos speed fosters creativity—it makes building a website fun again.
Enjoy powerful syntax highlighting for a large variety of programming languages with integrated Pygments support. Publish books, manuals, and other complex Asciidoc material with the included Asciidoctor distribution. Updates and themes can be pushed directly to an embedded Git repository, or can be edited via a web-based administrative interface.
Enjoy powerful syntax highlighting for a large variety of programming languages with integrated Pygments support. Publish books, manuals, and other complex Asciidoc material with the included Asciidoctor distribution. Updates and themes are pushed directly to an embedded Git repository.

View File

@ -1,28 +1,41 @@
<template>
<div>
<p>Your public site is available at <a :href="url" target="_blank">{{ url }}</a>.</p>
<div v-if="!isDemo">
<p>To set up your domain to point at your public site, add the following DNS records to your domain. Replace <code>blog.example.com</code> with your site's hostname.</p>
<table>
<thead>
<th>Name</th>
<th>Type</th>
<th>Value</th>
</thead>
<tbody>
<tr>
<td>blog.example.com</td>
<td>CNAME</td>
<td>{{ domain }}</td>
</tr>
<tr>
<td>sandstorm-www.blog.example.com</td>
<td>TXT</td>
<td>{{ publicId }}</td>
</tr>
</tbody>
</table>
</div>
<template v-if="isLoading">
<p>
Loading public site information...
</p>
</template>
<template v-else-if="loadError">
<p>
Unable to load public site information! Try restarting the grain.
This is a known bug.
</p>
</template>
<template v-else>
<p>Your public site is available at <a :href="url" rel="noopener" target="_blank">{{ url }}</a>.</p>
<div v-if="!isDemo">
<p>To set up your domain to point at your public site, add the following DNS records to your domain. Replace <code>blog.example.com</code> with your site's hostname.</p>
<table>
<thead>
<th>Name</th>
<th>Type</th>
<th>Value</th>
</thead>
<tbody>
<tr>
<td>blog.example.com</td>
<td>CNAME</td>
<td>{{ domain }}</td>
</tr>
<tr>
<td>sandstorm-www.blog.example.com</td>
<td>TXT</td>
<td>{{ publicId }}</td>
</tr>
</tbody>
</table>
</div>
</template>
<h2>Editing Your Site</h2>
<p>To check out the Git repository containing your site, first add an authorization key to Git:</p>
<render-template
@ -45,7 +58,11 @@
rpcId="gitPush"
:template="'git remote add origin ' + this.gitUrl + '\ngit push -fu origin master'"/>
<h2>Admin Interface</h2>
<p>Simple site changes can be made directly in the included <a href="/admin/">administrative interface</a>.</p>
<p>
...had to be removed temporarily because Caddy 1 isn't recommended anymore and
<a target="_blank" rel="noopener" href="https://caddy.community/t/new-old-plugin-http-filebrowser/5103">Caddy 2 needs some work to get working well with Hugo</a>.
<a target="_blank" rel="noopener" href="https://github.com/johnbintz/hugo-sandstorm">Want to help?</a>
</p>
</div>
</template>
@ -58,7 +75,9 @@
isDemo: true,
url: "",
domain: "",
publicId: ""
publicId: "",
isLoading: true,
loadError: null
}),
computed: {
gitHost: () => {
@ -74,17 +93,25 @@
return ""
}
},
mounted() {
fetch("/publicId", {
credentials: "same-origin"
}).then((r) => r.json())
.then((r) => {
this.isDemo = r.isDemo
this.url = r.url
this.publicId = r.publicId
this.domain = r.domain
})
.catch(console.error)
// mounted actions occur immediately. we use async here to
// simplify promise handling.
async mounted () {
this.isLoading = true
try {
const result = await fetch("/publicId", {
credentials: "same-origin"
})
const jsonResult = await result.json()
this.isDemo = jsonResult.isDemo
this.url = jsonResult.url
this.publicId = jsonResult.publicId
this.domain = jsonResult.domain
} catch (e) {
console.error(e)
this.loadError = e
} finally {
this.isLoading = false
}
},
head: {
title: "Home"

View File

@ -48,7 +48,10 @@ namespace sandstorm {
request.setId(sessionId);
auto session = request.send().getContext().castAs<HackSessionContext>();
kj::Promise<void> promise = session.getPublicIdRequest().send().then([](auto result) {
kj::Promise<void> promise = session
.getPublicIdRequest()
.send()
.then([](capnp::Response<sandstorm::HackSessionContext::GetPublicIdResults>&& result) {
auto publicId = result.getPublicId();
auto hostname = result.getHostname();
auto autoUrl = result.getAutoUrl();
@ -73,3 +76,4 @@ namespace sandstorm {
} // namespace sandstorm
KJ_MAIN(sandstorm::GetPublicIdMain)

View File

@ -1,9 +1,11 @@
import Nuxt from "nuxt"
import logger from "morgan"
const exec = require("child_process").exec
import fs from 'fs'
import Express from "express"
import gitBackend from "git-http-backend"
import httpProxy from "http-proxy"
// TODO: once Caddy 2 or something similar is in place, reinstate the
// admin proxy.
//import httpProxy from "http-proxy"
const spawn = require("child_process").spawn
const app = new Express()
@ -17,17 +19,52 @@ app.set("port", port)
app.get("/publicId", (req, res) => {
const sessionId = req.headers["x-sandstorm-session-id"]
exec(`getPublicId ${sessionId}`, (err, rv) => {
if(err)
return res.end(err)
const lines = rv.split("\n")
let allData = ""
// TODO: figure out why Cap'n Proto keeps crashing when
// getPublicId exits so we can get rid of this weird
// memoization hack I had to do!
const file = `/var/publicid-${sessionId}`
const handleResult = () => {
const lines = allData.split("\n")
const publicId = lines[0]
const hostname = lines[1]
const domain = publicId+"."+hostname
const url = lines[2]
const isDemo = lines[3] == "true"
res.json({publicId, hostname, domain, url, isDemo})
})
}
try {
allData = fs.readFileSync(file, 'utf8').toString()
} catch (e) {
// nothing
}
const lines = allData.split("\n")
if (lines.length >= 4) {
handleResult()
} else {
const gpId = spawn('getPublicId', [sessionId])
allData = ""
gpId.stdout.on('data', (data) => {
fs.appendFileSync(file, data)
allData += data
})
gpId.on('error', (err) => {
return res.send(err)
})
gpId.on('close', (code) => {
if (code !== 0) {
return res.send(code)
}
handleResult()
})
}
})
app.use("/git", (req, res) => {
@ -41,12 +78,12 @@ app.use("/git", (req, res) => {
})).pipe(res)
})
const proxy = httpProxy.createProxyServer({
target: "http://127.0.0.1:8001/admin/",
changeOrigin: true
})
//const proxy = httpProxy.createProxyServer({
// target: "http://127.0.0.1:8001/admin/",
// changeOrigin: true
//})
app.use("/admin/", (req, res) => proxy.web(req, res))
// app.use("/admin/", (req, res) => proxy.web(req, res))
// Import and Set Nuxt.js options
let config = require("./nuxt.config.js")

4100
yarn.lock

File diff suppressed because it is too large Load Diff