Skip to content

Commit 41655e6

Browse files
committed
Restructure site and bug fixes
Fixes coala#44 Closes coala#1
1 parent 3ef530f commit 41655e6

14 files changed

+280
-63
lines changed

activity/views.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.shortcuts import render
2+
3+
4+
def index(request):
5+
return render(request, 'activity.html')

community/context_processors.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from community.git import get_owner
2+
3+
4+
def get_org_name(request):
5+
org_name = get_owner()
6+
return {'org_name': org_name}

community/settings.py

+2
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,5 @@
8989
MEDIA_URL = '/media/'
9090
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
9191
STATICFILES_DIRS = ['static/']
92+
TEMPLATES[0]['OPTIONS']['context_processors'].append(
93+
'community.context_processors.get_org_name')

static/css/main.css

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.student {
2+
padding-bottom: 20px;
3+
}
4+
5+
.students {
6+
list-style: none;
7+
}
8+
nav {
9+
background-color: #38474e !important;
10+
}
11+
12+
.page-footer {
13+
background-color: #37474f !important;
14+
}
15+
16+
canvas {
17+
-moz-user-select: none;
18+
-webkit-user-select: none;
19+
-ms-user-select: none;
20+
}
File renamed without changes.
File renamed without changes.

static/main.css

-7
This file was deleted.

templates/activity.html

+22-34
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,29 @@
1-
<!doctype html>
2-
<html>
1+
{% extends 'includes.html' %}
2+
{% block content %}
3+
<div class="section no-pad-bot" id="index-banner">
4+
<div class="container">
5+
<h1 class="header center col-test">Welcome</h1>
6+
<div class="row center">
7+
<h5 class="header col s12 light">Hello, world. You are at the {{ org_name }} community GCI website.</h5>
8+
</div>
9+
</div>
10+
{% include 'issues_graph.html' %}
311

4-
<head>
5-
<title>Community Activity</title>
6-
<style>
7-
canvas {
8-
-moz-user-select: none;
9-
-webkit-user-select: none;
10-
-ms-user-select: none;
11-
}
12-
</style>
13-
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
14-
</head>
15-
16-
<body>
17-
<h1>Community Activity</h1>
18-
<br>
19-
<br>
20-
<div style="width:75%;">
21-
<canvas id="canvas"></canvas>
2212
</div>
23-
<select id="chartType">
24-
<option value="Month">Year</option>
25-
<option value="Week">Month</option>
26-
<option value="Day">Week</option>
27-
</select>
28-
<br>
29-
<br>
13+
14+
{% include 'footer.html' %}
15+
<!--Import jQuery before materialize.js-->
3016
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.bundle.js"></script>
31-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
32-
<script src="/static/charts.js"></script>
17+
<script src="../static/js/charts.js"></script>
3318
<script>
34-
$('#chartType').on('change', function(){
35-
updateChart($('#chartType').val())
36-
});
37-
updateChart($('#chartType').val());
19+
$(document).ready(function () {
20+
$('select').material_select();
21+
});
22+
$('#chartType').on('change', function () {
23+
updateChart($('#chartType').val())
24+
});
25+
updateChart($('#chartType').val());
3826
</script>
27+
{% endblock %}
3928
</body>
40-
4129
</html>

templates/footer.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<footer class="page-footer">
2+
<div class="container">
3+
<div class="row">
4+
<div class="col m3 s12">
5+
<h5 class="white-text fine">{{ org_name }}</h5>
6+
<ul>
7+
<li><a class="grey-text text-lighten-3" href="http://{{ org_name }}.io/docs">Documentation</a></li>
8+
<li><a class="grey-text text-lighten-3" href="http://{{ org_name }}.io/newcomer">Newcomer Docs</a>
9+
</li>
10+
<li><a class="grey-text text-lighten-3" href="http://{{ org_name }}.io/coc">Code of Conduct</a></li>
11+
<li><a class="grey-text text-lighten-3" href="http://blog.{{ org_name }}.io/">Blog</a></li>
12+
<li><a class="grey-text text-lighten-3" href="mailto:sponsoring@{{ org_name }}.io">Donate</a></li>
13+
</ul>
14+
</div>
15+
<div class="col m9 s12">
16+
<div class="row footer-btn-row">
17+
<div class="col m6 s12 center">
18+
<div class="twitter-btn center">
19+
<a href="https://twitter.com/{{ org_name }}_io"
20+
class="waves-effect waves-light btn-large"><i class="fa fa-twitter"
21+
aria-hidden="true"></i><span
22+
class="footer-btn-text">Follow Us On Twitter</span></a>
23+
</div>
24+
<br>
25+
</div>
26+
<div class="col m6 s12 center">
27+
<div class="gitter-btn center">
28+
<a href="https://gitter.im/{{ org_name }}" class="waves-effect waves-light btn-large"><i
29+
class="fa fa-commenting-o" aria-hidden="true"></i><span class="footer-btn-text">Join Chat On Gitter</span></a>
30+
</div>
31+
<br>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
</div>
37+
<div class="footer-copyright">
38+
<div class="container">
39+
<span class="left">© 2017 {{ org_name }}</span>
40+
<a class="grey-text text-lighten-4 right" href="#!">GNU AGPL v3.0</a>
41+
</div>
42+
</div>
43+
</footer>

templates/includes.html

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!--Import Google Icon Font-->
5+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
6+
<!--Import materialize.css-->
7+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
8+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
9+
<link rel="stylesheet" href="../static/css/main.css">
10+
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
11+
<!--Let browser know website is optimized for mobile-->
12+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
13+
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
14+
</head>
15+
<body>
16+
17+
<nav>
18+
<div class="nav-wrapper">
19+
<a href="#" class="brand-logo">&nbsp;<img
20+
src="https://api.{{ org_name }}.io/en/latest/_static/images/{{ org_name }}_logo.svg"></a>
21+
<ul id="nav-mobile" class="right hide-on-med-and-down">
22+
<li><a href="/gci">GCI</a></li>
23+
<li><a href="/activity">Github Activity</a></li>
24+
<li><a href="/twitter">Twitter Feed</a></li>
25+
</ul>
26+
</div>
27+
</nav>
28+
29+
{% block content %}
30+
{% endblock %}
31+
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>

templates/index.html

+107-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,108 @@
1-
<title>Community website</title>
2-
<body>
3-
<ul>
4-
<li><a href="/gci/">Google Code-in</a>
5-
<li><a href="/activity/">GitHub activity</a>
6-
<li><a href="/twitter/">Twitter Feed</a>
7-
</ul>
1+
{% extends 'includes.html' %}
2+
3+
{% block content %}
4+
<div class="section no-pad-bot" id="index-banner">
5+
<div class="container">
6+
<h1 class="header center col-test">Welcome</h1>
7+
<div class="row center">
8+
<h5 class="header col s12 light">Hello, world. You are at the {{ org_name }} community website.</h5>
9+
<h4 class="header col s12 light">Meet awesome mentors</h4>
10+
11+
</div>
12+
<div class="row">
13+
14+
<div class="col s4">
15+
<div class="card" style="overflow: visible;">
16+
<div class="card-image waves-effect waves-block waves-light">
17+
<img class="activator"
18+
src="https://api.{{ org_name }}.io/en/latest/_static/images/{{ org_name }}_logo.svg">
19+
</div>
20+
<div class="card-content">
21+
<span class="card-title activator grey-text text-darken-4">Mentor Name<i
22+
class="material-icons right">more_vert</i></span>
23+
24+
</div>
25+
<div class="card-reveal" style="display: none; transform: translateY(0px);">
26+
<span class="card-title grey-text text-darken-4">Card Title<i class="material-icons right">close</i></span>
27+
<p>Here is some more information about this product that is only revealed once clicked
28+
on.</p>
29+
</div>
30+
31+
<div class="card-action">
32+
<a href="#">Github</a>
33+
<a href="#">Twitter</a>
34+
</div>
35+
</div>
36+
</div>
37+
<div class="col s4">
38+
<div class="card" style="overflow: visible;">
39+
<div class="card-image waves-effect waves-block waves-light">
40+
<img class="activator"
41+
src="https://api.{{ org_name }}.io/en/latest/_static/images/{{ org_name }}_logo.svg">
42+
</div>
43+
<div class="card-content">
44+
<span class="card-title activator grey-text text-darken-4">Mentor Name<i
45+
class="material-icons right">more_vert</i></span>
46+
47+
</div>
48+
<div class="card-reveal" style="display: none; transform: translateY(0px);">
49+
<span class="card-title grey-text text-darken-4">Card Title<i class="material-icons right">close</i></span>
50+
<p>Here is some more information about this product that is only revealed once clicked
51+
on.</p>
52+
</div>
53+
54+
<div class="card-action">
55+
<a href="#">Github</a>
56+
<a href="#">Twitter</a>
57+
</div>
58+
</div>
59+
</div>
60+
<div class="col s4">
61+
<div class="card" style="overflow: visible;">
62+
<div class="card-image waves-effect waves-block waves-light">
63+
<img class="activator"
64+
src="https://api.{{ org_name }}.io/en/latest/_static/images/{{ org_name }}_logo.svg">
65+
</div>
66+
<div class="card-content">
67+
<span class="card-title activator grey-text text-darken-4">Mentor Name<i
68+
class="material-icons right">more_vert</i></span>
69+
70+
</div>
71+
<div class="card-reveal" style="display: none; transform: translateY(0px);">
72+
<span class="card-title grey-text text-darken-4">Card Title<i class="material-icons right">close</i></span>
73+
<p>Here is some more information about this product that is only revealed once clicked
74+
on.</p>
75+
</div>
76+
77+
<div class="card-action">
78+
<a href="#">Github</a>
79+
<a href="#">Twitter</a>
80+
</div>
81+
</div>
82+
</div>
83+
</div>
84+
<h4 class="header col s12 light center">Recent Activity</h4>
85+
<div class="section no-pad-bot" id="index-banner">
86+
87+
{% include 'issues_graph.html' %}
88+
</div>
89+
<!--Import jQuery before materialize.js-->
90+
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.bundle.js"></script>
91+
<script src="../static/js/charts.js"></script>
92+
<script>
93+
$(document).ready(function () {
94+
$('select').material_select();
95+
});
96+
$('#chartType').on('change', function () {
97+
updateChart($('#chartType').val())
98+
});
99+
updateChart($('#chartType').val());
100+
</script>
101+
</div>
102+
</div>
103+
104+
{% include 'footer.html' %}
105+
{% endblock %}
8106
</body>
107+
</html>
108+

templates/issues_graph.html

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="row center">
2+
<div class="input-field col s4">
3+
<select id="chartType">
4+
<option value="Month" selected>Year</option>
5+
<option value="Week">Month</option>
6+
<option value="Day">Week</option>
7+
</select>
8+
<label>Time Interval</label>
9+
</div>
10+
<div class="col s12 center">
11+
12+
<div class="card white darken-1">
13+
<div class="card-content black-text">
14+
<span class="card-title">Issues</span>
15+
16+
<div>
17+
<canvas id="canvas"></canvas>
18+
</div>
19+
</div>
20+
</div>
21+
</div>
22+
</div>

templates/twitter_feed.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% extends 'includes.html' %}
2+
{% block content %}
3+
<div class="section no-pad-bot" id="index-banner">
4+
<div class="container">
5+
<a class="twitter-timeline" href="https://twitter.com/{{ org_twitter_handle }}">Tweets
6+
by {{ org_twitter_handle }}
7+
</a>
8+
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
9+
</div>
10+
</div>
11+
12+
{% include 'footer.html' %}
13+
{% endblock %}
14+
</body>
15+
</html>

twitter/view_twitter.py

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.shortcuts import render
12
from django.http import HttpResponse
23
import requests
34
import json
@@ -6,26 +7,17 @@
67

78

89
def index(request):
9-
s = []
10-
1110
org_twitter_handle = org_name = get_owner()
12-
13-
s.append('<link rel="shortcut icon" type="image/png" '
14-
'href="../static/favicon.png"/>')
15-
1611
api_data_dump = json.loads(
1712
requests.get('https://gci-leaders.netlify.com/data.json').content)
1813
for item in api_data_dump:
1914
if item['name'] == org_name:
2015
org_twitter_handle = item['twitter_url'].split(
2116
'twitter.com/')[-1]
17+
org_data = {
18+
'org_twitter_handle': org_twitter_handle
19+
}
2220
if org_twitter_handle is not None:
23-
s.append('<a class="twitter-timeline" data-height="1000" '
24-
'data-link-color="#2B7BB9" '
25-
'href="https://twitter.com/{twitter_handle}">'
26-
'Tweets by {twitter_handle}</a> <script async '
27-
'src="https://platform.twitter.com/widgets.js" '
28-
'charset="utf-8"></script>'.format(
29-
twitter_handle=org_twitter_handle))
30-
31-
return HttpResponse('\n'.join(s))
21+
return render(request, 'twitter_feed.html', context=org_data)
22+
else:
23+
return HttpResponse("Sorry, Organisation's twitter handle not found!")

0 commit comments

Comments
 (0)