Better blog stuff
This commit is contained in:
parent
d73e57bff6
commit
a83eb4a58e
|
@ -13,6 +13,7 @@ local_settings.py
|
|||
.DS_Store
|
||||
|
||||
# utilities
|
||||
bower_components
|
||||
/fmartingrcom/themes/*/static/bower
|
||||
/fmartingrcom/themes/*/static/bower_components
|
||||
/node_modules
|
||||
|
|
|
@ -17,5 +17,7 @@
|
|||
"test",
|
||||
"tests"
|
||||
],
|
||||
"dependencies": {}
|
||||
"dependencies": {
|
||||
"google-code-prettify": "~1.0.4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from flask import Blueprint, render_template, request, abort
|
||||
#from flask_admin.contrib.sqla import ModelView
|
||||
from flask import Blueprint, render_template, request, abort, url_for
|
||||
from sqlalchemy import Column, String, Text, Integer, Boolean, DateTime
|
||||
from fmartingrcom import db, register_admin_model, conf
|
||||
|
||||
|
@ -19,22 +18,26 @@ class Post(db.Model):
|
|||
html = Column(Text)
|
||||
draft = Column(Boolean, default=True)
|
||||
|
||||
@property
|
||||
def absolute_url(self):
|
||||
return url_for('blog.blog_post',
|
||||
year=self.date.year,
|
||||
month=str(self.date.month).zfill(2),
|
||||
day=str(self.date.day).zfill(2),
|
||||
slug=self.slug)
|
||||
|
||||
if conf.ENABLE_ADMIN:
|
||||
register_admin_model(Post)
|
||||
|
||||
|
||||
# Views
|
||||
@blog.route('/blog/<int:year>/<int:month>/<int:day>/<slug>/')
|
||||
@blog.route('/blog/<int:year>/<string:month>/<string:day>/<slug>/')
|
||||
def blog_post(year, month, day, slug):
|
||||
try:
|
||||
item = Post.get(Post.slug == slug)
|
||||
context = {
|
||||
'item': item,
|
||||
}
|
||||
return render_template('blog/post.html', **context)
|
||||
except Post.DoesNotExist:
|
||||
return abort(404)
|
||||
item = Post.query.filter_by(slug=slug).first_or_404()
|
||||
context = {
|
||||
'item': item,
|
||||
}
|
||||
return render_template('blog/post.html', **context)
|
||||
|
||||
@blog.route('/blog/')
|
||||
def blog_list():
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
* {
|
||||
@include box-sizing(border-box);
|
||||
@include box-sizing(border-box);
|
||||
}
|
||||
|
||||
$pad: 20px;
|
||||
|
||||
.grid {
|
||||
background: white;
|
||||
margin: 0 0 $pad 0;
|
||||
background: white;
|
||||
margin: 0 0 $pad 0;
|
||||
|
||||
&:after {
|
||||
/* Or @extend clearfix */
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
&:after {
|
||||
/* Or @extend clearfix */
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
}
|
||||
|
||||
[class*='col-'] {
|
||||
float: left;
|
||||
padding-right: $pad;
|
||||
.grid &:last-of-type {
|
||||
padding-right: 0;
|
||||
}
|
||||
float: left;
|
||||
padding-right: $pad;
|
||||
.grid &:last-of-type {
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
.col-2-3 {
|
||||
width: 66.66%;
|
||||
width: 66.66%;
|
||||
}
|
||||
.col-1-3 {
|
||||
width: 33.33%;
|
||||
width: 33.33%;
|
||||
}
|
||||
.col-1-2 {
|
||||
width: 50%;
|
||||
width: 50%;
|
||||
}
|
||||
.col-1-4 {
|
||||
width: 25%;
|
||||
width: 25%;
|
||||
}
|
||||
.col-1-8 {
|
||||
width: 12.5%;
|
||||
width: 12.5%;
|
||||
}
|
||||
|
||||
/* Opt-in outside padding */
|
||||
.grid-pad {
|
||||
padding: $pad 0 $pad $pad;
|
||||
[class*='col-']:last-of-type {
|
||||
padding-right: $pad;
|
||||
}
|
||||
padding: $pad 0 $pad $pad;
|
||||
[class*='col-']:last-of-type {
|
||||
padding-right: $pad;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
body {
|
||||
font-family: 'Antic Slab';
|
||||
font-size: 20px;
|
||||
line-height: 1.5em
|
||||
}
|
||||
|
||||
.center {
|
||||
margin: 0 auto;
|
||||
max-width: 1000px;
|
||||
max-width: 920px;
|
||||
}
|
||||
|
||||
a {
|
||||
|
@ -18,21 +19,18 @@ a {
|
|||
img { max-width: 100%; }
|
||||
|
||||
header {
|
||||
h1 { margin-bottom: 0; font-size: 1.5em }
|
||||
h1 { margin-bottom: 0; font-size: 1.5em; text-align: right; }
|
||||
|
||||
h2 {
|
||||
font-size: 0.8em;
|
||||
font-weight: normal;
|
||||
margin-top: 0;
|
||||
}
|
||||
& + hr, hr {
|
||||
margin: 1em 0 1em 0;
|
||||
border-style: dashed;
|
||||
border-top: 0px;
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
nav.main-menu {
|
||||
text-align: center;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
footer {
|
||||
|
@ -40,6 +38,12 @@ footer {
|
|||
padding-top: 1em;
|
||||
}
|
||||
|
||||
hr.light {
|
||||
border: 0px;
|
||||
margin: 1em 0 1em 0;
|
||||
border-top: #CCC 1px solid;
|
||||
}
|
||||
|
||||
p:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
pre .str, code .str
|
||||
color: #65b042
|
||||
|
||||
pre .kwd, code .kwd
|
||||
color: #e28964
|
||||
|
||||
pre .com, code .com
|
||||
color: #aeaeae
|
||||
font-style: italic
|
||||
|
||||
pre .typ, code .typ
|
||||
color: #89bdff
|
||||
|
||||
pre .lit, code .lit
|
||||
color: #3387cc
|
||||
|
||||
pre .pun, code .pun, pre .pln, code .pln
|
||||
color: #fff
|
||||
|
||||
pre .tag, code .tag
|
||||
color: #89bdff
|
||||
|
||||
pre .atn, code .atn
|
||||
color: #bdb76b
|
||||
|
||||
pre .atv, code .atv
|
||||
color: #65b042
|
||||
|
||||
pre .dec, code .dec
|
||||
color: #3387cc
|
||||
|
||||
pre.prettyprint, code.prettyprint
|
||||
background-color: #242424
|
||||
border: 0 !important
|
||||
-moz-border-radius: 0
|
||||
-webkit-border-radius: 0
|
||||
-o-border-radius: 0
|
||||
-ms-border-radius: 0
|
||||
-khtml-border-radius: 0
|
||||
border-radius: 0
|
||||
|
||||
pre.prettyprint
|
||||
font-size: 84%
|
||||
line-height: 120%
|
||||
width: auto
|
||||
margin: 1em auto
|
||||
padding: 12px !important
|
||||
white-space: pre-wrap
|
||||
font-size: 86%
|
||||
|
||||
ol.linenums
|
||||
margin-top: 0
|
||||
margin-bottom: 0
|
||||
color: #aeaeae
|
||||
|
||||
li
|
||||
&.L0, &.L1, &.L2, &.L3, &.L5, &.L6, &.L7, &.L8
|
||||
list-style-type: none
|
||||
|
||||
@media print
|
||||
pre .str, code .str
|
||||
color: #060
|
||||
pre .kwd, code .kwd
|
||||
color: #006
|
||||
font-weight: bold
|
||||
pre .com, code .com
|
||||
color: #600
|
||||
font-style: italic
|
||||
pre .typ, code .typ
|
||||
color: #404
|
||||
font-weight: bold
|
||||
pre .lit, code .lit
|
||||
color: #044
|
||||
pre .pun, code .pun
|
||||
color: #440
|
||||
pre .pln, code .pln
|
||||
color: #000
|
||||
pre .tag, code .tag
|
||||
color: #006
|
||||
font-weight: bold
|
||||
pre .atn, code .atn
|
||||
color: #404
|
||||
pre .atv, code .atv
|
||||
color: #060
|
|
@ -1,4 +1,6 @@
|
|||
@import "./mediaqueries";
|
||||
@import "./mixins";
|
||||
@import "./grid";
|
||||
@import "./layout";
|
||||
@import "./blog";
|
||||
@import "./syntax";
|
|
@ -13,10 +13,11 @@
|
|||
<a href="{{ url_for('blog.blog_list') }}">Blog</a> //
|
||||
<a href="{{ url_for('portfolio.portfolio_list') }}">Portfolio</a>
|
||||
</nav>
|
||||
<hr class="light">
|
||||
</header>
|
||||
<hr>
|
||||
{% block main_content %}{% endblock %}
|
||||
<footer class="center text-center">
|
||||
<hr class="light">
|
||||
<div class="center text-center">
|
||||
<a href="mailto:me@fmartingr.com" target="_blank">E-mail</a> //
|
||||
<a href="https://telegram.me/fmartingr" target="_blank">Telegram</a> //
|
||||
|
@ -26,5 +27,6 @@
|
|||
</div>
|
||||
<a href="https://gitlab.com/fmartingr/fmartingr.com" target="_blank">This site is open source</a>. 2012-{{ current_year }}
|
||||
</footer>
|
||||
<script type="text/javascript" src="{{ url_for('static', filename='js/app-min.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{% block main_content %}
|
||||
{% for item in items %}
|
||||
{{ item.title }}
|
||||
<a href="{{ item.absolute_url }}">{{ item.title }}</a>
|
||||
{% endfor %}
|
||||
<hr >
|
||||
Blog, page {{ paginator.page }} of {{ paginator.pages }}
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
Published on {{ item.date.strftime('%B %d, %Y') }}. // <a href="#">No comments.</a>
|
||||
</div>
|
||||
<div class="content {{ item.type }}">
|
||||
{{ item.content|safe }}
|
||||
{{ item.html|safe }}
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
{% endblock %}
|
||||
|
||||
{% block body_class %}blog post{% endblock %}
|
||||
|
|
15
gulpfile.js
15
gulpfile.js
|
@ -5,10 +5,12 @@ var gulp = require('gulp');
|
|||
// Styles
|
||||
var sass = require('gulp-sass');
|
||||
var concatCss = require('gulp-concat-css');
|
||||
var concatJs = require('gulp-concat');
|
||||
var merge = require('merge-stream');
|
||||
var minifyCss = require('gulp-minify-css');
|
||||
var livereload = require('gulp-livereload');
|
||||
var yargs = require('yargs').argv;
|
||||
var minify = require('gulp-minify');
|
||||
|
||||
var default_theme = 'v3'
|
||||
var theme = yargs.theme || default_theme;
|
||||
|
@ -26,6 +28,19 @@ gulp.task('sass', function () {
|
|||
.pipe(livereload());
|
||||
});
|
||||
|
||||
gulp.task('js', function () {
|
||||
var bowerStream = gulp.src([
|
||||
'./fmartingrcom/static/bower_components/google-code-prettify/bin/run_prettify.min.js'
|
||||
])
|
||||
return bowerStream
|
||||
.pipe(concatJs('app.js'))
|
||||
.pipe(minify({
|
||||
exclude: [],
|
||||
ignoreFiles: []
|
||||
}))
|
||||
.pipe(gulp.dest('./fmartingrcom/themes/' + theme + '/static/js'))
|
||||
})
|
||||
|
||||
gulp.task('livereload', function () {
|
||||
return gulp.src('./fmartingrcom/themes/' + theme + '/templates/**/*.html').pipe(livereload());
|
||||
});
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"gulp-concat": "^2.6.0",
|
||||
"gulp-concat-css": "^2.2.0",
|
||||
"gulp-livereload": "^3.8.1",
|
||||
"gulp-minify": "0.0.5",
|
||||
"gulp-minify-css": "^1.2.2",
|
||||
"gulp-sass": "^2.0.4",
|
||||
"merge-stream": "^1.0.0",
|
||||
|
|
Loading…
Reference in New Issue