2017-03-19 17:04:38 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2020-04-10 12:06:19 +00:00
|
|
|
<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>
|
2020-04-10 13:43:03 +00:00
|
|
|
<p>Your public site is available at <a :href="url" rel="noopener" target="_blank">{{ url }}</a>.</p>
|
2020-04-10 12:06:19 +00:00
|
|
|
<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>
|
2017-03-19 17:04:38 +00:00
|
|
|
<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
|
|
|
|
rpcId="gitAuthorize"
|
|
|
|
:template="'echo url=' + this.gitHost + ' | git -c credential.helper=store credential approve'"/>
|
|
|
|
<p>Then run the following to clone the site:</p>
|
|
|
|
<render-template
|
|
|
|
rpcId="gitClone"
|
|
|
|
:template="'git clone -c credential.helper=store ' + this.gitUrl + ' site'"/>
|
|
|
|
<p>Here are a few pointers to help you get started:</p>
|
|
|
|
<ul>
|
2020-04-21 11:23:40 +00:00
|
|
|
<li>Choose a theme to make your site look nice. Hugo's <a target="_blank" rel="noopener" href="https://themes.gohugo.io">theme showcase</a> is a good place to start.</li>
|
2017-03-19 17:04:38 +00:00
|
|
|
<li>Add the theme to your Git repository as a subtree at <code>themes/themename</code>.</li>
|
2020-04-21 11:23:40 +00:00
|
|
|
<li>Add <code>theme = "themename"</code> to <code>config.toml</code>.</li>
|
2017-03-19 17:04:38 +00:00
|
|
|
<li>Push the repository, and your new site will be immediately published.</li>
|
|
|
|
</ul>
|
|
|
|
<h2>Pushing Existing Site</h2>
|
|
|
|
<p>If you have an existing Hugo site, run the following to publish in this grain:</p>
|
|
|
|
<render-template
|
|
|
|
rpcId="gitPush"
|
|
|
|
:template="'git remote add origin ' + this.gitUrl + '\ngit push -fu origin master'"/>
|
2020-04-15 02:19:34 +00:00
|
|
|
<h2>Upgrade notes from the 0.20 Sandstorm release:</h2>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
If you were using inline HTML in any Markdown files, enter the following into
|
|
|
|
your <code>config.toml</code> file:
|
|
|
|
<pre>
|
|
|
|
[markup.goldmark.renderer]
|
|
|
|
unsafe= true
|
|
|
|
</pre>
|
|
|
|
</li>
|
2020-04-21 11:23:40 +00:00
|
|
|
<li>
|
|
|
|
There have been updates/changes to how previous/next item handling has
|
|
|
|
changed over time. Ensure your previous/next item handling is
|
|
|
|
working as intended.
|
|
|
|
</li>
|
2020-04-15 02:19:34 +00:00
|
|
|
</ul>
|
2020-04-10 13:43:03 +00:00
|
|
|
<p>
|
2020-04-21 11:23:40 +00:00
|
|
|
Be sure to <a href="https://gohugo.io/news/" target="_blank" rel="noopener">read through the Hugo release notes</a>
|
2020-04-15 02:19:34 +00:00
|
|
|
if you notice any other odd behavior after upgrading.
|
2020-04-10 13:43:03 +00:00
|
|
|
</p>
|
2020-04-21 11:23:40 +00:00
|
|
|
<h2>Admin Interface (<a href="https://cloudcmd.io/" target="_blank" rel="noopener">Cloud Commander</a>)</h2>
|
2020-04-15 02:19:34 +00:00
|
|
|
<a :class="{disabled: !dirty}" class="button" @click="commitLocal">Commit & publish local changes</a>
|
|
|
|
<a :class="{disabled: !dirty}" class="button" @click="deleteLocal">Delete local changes (git reset --hard)</a>
|
|
|
|
<iframe id="files" src="/admin" style="width: 100%; height: 800px; margin-top: 1rem"></iframe>
|
2017-03-19 17:04:38 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import "isomorphic-fetch"
|
|
|
|
import RenderTemplate from "~components/render-template"
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data: () => ({
|
|
|
|
isDemo: true,
|
|
|
|
url: "",
|
|
|
|
domain: "",
|
2020-04-10 12:06:19 +00:00
|
|
|
publicId: "",
|
|
|
|
isLoading: true,
|
2020-04-15 02:19:34 +00:00
|
|
|
loadError: null,
|
|
|
|
dirty: false
|
2017-03-19 17:04:38 +00:00
|
|
|
}),
|
|
|
|
computed: {
|
|
|
|
gitHost: () => {
|
|
|
|
if(process.BROWSER_BUILD)
|
2017-04-19 16:25:49 +00:00
|
|
|
return window.location.protocol+"//git:$API_TOKEN@$API_HOST"
|
2017-03-19 17:04:38 +00:00
|
|
|
else
|
|
|
|
return ""
|
|
|
|
},
|
|
|
|
gitUrl: () => {
|
|
|
|
if(process.BROWSER_BUILD)
|
|
|
|
return `${window.location.protocol}//git@$API_HOST/git`
|
|
|
|
else
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
},
|
2020-04-10 12:06:19 +00:00
|
|
|
// mounted actions occur immediately. we use async here to
|
|
|
|
// simplify promise handling.
|
|
|
|
async mounted () {
|
|
|
|
this.isLoading = true
|
2020-04-21 11:23:40 +00:00
|
|
|
|
|
|
|
// TODO: needed until https://github.com/sandstorm-io/sandstorm/pull/3292 is merged
|
|
|
|
let publicIdLoadTries = 5
|
|
|
|
|
|
|
|
while (publicIdLoadTries > 0 && !this.url) {
|
|
|
|
try {
|
|
|
|
await this.fetchPublicId()
|
|
|
|
} catch (e) {
|
|
|
|
// wait 5 seconds and try again
|
|
|
|
await new Promise((resolve) => { setTimeout(resolve, 5000) })
|
|
|
|
|
|
|
|
publicIdLoadTries -= 1
|
|
|
|
|
|
|
|
if (publicIdLoadTries === 0) {
|
|
|
|
this.loadError = e
|
|
|
|
}
|
|
|
|
}
|
2020-04-10 12:06:19 +00:00
|
|
|
}
|
2020-04-15 02:19:34 +00:00
|
|
|
|
|
|
|
setInterval(this.checkDirty, 5000)
|
2017-03-19 17:04:38 +00:00
|
|
|
},
|
|
|
|
head: {
|
|
|
|
title: "Home"
|
|
|
|
},
|
2020-04-15 02:19:34 +00:00
|
|
|
methods: {
|
2020-04-21 11:23:40 +00:00
|
|
|
async fetchPublicId () {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
},
|
2020-04-15 02:19:34 +00:00
|
|
|
async commitLocal () {
|
|
|
|
if (!this.dirty) return
|
|
|
|
|
|
|
|
if (confirm('Are you sure?')) {
|
|
|
|
await fetch('/commit')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async deleteLocal () {
|
|
|
|
if (!this.dirty) return
|
|
|
|
|
|
|
|
if (confirm('Are you sure?')) {
|
|
|
|
await fetch('/reset-local')
|
|
|
|
|
|
|
|
document.getElementById('files').contentWindow.location.reload(true)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async checkDirty () {
|
|
|
|
const response = await fetch('/dirty')
|
|
|
|
const json = await response.json()
|
|
|
|
|
|
|
|
if (json.hasOwnProperty('dirty')) {
|
|
|
|
this.dirty = json.dirty
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2017-03-19 17:04:38 +00:00
|
|
|
components: {RenderTemplate}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|