Commit b2cb7ad7 authored by kaiyou's avatar kaiyou

Initial commit

parents
{
"name": "tedimg",
"private": true,
"dependencies": {
"Materialize": "materialize#~0.97.3",
"jquery": "~2.1.4"
}
}
var gulp = require('gulp'),
sass = require('gulp-ruby-sass')
notify = require("gulp-notify")
bower = require('gulp-bower');
var config = {
srcPath: './resources',
bowerDir: './bower_components',
dstPath: './tedimg/static'
}
var cssPath = [
config.srcPath,
config.bowerDir + '/Materialize/sass',
]
gulp.task('bower', function() {
return bower()
.pipe(gulp.dest(config.bowerDir))
});
gulp.task('styles', function () {
return sass(config.srcPath + '/main.scss', {loadPath: cssPath})
.on('error', sass.logError)
.pipe(gulp.dest(config.dstPath))
});


gulp.task('default', ['bower', 'styles']);
{
"name": "tedimg",
"dependencies": {},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-bower": "0.0.11",
"gulp-notify": "^2.2.0",
"gulp-ruby-sass": "^2.0.6"
}
}
@import "materialize";
/* Browser specific (not valid) styles to make preformatted text wrap */
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
from tedimg import app
from flask import send_from_directory
app.config.update(
STORAGE_PATH="./tedimg/static/images",
WEB_PATH="/static/images"
)
app.run(debug=True)
from flask import Flask
app = Flask(__name__)
app.config.update(
SITE_NAME="TedImg",
STORAGE_PATH="/tmp/images",
WEB_PATH="/images",
)
import tedimg.views
from tedimg import app
from os import path
def get_image(name):
""" Try and get basic image attributes.
"""
filename = path.basename(name)
return path.join(app.config["WEB_PATH"], filename)
{% extends "base.html" %}
{% block content %}
<div class="section no-pad-bot" id="index-banner">
<div class="container">
{% block banner_content %}
{% endblock %}
<br><br>
</div>
</div>
<div class="container">
<div class="section">
{% block section_content %}
{% endblock %}
</div>
</div>
{% endblock %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
<title>{{ config["SITE_NAME"] }}</title>
<link href="/static/main.css" type="text/css" rel="stylesheet" media="screen,projection"/>
</head>
<body>
<nav class="blue" role="navigation">
<div class="nav-wrapper container"><a href="/" class="brand-logo">TedImage</a>
<ul class="right">
<li><a href="#">Source code</a></li>
<li><a href="#">Help</a></li>
</ul>
</div>
</nav>
{% block content %}
{% endblock %}
<footer class="page-footer blue">
<div class="footer-copyright">
<div class="container">
Made with love using Python, JS, Flask, Gulp, Bower, and Materialize
</div>
</div>
</footer>
</body>
</html>
{% extends "banner.html" %}
{% block banner_content %}
<h1 class="header center orange-text">Upload your image!</h1>
<form action="#">
<div class="file-field input-field">
<div class="btn light-blue">
<span>File</span>
<input type="file" multiple>
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Upload one or more image">
</div>
</div>
<div class="input-field">
<i class="material-icons prefix">label</i>
<input id="icon_prefix" type="text" class="validate">
<label for="icon_prefix">http:// or paste your image URL</label>
</div>
</form>
{% endblock %}
{% extends "banner.html" %}
{% block banner_content %}
<h1 class="header center orange-text">Upload successful!</h1>
<div class="row center">
<a href="{{ image }}" class="btn-large waves-effect waves-light light-blue">Direct link</a>
</div>
{% endblock %}
{% block section_content %}
<div class="row">
<div class="col s12 m4">
<h5 class="center">HTML</h5>
<pre>&lt;a href="{{ image }}"&gt;&lt;img src="{{ image }}"&gt;&lt;/a&gt;</pre>
</div>
<div class="col s12 m4">
<h5 class="center">Markdown</h5>
<pre>[![Image]({{ image }})]({{ image }})</pre>
</div>
<div class="col s12 m4">
<h5 class="center">BBCode</h5>
<pre>[url={{ image }}][img]{{ image }}[/img][/url]</pre>
</div>
</div>
{% endblock %}
from tedimg import app, images
import flask
@app.route('/')
def index():
return flask.render_template("index.html")
@app.route('/show/<path:path>')
def show(path):
image = images.get_image(path)
return flask.render_template("show.html", image=image)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment