Skip to content

Commit

Permalink
update homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
gothack329 committed Feb 25, 2018
1 parent f9da029 commit 58b263d
Show file tree
Hide file tree
Showing 20 changed files with 226 additions and 44 deletions.
Binary file modified article/__pycache__/models.cpython-36.pyc
Binary file not shown.
18 changes: 18 additions & 0 deletions article/migrations/0008_article_cover.py
Original file line number Diff line number Diff line change
@@ -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/'),
),
]
18 changes: 18 additions & 0 deletions article/migrations/0009_auto_20180225_2027.py
Original file line number Diff line number Diff line change
@@ -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/'),
),
]
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions article/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
Binary file modified edconline/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added edconline/__pycache__/views.cpython-36.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions edconline/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import article
import userpage
import tinymce
import edconline.views as views

admin.autodiscover()

Expand All @@ -28,6 +29,7 @@


urlpatterns = [
path('', views.homepage),
path('admin/', admin.site.urls),
path('xadmin/', xadmin.site.urls),
path('tinymce/', include('tinymce.urls')),
Expand Down
30 changes: 30 additions & 0 deletions edconline/views.py
Original file line number Diff line number Diff line change
@@ -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})


61 changes: 57 additions & 4 deletions static/bootstrap/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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遮盖;*/
Expand All @@ -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;
Expand All @@ -69,8 +119,11 @@ footer, footer a{
padding:20px;
}


.foot-wrap .foot-bottom {
padding: 20px;
border-top:1px solid rgba(255,255,255,.2);
}




Binary file added static/upload/Intersection_Color_Mbp17.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/upload/bg_member.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/upload/clock.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed templates/.base.html.swp
Binary file not shown.
Binary file not shown.
59 changes: 33 additions & 26 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
<nav class="navbar-collapse collapse navbar-fixed-top">
<div class="container">
<ul class="nav navbar-nav">
<li> <p></p> </li>
<li class="css106de12c1c1bfaa ">
<a class="logo" href='/'>物志</a>
</li>
<li class="navbar-right">
{% if user.login %}
头像
{% if username %}
<a href="#">{{username}}</a>
{% else%}
<a href="#">登录</a>
{% endif %}
Expand All @@ -35,11 +36,19 @@
</div>
</nav>

{% block banner %}
<div class="banner">
<div class="container">
<h1>{% if title %}{{title}}{% endif %} </h1>
</div>
</div>
{% endblock %}

<div class="container-fluid">
<div class="container">
<div class="row ">
<div class="content col-md-8">

{% block content %}
<div class="card">
<p>这里是正文栏</p>
<p>这里是正文栏</p>
Expand Down Expand Up @@ -79,48 +88,46 @@
<p>这里是正文栏</p>
<p>这里是正文栏</p>
</div>
{% endblock%}

</div>

<div class="sidebar col-md-4">
{% block sidebar %}
{% endblock %}
<div class="card">
<p>这里是右侧边栏</p>
<p>用户模块</p>
<p>这里是右侧边栏</p>
<p>这里是右侧边栏</p>
</div>
<div class="card">
<p>广告</p>
<p>这里是右侧边栏</p>
<p>这里是右侧边栏</p>
<p>这里是右侧边栏</p>
</div>
</div>
{% endblock %}

</div>
</div>
</div>

<footer class="foot-wrap">
<!--采用container,使得页尾内容居中 -->
<div class="container">
<section class="foot-top">
<strong>
<a href="" >关于</a>
<a href="" >关于</a>
<a href="" >关于</a>
<a href="" >关于</a>
<strong>
</section>

<section class="foot-bottom">
<span class="css106de12c1c1bfaa" style="font-size:30px;font-color:#d73a49">
<a class="logo" href='/'>物志</a>
</span>
Copyright ©2018
</section>
</div>
<footer class="foot-wrap">
<div class="container">
<section class="foot-top">
<strong>
<a href="" >关于</a>
<strong>
</section>

<section class="foot-bottom">
<span class="css106de12c1c1bfaa" style="font-size:30px;font-color:#d73a49">
<a class="logo" href='/'>物志</a>
</span>
Copyright ©2018
</section>
</div>
</footer>

</footer>

<script src="/static/bootstrap/js/jquery.min.js"></script>
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
Expand Down
48 changes: 48 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% extends 'base.html' %}


{% block banner %}
<div class="banner" style="background:url(/static/upload/{{cover}}) no-repeat;background-position:center;background-size:cover;">
<div class="container">
<h1>{% if title %}{{title}}{% endif %} </h1>
</div>
</div>
{% endblock %}

{% block content %}

{% for i in arts %}
<div class="card">
<div class="preview row">
<div class="preview-image" style="background:url({{i.cover}}) no-repeat;background-position:center;background-size:cover;">
<p></p>
</div>
<div class="preview-info">
<h2>{{i.title}}</h2>
<p class="fad">{{i.detail|truncatewords:"30"|striptags}}</p>
<span class="glyphicon glyphicon-time fad"> </span>&nbsp;<span class="fad">{{i.publish_time}}</span>
&nbsp;&nbsp;&nbsp;
<span class="glyphicon glyphicon-user fad"> </span>&nbsp;<span class="fad">{{i.author}}</span>
<span class="pull-right">
<span><a href="/article/{{i.id}}/">阅读全文</a></span>
</span>
</div>
</div>

</div>
{% endfor %}

{% endblock %}

{% block sidebar %}

<div class="card">
<h4>分类</h4>
<span class="sep"></span>
{% for i in secs %}
<p><a href="">{{i.name}}</a></p>
<span class="sep"></span>
{% endfor %}
</div>

{% endblock %}
33 changes: 19 additions & 14 deletions userpage/templates/userpage/profile.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{% extends "base.html"%}


{% if messages %}
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}

<form method="post">
{% csrf_token %}
{{ user_form.as_p }}
{{ profile_form.as_p }}
<button type="submit">Save changes</button>
</form>
{% block content%}
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}

<div class="card">
<form method="post">
{% csrf_token %}
{{ user_form.as_p }}
{{ profile_form.as_p }}
<button type="submit">Save changes</button>
</form>
</div>
{% endblock %}

0 comments on commit 58b263d

Please sign in to comment.