Browse Source

Basic download page

master
Noah Petherbridge 2 years ago
parent
commit
27214d96fc
3 changed files with 33 additions and 28 deletions
  1. +1
    -1
      www/blog/tags.partial.gohtml
  2. +1
    -1
      www/contact/index.gohtml
  3. +31
    -26
      www/download.gohtml

+ 1
- 1
www/blog/tags.partial.gohtml View File

@@ -8,7 +8,7 @@
</ul>
{{ else }}
<ul>
<li>&#0187; <a href="/blog/archive">Blog Archives</a></li>
<li>&#0187; <a href="/archive">Blog Archives</a></li>
{{ range .Tags }}
{{ if ge .Count 8 }}
<li>&#0187; <a href="/tagged/{{ .Name }}">{{ .Name }}</a>


+ 1
- 1
www/contact/index.gohtml View File

@@ -44,7 +44,7 @@ Things that you <strong>SHOULD NOT</strong> use this form for:
For anything else:<p>

<form name="contact" action="/contact" method="POST">
<input type="hidden" name="token" value="{{ .CSRF }}">
<input type="hidden" name="_csrf" value="{{ .CSRF }}">

<strong>Your name:</strong><br>
<small>(so I know who you are)</small><br>


+ 31
- 26
www/download.gohtml View File

@@ -1,13 +1,17 @@
{{ define "title" }}Download{{ end }}
{{ define "content" }}

{% block title %}Download Manager{% endblock %}
{% block content %}
{{ $method := or (.Request.FormValue "method") "index" }}
{{ $project := .Request.FormValue "project" }}
{{ $file := .Request.FormValue "file" }}
{{ if eq $project "" }}
<h1>An error has occurred</h1>
{{ else if eq $method "index" }}
<h1>Project {{ $project }}</h1>

{% if method == "index" %}
<h1>Project {{ project }}</h1>

You are about to download the file <strong>{{ file }}</strong> from the
project <strong>{{ project }}</strong>. This file has been downloaded
{{ hits }} time(s).
You are about to download the file <strong>{{ $file }}</strong> from the
project <strong>{{ $project }}</strong>. <!-- This file has been downloaded
0 time(s). -->

<h1>Download</h1>

@@ -15,30 +19,31 @@
<br><br><br>

<form name="download" action="/download" method="POST">
<input type="hidden" name="token" value="{{ csrf_token() }}">
<input type="hidden" name="_csrf" value="{{ .CSRF }}">
<input type="hidden" name="method" value="get">
<input type="hidden" name="project" value="{{ project }}">
<input type="hidden" name="file" value="{{ file }}">
<input type="hidden" name="project" value="{{ $project }}">
<input type="hidden" name="file" value="{{ $file }}">

<span style="background-color: #88AADD; padding: 15px; border-top: 2px solid #006699;
border-left: 2px solid #006699; border-right: 2px solid #AACCFF; border-bottom: 2px solid #AACCFF">
<button type="submit">Download Now</button>
</span>
</form>
{% elif method == "get" %}
{{ else if eq $method "get" }}
<h1>Downloading File...</h1>

Your download of <strong>{{ file }}</strong> will begin shortly. If it doesn't,
<a href="/projects/{{ project }}/{{ file }}">download it directly</a>.
{% endif %}

{% endblock %}
{% block scripts %}
{% if method == "get" %}
<script>
$(document).ready(function() {
window.location.href = "/projects/{{ project }}/{{ file }}";
});
</script>
{% endif %}
{% endblock %}
Your download of <strong>{{ $file }}</strong> will begin shortly. If it doesn't,
<a href="/projects/{{ $project }}/{{ $file }}">download it directly</a>.

<script type="text/javascript">
(function() {
setTimeout(function() {
window.location.href = "/projects/{{ $project }}/{{ $file }}";
}, 2000);
})();
</script>
{{ else }}
<h1>An error has occurred.</h1>
{{ end}}

{{ end }}

Loading…
Cancel
Save