Bare /static support, some css/templates import

This commit is contained in:
andreimarcu 2015-09-24 16:04:51 -04:00
parent d130cfe8e1
commit d869599da7
9 changed files with 791 additions and 24 deletions

View File

@ -2,7 +2,6 @@ package main
import (
"flag"
"fmt"
"log"
"net"
"net/http"
@ -26,16 +25,16 @@ func main() {
"name of the site")
flag.Parse()
fmt.Printf("About to listen on http://%s\n", Config.bind)
nameRe := regexp.MustCompile(`^/(?P<name>[a-z0-9-\.]+)$`)
selifRe := regexp.MustCompile(`^/selif/(?P<name>[a-z0-9-\.]+)$`)
goji.Get("/", indexHandler)
goji.Post("/upload", uploadPostHandler)
goji.Put("/upload", uploadPutHandler)
goji.Get("/static/*", http.StripPrefix("/static/",
http.FileServer(http.Dir("static/"))))
goji.Get(nameRe, fileDisplayHandler)
goji.Handle(selifRe, http.StripPrefix("/selif/", http.FileServer(http.Dir(Config.filesDir))))
goji.Get(selifRe, fileServeHandler)
listener, err := net.Listen("tcp", Config.bind)
if err != nil {

BIN
static/favicon.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

689
static/linx.css Normal file
View File

@ -0,0 +1,689 @@
body {
background-color: #E8ECF0;
color: #556A7F;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
#container_container {
display: table;
table-layout: fixed;
margin-left: auto;
margin-right: auto;
}
#container {
display: table-cell;
min-width: 200px;
}
#header a {
text-decoration: none;
color: #556A7F;
}
#navigation {
margin-top: 4px;
}
#navigation a {
text-decoration: none;
border-bottom: 1px dotted #556A7F;
color: #556A7F;
}
#navigation a:hover {
background-color: #C7D1EB;
}
#main {
background-color: white;
padding: 6px 5px 8px 5px;
-moz-box-shadow: 1px 1px 1px 1px #ccc;
-webkit-box-shadow: 1px 1px 1px 1px #ccc;
box-shadow: 1px 1px 1px 1px #ccc;
text-align: center;
}
#main a {
color: #556A7F;
}
#normal-content {
word-wrap: break-word;
}
.ninfo {
margin-bottom: 5px;
}
#info {
text-align: left;
background-color: white;
padding: 5px 5px 5px 5px;
}
#info .float-left {
margin-top: 2px;
margin-right: 20px;
}
#info .right {
font-size: 13px;
}
#info a {
text-decoration: none;
color: #556A7F;
}
#info a:hover {
border-bottom: 1px dotted gray;
background-color: #E8ECF0;
}
#info input[type=text] {
border: 0;
color: #556A7F;
}
#footer {
color: gray;
text-align: right;
margin-top: 30px;
margin-bottom: 10px;
font-size: 11px;
}
#footer a {
color: gray;
text-decoration: none;
}
.normal {
text-align: left;
font-size: 13px;
}
.normal a {
text-decoration: none;
border-bottom: 1px dotted gray;
}
.normal a:hover {
color: black;
background-color: #E8ECF0;
}
.normal ul {
padding-left: 15px;
}
.normal li {
margin-bottom: 3px;
list-style: none;
}
.normal li a {
font-weight: bold;
}
.fixed {
width: 800px;
}
.needs-border {
border-top: 1px solid rgb(214, 214, 214);
}
.left {
text-align: left;
}
.float-left {
float: left;
}
.pad-right {
padding-right: 10px;
}
.text-right {
text-align: right;
}
.center {
text-align: center;
}
.float-right, .right {
float: right;
}
.clear {
clear:both;
}
#upload_header {
text-align: center;
font-size: 18px;
}
#html5 {
text-align: center;
}
#file-uploader a {
text-decoration: none;
border-bottom: 1px dotted #556A7F;
color: #556A7F;
font-weight: bold;
}
#filesUploaded {
display:none;
text-align:left;
}
#linx_display_links {
display:none;
padding: 20px;
background-color: #00AFF5;
border-top: 3px solid #6bacf5;
border-left: 3px solid #6bacf5;
border-right: 3px solid #6bacf5;
border-bottom: 3px solid #6bacf5;
margin-top: 15px;
margin-bottom: 10px;
font-size: 12px;
}
#linx_display_links a,a:active,a:visited {
color: white;
}
#supported_files {
display:none;
text-align:left;
}
#upload_btn {
background-color: white;
border: 2px solid #C9C9C9;
width: 90px;
height: 30px;
}
#expires {
width:75px;
}
#choices {
float: left;
width: 100%;
text-align: left;
vertical-align: bottom;
margin-top: 5px;
font-size:13px;
}
#expiry {
float: right;
padding-top: 1px;
}
/* cat.js */
.qq-uploader { position:relative; width: 100%;}
.qq-upload-button {
width: 400px;
padding-top: 60px;
height: 75px;
margin-left:auto;
margin-right:auto;
border: 2px dashed #C9C9C9;
color:#C9C9C9;
font: 14px "helvetica neue", helvetica, arial, sans-serif;
background-color: #FAFBFC;
}
.qq-upload-button-hover {
background:#EFF4F8;
}
.qq-upload-button-focus {outline:1px dotted black;}
.qq-upload-button-depr {
background-color: #8C9CBF;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #8C9CBF), color-stop(50%, #546A9E), color-stop(50%, #36518F), color-stop(100%, #3D5691));
background-image: -webkit-linear-gradient(top, #8C9CBF 0%, #546A9E 50%, #36518F 50%, #3D5691 100%);
background-image: -moz-linear-gradient(top, #8C9CBF 0%, #546A9E 50%, #36518F 50%, #3D5691 100%);
background-image: -ms-linear-gradient(top, #8C9CBF 0%, #546A9E 50%, #36518F 50%, #3D5691 100%);
background-image: -o-linear-gradient(top, #8C9CBF 0%, #546A9E 50%, #36518F 50%, #3D5691 100%);
background-image: linear-gradient(top, #8C9CBF 0%, #546A9E 50%, #36518F 50%, #3D5691 100%);
border: 1px solid #172D6E;
border-bottom: 1px solid #0E1D45;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: inset 0 1px 0 0 #b1b9cb;
-moz-box-shadow: inset 0 1px 0 0 #b1b9cb;
box-shadow: inset 0 1px 0 0 #b1b9cb;
color: white;
font: bold 14px "helvetica neue", helvetica, arial, sans-serif;
padding: 7px 0 8px 0;
text-decoration: none;
text-align: center;
text-shadow: 0 -1px 1px #000F4D;
width: 140px;
}
.qq-upload-button2 {
display:block; /* or inline-block */
margin-left:auto;
margin-right:auto;
width: 105px; padding: 7px 0; text-align:center;
background: hsl(212, 77%, 26%); border-bottom:1px solid #ddd;color:#fff;
}
.qq-upload-drop-area {
position:absolute; top:0; left:0; width:100%; height:100%; min-height: 50px; z-index:2;
background:#2c89f0; text-align:center;
border: 2px dashed #C9C9C9;
color:white;
}
.qq-upload-drop-area span {
display:block; position:absolute; top: 50%; width:100%; margin-top:-8px; font-size:16px;
}
.qq-upload-drop-area-active {background:#093E7C;}
#toggleme{
display:none;
}
.qq-upload-list {
margin: 15px 3px 10px 3px;
font-size: 12px;
}
.qq-upload-list li {
display: block;
background-color:#E8ECF0;
padding: 8px 5px 8px 5px;
margin: 5px 0 0 0;
border: 1px solid #C9C9C9;
font-size:13px;
text-align: left;
list-style: none;
line-height: normal;
}
.qq-upload-list li a:hover {
}
.qq-upload-list li a {
}
.qq-upload-file, .qq-upload-spinner, .qq-upload-size, .qq-upload-cancel, .qq-upload-failed-text {
margin-right: 7px;
}
.qq-upload-file {}
.qq-upload-spinner {display:inline-block; background: url("/images/loading.gif"); width:15px; height:15px; vertical-align:text-bottom;}
.qq-upload-size,.qq-upload-cancel {font-size:11px;}
.qq-upload-failed-text {display:none;}
.qq-upload-fail .qq-upload-failed-text {display:inline;}
/*
Uploadify v2.1.4
Release Date: November 8, 2010
Copyright (c) 2010 Ronnie Garcia, Travis Nickels
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
.uploadifyQueueItem {
background-color: #F5F5F5;
border: 2px solid #E5E5E5;
font: 11px Verdana, Geneva, sans-serif;
margin-top: 5px;
padding: 10px;
width: 350px;
}
.uploadifyError {
background-color: #FDE5DD !important;
border: 2px solid #FBCBBC !important;
}
.uploadifyQueueItem .cancel {
float: right;
}
.uploadifyQueue .completed {
background-color: #E5E5E5;
}
.uploadifyProgress {
background-color: #E5E5E5;
margin-top: 10px;
width: 100%;
}
.uploadifyProgressBar {
background-color: #0099FF;
height: 3px;
width: 1px;
}
/*! Hint.css - v1.3.1 - 2013-11-23
* http://kushagragour.in/lab/hint/
* Copyright (c) 2013 Kushagra Gour; Licensed MIT */
/*-------------------------------------*\
HINT.css - A CSS tooltip library
\*-------------------------------------*/
/**
* HINT.css is a tooltip library made in pure CSS.
*
* Source: https://github.com/chinchang/hint.css
* Demo: http://kushagragour.in/lab/hint/
*
* Release under The MIT License
*
*/
/**
* source: hint-core.scss
*
* Defines the basic styling for the tooltip.
* Each tooltip is made of 2 parts:
* 1) body (:after)
* 2) arrow (:before)
*
* Classes added:
* 1) hint
*/
.hint, [data-hint] {
position: relative;
display: inline-block;
/**
* tooltip arrow
*/
/**
* tooltip body
*/ }
.hint:before, .hint:after, [data-hint]:before, [data-hint]:after {
position: absolute;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
visibility: hidden;
opacity: 0;
z-index: 1000000;
pointer-events: none;
-webkit-transition: 0.3s ease;
-moz-transition: 0.3s ease;
transition: 0.3s ease; }
.hint:hover:before, .hint:hover:after, .hint:focus:before, .hint:focus:after, [data-hint]:hover:before, [data-hint]:hover:after, [data-hint]:focus:before, [data-hint]:focus:after {
visibility: visible;
opacity: 1; }
.hint:before, [data-hint]:before {
content: '';
position: absolute;
background: transparent;
border: 6px solid transparent;
z-index: 1000001; }
.hint:after, [data-hint]:after {
content: attr(data-hint);
background: #556A7F;
color: white;
text-shadow: 0 -1px 0px black;
padding: 8px 10px;
font-size: 12px;
line-height: 12px;
white-space: nowrap;
box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3); }
/**
* source: hint-position.scss
*
* Defines the positoning logic for the tooltips.
*
* Classes added:
* 1) hint--top
* 2) hint--bottom
* 3) hint--left
* 4) hint--right
*/
/**
* set default color for tooltip arrows
*/
.hint--top:before {
border-top-color: #556A7F; }
.hint--bottom:before {
border-bottom-color: #556A7F; }
.hint--left:before {
border-left-color: #556A7F; }
.hint--right:before {
border-right-color: #556A7F; }
/**
* top tooltip
*/
.hint--top:before {
margin-bottom: -12px; }
.hint--top:after {
margin-left: -18px; }
.hint--top:before, .hint--top:after {
bottom: 100%;
left: 50%; }
.hint--top:hover:after, .hint--top:hover:before, .hint--top:focus:after, .hint--top:focus:before {
-webkit-transform: translateY(-8px);
-moz-transform: translateY(-8px);
transform: translateY(-8px); }
/**
* bottom tooltip
*/
.hint--bottom:before {
margin-top: -12px; }
.hint--bottom:after {
margin-left: -18px; }
.hint--bottom:before, .hint--bottom:after {
top: 100%;
left: 50%; }
.hint--bottom:hover:after, .hint--bottom:hover:before, .hint--bottom:focus:after, .hint--bottom:focus:before {
-webkit-transform: translateY(8px);
-moz-transform: translateY(8px);
transform: translateY(8px); }
/**
* right tooltip
*/
.hint--right:before {
margin-left: -12px;
margin-bottom: -6px; }
.hint--right:after {
margin-bottom: -14px; }
.hint--right:before, .hint--right:after {
left: 100%;
bottom: 50%; }
.hint--right:hover:after, .hint--right:hover:before, .hint--right:focus:after, .hint--right:focus:before {
-webkit-transform: translateX(8px);
-moz-transform: translateX(8px);
transform: translateX(8px); }
/**
* left tooltip
*/
.hint--left:before {
margin-right: -12px;
margin-bottom: -6px; }
.hint--left:after {
margin-bottom: -14px; }
.hint--left:before, .hint--left:after {
right: 100%;
bottom: 50%; }
.hint--left:hover:after, .hint--left:hover:before, .hint--left:focus:after, .hint--left:focus:before {
-webkit-transform: translateX(-8px);
-moz-transform: translateX(-8px);
transform: translateX(-8px); }
/**
* source: hint-color-types.scss
*
* Contains tooltips of various types based on color differences.
*
* Classes added:
* 1) hint--error
* 2) hint--warning
* 3) hint--info
* 4) hint--success
*
*/
/**
* Error
*/
.hint--error:after {
background-color: #b34e4d;
text-shadow: 0 -1px 0px #592726; }
.hint--error.hint--top:before {
border-top-color: #b34e4d; }
.hint--error.hint--bottom:before {
border-bottom-color: #b34e4d; }
.hint--error.hint--left:before {
border-left-color: #b34e4d; }
.hint--error.hint--right:before {
border-right-color: #b34e4d; }
/**
* Warning
*/
.hint--warning:after {
background-color: #c09854;
text-shadow: 0 -1px 0px #6c5328; }
.hint--warning.hint--top:before {
border-top-color: #c09854; }
.hint--warning.hint--bottom:before {
border-bottom-color: #c09854; }
.hint--warning.hint--left:before {
border-left-color: #c09854; }
.hint--warning.hint--right:before {
border-right-color: #c09854; }
/**
* Info
*/
.hint--info:after {
background-color: #3986ac;
text-shadow: 0 -1px 0px #193b4d; }
.hint--info.hint--top:before {
border-top-color: #3986ac; }
.hint--info.hint--bottom:before {
border-bottom-color: #3986ac; }
.hint--info.hint--left:before {
border-left-color: #3986ac; }
.hint--info.hint--right:before {
border-right-color: #3986ac; }
/**
* Success
*/
.hint--success:after {
background-color: #458746;
text-shadow: 0 -1px 0px #1a321a; }
.hint--success.hint--top:before {
border-top-color: #458746; }
.hint--success.hint--bottom:before {
border-bottom-color: #458746; }
.hint--success.hint--left:before {
border-left-color: #458746; }
.hint--success.hint--right:before {
border-right-color: #458746; }
/**
* source: hint-always.scss
*
* Defines a persisted tooltip which shows always.
*
* Classes added:
* 1) hint--always
*
*/
.hint--always:after, .hint--always:before {
opacity: 1;
visibility: visible; }
.hint--always.hint--top:after, .hint--always.hint--top:before {
-webkit-transform: translateY(-8px);
-moz-transform: translateY(-8px);
transform: translateY(-8px); }
.hint--always.hint--bottom:after, .hint--always.hint--bottom:before {
-webkit-transform: translateY(8px);
-moz-transform: translateY(8px);
transform: translateY(8px); }
.hint--always.hint--left:after, .hint--always.hint--left:before {
-webkit-transform: translateX(-8px);
-moz-transform: translateX(-8px);
transform: translateX(-8px); }
.hint--always.hint--right:after, .hint--always.hint--right:before {
-webkit-transform: translateX(8px);
-moz-transform: translateX(8px);
transform: translateX(8px); }
/**
* source: hint-rounded.scss
*
* Defines rounded corner tooltips.
*
* Classes added:
* 1) hint--rounded
*
*/
.hint--rounded:after {
border-radius: 4px; }
/**
* source: hint-effects.scss
*
* Defines various transition effects for the tooltips.
*
* Classes added:
* 1) hint--bounce
*
*/
.hint--bounce:before, .hint--bounce:after {
-webkit-transition: opacity 0.3s ease, visibility 0.3s ease, -webkit-transform 0.3s cubic-bezier(0.71, 1.7, 0.77, 1.24);
-moz-transition: opacity 0.3s ease, visibility 0.3s ease, -moz-transform 0.3s cubic-bezier(0.71, 1.7, 0.77, 1.24);
transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s cubic-bezier(0.71, 1.7, 0.77, 1.24); }

View File

@ -1,13 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{{ sitename }}{% endblock %}</title>
<title>{% block title %}{{ sitename }}{% endblock %}</title>
<meta charset='utf-8' content='text/html' http-equiv='content-type'>
<link href='/static/linx.css' media='screen, projection' rel='stylesheet' type='text/css'>
<link href='/static/favicon.gif' rel='icon' type='image/gif'>
{% block head %}{% endblock %}
</head>
<body>
<div id="container_container">
<div id="container">
<div id="header">
<div id="navigation" class="right">
<a href="/">Upload</a>
</div>
<h2><a href="/" title="{{ sitename }}">{{ sitename }}</a></h2>
</div>
<div>
{% block content %}{% endblock %}
</div>
{% block content %}{% endblock %}
<div id="footer">
<a href="https://github.com/andreimarcu/linx-server">linx</a>
</div>
</div>
</div>
</body>
</html>
</html>

View File

@ -0,0 +1,25 @@
{% extends "../base.html" %}
{% block title %}{{ filename }}{% endblock %}
{% block bodymore %}{% endblock %}
{% block content %}
<div id="info" class="dinfo">
<div class="float-left" id="filename">
{{ filename }}
</div>
{% block infoleft %}{% endblock %}
<div class="clear"></div>
</div>
<div id="main">
<div id='inner_content'>
{% block main %}{% endblock %}
</div>
</div>
{% endblock %}

View File

@ -1,6 +1,7 @@
{% extends "../base.html" %}
{% extends "base.html" %}
{% block content %}
<p>Viewing file {{ filename }} of mime: {{ mime }}</p>
<p><a href="/selif/{{ filename }}">Click to download</a></p>
{% block main %}
<div class="normal">
<p class="center">You are requesting <a href="/selif/{{ filename }}">{{ filename }}</a>, <a href="/selif/{{ filename }}">>click here</a> to download.</p>
</div>
{% endblock %}

View File

@ -1,6 +1,5 @@
{% extends "../base.html" %}
{% extends "base.html" %}
{% block content %}
<p>Viewing file {{ filename }}</p>
<img src="/selif/{{ filename }}" />
{% block main %}
<img style="margin-bottom: -6px; max-width: 800px;" src="/selif/{{ filename }}" />
{% endblock %}

View File

@ -1,8 +1,45 @@
{% extends "base.html" %}
{% block content %}
<form enctype="multipart/form-data" action="/upload" method="post">
<input type="file" name="file" />
<input type="submit" value="upload" />
</form>
{% endblock %}
{% block content %}
<div id="fileupload">
<div id="html5">
<div class="clear"></div>
<form action="/upload" method="POST" enctype="multipart/form-data">
<div id="file-uploader" style="min-width: 400px;">
<br />
<input type="file" name="file" id="file_upload" name="file"><br/ ><br/ >
<input id ="upload_btn" type="submit" value="Upload">
<br /><br />
</div>
<div id="choices">
<div id="expiry">
<label>File expiry:
<select name="expires" id="expires">
</label>
<option value="never">never</option>
<option value="a minute">a minute</option>
<option value="5 minutes">5 minutes</option>
<option value="an hour">an hour</option>
<option value="a day">a day</option>
<option value="a week">a week</option>
<option value="a month">a month</option>
<option value="a year">a year</option>
</select>
</div>
<label><input name="randomize" id="randomize" type="checkbox" checked /> Randomize filename</label>
</div>
</form>
<div style="clear:both;"></div>
</div>
</div>
{% endblock %}

View File

@ -46,7 +46,7 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) {
return
}
fmt.Fprintf(w, "File %s uploaded successfully.", upload.Filename)
http.Redirect(w, r, "/"+upload.Filename, 301)
}
func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) {