From f9159f05442045838be5b4b00e9bd62be42a4469 Mon Sep 17 00:00:00 2001 From: Marco Rougeth Date: Mon, 5 May 2014 10:57:12 -0300 Subject: [PATCH] Add Dpaste to colab --- requirements.txt | 3 +++ src/colab/custom_settings.py | 15 ++++++++++++++- src/colab/urls.py | 2 +- src/static/dpaste/css/theme.css | 212 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/templates/base.html | 2 ++ src/templates/dpaste/base.html | 16 ++++++++++++++++ src/templates/dpaste/snippet_details.html | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/templates/dpaste/snippet_diff.html | 14 ++++++++++++++ src/templates/dpaste/snippet_form.html | 33 +++++++++++++++++++++++++++++++++ src/templates/dpaste/snippet_new.html | 7 +++++++ 10 files changed, 509 insertions(+), 2 deletions(-) create mode 100644 src/static/dpaste/css/theme.css create mode 100644 src/templates/dpaste/base.html create mode 100644 src/templates/dpaste/snippet_details.html create mode 100644 src/templates/dpaste/snippet_diff.html create mode 100644 src/templates/dpaste/snippet_form.html create mode 100644 src/templates/dpaste/snippet_new.html diff --git a/requirements.txt b/requirements.txt index ad48fab..2d90355 100644 --- a/requirements.txt +++ b/requirements.txt @@ -48,3 +48,6 @@ transliterate==1.5 # Diazo #diazo git+https://github.com/plone/diazo@44ca0da7de5a7ee5d4085c7344701b9cfecfb419 + +# Dpaste +git+https://github.com/interlegis/dpaste diff --git a/src/colab/custom_settings.py b/src/colab/custom_settings.py index 6738121..e9833ca 100644 --- a/src/colab/custom_settings.py +++ b/src/colab/custom_settings.py @@ -107,6 +107,8 @@ INSTALLED_APPS = INSTALLED_APPS + ( 'haystack', 'hitcounter', 'i18n_model', + 'mptt', + 'dpaste', # Own apps 'super_archives', @@ -207,7 +209,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.tz', 'django.contrib.messages.context_processors.messages', 'django.core.context_processors.request', - 'django_browserid.context_processors.browserid', 'django_mobile.context_processors.is_mobile', 'super_archives.context_processors.mailarchive', 'home.context_processors.robots', @@ -303,6 +304,18 @@ CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True TASTYPIE_DEFAULT_FORMATS = ['json', ] +# Dpaste settings +DPASTE_EXPIRE_CHOICES = ( + ('onetime', _(u'One Time Snippet')), + (3600, _(u'In one hour')), + (3600 * 24 * 7, _(u'In one week')), + (3600 * 24 * 30, _(u'In one month')), + ('never', _(u'Never')), +) +DPASTE_EXPIRE_DEFAULT = DPASTE_EXPIRE_CHOICES[4][0] +DPASTE_DEFAULT_GIST_DESCRIPTION = 'Gist created on Colab' +DPASTE_DEFAULT_GIST_NAME = 'colab_paste' + try: from local_settings import * except ImportError: diff --git a/src/colab/urls.py b/src/colab/urls.py index da4beaa..524e7ce 100644 --- a/src/colab/urls.py +++ b/src/colab/urls.py @@ -28,7 +28,7 @@ urlpatterns = patterns('', url(r'^planet/', include('feedzilla.urls')), - url(r'', include('django_browserid.urls')), + url(r'paste/', include('dpaste.urls.dpaste')), # Uncomment the next line to enable the admin: url(r'^colab/admin/', include(admin.site.urls)), diff --git a/src/static/dpaste/css/theme.css b/src/static/dpaste/css/theme.css new file mode 100644 index 0000000..5da06ca --- /dev/null +++ b/src/static/dpaste/css/theme.css @@ -0,0 +1,212 @@ + +.shortcut { + color: #AAA; + font-size: 13px; + font-weight: 300; + margin-left: 15px; +} + +.form-horizontal .form-group { + margin: 0 0 20px 0; +} + +#id_content{ + width: 100%; + font-family: monospace; + font-size: 14px; + line-height: 16px; +} + +/* ---------------------------------------------------------------------------- + Snippet Details +---------------------------------------------------------------------------- */ +#snippet-diff { + display: none; +} +.snippet-options{ + margin-bottom: 20px; +} + +.snippet-reply { + margin-top: 30px; +} + +.snippet-reply-hidden { + opacity: 0.3; +} + +.snippet-reply-hidden, +.snippet-reply-hidden *{ + cursor: pointer; +} + +.snippet-diff-form { +} + +.snippet-rendered { + color: #666; + font-size: 16px; + line-height: 24px; + max-width: 620px; + font-family: Helvetica, FreeSerif, serif; + font-weight: 300; +} +.diff-form { +/* margin-bottom: 10px;*/ +} + +#diff { + margin-bottom: 10px; +/* display: none;*/ +} + +.tree{ + width: 100%; + line-height: 1.8em; +} + +.tree ul, +.tree ul li{ + margin: 0; + padding: 0; + list-style: none; +} + +.tree ul li{ + color: #ccc; + clear: both; +} + +.tree ul li div{ + border-bottom: 1px solid #EEE; +} + +.tree strong{ + color: #111; + font-weight: normal; +} + +.tree ul li li{ + padding-left: 0; + margin-left: 15px; + color: #ccc; + list-style: circle; +} + +/* ---------------------------------------------------------------------------- + .code +---------------------------------------------------------------------------- */ + +.code { + width: 100%; + background: #232829; + color: #f8f8f2; + padding: 20px 30px !important; + border-radius: 0; + padding: 20px 30px; + font-family: Monaco,Menlo,Consolas,"Courier New",monospace; +} + +.code.wordwrap { + overflow: auto; + white-space: nowrap; +} + +.code ol { + margin: 0 0 0 45px; +} + +.code ol li { + color: #aaa; + font-size: 12px; + line-height: 21px; + cursor: pointer; + padding-left: 5px; +} + +.code ol li.marked { + color: #f4e009; + background-color: #4f4800; + margin-right: -30px; + padding-right: 30px; +} + +/* ---------------------------------------------------------------------------- + Pygments +---------------------------------------------------------------------------- */ + +.code .gd { color: #FF494F; display: block; } +.code .gi { color: #53C64A; display: block; } + +.code .hll { background-color: #49483e } +.code .c { color: #75715e } /* Comment */ +.code .err { color: #960050; background-color: #1e0010 } /* Error */ +.code .k { color: #66d9ef } /* Keyword */ +.code .l { color: #ae81ff } /* Literal */ +.code .n { color: #f8f8f2 } /* Name */ +.code .o { color: #f92672 } /* Operator */ +.code .p { color: #f8f8f2 } /* Punctuation */ +.code .cm { color: #75715e } /* Comment.Multiline */ +.code .cp { color: #75715e } /* Comment..codeproc */ +.code .c1 { color: #75715e } /* Comment.Single */ +.code .cs { color: #75715e } /* Comment.Special */ +.code .ge { font-style: italic } /* Generic.Emph */ +.code .gs { font-weight: bold } /* Generic.Strong */ +.code .kc { color: #66d9ef } /* Keyword.Constant */ +.code .kd { color: #66d9ef } /* Keyword.Declaration */ +.code .kn { color: #f92672 } /* Keyword.Namespace */ +.code .kp { color: #66d9ef } /* Keyword.Pseudo */ +.code .kr { color: #66d9ef } /* Keyword.Reserved */ +.code .kt { color: #66d9ef } /* Keyword.Type */ +.code .ld { color: #e6db74 } /* Literal.Date */ +.code .m { color: #ae81ff } /* Literal.Number */ +.code .s { color: #e6db74 } /* Literal.String */ +.code .na { color: #a6e22e } /* Name.Attribute */ +.code .nb { color: #f8f8f2 } /* Name.Builtin */ +.code .nc { color: #a6e22e } /* Name.Class */ +.code .no { color: #66d9ef } /* Name.Constant */ +.code .nd { color: #a6e22e } /* Name.Decorator */ +.code .ni { color: #f8f8f2 } /* Name.Entity */ +.code .ne { color: #a6e22e } /* Name.Exception */ +.code .nf { color: #a6e22e } /* Name.Function */ +.code .nl { color: #f8f8f2 } /* Name.Label */ +.code .nn { color: #f8f8f2 } /* Name.Namespace */ +.code .nx { color: #a6e22e } /* Name.Other */ +.code .py { color: #f8f8f2 } /* Name.Property */ +.code .nt { color: #f92672 } /* Name.Tag */ +.code .nv { color: #f8f8f2 } /* Name.Variable */ +.code .ow { color: #f92672 } /* Operator.Word */ +.code .w { color: #f8f8f2 } /* Text.Whitespace */ +.code .mf { color: #ae81ff } /* Literal.Number.Float */ +.code .mh { color: #ae81ff } /* Literal.Number.Hex */ +.code .mi { color: #ae81ff } /* Literal.Number.Integer */ +.code .mo { color: #ae81ff } /* Literal.Number.Oct */ +.code .sb { color: #e6db74 } /* Literal.String.Backtick */ +.code .sc { color: #e6db74 } /* Literal.String.Char */ +.code .sd { color: #e6db74 } /* Literal.String.Doc */ +.code .s2 { color: #e6db74 } /* Literal.String.Double */ +.code .se { color: #ae81ff } /* Literal.String.Escape */ +.code .sh { color: #e6db74 } /* Literal.String.Heredoc */ +.code .si { color: #e6db74 } /* Literal.String.Interpol */ +.code .sx { color: #e6db74 } /* Literal.String.Other */ +.code .sr { color: #e6db74 } /* Literal.String.Regex */ +.code .s1 { color: #e6db74 } /* Literal.String.Single */ +.code .ss { color: #e6db74 } /* Literal.String.Symbol */ +.code .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ +.code .vc { color: #f8f8f2 } /* Name.Variable.Class */ +.code .vg { color: #f8f8f2 } /* Name.Variable.Global */ +.code .vi { color: #f8f8f2 } /* Name.Variable.Instance */ +.code .il { color: #ae81ff } /* Literal.Number.Integer.Long */ + + +/* ---------------------------------------------------------------------------- + Mobile +---------------------------------------------------------------------------- */ + +@media (max-width: 580px) { + .form-options-expire { + float: left; + clear: left; + margin-top: 10px; + } +} diff --git a/src/templates/base.html b/src/templates/base.html index d571de5..7999fdd 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -184,5 +184,7 @@ {% include "tz/set_utc_offset.html" %} {% browserid_js %} + + {% block footer_js %}{% endblock %} diff --git a/src/templates/dpaste/base.html b/src/templates/dpaste/base.html new file mode 100644 index 0000000..949f3a2 --- /dev/null +++ b/src/templates/dpaste/base.html @@ -0,0 +1,16 @@ +{% extends 'base.html' %} + +{% block head_css %} + +{% endblock %} + +{% block header %} +

Paste

+{% endblock %} + +{% block main-content %} +{% block page %}{% endblock %} +{% endblock %} + +{% block footer_js %}{% endblock %} diff --git a/src/templates/dpaste/snippet_details.html b/src/templates/dpaste/snippet_details.html new file mode 100644 index 0000000..422c0d5 --- /dev/null +++ b/src/templates/dpaste/snippet_details.html @@ -0,0 +1,207 @@ +{% extends "dpaste/base.html" %} + +{% load mptt_tags %} +{% load i18n %} +{% load dpaste_tags %} + +{% block page %} + +{# Snippet options #} + + +
+
+ +
+
+
+ {% csrf_token %} +
+ {% for tree_item,structure in tree|tree_info %} + {% if structure.new_level %}
  • {% else %}
  • {% endif %} +
    + + + + + {% ifequal snippet tree_item %} + #{{ tree_item.id }} + {% else %} + #{{ tree_item.id }} + {% endifequal %} +
    + {% for level in structure.closed_levels %}
{% endfor %} + {% endfor %} +
+
+ +
+
+
+
+ + +
+ + {% if snippet.expire_type == 1 %} + {% blocktrans with date=snippet.expires|timeuntil %}Expires in: {{ date }}{% endblocktrans %} + {% elif snippet.expire_type == 2 %} + {% trans "Snippet never expires" %} + {% elif snippet.expire_type == 3 %} + {% trans "One-time snippet" %} + {% endif %} + + + {% if snippet.pk|in_list:request.session.snippet_list %} + + + {% trans "Delete Now" %} + + {% endif %} + + {% if not snippet.is_single %} + + + {% trans "Compare Snippets" %} + + {% endif %} + + + + {% trans "View Raw" %} + + + + {% trans "Gist" %} + + + New snippet + + +
+ + + {% if snippet.expire_type == 3 %} +
+ + + {% trans "This is a one-time snippet." %} + {% if snippet.remaining_views > 1 %} + {% trans "It will automatically get deleted after {{ remaining }} further views." %} + {% elif snippet.remaining_views == 1 %} + {% trans "It will automatically get deleted after the next view." %} + {% else %} + {% trans "It cannot be viewed again." %} + {% endif %} +
+ {% endif %} + + {% if snippet.lexer == 'text' %} +
+ {{ snippet.content|linebreaksbr }} +
+ {% else %} + {% include "dpaste/snippet_pre.html" %} + {% endif %} + + {% if not snippet.expire_type == 3 %} +
+

{% trans "Reply to this snippet" %} →

+ {% include "dpaste/snippet_form.html" %} +
+ {% endif %} + + + +{% block footer_js %} + +{% endblock %} +{% endblock %} diff --git a/src/templates/dpaste/snippet_diff.html b/src/templates/dpaste/snippet_diff.html new file mode 100644 index 0000000..86bcdb5 --- /dev/null +++ b/src/templates/dpaste/snippet_diff.html @@ -0,0 +1,14 @@ +{% load i18n %} +{% load url from future %} + +

+ {% blocktrans with fileA.get_absolute_url as filea_url and fileB.get_absolute_url as fileb_url and fileA.id as filea_id and fileB.id as fileb_id %} + Diff between #{{ filea_id }} and #{{ fileb_id }} + {% endblocktrans %} +

+ +{% if snippet.lexer == 'diff' %} + {% include "dpaste/snippet_pre.html" %} +{% else %} +

{{ snippet.content }}

+{% endif %} diff --git a/src/templates/dpaste/snippet_form.html b/src/templates/dpaste/snippet_form.html new file mode 100644 index 0000000..adf22f4 --- /dev/null +++ b/src/templates/dpaste/snippet_form.html @@ -0,0 +1,33 @@ +{% load i18n %} + +
+ {% csrf_token %} + {{ snippet_form.non_field_errors }} + +
+ {{ snippet_form.content }} +
+ +
+ +
+ {{ snippet_form.lexer }} +
+ +
+
+ + {{ snippet_form.expires }} +
+ +
+
+ +
+
+ + Ctrl+⏎ ou ⌘+⏎ +
+
+ +
diff --git a/src/templates/dpaste/snippet_new.html b/src/templates/dpaste/snippet_new.html new file mode 100644 index 0000000..648240b --- /dev/null +++ b/src/templates/dpaste/snippet_new.html @@ -0,0 +1,7 @@ +{% extends 'dpaste/base.html' %} + +{% load i18n %} + +{% block page %} + {% include "dpaste/snippet_form.html" %} +{% endblock %} -- libgit2 0.21.2