Commit 0bff4836 authored by eric's avatar eric

Remove code specific to http://relearn.be/

parent a68948ae
from fabric.api import run, cd, env, local, sudo
env.hosts = ['osp@osp.constantvzw.org']
env.path = '/home/osp/apps/relearn/relearn.be/'
def getdb():
pass
def deploy():
with cd(env.path):
run('git pull origin master')
run('/home/osp/apps/venvs/relearn/bin/python manage.py collectstatic --noinput')
sudo('supervisorctl restart relearn')
from fabric.api import run, cd, env, local, sudo
"""
This is how we like to do Django deployments at OSP—
quite minimalist.
"""
env.hosts = ['user@example.com']
env.path = '/path/to/remote/git/repo/'
def getdb():
pass
def deploy():
with cd(env.path):
run('git pull origin master')
run('/path/to/remote/python manage.py collectstatic --noinput')
sudo('supervisorctl restart appname')
# the last stop of course depends on what kind of server/supervisor is
# running your app. With Apache it would be more likely:
# sudo('/usr/sbin/apachectl graceful')
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This file is part of gitcal and is © the contributors, listed in README.txt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
Expects a visual culture style git api,
returns Ical Calendars of the commits
Dependency: vobject
"""
import json
from urllib2 import urlopen
from relearn.settings import API_PATH
def get_api(*args):
url = API_PATH + '/'.join(args)
res = urlopen(url)
dict = json.loads(res.read())
res.close
return dict
def commits(repo_slug):
repo = get_api(repo_slug)
return repo['commits']
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This file is part of gitcal and is © the contributors, listed in README.txt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
"""
from django.conf.urls.defaults import patterns, url
urlpatterns = patterns('gitcal.views',
url(r'(?P<repo_slug>[\w\.\-_]+)\.ics$', 'render'),
)
"""
This script connects to an IMAP mailbox, reads unread emails and mark them as
read.
"""
import os
import email
import imaplib
import settings as bot_settings
from django.template import Template, Context
from django.template import loader
from django.conf import settings
conn = imaplib.IMAP4_SSL(bot_settings.SERVER)
try:
(retcode, capabilities) = conn.login(bot_settings.USER, bot_settings.PASSWORD)
except:
print sys.exc_info()[1]
sys.exit(1)
ret = conn.select() # Select inbox or default namespace
(retcode, messages) = conn.search(None, '(UNSEEN)')
if retcode == 'OK':
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
settings.configure(
TEMPLATE_DIRS=(os.path.join(PROJECT_DIR, 'templates'),),
)
t = loader.get_template('issue.html')
for num in messages[0].split(' '):
if num:
typ, data = conn.fetch(num,'(RFC822)')
msg = email.message_from_string(data[0][1])
ret, data = conn.store(num,'+FLAGS', '\\Seen')
if ret == 'OK':
c = Context({
'from': msg.get('From'),
'date': msg.get('Date'),
'subject': msg.get('Subject'),
'body':msg.get_payload()
})
print(t.render(c))
# If needed we can save this html to file
import codecs
output = 'email_%s.html' % msg.get('Date').replace(" ", "").replace(":", "")
f = codecs.open(output, "w", encoding="utf-8")
f.write(t.render(c))
f.close()
import os
cmd = "phantomjs print.js %s && lpr -P OSP -o media=A4 %s.pdf" % (output, output)
os.system(cmd)
conn.close()
var page = require('webpage').create();
system = require("system")
source = system.args[1]
page.open(source, function () {
page.viewportSize = { width: 1190, height: 873 };
page.paperSize = { format: 'A4', orientation: 'portrait', margin: '1cm' };
page.render(source + '.pdf')
phantom.exit()
});
"""
Settings for the imapbot
"""
SERVER = "mailserveur.net"
USER = "username"
PASSWORD = "password"
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Re: [Osp] not relearn</title>
<link rel="stylesheet" href="../relearn/static/less/reset.css" type="text/css" charset="utf-8">
<style type="text/css">
@font-face {
font-family: 'patin';
src: url('../relearn/static/fonts/osp_le-patin-helvete-webfont.eot');
src: url('../relearn/static/fonts/osp_le-patin-helvete-webfont.eot?#iefix') format('embedded-opentype'),
url('../relearn/static/fonts/osp_le-patin-helvete-webfont.woff') format('woff'),
url('../relearn/static/fonts/osp_le-patin-helvete-webfont.ttf') format('truetype'),
url('../relearn/static/fonts/osp_le-patin-helvete-webfont.svg#osp_le-patin-helvete') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Crickx';
src: url('../relearn/static/fonts/crickxsharkcut-webfont.eot');
src: url('../relearn/static/fonts/crickxsharkcut-webfont.eot?#iefix') format('embedded-opentype'),
url('../relearn/static/fonts/crickxsharkcut-webfont.woff') format('woff'),
url('../relearn/static/fonts/crickxsharkcut-webfont.ttf') format('truetype'),
url('../relearn/static/fonts/crickxsharkcut-webfont.svg#crickxsharkcut') format('svg');
font-weight: normal;
font-style: normal;
}
* {
-webkit-print-color-adjust: exact; /* Allows printing of background colors */
}
html,
body {
height: 97%;
}
body {
font-family: "patin" !important;
font-size: 16px;
line-height: 1.5em;
padding: 0.5em;
}
.wrap {
margin-bottom: 20px;
}
.left-side,
.middle,
.right-side {
float: left;
padding: 10px;
}
a {
color: inherit;
}
a:hover {
background-color: yellow;
}
h1,
h2,
h3,
h4 {
font-weight: normal;
font-family: "Crickx" !important;
text-transform: uppercase;
}
h1 {
font-size: 2em;
line-height: 0.5em;
position: relative;
z-index: 20;
}
h2 {
font-size: 1.5em;
line-height: 0.5em;
}
h3 {
margin-top: 48px;
text-transform: uppercase;
margin-bottom: 0;
font-size: 28px;
}
h4 {
text-decoration: underline;
margin-bottom: 0;
}
em {
font-style: italic;
}
strong {
font-weight: bold;
}
div#quotes {
text-align: center;
height: 360px;
}
blockquote {
display: none;
text-align: center;
width: 85%;
margin: auto;
font-family: "Crickx" !important;
text-transform: uppercase;
font-size: 2em;
line-height: 1em;
}
blockquote div {
font-family: patin, serif;
}
p {
margin: 0;
}
p + p {
text-indent: 1.5em;
}
sup {
font-size: 0.75em;
line-height: 0;
vertical-align: 0.25em;
}
img {
border: 3px solid lightseagreen;
max-width: 70%;
margin-left: 15%;
margin-bottom: 1em;
}
.button {
text-decoration: none;
border: 1px solid MediumSeaGreen;
padding: 7px 5px;
box-shadow: 0 0 30px 10px yellow;
margin: 0 0.5em;
position: relative;
top: -3px;
background-color: yellow;
}
.button:hover {
background-color: white;
}
@page {
size:21cm 29.7cm; // format supplément avec cropmarks => 6.22 inches * 8.27 inches ou 597 x 793,7 px
margin: 0;
}
body {
margin: 1em 2em;
max-width: 18cm;
font-size: 24pt;
}
h1 {
line-height: 1.2em;
}
div.date {
}
div.from {
margin-top: 1em;
}
</style>
</head>
<body>
<div class="date">{{ date }}</div>
<h1>{{ subject }}</h1>
{{ body|linebreaksbr }}
</body>
</html>
...@@ -4,8 +4,6 @@ from etherpadlite.models import Pad, PadAuthor, PadServer ...@@ -4,8 +4,6 @@ from etherpadlite.models import Pad, PadAuthor, PadServer
from django.contrib.auth.models import AnonymousUser from django.contrib.auth.models import AnonymousUser
from django.contrib.sites.models import get_current_site from django.contrib.sites.models import get_current_site
from gitcommits.models import commits
def site_name(request): def site_name(request):
current_site = get_current_site(request) current_site = get_current_site(request)
# maybe something that sounds more to the point than stite_name? # maybe something that sounds more to the point than stite_name?
...@@ -28,28 +26,7 @@ def pads(request): ...@@ -28,28 +26,7 @@ def pads(request):
) )
author.save() author.save()
author.GroupSynch() author.GroupSynch()
hash['author'] = author hash['author'] = author
hash['pads'] = Pad.objects.all() hash['pads'] = Pad.objects.all()
return hash return hash
def filter_commits(commits):
filtered_commits = []
i = 0
for commit in commits:
if "Merge branch '" in commit['message']:
continue
commit['commit_time'] = datetime.fromtimestamp(commit['commit_time'])
commit['repo_name'] = commit['repo_name'].replace('osp.', '')
filtered_commits.append(commit)
i += 1
if i == 10:
break
return filtered_commits
def compose_commits(request):
if 'admin' in request.path:
return {}
commit_stream = commits("osp.relearn.off-grid") + commits("osp.relearn.gesturing-paths") + commits("osp.relearn.be") + commits("osp.relearn.can-it-scale-to-the-universe")
commit_stream.sort(reverse=True, key=lambda c: c['commit_time'])
return { 'commits' : filter_commits(commit_stream) }
...@@ -37,9 +37,6 @@ ...@@ -37,9 +37,6 @@
<div class="left-side screen-only"> <div class="left-side screen-only">
<nav> <nav>
<ul> <ul>
<li><a href="/r/relearn::welcome">Welcome</a></li>
<li><a href="/r/relearn::about">About</a></li>
<li><a href="/r/relearn::contact">Contact</a></li>
{% if author %} {% if author %}
<li id="create-pad"><a class="button" href="{% url 'pad-create' author.group.all.0.id %}">Create pad</a></li> <li id="create-pad"><a class="button" href="{% url 'pad-create' author.group.all.0.id %}">Create pad</a></li>
{% endif %} {% endif %}
...@@ -53,29 +50,7 @@ ...@@ -53,29 +50,7 @@
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
<div class="right-side screen-only"> <div class="right-side screen-only">
{% if author %} <h2>The right side</h2>
<h2>Point out an issue</h2>
<p> If you want to point an issue to the Relearn team, please send an e-mail to : <a href="mailto:relearn@lists.constantvzw.org">relearn@lists.constantvzw.org</a>
<br>
</p>
{% comment %}
<h2>Upload files</h2>
<form id="upload-form" action="base_submit" method="post" accept-charset="utf-8">
<input style="width: 70%" type="file" name="image_file" id="image_file" />
<input id="send-file" type="submit" value="Upload">
</form>
{% endcomment %}
{% endif %}
<h2>What we say</h2>
<p>The latest 10 commits, excluding the merges. There is a delay of an hour…</p>
{% for commit in commits %}
<h3>{{ commit.repo_name }}</h3>
<p class='commit-message'>{{ commit.message|urlize|linebreaksbr }}</p>
<p>By <span class='commit-author'>{{ commit.author }}</span> on <span class='commit-date'>{{ commit.commit_time }}</span></p>
{% endfor %}
</div> </div>
</div> </div>
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}
......
...@@ -11,12 +11,3 @@ def dewikify(name): ...@@ -11,12 +11,3 @@ def dewikify(name):
name = name.replace('-', ' ') name = name.replace('-', ' ')
name = name.replace('::', u' → ') name = name.replace('::', u' → ')
return name return name
@register.filter(name='is_relearn')
@stringfilter
def is_relearn(name):
name = name.replace('-', ' ')
name = name.replace('::', ' ')
name = name.split(" ")
if name[0] == "relearn":
return True
...@@ -5,8 +5,6 @@ from django.views.generic import TemplateView ...@@ -5,8 +5,6 @@ from django.views.generic import TemplateView
from django.contrib import admin from django.contrib import admin
admin.autodiscover() admin.autodiscover()
from etherpadlite.models import *
urlpatterns = patterns( urlpatterns = patterns(
'', '',
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
...@@ -19,17 +17,7 @@ urlpatterns = patterns( ...@@ -19,17 +17,7 @@ urlpatterns = patterns(
url(r'^etherpad/create/(?P<pk>\d+)/$', 'relearn.views.padCreate', name='pad-create'), url(r'^etherpad/create/(?P<pk>\d+)/$', 'relearn.views.padCreate', name='pad-create'),
url(r'^etherpad/delete/(?P<pk>\d+)/$', 'relearn.views.padDelete', name='pad-delete'), url(r'^etherpad/delete/(?P<pk>\d+)/$', 'relearn.views.padDelete', name='pad-delete'),
url(r'^group/create$', 'relearn.views.groupCreate'), url(r'^group/create$', 'relearn.views.groupCreate'),
url(r'^commits/$', 'relearn.views.all_commits', name='commits'),
url(r'r/(?P<slug>[\w\.\-_\:]+)$', 'relearn.views.pad_read', name='pad-read'), url(r'r/(?P<slug>[\w\.\-_\:]+)$', 'relearn.views.pad_read', name='pad-read'),
url(r'w/(?P<slug>[\w\.\-_\:]+)$', 'relearn.views.pad', name='pad-write'), url(r'w/(?P<slug>[\w\.\-_\:]+)$', 'relearn.views.pad', name='pad-write'),
url(r'^tracker/$', TemplateView.as_view(template_name="tracker.html")),
url(r'^send-issue/$', 'relearn.views.post_issue', name="relearn-issue-send"),
url(r'^issue/$', TemplateView.as_view(template_name="issue.html"), name="relearn-issue-success"),
) )
...@@ -19,7 +19,6 @@ from django.contrib.auth.decorators import login_required ...@@ -19,7 +19,6 @@ from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from py_etherpad import EtherpadLiteClient from py_etherpad import EtherpadLiteClient
from gitcommits.models import commits
from etherpadlite.models import * from etherpadlite.models import *
from etherpadlite import forms from etherpadlite import forms
...@@ -322,48 +321,11 @@ def pad_read(request, pk=None, slug=None): ...@@ -322,48 +321,11 @@ def pad_read(request, pk=None, slug=None):
return render_to_response("pad-read.html", tpl_params, context_instance = RequestContext(request)) return render_to_response("pad-read.html", tpl_params, context_instance = RequestContext(request))
def filter_commits(commits):
filtered_commits = []
for commit in commits:
if "Merge branch '" in commit['message']:
continue
commit['commit_time'] = datetime.datetime.fromtimestamp(commit['commit_time'])
commit['repo_name'] = commit['repo_name'].replace('osp.', '')
filtered_commits.append(commit)
return filtered_commits
def all_commits (request):
commit_stream = commits("osp.relearn.off-grid") + commits("osp.relearn.gesturing-paths") + commits("osp.relearn.be") + commits("osp.relearn.can-it-scale-to-the-universe")
commit_stream.sort(reverse=True, key=lambda c: c['commit_time'])
tpl_params = { 'all_commits' : filter_commits(commit_stream) }
return render_to_response("commits.html", tpl_params, context_instance = RequestContext(request))
def home(request): def home(request):
# The homepage is the pad called ‘start’ (props to DokuWiki!) # The homepage is the pad called ‘start’ (props to DokuWiki!)
try: try:
Pad.objects.get(name='relearn::start') Pad.objects.get(name='start')
return pad_read(request, slug='relearn::start') return pad_read(request, slug='start')
except Pad.DoesNotExist: except Pad.DoesNotExist:
return HttpResponseRedirect(reverse('login')) return HttpResponseRedirect(reverse('login'))
def post_issue(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
name = form.cleaned_data['name']
subject = "[issue spotted] %s" % form.cleaned_data['subject']
message = "%s\n\n-- %s" % (form.cleaned_data['message'], name)
#message = "%s" % (form.cleaned_data['message'])
email = form.cleaned_data['email']
recipients = ['relearn@lists.constantvzw.org']
send_mail(subject, message, email, recipients)
return HttpResponseRedirect(reverse('relearn-issue-success')) # Redirect after POST
else:
form = ContactForm() # An unbound form
return render(request, 'form.html', {'form': form})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment