commit
99be726e95
@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
@version: ??
|
||||||
|
@author: liangliangyy
|
||||||
|
@license: MIT Licence
|
||||||
|
@contact: liangliangyy@gmail.com
|
||||||
|
@site: https://www.lylinux.org/
|
||||||
|
@software: PyCharm
|
||||||
|
@file: create_testdata.py
|
||||||
|
@time: 2017/3/11 上午1:58
|
||||||
|
"""
|
||||||
|
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from blog.models import Article, Tag, Category
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'create test datas'
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
user = \
|
||||||
|
get_user_model().objects.get_or_create(email='test@test.com', username='testuser',
|
||||||
|
password='test!q@w#eTYU')[0]
|
||||||
|
|
||||||
|
pcategory = Category.objects.get_or_create(name='pcategory', parent_category=None)[0]
|
||||||
|
|
||||||
|
category = Category.objects.get_or_create(name='category', parent_category=pcategory)[0]
|
||||||
|
|
||||||
|
category.save()
|
||||||
|
for i in range(1, 10):
|
||||||
|
article = Article.objects.get_or_create(category=category,
|
||||||
|
title='nice title ' + str(i),
|
||||||
|
body='nice content ' + str(i),
|
||||||
|
author=user
|
||||||
|
)
|
||||||
|
from DjangoBlog.utils import cache
|
||||||
|
cache.clear()
|
||||||
|
self.stdout.write(self.style.SUCCESS('created test datas \n'))
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
/* Make clicks pass-through */
|
||||||
|
#nprogress {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nprogress .bar {
|
||||||
|
background: red;
|
||||||
|
|
||||||
|
position: fixed;
|
||||||
|
z-index: 1031;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
height: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fancy blur effect */
|
||||||
|
#nprogress .peg {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
right: 0px;
|
||||||
|
width: 100px;
|
||||||
|
height: 100%;
|
||||||
|
box-shadow: 0 0 10px #29d, 0 0 5px #29d;
|
||||||
|
opacity: 1.0;
|
||||||
|
|
||||||
|
-webkit-transform: rotate(3deg) translate(0px, -4px);
|
||||||
|
-ms-transform: rotate(3deg) translate(0px, -4px);
|
||||||
|
transform: rotate(3deg) translate(0px, -4px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove these to get rid of the spinner */
|
||||||
|
#nprogress .spinner {
|
||||||
|
display: block;
|
||||||
|
position: fixed;
|
||||||
|
z-index: 1031;
|
||||||
|
top: 15px;
|
||||||
|
right: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nprogress .spinner-icon {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
border: solid 2px transparent;
|
||||||
|
border-top-color: red;
|
||||||
|
border-left-color: red;
|
||||||
|
border-radius: 50%;
|
||||||
|
|
||||||
|
-webkit-animation: nprogress-spinner 400ms linear infinite;
|
||||||
|
animation: nprogress-spinner 400ms linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nprogress-custom-parent {
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nprogress-custom-parent #nprogress .spinner,
|
||||||
|
.nprogress-custom-parent #nprogress .bar {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes nprogress-spinner {
|
||||||
|
0% { -webkit-transform: rotate(0deg); }
|
||||||
|
100% { -webkit-transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
@keyframes nprogress-spinner {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,305 @@
|
|||||||
|
|
||||||
|
.icon-sn-google {
|
||||||
|
background-position: 0 -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-google {
|
||||||
|
background-color: #4285f4;
|
||||||
|
background-position: 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-google {
|
||||||
|
color: #4285f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-github {
|
||||||
|
background-position: -28px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-github {
|
||||||
|
background-color: #333;
|
||||||
|
background-position: -28px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-github {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-weibo {
|
||||||
|
background-position: -56px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-weibo {
|
||||||
|
background-color: #e90d24;
|
||||||
|
background-position: -56px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-weibo {
|
||||||
|
color: #e90d24;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-qq {
|
||||||
|
background-position: -84px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-qq {
|
||||||
|
background-color: #0098e6;
|
||||||
|
background-position: -84px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-qq {
|
||||||
|
color: #0098e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-twitter {
|
||||||
|
background-position: -112px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-twitter {
|
||||||
|
background-color: #50abf1;
|
||||||
|
background-position: -112px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-twitter {
|
||||||
|
color: #50abf1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-facebook {
|
||||||
|
background-position: -140px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-facebook {
|
||||||
|
background-color: #4862a3;
|
||||||
|
background-position: -140px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-facebook {
|
||||||
|
color: #4862a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-renren {
|
||||||
|
background-position: -168px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-renren {
|
||||||
|
background-color: #197bc8;
|
||||||
|
background-position: -168px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-renren {
|
||||||
|
color: #197bc8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-tqq {
|
||||||
|
background-position: -196px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-tqq {
|
||||||
|
background-color: #1f9ed2;
|
||||||
|
background-position: -196px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-tqq {
|
||||||
|
color: #1f9ed2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-douban {
|
||||||
|
background-position: -224px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-douban {
|
||||||
|
background-color: #279738;
|
||||||
|
background-position: -224px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-douban {
|
||||||
|
color: #279738;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-weixin {
|
||||||
|
background-position: -252px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-weixin {
|
||||||
|
background-color: #00b500;
|
||||||
|
background-position: -252px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-weixin {
|
||||||
|
color: #00b500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-dotted {
|
||||||
|
background-position: -280px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-dotted {
|
||||||
|
background-color: #eee;
|
||||||
|
background-position: -280px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-dotted {
|
||||||
|
color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-site {
|
||||||
|
background-position: -308px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-site {
|
||||||
|
background-color: #00b500;
|
||||||
|
background-position: -308px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-site {
|
||||||
|
color: #00b500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-linkedin {
|
||||||
|
background-position: -336px -28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-sn-bg-linkedin {
|
||||||
|
background-color: #0077b9;
|
||||||
|
background-position: -336px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa-sn-linkedin {
|
||||||
|
color: #0077b9;
|
||||||
|
}
|
||||||
|
|
||||||
|
[class*=icon-sn-] {
|
||||||
|
display: inline-block;
|
||||||
|
background-image: url('../img/icon-sn.svg');
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
vertical-align: middle;
|
||||||
|
background-size: auto 56px;
|
||||||
|
}
|
||||||
|
|
||||||
|
[class*=icon-sn-]:hover {
|
||||||
|
opacity: .8;
|
||||||
|
filter: alpha(opacity=80);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-google {
|
||||||
|
background: #4285f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-google:active, .btn-sn-google:focus, .btn-sn-google:hover {
|
||||||
|
background: #2a75f3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-github {
|
||||||
|
background: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-github:active, .btn-sn-github:focus, .btn-sn-github:hover {
|
||||||
|
background: #262626;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-weibo {
|
||||||
|
background: #e90d24;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-weibo:active, .btn-sn-weibo:focus, .btn-sn-weibo:hover {
|
||||||
|
background: #d10c20;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-qq {
|
||||||
|
background: #0098e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-qq:active, .btn-sn-qq:focus, .btn-sn-qq:hover {
|
||||||
|
background: #0087cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-twitter {
|
||||||
|
background: #50abf1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-twitter:active, .btn-sn-twitter:focus, .btn-sn-twitter:hover {
|
||||||
|
background: #38a0ef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-facebook {
|
||||||
|
background: #4862a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-facebook:active, .btn-sn-facebook:focus, .btn-sn-facebook:hover {
|
||||||
|
background: #405791;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-renren {
|
||||||
|
background: #197bc8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-renren:active, .btn-sn-renren:focus, .btn-sn-renren:hover {
|
||||||
|
background: #166db1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-tqq {
|
||||||
|
background: #1f9ed2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-tqq:active, .btn-sn-tqq:focus, .btn-sn-tqq:hover {
|
||||||
|
background: #1c8dbc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-douban {
|
||||||
|
background: #279738;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-douban:active, .btn-sn-douban:focus, .btn-sn-douban:hover {
|
||||||
|
background: #228330;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-weixin {
|
||||||
|
background: #00b500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-weixin:active, .btn-sn-weixin:focus, .btn-sn-weixin:hover {
|
||||||
|
background: #009c00;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-dotted {
|
||||||
|
background: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-dotted:active, .btn-sn-dotted:focus, .btn-sn-dotted:hover {
|
||||||
|
background: #e1e1e1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-site {
|
||||||
|
background: #00b500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-site:active, .btn-sn-site:focus, .btn-sn-site:hover {
|
||||||
|
background: #009c00;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-linkedin {
|
||||||
|
background: #0077b9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-linkedin:active, .btn-sn-linkedin:focus, .btn-sn-linkedin:hover {
|
||||||
|
background: #0067a0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[class*=btn-sn-], [class*=btn-sn-]:active, [class*=btn-sn-]:focus, [class*=btn-sn-]:hover {
|
||||||
|
border: none;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-more {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sn-more, .btn-sn-more:active, .btn-sn-more:hover {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
[class*=btn-sn-] [class*=icon-sn-] {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
@ -0,0 +1,480 @@
|
|||||||
|
/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
|
||||||
|
* @license MIT */
|
||||||
|
|
||||||
|
;(function(root, factory) {
|
||||||
|
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
define(factory);
|
||||||
|
} else if (typeof exports === 'object') {
|
||||||
|
module.exports = factory();
|
||||||
|
} else {
|
||||||
|
root.NProgress = factory();
|
||||||
|
}
|
||||||
|
|
||||||
|
})(this, function() {
|
||||||
|
var NProgress = {};
|
||||||
|
|
||||||
|
NProgress.version = '0.2.0';
|
||||||
|
|
||||||
|
var Settings = NProgress.settings = {
|
||||||
|
minimum: 0.08,
|
||||||
|
easing: 'linear',
|
||||||
|
positionUsing: '',
|
||||||
|
speed: 200,
|
||||||
|
trickle: true,
|
||||||
|
trickleSpeed: 200,
|
||||||
|
showSpinner: true,
|
||||||
|
barSelector: '[role="bar"]',
|
||||||
|
spinnerSelector: '[role="spinner"]',
|
||||||
|
parent: 'body',
|
||||||
|
template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates configuration.
|
||||||
|
*
|
||||||
|
* NProgress.configure({
|
||||||
|
* minimum: 0.1
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
NProgress.configure = function(options) {
|
||||||
|
var key, value;
|
||||||
|
for (key in options) {
|
||||||
|
value = options[key];
|
||||||
|
if (value !== undefined && options.hasOwnProperty(key)) Settings[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last number.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NProgress.status = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the progress bar status, where `n` is a number from `0.0` to `1.0`.
|
||||||
|
*
|
||||||
|
* NProgress.set(0.4);
|
||||||
|
* NProgress.set(1.0);
|
||||||
|
*/
|
||||||
|
|
||||||
|
NProgress.set = function(n) {
|
||||||
|
var started = NProgress.isStarted();
|
||||||
|
|
||||||
|
n = clamp(n, Settings.minimum, 1);
|
||||||
|
NProgress.status = (n === 1 ? null : n);
|
||||||
|
|
||||||
|
var progress = NProgress.render(!started),
|
||||||
|
bar = progress.querySelector(Settings.barSelector),
|
||||||
|
speed = Settings.speed,
|
||||||
|
ease = Settings.easing;
|
||||||
|
|
||||||
|
progress.offsetWidth; /* Repaint */
|
||||||
|
|
||||||
|
queue(function(next) {
|
||||||
|
// Set positionUsing if it hasn't already been set
|
||||||
|
if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS();
|
||||||
|
|
||||||
|
// Add transition
|
||||||
|
css(bar, barPositionCSS(n, speed, ease));
|
||||||
|
|
||||||
|
if (n === 1) {
|
||||||
|
// Fade out
|
||||||
|
css(progress, {
|
||||||
|
transition: 'none',
|
||||||
|
opacity: 1
|
||||||
|
});
|
||||||
|
progress.offsetWidth; /* Repaint */
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
css(progress, {
|
||||||
|
transition: 'all ' + speed + 'ms linear',
|
||||||
|
opacity: 0
|
||||||
|
});
|
||||||
|
setTimeout(function() {
|
||||||
|
NProgress.remove();
|
||||||
|
next();
|
||||||
|
}, speed);
|
||||||
|
}, speed);
|
||||||
|
} else {
|
||||||
|
setTimeout(next, speed);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
NProgress.isStarted = function() {
|
||||||
|
return typeof NProgress.status === 'number';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the progress bar.
|
||||||
|
* This is the same as setting the status to 0%, except that it doesn't go backwards.
|
||||||
|
*
|
||||||
|
* NProgress.start();
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
NProgress.start = function() {
|
||||||
|
if (!NProgress.status) NProgress.set(0);
|
||||||
|
|
||||||
|
var work = function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
if (!NProgress.status) return;
|
||||||
|
NProgress.trickle();
|
||||||
|
work();
|
||||||
|
}, Settings.trickleSpeed);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Settings.trickle) work();
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides the progress bar.
|
||||||
|
* This is the *sort of* the same as setting the status to 100%, with the
|
||||||
|
* difference being `done()` makes some placebo effect of some realistic motion.
|
||||||
|
*
|
||||||
|
* NProgress.done();
|
||||||
|
*
|
||||||
|
* If `true` is passed, it will show the progress bar even if its hidden.
|
||||||
|
*
|
||||||
|
* NProgress.done(true);
|
||||||
|
*/
|
||||||
|
|
||||||
|
NProgress.done = function(force) {
|
||||||
|
if (!force && !NProgress.status) return this;
|
||||||
|
|
||||||
|
return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increments by a random amount.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NProgress.inc = function(amount) {
|
||||||
|
var n = NProgress.status;
|
||||||
|
|
||||||
|
if (!n) {
|
||||||
|
return NProgress.start();
|
||||||
|
} else if(n > 1) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (typeof amount !== 'number') {
|
||||||
|
if (n >= 0 && n < 0.2) { amount = 0.1; }
|
||||||
|
else if (n >= 0.2 && n < 0.5) { amount = 0.04; }
|
||||||
|
else if (n >= 0.5 && n < 0.8) { amount = 0.02; }
|
||||||
|
else if (n >= 0.8 && n < 0.99) { amount = 0.005; }
|
||||||
|
else { amount = 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
n = clamp(n + amount, 0, 0.994);
|
||||||
|
return NProgress.set(n);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NProgress.trickle = function() {
|
||||||
|
return NProgress.inc();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits for all supplied jQuery promises and
|
||||||
|
* increases the progress as the promises resolve.
|
||||||
|
*
|
||||||
|
* @param $promise jQUery Promise
|
||||||
|
*/
|
||||||
|
(function() {
|
||||||
|
var initial = 0, current = 0;
|
||||||
|
|
||||||
|
NProgress.promise = function($promise) {
|
||||||
|
if (!$promise || $promise.state() === "resolved") {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current === 0) {
|
||||||
|
NProgress.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
initial++;
|
||||||
|
current++;
|
||||||
|
|
||||||
|
$promise.always(function() {
|
||||||
|
current--;
|
||||||
|
if (current === 0) {
|
||||||
|
initial = 0;
|
||||||
|
NProgress.done();
|
||||||
|
} else {
|
||||||
|
NProgress.set((initial - current) / initial);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Internal) renders the progress bar markup based on the `template`
|
||||||
|
* setting.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NProgress.render = function(fromStart) {
|
||||||
|
if (NProgress.isRendered()) return document.getElementById('nprogress');
|
||||||
|
|
||||||
|
addClass(document.documentElement, 'nprogress-busy');
|
||||||
|
|
||||||
|
var progress = document.createElement('div');
|
||||||
|
progress.id = 'nprogress';
|
||||||
|
progress.innerHTML = Settings.template;
|
||||||
|
|
||||||
|
var bar = progress.querySelector(Settings.barSelector),
|
||||||
|
perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
|
||||||
|
parent = document.querySelector(Settings.parent),
|
||||||
|
spinner;
|
||||||
|
|
||||||
|
css(bar, {
|
||||||
|
transition: 'all 0 linear',
|
||||||
|
transform: 'translate3d(' + perc + '%,0,0)'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!Settings.showSpinner) {
|
||||||
|
spinner = progress.querySelector(Settings.spinnerSelector);
|
||||||
|
spinner && removeElement(spinner);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent != document.body) {
|
||||||
|
addClass(parent, 'nprogress-custom-parent');
|
||||||
|
}
|
||||||
|
|
||||||
|
parent.appendChild(progress);
|
||||||
|
return progress;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the element. Opposite of render().
|
||||||
|
*/
|
||||||
|
|
||||||
|
NProgress.remove = function() {
|
||||||
|
removeClass(document.documentElement, 'nprogress-busy');
|
||||||
|
removeClass(document.querySelector(Settings.parent), 'nprogress-custom-parent');
|
||||||
|
var progress = document.getElementById('nprogress');
|
||||||
|
progress && removeElement(progress);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the progress bar is rendered.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NProgress.isRendered = function() {
|
||||||
|
return !!document.getElementById('nprogress');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine which positioning CSS rule to use.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NProgress.getPositioningCSS = function() {
|
||||||
|
// Sniff on document.body.style
|
||||||
|
var bodyStyle = document.body.style;
|
||||||
|
|
||||||
|
// Sniff prefixes
|
||||||
|
var vendorPrefix = ('WebkitTransform' in bodyStyle) ? 'Webkit' :
|
||||||
|
('MozTransform' in bodyStyle) ? 'Moz' :
|
||||||
|
('msTransform' in bodyStyle) ? 'ms' :
|
||||||
|
('OTransform' in bodyStyle) ? 'O' : '';
|
||||||
|
|
||||||
|
if (vendorPrefix + 'Perspective' in bodyStyle) {
|
||||||
|
// Modern browsers with 3D support, e.g. Webkit, IE10
|
||||||
|
return 'translate3d';
|
||||||
|
} else if (vendorPrefix + 'Transform' in bodyStyle) {
|
||||||
|
// Browsers without 3D support, e.g. IE9
|
||||||
|
return 'translate';
|
||||||
|
} else {
|
||||||
|
// Browsers without translate() support, e.g. IE7-8
|
||||||
|
return 'margin';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helpers
|
||||||
|
*/
|
||||||
|
|
||||||
|
function clamp(n, min, max) {
|
||||||
|
if (n < min) return min;
|
||||||
|
if (n > max) return max;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Internal) converts a percentage (`0..1`) to a bar translateX
|
||||||
|
* percentage (`-100%..0%`).
|
||||||
|
*/
|
||||||
|
|
||||||
|
function toBarPerc(n) {
|
||||||
|
return (-1 + n) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Internal) returns the correct CSS for changing the bar's
|
||||||
|
* position given an n percentage, and speed and ease from Settings
|
||||||
|
*/
|
||||||
|
|
||||||
|
function barPositionCSS(n, speed, ease) {
|
||||||
|
var barCSS;
|
||||||
|
|
||||||
|
if (Settings.positionUsing === 'translate3d') {
|
||||||
|
barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };
|
||||||
|
} else if (Settings.positionUsing === 'translate') {
|
||||||
|
barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };
|
||||||
|
} else {
|
||||||
|
barCSS = { 'margin-left': toBarPerc(n)+'%' };
|
||||||
|
}
|
||||||
|
|
||||||
|
barCSS.transition = 'all '+speed+'ms '+ease;
|
||||||
|
|
||||||
|
return barCSS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Internal) Queues a function to be executed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var queue = (function() {
|
||||||
|
var pending = [];
|
||||||
|
|
||||||
|
function next() {
|
||||||
|
var fn = pending.shift();
|
||||||
|
if (fn) {
|
||||||
|
fn(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return function(fn) {
|
||||||
|
pending.push(fn);
|
||||||
|
if (pending.length == 1) next();
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Internal) Applies css properties to an element, similar to the jQuery
|
||||||
|
* css method.
|
||||||
|
*
|
||||||
|
* While this helper does assist with vendor prefixed property names, it
|
||||||
|
* does not perform any manipulation of values prior to setting styles.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var css = (function() {
|
||||||
|
var cssPrefixes = [ 'Webkit', 'O', 'Moz', 'ms' ],
|
||||||
|
cssProps = {};
|
||||||
|
|
||||||
|
function camelCase(string) {
|
||||||
|
return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function(match, letter) {
|
||||||
|
return letter.toUpperCase();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVendorProp(name) {
|
||||||
|
var style = document.body.style;
|
||||||
|
if (name in style) return name;
|
||||||
|
|
||||||
|
var i = cssPrefixes.length,
|
||||||
|
capName = name.charAt(0).toUpperCase() + name.slice(1),
|
||||||
|
vendorName;
|
||||||
|
while (i--) {
|
||||||
|
vendorName = cssPrefixes[i] + capName;
|
||||||
|
if (vendorName in style) return vendorName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStyleProp(name) {
|
||||||
|
name = camelCase(name);
|
||||||
|
return cssProps[name] || (cssProps[name] = getVendorProp(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyCss(element, prop, value) {
|
||||||
|
prop = getStyleProp(prop);
|
||||||
|
element.style[prop] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return function(element, properties) {
|
||||||
|
var args = arguments,
|
||||||
|
prop,
|
||||||
|
value;
|
||||||
|
|
||||||
|
if (args.length == 2) {
|
||||||
|
for (prop in properties) {
|
||||||
|
value = properties[prop];
|
||||||
|
if (value !== undefined && properties.hasOwnProperty(prop)) applyCss(element, prop, value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
applyCss(element, args[1], args[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Internal) Determines if an element or space separated list of class names contains a class name.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function hasClass(element, name) {
|
||||||
|
var list = typeof element == 'string' ? element : classList(element);
|
||||||
|
return list.indexOf(' ' + name + ' ') >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Internal) Adds a class to an element.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function addClass(element, name) {
|
||||||
|
var oldList = classList(element),
|
||||||
|
newList = oldList + name;
|
||||||
|
|
||||||
|
if (hasClass(oldList, name)) return;
|
||||||
|
|
||||||
|
// Trim the opening space.
|
||||||
|
element.className = newList.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Internal) Removes a class from an element.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function removeClass(element, name) {
|
||||||
|
var oldList = classList(element),
|
||||||
|
newList;
|
||||||
|
|
||||||
|
if (!hasClass(element, name)) return;
|
||||||
|
|
||||||
|
// Replace the class name.
|
||||||
|
newList = oldList.replace(' ' + name + ' ', ' ');
|
||||||
|
|
||||||
|
// Trim the opening and closing spaces.
|
||||||
|
element.className = newList.substring(1, newList.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Internal) Gets a space separated list of the class names on the element.
|
||||||
|
* The list is wrapped with a single space on each end to facilitate finding
|
||||||
|
* matches within the list.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function classList(element) {
|
||||||
|
return (' ' + (element && element.className || '') + ' ').replace(/\s+/gi, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Internal) Removes an element from the DOM.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function removeElement(element) {
|
||||||
|
element && element.parentNode && element.parentNode.removeChild(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NProgress;
|
||||||
|
});
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
@version: ??
|
||||||
|
@author: liangliangyy
|
||||||
|
@license: MIT Licence
|
||||||
|
@contact: liangliangyy@gmail.com
|
||||||
|
@site: https://www.lylinux.org/
|
||||||
|
@software: PyCharm
|
||||||
|
@file: forms.py
|
||||||
|
@time: 2017/3/7 下午8:58
|
||||||
|
"""
|
||||||
|
|
||||||
|
from django.contrib.auth.forms import forms
|
||||||
|
from django.forms import widgets
|
||||||
|
|
||||||
|
|
||||||
|
class RequireEmailForm(forms.Form):
|
||||||
|
email = forms.EmailField(label='电子邮箱', required=True)
|
||||||
|
oauthid = forms.IntegerField(widget=forms.HiddenInput, required=False)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(RequireEmailForm, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['email'].widget = widgets.EmailInput(attrs={'placeholder': "email", "class": "form-control"})
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
@version: ??
|
||||||
|
@author: liangliangyy
|
||||||
|
@license: MIT Licence
|
||||||
|
@contact: liangliangyy@gmail.com
|
||||||
|
@site: https://www.lylinux.org/
|
||||||
|
@software: PyCharm
|
||||||
|
@file: __init__.py
|
||||||
|
@time: 2017/3/4 下午3:22
|
||||||
|
"""
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
@version: ??
|
||||||
|
@author: liangliangyy
|
||||||
|
@license: MIT Licence
|
||||||
|
@contact: liangliangyy@gmail.com
|
||||||
|
@site: https://www.lylinux.org/
|
||||||
|
@software: PyCharm
|
||||||
|
@file: oauth_tags.py
|
||||||
|
@time: 2017/3/4 下午3:22
|
||||||
|
"""
|
||||||
|
from oauth.oauthmanager import get_oauth_apps
|
||||||
|
|
||||||
|
from django import template
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.inclusion_tag('oauth/oauth_applications.html')
|
||||||
|
def load_oauth_applications():
|
||||||
|
applications = get_oauth_apps()
|
||||||
|
apps = list(map(lambda x: (x.ICON_NAME, x.get_authorization_url()), applications))
|
||||||
|
return {
|
||||||
|
'apps': apps
|
||||||
|
}
|
||||||
@ -1,13 +1,3 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
|
||||||
class OAuthTet(TestCase):
|
|
||||||
def setUp(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
from oauth.oauthmanager import WBOauthManager
|
|
||||||
from django.conf import settings
|
|
||||||
settings.OAHUTH['sina']
|
|
||||||
manager=WBOauthManager(client_id=settings.OAHUTH['sina']['appkey'],client_secret=settings.OAHUTH['sina']['appsecret'],callback_url=settings.OAHUTH['sina']['callbackurl'])
|
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
<div class="widget-login">
|
||||||
|
<small>
|
||||||
|
快捷登录:
|
||||||
|
</small>
|
||||||
|
{% for icon,url in apps %}
|
||||||
|
<a href="{{ url }}" rel="nofollow">
|
||||||
|
<span class="icon-sn-{{ icon }}"></span>
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
{% extends 'share_layout/base_account.html' %}
|
||||||
|
|
||||||
|
{% load static %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<h2 class="form-signin-heading text-center">Binding E-mail account</h2>
|
||||||
|
|
||||||
|
<div class="card card-signin">
|
||||||
|
{% if picture %}
|
||||||
|
<img class="img-circle profile-img" src="{{ picture }}" alt="">
|
||||||
|
{% else %}
|
||||||
|
<img class="img-circle profile-img" src="{% static 'blog/img/avatar.png' %}" alt="">
|
||||||
|
{% endif %}
|
||||||
|
<form class="form-signin" action="" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% comment %}<label for="inputEmail" class="sr-only">Email address</label>
|
||||||
|
<input type="email" id="inputEmail" class="form-control" placeholder="Email" required autofocus>
|
||||||
|
<label for="inputPassword" class="sr-only">Password</label>
|
||||||
|
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>{% endcomment %}
|
||||||
|
{{ form.non_field_errors }}
|
||||||
|
{% for field in form %}
|
||||||
|
{{ field }}
|
||||||
|
{{ field.errors }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
<button class="btn btn-lg btn-primary btn-block" type="submit">Submit</button>
|
||||||
|
|
||||||
|
{% comment %}
|
||||||
|
<div class="checkbox">
|
||||||
|
<a class="pull-right">Need help?</a>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" value="remember-me"> Stay signed in
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{% endcomment %}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="text-center">
|
||||||
|
<a href="{% url "account:login" %}">Sign In</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div> <!-- /container -->
|
||||||
|
{% endblock %}
|
||||||
Loading…
Reference in new issue