diff --git a/article/__pycache__/models.cpython-36.pyc b/article/__pycache__/models.cpython-36.pyc index 4bce412..6bc0210 100644 Binary files a/article/__pycache__/models.cpython-36.pyc and b/article/__pycache__/models.cpython-36.pyc differ diff --git a/article/migrations/0008_article_cover.py b/article/migrations/0008_article_cover.py new file mode 100644 index 0000000..09a2555 --- /dev/null +++ b/article/migrations/0008_article_cover.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.2 on 2018-02-25 12:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('article', '0007_auto_20180224_0328'), + ] + + operations = [ + migrations.AddField( + model_name='article', + name='cover', + field=models.ImageField(blank=True, null=True, upload_to='upload/'), + ), + ] diff --git a/article/migrations/0009_auto_20180225_2027.py b/article/migrations/0009_auto_20180225_2027.py new file mode 100644 index 0000000..c263100 --- /dev/null +++ b/article/migrations/0009_auto_20180225_2027.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.2 on 2018-02-25 12:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('article', '0008_article_cover'), + ] + + operations = [ + migrations.AlterField( + model_name='article', + name='cover', + field=models.ImageField(blank=True, null=True, upload_to='static/upload/'), + ), + ] diff --git a/article/migrations/__pycache__/0008_article_cover.cpython-36.pyc b/article/migrations/__pycache__/0008_article_cover.cpython-36.pyc new file mode 100644 index 0000000..3801298 Binary files /dev/null and b/article/migrations/__pycache__/0008_article_cover.cpython-36.pyc differ diff --git a/article/migrations/__pycache__/0009_auto_20180225_2027.cpython-36.pyc b/article/migrations/__pycache__/0009_auto_20180225_2027.cpython-36.pyc new file mode 100644 index 0000000..16a650e Binary files /dev/null and b/article/migrations/__pycache__/0009_auto_20180225_2027.cpython-36.pyc differ diff --git a/article/models.py b/article/models.py index f8f2623..9597c68 100644 --- a/article/models.py +++ b/article/models.py @@ -27,6 +27,7 @@ class Article(models.Model): author = models.CharField(max_length=128,default='') #author_id = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE) publish_time = models.DateTimeField(auto_now_add=True) + cover = models.ImageField(upload_to='static/upload/', blank=True, null=True) title = models.CharField(max_length=1024) detail = HTMLField() ip = models.GenericIPAddressField(blank=True,null=True) diff --git a/db.sqlite3 b/db.sqlite3 index c7d5312..1cc89df 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/edconline/__pycache__/urls.cpython-36.pyc b/edconline/__pycache__/urls.cpython-36.pyc index 31f684b..27e4383 100644 Binary files a/edconline/__pycache__/urls.cpython-36.pyc and b/edconline/__pycache__/urls.cpython-36.pyc differ diff --git a/edconline/__pycache__/views.cpython-36.pyc b/edconline/__pycache__/views.cpython-36.pyc new file mode 100644 index 0000000..085f72c Binary files /dev/null and b/edconline/__pycache__/views.cpython-36.pyc differ diff --git a/edconline/urls.py b/edconline/urls.py index e9c52f4..0834bf3 100644 --- a/edconline/urls.py +++ b/edconline/urls.py @@ -20,6 +20,7 @@ import article import userpage import tinymce +import edconline.views as views admin.autodiscover() @@ -28,6 +29,7 @@ urlpatterns = [ + path('', views.homepage), path('admin/', admin.site.urls), path('xadmin/', xadmin.site.urls), path('tinymce/', include('tinymce.urls')), diff --git a/edconline/views.py b/edconline/views.py new file mode 100644 index 0000000..7fce85f --- /dev/null +++ b/edconline/views.py @@ -0,0 +1,30 @@ +from django.shortcuts import render +from django.http import HttpResponse,HttpResponseRedirect +from django.template import RequestContext,Template,Context,loader,defaultfilters +from django.shortcuts import render_to_response +from article.models import * +import os,random +import userpage + +# Create your views here. + +def user_login(request): + return { + 'username':request.user, + } + +def homepage(request): + + if request.user.is_authenticated :# and request.user.has_perm('cmdb.permit')): + username = request.user.username + else: + username = None + + imgs = os.listdir('static/upload/') + cover = random.sample(imgs,1)[0] + + arts = Article.objects.all() + secs = Section.objects.all() + return render(request,'index.html',{'cover':cover,'username':username,'arts':arts,'secs':secs}) + + diff --git a/static/bootstrap/css/style.css b/static/bootstrap/css/style.css index 7ef18af..372a49b 100755 --- a/static/bootstrap/css/style.css +++ b/static/bootstrap/css/style.css @@ -5,6 +5,20 @@ html,body { height: 100%; } +.banner { + top:0; + width:100%; + height:400px; + min-height:50px; + box-shadow: 0 0 12px 0 #25292e inset; +} + +.banner h1 { + position: relative; + top:250px; + color:white; +} + .navbar-collapse { background-color: rgba(38,41,46,0.9); box-shadow:0 0 2px 0 #25292e; @@ -30,8 +44,9 @@ ul.nav.navbar-nav li a:hover { text-decoration:none; } -.container-fluid { - padding-top:50px; +div.container-fluid { + margin:0; + position:relative; min-height:100%; /*设置padding-bottom值大于等于footer的height值,以保证main的内容能够全部显示出来而不被footer遮盖;*/ @@ -45,13 +60,48 @@ ul.nav.navbar-nav li a:hover { .card { width:100%; - margin:10px; padding:10px; + margin:10px; border: 1px solid #e2e2e2; box-shadow: 1px 1px 1px 1px #e2e2e2; background-color:white; } +.card .preview div { + display: block; + padding:0 20px 0 20px; +} + +.card a { + color:#d73a49; +} + +.card p { + padding:0 10px 0 10px; +} + +.card .preview .preview-image { + margin:0 20px 20px 20px; + width: auto; + height:130px; +} + +.fad { + color:gray; +} + +.card .sep { + display:block; + margin-bottom:10px; + border-bottom:1px solid #e2e2e2; +} + + + + + + + footer { position: absolute; @@ -69,8 +119,11 @@ footer, footer a{ padding:20px; } - .foot-wrap .foot-bottom { padding: 20px; border-top:1px solid rgba(255,255,255,.2); } + + + + diff --git a/static/upload/Intersection_Color_Mbp17.jpg b/static/upload/Intersection_Color_Mbp17.jpg new file mode 100644 index 0000000..60c0755 Binary files /dev/null and b/static/upload/Intersection_Color_Mbp17.jpg differ diff --git a/static/upload/bg_member.jpg b/static/upload/bg_member.jpg new file mode 100644 index 0000000..7d73fdd Binary files /dev/null and b/static/upload/bg_member.jpg differ diff --git a/static/upload/clock.jpg b/static/upload/clock.jpg new file mode 100644 index 0000000..bccce76 Binary files /dev/null and b/static/upload/clock.jpg differ diff --git a/templates/.base.html.swp b/templates/.base.html.swp deleted file mode 100644 index ac26b81..0000000 Binary files a/templates/.base.html.swp and /dev/null differ diff --git a/static/bootstrap/css/.style.css.swp b/templates/.index.html.swp similarity index 84% rename from static/bootstrap/css/.style.css.swp rename to templates/.index.html.swp index b5e42d4..a561004 100644 Binary files a/static/bootstrap/css/.style.css.swp and b/templates/.index.html.swp differ diff --git a/templates/base.html b/templates/base.html index 835e682..6e2b140 100644 --- a/templates/base.html +++ b/templates/base.html @@ -20,12 +20,13 @@ + {% block banner %} + + {% endblock %} +
- + {% block content %}

这里是正文栏

这里是正文栏

@@ -79,48 +88,46 @@

这里是正文栏

这里是正文栏

+ {% endblock%}
+ {% endblock %}
- diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..835cef5 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,48 @@ +{% extends 'base.html' %} + + +{% block banner %} + +{% endblock %} + +{% block content %} + + {% for i in arts %} +
+
+
+

+
+
+

{{i.title}}

+

{{i.detail|truncatewords:"30"|striptags}}

+  {{i.publish_time}} +     +  {{i.author}} + + 阅读全文 + +
+
+ +
+ {% endfor %} + +{% endblock %} + +{% block sidebar %} + +
+

分类

+ + {% for i in secs %} +

{{i.name}}

+ + {% endfor %} +
+ +{% endblock %} diff --git a/userpage/templates/userpage/profile.html b/userpage/templates/userpage/profile.html index 9f2a0ae..0c91369 100644 --- a/userpage/templates/userpage/profile.html +++ b/userpage/templates/userpage/profile.html @@ -1,16 +1,21 @@ +{% extends "base.html"%} -{% if messages %} -
    - {% for message in messages %} - {{ message }} - {% endfor %} -
-{% endif %} - -
- {% csrf_token %} - {{ user_form.as_p }} - {{ profile_form.as_p }} - -
+{% block content%} + {% if messages %} +
    + {% for message in messages %} + {{ message }} + {% endfor %} +
+ {% endif %} + +
+
+ {% csrf_token %} + {{ user_form.as_p }} + {{ profile_form.as_p }} + +
+
+{% endblock %}