-
Notifications
You must be signed in to change notification settings - Fork 0
/
INTERFACES
92 lines (71 loc) · 3.27 KB
/
INTERFACES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
Last Modified: 2013-01-26 By Thomas Dean <mrdean@yeah.net>
--------------------------------------------------------------------
Website Structure
The website is composed of 6 parts. The details is described in the
separated INTERFACES for each part. For example, the detailed
INTERFACES for homepage is placed in /homepage/INTERFACES.
1. homepage
The index page (homepage) of the website.
2. activity
The part that shows the activities held by the class.
3. chat
The jiecaoless chat board for classmates.
4. photo
The online photo viewer.
5. resources
The resources-downloaded site.
6. account
Account management page.
All the templates and related images should be placed in directory
/templates.
------------------------------------------------------------------
How to write an INTERFACES file.
First of all, English please. You see, this file is written
obscurely due to my broken written English skills, but I'm trying to
make it easy to understand and concise. So, don't panic. Just try it.
Next is what should be written in INTERFACES. Besides what movies have
been watched by our dear God Two Tons and their torrents, you should
make clear three things: the template file this part (I'm going to say
'app' rather than 'part' in accord with django termiology, but you
should know that they are the same thing) needs, the url to jump to
this app, and the objects passed from Django views to templates.
1. The template file this app needs.
The template files should be placed in templates/ directory. And the
static files (i.e. images, css, and js) should be placed in the
static/ directory for their own app. For example, photo.jpg for photo
app should be placed in photo/static/photo/ directory. And in the
template file, you should use the image like this:
<img src="{{ STATIC_URL }}photo/photo.jpg">
The photo subdirectory in static/ is used to avoid name conflicts
between different apps.
However, common static files should be placed in common_static/
directory.
2. The url to jump to this app.
It describes how to jump to this page. For example, url / is
associated with the homepage app. Just jump to / and you'll see the
homepage. Don't be confused. When I say /, I means
http://www.class25.net/ or http://cst25.tsinghua.edu.cn/ or whatever.
But the domain name part (i.e. http://www.class25.net) is not what we
concerns about. We concerns only about the absolute path, which is /.
For another example, url /activity/<Year>/<Month>/<Day>/ is associated
with the activity in the specified date. So if you want to show the
detailed activity happened in 2012-12-15, you just jump to
/activity/2012/12/15/.
3. The objects passed from Django views to templates.
It describes the texts to fill the holes in the templates. For
example, the following is written in INTERFACES:
latest_announce
The latest announcement.
latest_announce.contents
The content of the announcement.
latest_announce.auther
The author writing this announcement.
And in the template page, you can write:
<h1>{{ latest_announce.contents }}</h1>
---------------------------
Global Objects
This file descibes the objects that will be passed to every template.
user.is_authenticated
Returns True if any user has logged in.
user.username
The username of the logged-in user.