Author
|
zPlus <zplus@peers.community>
2017-10-02 15:39:55
|
Committer
|
zPlus <zplus@peers.community>
2017-10-02 15:39:55
|
Commit
|
44e5124
(patch)
|
Tree
|
4c946b6
|
Parent(s)
|
|
Fix #67 Light up link of current page
commits diff:
c1ea023..44e5124
7 files changed,
42 insertions,
25 deletions
—
download
Diffstat
Diff options
+3/-1
M about.php
6
|
6
|
|
// Render template
|
7
|
7
|
|
echo $twig->render (
|
8
|
8
|
|
'about.twig',
|
9
|
|
- |
array ('title' => 'About')); |
9
|
|
> |
\ No newline at end of file
|
|
9
|
+ |
array (
|
|
10
|
+ |
'page' => 'about',
|
|
11
|
+ |
'title' => 'About'));
|
+12/-5
M css/freepost.styl
53
|
53
|
|
width 80%
|
54
|
54
|
|
|
55
|
55
|
|
> .flex-item
|
56
|
|
- |
order 0
|
57
|
|
- |
flex 0 1 auto
|
58
|
|
- |
align-self auto
|
|
56
|
+ |
flex 0 1 auto
|
|
57
|
+ |
align-self auto
|
|
58
|
+ |
order 0
|
59
|
59
|
|
|
60
|
|
- |
margin .5em 1em
|
|
60
|
+ |
border 0
|
|
61
|
+ |
border-bottom 1px solid transparent
|
|
62
|
+ |
margin .5em 1em
|
|
63
|
+ |
padding .2em 0
|
|
64
|
+ |
|
|
65
|
+ |
/* Highlight menu item of the current active page (Hot/New/Submit/...) */
|
|
66
|
+ |
> .active_page
|
|
67
|
+ |
border-bottom 3px solid rgb(255, 175, 50)
|
61
|
68
|
|
|
62
|
69
|
|
/* Highlight username if there are unread messages */
|
63
|
70
|
|
.new_messages
|
317
|
324
|
|
|
318
|
325
|
|
> li
|
319
|
326
|
|
float left
|
320
|
|
- |
margin 0 2em 0 0 |
320
|
|
> |
\ No newline at end of file
|
|
327
|
+ |
margin 0 2em 0 0
|
+15/-10
M index.php
12
|
12
|
|
// Pagination. What page are we in?
|
13
|
13
|
|
if (isset ($_GET['page']))
|
14
|
14
|
|
{
|
15
|
|
- |
$page = intval ($_GET['page']);
|
|
15
|
+ |
$page_number = intval ($_GET['page']);
|
16
|
16
|
|
|
17
|
|
- |
if ($page < 0)
|
18
|
|
- |
$page = 0;
|
|
17
|
+ |
if ($page_number < 0)
|
|
18
|
+ |
$page_number = 0;
|
19
|
19
|
|
} else {
|
20
|
|
- |
$page = 0;
|
|
20
|
+ |
$page_number = 0;
|
21
|
21
|
|
}
|
22
|
22
|
|
|
23
|
23
|
|
// Retrieve list of posts
|
24
|
24
|
|
if (isset ($_GET['new']))
|
25
|
|
- |
$posts = $db->get_new_posts ($page);
|
26
|
|
- |
else
|
27
|
|
- |
$posts = $db->get_hot_posts ($page);
|
|
25
|
+ |
{
|
|
26
|
+ |
$posts = $db->get_new_posts ($page_number);
|
|
27
|
+ |
$page = 'new';
|
|
28
|
+ |
} else {
|
|
29
|
+ |
$posts = $db->get_hot_posts ($page_number);
|
|
30
|
+ |
$page = 'hot';
|
|
31
|
+ |
}
|
28
|
32
|
|
|
29
|
33
|
|
// Retrieve a list of user votes for the posts
|
30
|
34
|
|
$IDs = array ();
|
38
|
42
|
|
echo $twig->render (
|
39
|
43
|
|
'index.twig',
|
40
|
44
|
|
array(
|
41
|
|
- |
'posts' => $posts,
|
42
|
|
- |
'votes' => $votes,
|
43
|
|
- |
'page' => $page));
|
|
45
|
+ |
'posts' => $posts,
|
|
46
|
+ |
'page' => $page,
|
|
47
|
+ |
'votes' => $votes,
|
|
48
|
+ |
'page_number' => $page_number));
|
+1/-0
M login.php
+3/-1
M submit.php
57
|
57
|
|
// Render template
|
58
|
58
|
|
echo $twig->render (
|
59
|
59
|
|
'submit.twig',
|
60
|
|
- |
array ('title' => 'Submit'));
|
|
60
|
+ |
array (
|
|
61
|
+ |
'page' => 'submit',
|
|
62
|
+ |
'title' => 'Submit'));
|
+7/-7
M template/header.twig
33
|
33
|
|
</div>
|
34
|
34
|
|
|
35
|
35
|
|
<div class="menu">
|
36
|
|
- |
<a href="{{ ''|docroot }}" class="flex-item">Hot</a>
|
37
|
|
- |
<a href="{{ 'new'|docroot }}" class="flex-item">New</a>
|
|
36
|
+ |
<a href="{{ ''|docroot }}" class="flex-item {{ page == "hot" ? "active_page" }}">Hot</a>
|
|
37
|
+ |
<a href="{{ 'new'|docroot }}" class="flex-item {{ page == "new" ? "active_page" }}">New</a>
|
38
|
38
|
|
|
39
|
39
|
|
{% if user %}
|
40
|
40
|
|
{% set unread_messages = new_messages() %}
|
41
|
41
|
|
|
42
|
|
- |
<a href="{{ 'submit'|docroot }}" class="flex-item">Submit</a>
|
|
42
|
+ |
<a href="{{ 'submit'|docroot }}" class="flex-item {{ page == "submit" ? "active_page" }}">Submit</a>
|
43
|
43
|
|
|
44
|
44
|
|
{% if unread_messages %}
|
45
|
45
|
|
<a href="{{ 'user_activity/replies'|docroot }}" class="new_messages flex-item">
|
50
|
50
|
|
{{ user.name }}
|
51
|
51
|
|
</a>
|
52
|
52
|
|
{% endif %}
|
53
|
|
- |
{% endif %}
|
|
53
|
+ |
{% endif %}
|
54
|
54
|
|
|
55
|
|
- |
<a href="{{ 'about'|docroot }}" class="flex-item">About</a>
|
|
55
|
+ |
<a href="{{ 'about'|docroot }}" class="flex-item {{ page == "about" ? "active_page" }}">About</a>
|
56
|
56
|
|
|
57
|
|
- |
{% if user %}
|
|
57
|
+ |
{% if user %}
|
58
|
58
|
|
<a href="{{ 'logout'|docroot }}" class="flex-item">Log out</a>
|
59
|
59
|
|
{% else %}
|
60
|
|
- |
<a href="{{ 'login'|docroot }}" class="flex-item">Log in</a>
|
|
60
|
+ |
<a href="{{ 'login'|docroot }}" class="flex-item {{ page == "login" ? "active_page" }}">Log in</a>
|
61
|
61
|
|
{% endif %}
|
62
|
62
|
|
</div>
|
63
|
63
|
|
</div>
|
+1/-1
M template/index.twig
63
|
63
|
|
{% endfor %}
|
64
|
64
|
|
|
65
|
65
|
|
<div class="more">
|
66
|
|
- |
<a href="?page={{ page + 1 }}" class="button button_default1">
|
|
66
|
+ |
<a href="?page={{ page_number + 1 }}" class="button button_default1">
|
67
|
67
|
|
More
|
68
|
68
|
|
</a>
|
69
|
69
|
|
</div>
|