diff --git a/fabfile.py b/fabfile.py deleted file mode 100644 index 726df986a23f727c6567cd7ac02f6f515d0b2af0..0000000000000000000000000000000000000000 --- a/fabfile.py +++ /dev/null @@ -1,14 +0,0 @@ -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') diff --git a/fabfile.py.example b/fabfile.py.example new file mode 100644 index 0000000000000000000000000000000000000000..b801e7e508133d920bd6c3de2e380c63824221e3 --- /dev/null +++ b/fabfile.py.example @@ -0,0 +1,22 @@ +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 diff --git a/gitcommits/__init__.py b/gitcommits/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/gitcommits/models.py b/gitcommits/models.py deleted file mode 100644 index f763255e43914603305a6563e1868438ca37a482..0000000000000000000000000000000000000000 --- a/gitcommits/models.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/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'] - diff --git a/gitcommits/urls.py b/gitcommits/urls.py deleted file mode 100644 index f8c9bd86f69082c30d7e8c2eaa96407bacadd43c..0000000000000000000000000000000000000000 --- a/gitcommits/urls.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/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[\w\.\-_]+)\.ics$', 'render'), -) diff --git a/list-bot/imapbot.py b/list-bot/imapbot.py deleted file mode 100644 index 46b3f31dd9e0c0769bd92dcf8fcf6b9fd436b342..0000000000000000000000000000000000000000 --- a/list-bot/imapbot.py +++ /dev/null @@ -1,64 +0,0 @@ -""" -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() diff --git a/list-bot/print.js b/list-bot/print.js deleted file mode 100644 index a3aa3afbc4af786bd44b7abb3d9085234ac91c49..0000000000000000000000000000000000000000 --- a/list-bot/print.js +++ /dev/null @@ -1,9 +0,0 @@ -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() -}); diff --git a/list-bot/settings.example.py b/list-bot/settings.example.py deleted file mode 100644 index 554f50c5389118351cb13a2a3161c2f7c89f5ab0..0000000000000000000000000000000000000000 --- a/list-bot/settings.example.py +++ /dev/null @@ -1,8 +0,0 @@ -""" -Settings for the imapbot -""" - - -SERVER = "mailserveur.net" -USER = "username" -PASSWORD = "password" diff --git a/list-bot/templates/issue.html b/list-bot/templates/issue.html deleted file mode 100644 index bbf79f4b4fd3147a3daabee99b2e3f05930821ec..0000000000000000000000000000000000000000 --- a/list-bot/templates/issue.html +++ /dev/null @@ -1,168 +0,0 @@ - - - - - Re: [Osp] not relearn - - - - - - - -
{{ date }}
-

{{ subject }}

- {{ body|linebreaksbr }} - - diff --git a/relearn/context_processors.py b/relearn/context_processors.py index e46f70adcc669c1c2fcc49f614f3d54ff8154066..d5ec13b81290745bb6c36603911a75f1de37738b 100644 --- a/relearn/context_processors.py +++ b/relearn/context_processors.py @@ -4,8 +4,6 @@ from etherpadlite.models import Pad, PadAuthor, PadServer from django.contrib.auth.models import AnonymousUser from django.contrib.sites.models import get_current_site -from gitcommits.models import commits - def site_name(request): current_site = get_current_site(request) # maybe something that sounds more to the point than stite_name? @@ -28,28 +26,7 @@ def pads(request): ) author.save() author.GroupSynch() - hash['author'] = author hash['pads'] = Pad.objects.all() 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) } diff --git a/relearn/templates/base.html b/relearn/templates/base.html index 98c01fe12db36bcaa3a2fb0a4b21c585735a8ea6..8368718960e72f0b9df0c81a8c44eb26d60ff6f7 100644 --- a/relearn/templates/base.html +++ b/relearn/templates/base.html @@ -37,9 +37,6 @@
- {% if author %} -

Point out an issue

- -

If you want to point an issue to the Relearn team, please send an e-mail to : relearn@lists.constantvzw.org -
-

- - {% comment %} -

Upload files

-
- - -
- {% endcomment %} - {% endif %} - -

What we say

-

The latest 10 commits, excluding the merges. There is a delay of an hour…

- {% for commit in commits %} -

{{ commit.repo_name }}

-

{{ commit.message|urlize|linebreaksbr }}

-

By {{ commit.author }} on {{ commit.commit_time }}

- {% endfor %} +

The right side

{% block scripts %}{% endblock %} diff --git a/relearn/templatetags/wikify.py b/relearn/templatetags/wikify.py index c3722e99b1a24dfba3f14d7c04292b9062920582..6e334b7b30e8c9f13adf7a1f33362e46c4fd7f3c 100644 --- a/relearn/templatetags/wikify.py +++ b/relearn/templatetags/wikify.py @@ -11,12 +11,3 @@ def dewikify(name): name = name.replace('-', ' ') name = name.replace('::', u' → ') 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 diff --git a/relearn/urls.py b/relearn/urls.py index 125cb36a969565f3daa37cc56dbedae0109faf3a..ef85535d2f9b3014670a8e8785daa5d781445d20 100644 --- a/relearn/urls.py +++ b/relearn/urls.py @@ -5,8 +5,6 @@ from django.views.generic import TemplateView from django.contrib import admin admin.autodiscover() -from etherpadlite.models import * - urlpatterns = patterns( '', url(r'^admin/', include(admin.site.urls)), @@ -19,17 +17,7 @@ urlpatterns = patterns( url(r'^etherpad/create/(?P\d+)/$', 'relearn.views.padCreate', name='pad-create'), url(r'^etherpad/delete/(?P\d+)/$', 'relearn.views.padDelete', name='pad-delete'), url(r'^group/create$', 'relearn.views.groupCreate'), - - url(r'^commits/$', 'relearn.views.all_commits', name='commits'), - url(r'r/(?P[\w\.\-_\:]+)$', 'relearn.views.pad_read', name='pad-read'), - url(r'w/(?P[\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"), ) diff --git a/relearn/views.py b/relearn/views.py index 0b1e1c414ae75e416ff4add4a2f69a7a031a6f18..2600f4a4d30ac33c058c6bd6832257c6e692aedb 100644 --- a/relearn/views.py +++ b/relearn/views.py @@ -19,7 +19,6 @@ from django.contrib.auth.decorators import login_required from django.utils.translation import ugettext_lazy as _ from py_etherpad import EtherpadLiteClient -from gitcommits.models import commits from etherpadlite.models import * from etherpadlite import forms @@ -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)) -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): # The homepage is the pad called ‘start’ (props to DokuWiki!) try: - Pad.objects.get(name='relearn::start') - return pad_read(request, slug='relearn::start') + Pad.objects.get(name='start') + return pad_read(request, slug='start') except Pad.DoesNotExist: 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})