Skip to content

Commit

Permalink
apropos + cookies + errors pages 403 404 500 + maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodraak committed Oct 26, 2014
1 parent ef00629 commit d100163
Show file tree
Hide file tree
Showing 19 changed files with 440 additions and 176 deletions.
4 changes: 2 additions & 2 deletions assets/sass/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ $portrait: "only screen and (orientation: portrait)";
// $h1-font-size: em-calc(44);
// $h2-font-size: em-calc(37);
// $h3-font-size: em-calc(27);
// $h4-font-size: em-calc(23);
// $h5-font-size: em-calc(18);
$h4-font-size: em-calc(20); /* default : 23 */
$h5-font-size: em-calc(15); /* default : 18 */
// $h6-font-size: 1em;

// Control how subheaders are styled.
Expand Down
29 changes: 14 additions & 15 deletions cdc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@

------------------------------------------------------------
todo long run
-> dump iteam.org
-> tests
-> use pk not id
-> no style in html template -> css
-> <img> : alt
-> button radius
-> flake8 compliant (pep8 + other stuff)
- dump iteam.org
- tests
- use pk not id
- no style in html template -> css
- <img> : alt
- button radius
- flake8 compliant (pep8 + other stuff)

to do now
- 403, 404 and 500 templates (500 template should be raw html)
- https://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/
- robots.txt + htaccess (index follow)
- a propos / l'iteam + cookies
- publication slug -> user-friendly url

to do quickly
- previsualisation des posts
- news / tuto / articles : export pdf (pandoc)
- syndication (rss + atom) : https://docs.djangoproject.com/en/dev/ref/contrib/syndication/
- noscript : menu, (logout ok)
- media sociaux (syncro fb, twitter, google)

osef ?
to do maybe
- noscript : menu, (logout ok)
- media sociaux (syncro fb, twitter, google) -> https://github.com/foxmask/django-th
- calendar : list (prochain, passés, ...)
- publications : tags, multi-page
- better member (mail, citation, bio, ... osef ?)
Expand Down Expand Up @@ -107,9 +106,9 @@ un script (par site google + facebook + twitter) qui permet de poster sur nos di
**Contient**
autant de scripts que nécessaire.

-> https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed

-> ifttt
- https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed
- ifttt
- https://github.com/foxmask/django-th

----------------
## Users tests
Expand Down
3 changes: 2 additions & 1 deletion iTeam/pages/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# @Author: Adrien Chardon
# @Date: 2014-08-19 18:35:27
# @Last Modified by: Adrien Chardon
# @Last Modified time: 2014-08-22 17:02:41
# @Last Modified time: 2014-10-26 16:24:58

# This file is part of iTeam.org.
# Copyright (C) 2014 Adrien Chardon (Nodraak).
Expand All @@ -28,6 +28,7 @@

urlpatterns = patterns(
'',
url(r'^$', views.index, name='index'),
url(r'^apropos/$', views.apropos, name='apropos'),
url(r'^hallOfFame/$', views.hallOfFame, name='hallOfFame'),
url(r'^cookies/$', views.cookies, name='cookies'),
Expand Down
6 changes: 5 additions & 1 deletion iTeam/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# @Author: Adrien Chardon
# @Date: 2014-08-19 18:35:38
# @Last Modified by: Adrien Chardon
# @Last Modified time: 2014-09-01 17:55:37
# @Last Modified time: 2014-10-26 16:28:12

# This file is part of iTeam.org.
# Copyright (C) 2014 Adrien Chardon (Nodraak).
Expand All @@ -29,6 +29,10 @@
from iTeam.events.models import Event


def index(request):
return render(request, 'pages/index.html')


def home(request):
publications_list = Publication.objects.all().filter(pub_date__lte=timezone.now(), is_draft=False). \
order_by('-pub_date')[:5]
Expand Down
50 changes: 50 additions & 0 deletions prod/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
#
# iTeam deployment script
#
# Deploys specified version of Zeste de Savoir
#
# Usage:
# - This script has exactly 1 parameter : the tag name to deploy

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <tag name>" >&2
exit 1
fi

cd /opt/iteam-env/iteam-site/

# Maintenance mode
sudo rm /etc/nginx/sites-enabled/iteam
sudo ln -s /etc/nginx/sites-available/iteam-maintenance /etc/nginx/sites-enabled/iteam-maintenance
sudo service nginx reload

# Delete old branch if exists
git checkout prod
git branch -D $1
# Switch to new tag
git fetch --tags
# Server has git < 1.9, git fetch --tags doesn't retrieve commits...
git fetch
# Checkout the tag
git checkout $1
# Create a branch with the same name - required to have version data in footer
git checkout -b $1

# Update application data
source ../bin/activate
pip install --upgrade -r requirements.txt
python manage.py migrate
deactivate

# Restart iteam
sudo supervisorctl restart iteam

# Exit maintenance mode
sudo rm /etc/nginx/sites-enabled/iteam-maintenance
sudo ln -s /etc/nginx/sites-available/iteam /etc/nginx/sites-enabled/iteam
sudo service nginx reload

# Display current branch and commit
git status
echo "Commit deployé : `git rev-parse HEAD`"
10 changes: 5 additions & 5 deletions prod/gunicorn_start.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status.

WORKINGDIR=/home/nodraak/Telechargements/iteam.org/
WORKINGDIR=/opt/iteam-env/iteam-site/

LOGFILE=$WORKINGDIR/gunicorn.log
ERRFILE=$WORKINGDIR/gunicorn_err.log
LOGFILE=$WORKINGDIR/../log/gunicorn.log
ERRFILE=$WORKINGDIR/../log/gunicorn_err.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=3 # how many worker processes : should be nb_cpu*2+1
USER=nodraak
GROUP=nodraak
USER=iteam
GROUP=iteam

cd $WORKINGDIR
exec ../bin/gunicorn iTeam.wsgi:application \
Expand Down
51 changes: 51 additions & 0 deletions prod/nginx-maintenance.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

# Redirect www.domain.tld to domain.tld
#server {
# listen 80;
# server_name www.example.com;
#
# return 301 http://example.com$request_uri;
#}

server {
listen 80;
server_name beta.iteam.org;

access_log /opt/iteam-env/log/nginx-access.log;
error_log /opt/iteam-env/log/nginx-error.log;


# media and static files

location /static/ {
alias /opt/iteam-env/iteam_static/;
expires 1d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

location /media/ {
alias /opt/iteam-env/media/;
expires 1d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}


# default : redirect to gunicorn (which will redirect to django)

location / {
client_max_body_size 100M;

return 503 //opt/iteam-env/iteam-site/templates/maintenance.html;
}


# Error pages

error_page 500 501 502 503 504 /500.html;
location = /500.html {
root //opt/iteam-env/iteam-site/templates/;
}
}

24 changes: 12 additions & 12 deletions prod/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@


# Redirect www.domain.tld to domain.tld
server {
listen 80;
server_name www.example.com;

return 301 http://example.com$request_uri;
}
#server {
# listen 80;
# server_name www.iteam.org;
#
# return 301 http://iteam.org$request_uri;
#}

server {
listen 80;
server_name famillechardon.fr;
server_name beta.iteam.org;

access_log /home/nodraak/Telechargements/iteam.org/nginx-access.log;
error_log /home/nodraak/Telechargements/iteam.org/nginx-error.log;
access_log /opt/iteam-env/log/nginx-access.log;
error_log /opt/iteam-env/log/nginx-error.log;


# media and static files

location /static/ {
alias /home/nodraak/Telechargements/iteam_static/;
alias /opt/iteam-env/static/;
expires 1d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

location /media/ {
alias /home/nodraak/Telechargements/iteam_media/;
alias /opt/iteam-env/media/;
expires 1d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
Expand Down Expand Up @@ -61,7 +61,7 @@ server {

error_page 500 501 502 503 504 /500.html;
location = /500.html {
root /home/nodraak/Telechargements/iteam.org/templates/;
root /opt/iteam-env/iteam-site/templates/;
}
}

4 changes: 1 addition & 3 deletions prod/settings_prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
SERVE = False


ALLOWED_HOSTS = ['.famillechardon.fr', '192.168.0.100', 'localhost']
# since every request pass by nginx then gunicorn, and gunicorn proxy all via
# localhost, should we only have localhost ?
ALLOWED_HOSTS = ['localhost']

# Make this unique, and don't share it with anybody.
# SECURITY WARNING: keep the secret key used in production secret!
Expand Down
6 changes: 3 additions & 3 deletions prod/supervisor.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[program:iteam]
command = /opt/zdsenv/unicorn_start.sh ;
command = /opt/iteam-env/iteam-site/gunicorn_start.sh ;
user = nodraak ;
stdout_logfile = /opt/zdsenv/logs/supervisor_stdout.log ;
stderr_logfile = /opt/zdsenv/logs/supervisor_stderr.log ;
stdout_logfile = /opt/iteam-env/log/supervisor_stdout.log ;
stderr_logfile = /opt/iteam-env/log/supervisor_stderr.log ;
redirect_stderr = true ;
autorestart = true ;
autostart = true ;
21 changes: 18 additions & 3 deletions templates/403.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,24 @@

<div class="row">
<div class="large-12 columns">
<p>
Vous n'avez pas le droit d'effectuer cette action.
</p>
{# title #}
<div class="home-app-title">
<div class="row">
<div class="large-12 columns">
<h1>
Erreur 403
</h1>
</div>
</div>
</div>
{# content #}
<div class="row">
<div class="large-12 columns">
<p>
Vous n'avez pas le droit d'effectuer cette action.
</p>
</div>
</div>
</div>
</div>

Expand Down
39 changes: 39 additions & 0 deletions templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% extends "base.html" %}

{% load staticfiles %}

{% block title_app %}
Erreur 404
{% endblock %}

{% block breadcrumb_page %}
<li class="current"><a href="#">Erreur 404</a></li>
{% endblock %}


{% block content %}

<div class="row">
<div class="large-12 columns">
{# title #}
<div class="home-app-title">
<div class="row">
<div class="large-12 columns">
<h1>
Erreur 404
</h1>
</div>
</div>
</div>
{# content #}
<div class="row">
<div class="large-12 columns">
<p>
La page demandée n'a pas été trouvée.
</p>
</div>
</div>
</div>
</div>

{% endblock %}
16 changes: 3 additions & 13 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,17 @@
<footer class="row">
<div class="large-6 columns">
<p>
iTeam 2014 - <a href="https://github.com/Nodraak/iTeam.org">open source</a>
iTeam 2014 - <a href="https://github.com/Nodraak/iteam-site">Open source</a>
</p>
</div>
<div class="large-6 columns hide-for-medium hide-for-large hide-for-xlarge hide-for-xxlarge">
<ul class="inline-list left">
<li><a href="{% url 'pages:apropos' %}">À propos</a></li>
<li><a href="{% url 'pages:cookies' %}">Cookies</a></li>
<li><a href="{% url 'pages:hallOfFame' %}">Hall of fame</a></li>
<li><a href="http://irc.iteam.org">IRC</a></li>
<li><a href="http://ece.fr">ECE</a></li>
<li><a href="#h"></a></li>
{% include "footer.html" %}
</ul>
</div>
<div class="large-6 columns hide-for-small">
<ul class="inline-list right">
<li><a href="{% url 'pages:apropos' %}">À propos</a></li>
<li><a href="{% url 'pages:cookies' %}">Cookies</a></li>
<li><a href="{% url 'pages:hallOfFame' %}">Hall of fame</a></li>
<li><a href="http://irc.iteam.org">IRC</a></li>
<li><a href="http://ece.fr">ECE</a></li>
<li><a href="#h"></a></li>
{% include "footer.html" %}
</ul>
</div>
</footer>
Expand Down
Loading

0 comments on commit d100163

Please sign in to comment.