Huge design overhaul.

This commit is contained in:
Martin Mahner 2013-03-19 19:17:07 +01:00
parent 4183c58cdd
commit f7916a6960
16 changed files with 810 additions and 711 deletions

View file

@ -13,18 +13,31 @@ EXPIRE_CHOICES = (
(3600, _(u'In one hour')),
(3600 * 24 * 7, _(u'In one week')),
(3600 * 24 * 30, _(u'In one month')),
#(3600*24*30*12*100, _(u'Save forever')), # 100 years, I call it forever ;)
)
EXPIRE_DEFAULT = 3600 * 24 * 30
class SnippetForm(forms.ModelForm):
lexer = forms.ChoiceField(choices=LEXER_LIST, initial=LEXER_DEFAULT, label=_(u'Lexer'))
expire_options = forms.ChoiceField(choices=EXPIRE_CHOICES, initial=EXPIRE_DEFAULT, label=_(u'Expires'))
lexer = forms.ChoiceField(
label=_(u'Lexer'),
choices=LEXER_LIST,
initial=LEXER_DEFAULT,
widget=forms.TextInput,
)
expire_options = forms.ChoiceField(
label=_(u'Expires'),
choices=EXPIRE_CHOICES,
initial=EXPIRE_DEFAULT,
)
# Honeypot field
title = forms.CharField(required=False, label=_(u'Title'),
widget=forms.TextInput(attrs={'autocomplete': 'off'}))
title = forms.CharField(
label=_(u'Title'),
required=False,
widget=forms.TextInput(attrs={'autocomplete': 'off'}),
)
def __init__(self, request, *args, **kwargs):
super(SnippetForm, self).__init__(*args, **kwargs)
@ -75,39 +88,3 @@ class SnippetForm(forms.ModelForm):
'content',
'lexer',
)
#===============================================================================
# User Settings
#===============================================================================
USERPREFS_FONT_CHOICES = [(None, _(u'Default'))] + [
(i, i) for i in sorted((
'Monaco',
'Bitstream Vera Sans Mono',
'Courier New',
'Consolas',
))
]
USERPREFS_SIZES = [(None, _(u'Default'))] + [(i, '%dpx' % i) for i in range(5, 25)]
class UserSettingsForm(forms.Form):
default_name = forms.CharField(label=_(u'Default Name'), required=False)
display_all_lexer = forms.BooleanField(
label=_(u'Display all lexer'),
required=False,
widget=forms.CheckboxInput,
help_text=_(u'This also enables the super secret \'guess lexer\' function.'),
)
wordwrap = forms.BooleanField(
label=_('Always enable wordwrap'),
required=False,
widget=forms.CheckboxInput,
help_text=_(u'Wordwrap is always enabled for text lexers such as \'text\' or \'reStructuredText\'.'),
)
font_family = forms.ChoiceField(label=_(u'Font Family'), required=False, choices=USERPREFS_FONT_CHOICES)
font_size = forms.ChoiceField(label=_(u'Font Size'), required=False, choices=USERPREFS_SIZES)
line_height = forms.ChoiceField(label=_(u'Line Height'), required=False, choices=USERPREFS_SIZES)

View file

@ -0,0 +1,404 @@
body{
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
}
a:link,
a:visited{
color: #3D813A;
text-decoration: none;
}
a:hover{
color: #52AA4D;
text-decoration: underline;
}
p.hint{
color: #333;
margin-top: 30px;
}
p.hint em{
color: black;
background-color: #c9f8b4;
display: inline-block;
padding: 2px 3px;
font-style: normal;
}
hr.clear{
clear: both;
border: none;
margin: 0;
padding: 0;
height: 0;
overflow: hidden;
font-size: 0;
line-height: 0;
visibility: hidden;
}
div.success{
background-color: green;
color: White;
margin: 10px 0;
padding: 10px 20px;
}
div.success a{
color: White;
text-decoration: underline;
}
div.hint{
padding: 5px 20px;
background-color: #F7F1C9;
margin: 20px 0;
}
/* *******************************************
* Header
******************************************* */
#header{
background-color: #D6F1B7;
border-bottom: 1px solid #C6EB9A;
padding: 10px 20px;
font-size: 14px;
}
#header span.new_snippet{
float: right;
}
#header h1{
margin: 0;
color: #555555;
font-size: 14px;
}
#header h1 span.date{
color: gray;
color: #666;
padding-left: 15px;
}
#header a:link,
#header a:visited{
text-decoration: none;
color: #333;
font-weight: Bold;
}
#header a:hover{
text-decoration: underline;
}
/* *******************************************
* Content
******************************************* */
#content{
padding: 0 20px;
margin: 0;
width: 70%;
float: left;
}
#content h2{
font-size: 1.3em;
line-height: 1.6em;
}
#content h2.divider{
font-size: 1em;
padding: 5px 20px;
background-color: #f8f8f8;
margin: 40px 0 20px 0;
}
#content h2 span{
font-weight: normal;
}
div.accordion h2{
cursor: pointer;
color: #3D813A;
}
div.accordion h2:hover{
text-decoration: underline;
}
/* *******************************************
* Snippet table
******************************************* */
div.snippet{
overflow: auto;
}
div.snippet-options{
float: right;
font-size: 0.9em;
margin-top: 5px;
}
div.snippet table{
margin: 0;
padding: 0;
border-collapse: collapse;
}
div.snippet table td{
margin: 0;
padding: 0 4px;
vertical-align: top;
}
div.snippet table th{
border-right: 1px solid #ccc;
vertical-align: top;
}
div.snippet table th a{
display: block;
text-decoration: none;
color: #888;
text-align: right;
padding: 0 4px 0 18px;
}
/* *******************************************
* Form
******************************************* */
form.snippetform ol{
margin: 0;
padding: 0;
list-style: none;
}
form.snippetform ol li{
margin: 0;
padding: 5px 10px;
border-bottom: 1px solid #EEE;
clear: left;
}
form.snippetform label{
width: 125px;
display: inline-block;
}
form.snippetform #id_content{
width: 80%;
height: 320px;
font-family: monospace;
font-size: 0.9em;
}
form.snippetform #id_author,
form.snippetform #id_title{
width: 60%;
opacity: 0.7;
}
form.snippetform li.submit input{
margin-left: 125px;
}
form.snippetform ul.errorlist,
form.snippetform ul.errorlist li{
margin: 0;
padding: 0;
list-style: none;
color: #c00;
font-weight: bold;
border: none;
}
form.snippetform ul.errorlist li{
padding: 10px 0 5px 0;
}
/* *******************************************
* History + Tree
******************************************* */
#sidebar{
padding: 0 20px 0 10px;
margin: 20px 0 0 0;
float: right;
width: 20%;
overflow: auto;
border-left: 1px solid #DDD;
}
#sidebar h2{
font-size: 1em;
border-bottom: 1px solid #DDD;
color: #888;
margin-top: 0;
text-transform: uppercase;
width: auto !important;
}
div.tree{
margin: 0 0 15px 0;
line-height: 1.8em;
}
div.tree ul,
div.tree ul li{
margin: 0;
padding: 0;
list-style: none;
}
div.tree ul li{
clear: both;
}
div.tree ul li div{
border-bottom: 1px solid #EEE;
}
div.tree span.diff{
float: right;
}
div.tree strong{
color: #111;
font-weight: normal;
}
div.tree ul li li{
padding-left: 0;
margin-left: 15px;
color: #ccc;
list-style: circle;
}
div.tree div.submit{
margin: 8px 0 0 0;
text-align: right;
}
div.tree div.submit input{
font-size: 0.8em;
}
/* *******************************************
* Footer
******************************************* */
#footer{
position: fixed;
right: 1em;
bottom: 1em;
}
#footer form.setlang{
display: inline;
padding-right: 15px;
}
#footer form.setlang input,
#footer form.setlang select{
font-size: 0.8em;
}
#footer a:link,
#footer a:visited{
background-color: #D6F1B7;
color: #555;
text-decoration: none;
padding: 3px 6px;
}
#footer a:hover,
#footer a:active{
background-color: #D6F1B7;
color: #000;
text-decoration: none;
}
/* *******************************************
* Pygments
******************************************* */
pre.code {
font-family: "Bitstream Vera Sans Mono", Monaco, Consolas, monospace;
font-size: 12px;
line-height: 17px;
margin: 0;
padding: 0;
}
pre.code div.line:hover{
background-color: #FFFFE6;
}
pre.code div.line.marked,
pre.code div.line.marked *{
background-color: #BAE688 !important;
}
.code .c { color: #999988; font-style: italic } /* Comment */
/* .code .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.code .k { font-weight: bold } /* Keyword */
.code .o { font-weight: bold } /* Operator */
.code .cm { color: #999988; font-style: italic } /* Comment.Multiline */
.code .cp { color: #999999; font-weight: bold } /* Comment..codeproc */
.code .c1 { color: #999988; font-style: italic } /* Comment.Single */
.code .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.code .ge { font-style: italic } /* Generic.Emph */
.code .gr { color: #aa0000 } /* Generic.Error */
.code .gh { color: #999999 } /* Generic.Heading */
.code .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.code .go { color: #888888 } /* Generic.Output */
.code .gp { color: #555555 } /* Generic.Prompt */
.code .gs { font-weight: bold } /* Generic.Strong */
.code .gu { color: #aaaaaa } /* Generic.Subheading */
.code .gt { color: #aa0000 } /* Generic.Traceback */
.code .kc { font-weight: bold } /* Keyword.Constant */
.code .kd { font-weight: bold } /* Keyword.Declaration */
.code .kp { font-weight: bold } /* Keyword.Pseudo */
.code .kr { font-weight: bold } /* Keyword.Reserved */
.code .kt { color: #445588; font-weight: bold } /* Keyword.Type */
.code .m { color: #009999 } /* Literal.Number */
.code .s { color: #bb8844 } /* Literal.String */
.code .na { color: #008080 } /* Name.Attribute */
.code .nb { color: #999999 } /* Name.Builtin */
.code .nc { color: #445588; font-weight: bold } /* Name.Class */
.code .no { color: #ff99ff } /* Name.Constant */
.code .ni { color: #800080 } /* Name.Entity */
.code .ne { color: #990000; font-weight: bold } /* Name.Exception */
.code .nf { color: #990000; font-weight: bold } /* Name.Function */
.code .nn { color: #555555 } /* Name.Namespace */
.code .nt { color: #000080 } /* Name.Tag */
.code .nv { color: purple } /* Name.Variable */
.code .ow { font-weight: bold } /* Operator.Word */
.code .mf { color: #009999 } /* Literal.Number.Float */
.code .mh { color: #009999 } /* Literal.Number.Hex */
.code .mi { color: #009999 } /* Literal.Number.Integer */
.code .mo { color: #009999 } /* Literal.Number.Oct */
.code .sb { color: #bb8844 } /* Literal.String.Backtick */
.code .sc { color: #bb8844 } /* Literal.String.Char */
.code .sd { color: #bb8844 } /* Literal.String.Doc */
.code .s2 { color: #bb8844 } /* Literal.String.Double */
.code .se { color: #bb8844 } /* Literal.String.Escape */
.code .sh { color: #bb8844 } /* Literal.String.Heredoc */
.code .si { color: #bb8844 } /* Literal.String.Interpol */
.code .sx { color: #bb8844 } /* Literal.String.Other */
.code .sr { color: #808000 } /* Literal.String.Regex */
.code .s1 { color: #bb8844 } /* Literal.String.Single */
.code .ss { color: #bb8844 } /* Literal.String.Symbol */
.code .bp { color: #999999 } /* Name.Builtin.Pseudo */
.code .vc { color: #ff99ff } /* Name.Variable.Class */
.code .vg { color: #ff99ff } /* Name.Variable.Global */
.code .vi { color: #ff99ff } /* Name.Variable.Instance */
.code .il { color: #009999 } /* Literal.Number.Integer.Long */

View file

@ -1,249 +1,86 @@
body{
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
/* ----------------------------------------------------------------------------
Basics
---------------------------------------------------------------------------- */
body {
padding: 10px 20px 40px 20px;
}
a:link,
a:visited{
color: #3D813A;
text-decoration: none;
/* Custom container */
.container-fluid {
margin: 0 auto;
max-width: 1100px;
}
a:hover{
color: #52AA4D;
text-decoration: underline;
.container > hr {
margin: 20px 0;
}
p.hint{
color: #333;
margin-top: 30px;
.headline{
color: #5393b4;
}
p.hint em{
color: black;
background-color: #c9f8b4;
display: inline-block;
padding: 2px 3px;
font-style: normal;
/* ----------------------------------------------------------------------------
Snippet form
---------------------------------------------------------------------------- */
#id_content{
box-sizing: border-box;
width: 100%;
height: 300px;
font-family: monospace;
font-size: 12px;
line-height: 16px;
}
hr.clear{
clear: both;
border: none;
margin: 0;
padding: 0;
height: 0;
overflow: hidden;
font-size: 0;
line-height: 0;
visibility: hidden;
}
div.success{
background-color: green;
color: White;
margin: 10px 0;
padding: 10px 20px;
}
div.success a{
color: White;
text-decoration: underline;
}
div.hint{
padding: 5px 20px;
background-color: #F7F1C9;
margin: 20px 0;
}
/* *******************************************
* Header
******************************************* */
#header{
background-color: #D6F1B7;
border-bottom: 1px solid #C6EB9A;
padding: 10px 20px;
font-size: 14px;
}
#header span.new_snippet{
float: right;
}
#header h1{
margin: 0;
color: #555555;
font-size: 14px;
}
#header h1 span.date{
color: gray;
color: #666;
padding-left: 15px;
}
#header a:link,
#header a:visited{
text-decoration: none;
color: #333;
font-weight: Bold;
}
#header a:hover{
text-decoration: underline;
}
/* *******************************************
* Content
******************************************* */
#content{
padding: 0 20px;
margin: 0;
width: 70%;
.form-options-lexer {
float: left;
}
#content h2{
font-size: 1.3em;
line-height: 1.6em;
.form-options-expire {
float: right;
}
#content h2.divider{
font-size: 1em;
padding: 5px 20px;
background-color: #f8f8f8;
margin: 40px 0 20px 0;
.form-options-expire .add-on{
border-radius: 4px !important;
margin-right: 3px;
}
#content h2 span{
font-weight: normal;
.form-horizontal .form-actions {
padding-left: 20px;
}
div.accordion h2{
.twitter-follow-button-container {
float:right;
opacity: 0.5
}
.twitter-follow-button-container:hover{
opacity: 1;
}
/* ----------------------------------------------------------------------------
Snippet Details
---------------------------------------------------------------------------- */
.snippet-options{
margin-bottom: 20px;
}
.snippet-reply-hidden {
opacity: 0.3;
}
.snippet-reply-hidden,
.snippet-reply-hidden *{
cursor: pointer;
color: #3D813A;
}
div.accordion h2:hover{
text-decoration: underline;
}
.snippet-diff {
background: #f3f3f3;
margin-bottom: 30px;
padding: 1em 1em 0 1em;
border-radius: 4px;
/* *******************************************
* Snippet table
******************************************* */
div.snippet{
overflow: auto;
}
div.snippet-options{
float: right;
font-size: 0.9em;
margin-top: 5px;
}
div.snippet table{
margin: 0;
padding: 0;
border-collapse: collapse;
}
div.snippet table td{
margin: 0;
padding: 0 4px;
vertical-align: top;
}
div.snippet table th{
border-right: 1px solid #ccc;
vertical-align: top;
}
div.snippet table th a{
display: block;
text-decoration: none;
color: #888;
text-align: right;
padding: 0 4px 0 18px;
}
/* *******************************************
* Form
******************************************* */
form.snippetform ol{
margin: 0;
padding: 0;
list-style: none;
}
form.snippetform ol li{
margin: 0;
padding: 5px 10px;
border-bottom: 1px solid #EEE;
clear: left;
}
form.snippetform label{
width: 125px;
display: inline-block;
}
form.snippetform #id_content{
width: 80%;
height: 320px;
font-family: monospace;
font-size: 0.9em;
}
form.snippetform #id_author,
form.snippetform #id_title{
width: 60%;
opacity: 0.7;
}
form.snippetform li.submit input{
margin-left: 125px;
}
form.snippetform ul.errorlist,
form.snippetform ul.errorlist li{
margin: 0;
padding: 0;
list-style: none;
color: #c00;
font-weight: bold;
border: none;
}
form.snippetform ul.errorlist li{
padding: 10px 0 5px 0;
}
/* *******************************************
* History + Tree
******************************************* */
#sidebar{
padding: 0 20px 0 10px;
margin: 20px 0 0 0;
float: right;
width: 20%;
overflow: auto;
border-left: 1px solid #DDD;
}
#sidebar h2{
font-size: 1em;
border-bottom: 1px solid #DDD;
color: #888;
margin-top: 0;
text-transform: uppercase;
width: auto !important;
display: none;
}
div.tree{
@ -291,114 +128,94 @@ div.tree div.submit input{
font-size: 0.8em;
}
/* *******************************************
* Footer
******************************************* */
/* ----------------------------------------------------------------------------
Pre
---------------------------------------------------------------------------- */
#footer{
position: fixed;
right: 1em;
bottom: 1em;
.prettyprint {
background-color: #272822;
padding: 10px 15px 10px 0;
}
#footer form.setlang{
display: inline;
padding-right: 15px;
ol.linenums {
margin: 0 0 0 45px; /* IE indents via margin-left */
}
#footer form.setlang input,
#footer form.setlang select{
font-size: 0.8em;
}
#footer a:link,
#footer a:visited{
background-color: #D6F1B7;
ol.linenums li {
color: #555;
text-decoration: none;
padding: 3px 6px;
}
#footer a:hover,
#footer a:active{
background-color: #D6F1B7;
color: #000;
text-decoration: none;
}
/* *******************************************
* Pygments
******************************************* */
pre.code {
font-family: "Bitstream Vera Sans Mono", Monaco, Consolas, monospace;
font-size: 12px;
line-height: 17px;
margin: 0;
padding: 0;
line-height: 20px;
cursor: pointer;
}
pre.code div.line:hover{
background-color: #FFFFE6;
ol.linenums li.marked {
background-color: #5e6152;
}
pre.code div.line.marked,
pre.code div.line.marked *{
background-color: #BAE688 !important;
}
/* ----------------------------------------------------------------------------
Pygments
---------------------------------------------------------------------------- */
pre .gd { background-color: #d68c83; display: block; }
pre .gi { background-color: #a7cb7d; display: block; }
.code .c { color: #999988; font-style: italic } /* Comment */
/* .code .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.code .k { font-weight: bold } /* Keyword */
.code .o { font-weight: bold } /* Operator */
.code .cm { color: #999988; font-style: italic } /* Comment.Multiline */
.code .cp { color: #999999; font-weight: bold } /* Comment..codeproc */
.code .c1 { color: #999988; font-style: italic } /* Comment.Single */
.code .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.code .ge { font-style: italic } /* Generic.Emph */
.code .gr { color: #aa0000 } /* Generic.Error */
.code .gh { color: #999999 } /* Generic.Heading */
.code .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.code .go { color: #888888 } /* Generic.Output */
.code .gp { color: #555555 } /* Generic.Prompt */
.code .gs { font-weight: bold } /* Generic.Strong */
.code .gu { color: #aaaaaa } /* Generic.Subheading */
.code .gt { color: #aa0000 } /* Generic.Traceback */
.code .kc { font-weight: bold } /* Keyword.Constant */
.code .kd { font-weight: bold } /* Keyword.Declaration */
.code .kp { font-weight: bold } /* Keyword.Pseudo */
.code .kr { font-weight: bold } /* Keyword.Reserved */
.code .kt { color: #445588; font-weight: bold } /* Keyword.Type */
.code .m { color: #009999 } /* Literal.Number */
.code .s { color: #bb8844 } /* Literal.String */
.code .na { color: #008080 } /* Name.Attribute */
.code .nb { color: #999999 } /* Name.Builtin */
.code .nc { color: #445588; font-weight: bold } /* Name.Class */
.code .no { color: #ff99ff } /* Name.Constant */
.code .ni { color: #800080 } /* Name.Entity */
.code .ne { color: #990000; font-weight: bold } /* Name.Exception */
.code .nf { color: #990000; font-weight: bold } /* Name.Function */
.code .nn { color: #555555 } /* Name.Namespace */
.code .nt { color: #000080 } /* Name.Tag */
.code .nv { color: purple } /* Name.Variable */
.code .ow { font-weight: bold } /* Operator.Word */
.code .mf { color: #009999 } /* Literal.Number.Float */
.code .mh { color: #009999 } /* Literal.Number.Hex */
.code .mi { color: #009999 } /* Literal.Number.Integer */
.code .mo { color: #009999 } /* Literal.Number.Oct */
.code .sb { color: #bb8844 } /* Literal.String.Backtick */
.code .sc { color: #bb8844 } /* Literal.String.Char */
.code .sd { color: #bb8844 } /* Literal.String.Doc */
.code .s2 { color: #bb8844 } /* Literal.String.Double */
.code .se { color: #bb8844 } /* Literal.String.Escape */
.code .sh { color: #bb8844 } /* Literal.String.Heredoc */
.code .si { color: #bb8844 } /* Literal.String.Interpol */
.code .sx { color: #bb8844 } /* Literal.String.Other */
.code .sr { color: #808000 } /* Literal.String.Regex */
.code .s1 { color: #bb8844 } /* Literal.String.Single */
.code .ss { color: #bb8844 } /* Literal.String.Symbol */
.code .bp { color: #999999 } /* Name.Builtin.Pseudo */
.code .vc { color: #ff99ff } /* Name.Variable.Class */
.code .vg { color: #ff99ff } /* Name.Variable.Global */
.code .vi { color: #ff99ff } /* Name.Variable.Instance */
.code .il { color: #009999 } /* Literal.Number.Integer.Long */
pre .hll { background-color: #49483e }
pre { background: #272822; color: #f8f8f2 }
pre .c { color: #75715e } /* Comment */
pre .err { color: #960050; background-color: #1e0010 } /* Error */
pre .k { color: #66d9ef } /* Keyword */
pre .l { color: #ae81ff } /* Literal */
pre .n { color: #f8f8f2 } /* Name */
pre .o { color: #f92672 } /* Operator */
pre .p { color: #f8f8f2 } /* Punctuation */
pre .cm { color: #75715e } /* Comment.Multiline */
pre .cp { color: #75715e } /* Comment.Preproc */
pre .c1 { color: #75715e } /* Comment.Single */
pre .cs { color: #75715e } /* Comment.Special */
pre .ge { font-style: italic } /* Generic.Emph */
pre .gs { font-weight: bold } /* Generic.Strong */
pre .kc { color: #66d9ef } /* Keyword.Constant */
pre .kd { color: #66d9ef } /* Keyword.Declaration */
pre .kn { color: #f92672 } /* Keyword.Namespace */
pre .kp { color: #66d9ef } /* Keyword.Pseudo */
pre .kr { color: #66d9ef } /* Keyword.Reserved */
pre .kt { color: #66d9ef } /* Keyword.Type */
pre .ld { color: #e6db74 } /* Literal.Date */
pre .m { color: #ae81ff } /* Literal.Number */
pre .s { color: #e6db74 } /* Literal.String */
pre .na { color: #a6e22e } /* Name.Attribute */
pre .nb { color: #f8f8f2 } /* Name.Builtin */
pre .nc { color: #a6e22e } /* Name.Class */
pre .no { color: #66d9ef } /* Name.Constant */
pre .nd { color: #a6e22e } /* Name.Decorator */
pre .ni { color: #f8f8f2 } /* Name.Entity */
pre .ne { color: #a6e22e } /* Name.Exception */
pre .nf { color: #a6e22e } /* Name.Function */
pre .nl { color: #f8f8f2 } /* Name.Label */
pre .nn { color: #f8f8f2 } /* Name.Namespace */
pre .nx { color: #a6e22e } /* Name.Other */
pre .py { color: #f8f8f2 } /* Name.Property */
pre .nt { color: #f92672 } /* Name.Tag */
pre .nv { color: #f8f8f2 } /* Name.Variable */
pre .ow { color: #f92672 } /* Operator.Word */
pre .w { color: #f8f8f2 } /* Text.Whitespace */
pre .mf { color: #ae81ff } /* Literal.Number.Float */
pre .mh { color: #ae81ff } /* Literal.Number.Hex */
pre .mi { color: #ae81ff } /* Literal.Number.Integer */
pre .mo { color: #ae81ff } /* Literal.Number.Oct */
pre .sb { color: #e6db74 } /* Literal.String.Backtick */
pre .sc { color: #e6db74 } /* Literal.String.Char */
pre .sd { color: #e6db74 } /* Literal.String.Doc */
pre .s2 { color: #e6db74 } /* Literal.String.Double */
pre .se { color: #ae81ff } /* Literal.String.Escape */
pre .sh { color: #e6db74 } /* Literal.String.Heredoc */
pre .si { color: #e6db74 } /* Literal.String.Interpol */
pre .sx { color: #e6db74 } /* Literal.String.Other */
pre .sr { color: #e6db74 } /* Literal.String.Regex */
pre .s1 { color: #e6db74 } /* Literal.String.Single */
pre .ss { color: #e6db74 } /* Literal.String.Symbol */
pre .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
pre .vc { color: #f8f8f2 } /* Name.Variable.Class */
pre .vg { color: #f8f8f2 } /* Name.Variable.Global */
pre .vi { color: #f8f8f2 } /* Name.Variable.Instance */
pre .il { color: #ae81ff } /* Literal.Number.Integer.Long */

View file

@ -1,11 +1,11 @@
{% extends "dpaste/base.html" %}
{% block headline %}
<h1>About dpaste.de</h1>
{% endblock %}
{% block title %}About dpaste.de{% endblock %}
{% block headline %}About dpaste.de{% endblock %}
{% block dpaste_nav_about %}active{% endblock %}
{% block content %}
<h2>API</h2>
{% block page %}
<h3>API</h3>
<pre>#!/usr/bin/env python
@ -31,43 +31,30 @@ if __name__ == '__main__':
<p>Or you could use <code>curl</code>:
<code>alias dpaste="curl -F 'content=&lt;-' http://dpaste.de/api/</code></p>
<h2>Applications using the API:</h2>
<hr>
<h3>Applications using the API:</h3>
<ul>
<li><a href="https://github.com/bartTC/dpasteGUI/wiki">dpasteGUI</a>, a OS X interface</li>
<li><a href="https://github.com/bartTC/SubDpaste">a dpaste Sublime 2 plugin</a></li>
<li><a href="http://marmalade-repo.org/packages/dpaste_de">Marmalade</a>, a Emacs plugin</li>
</ul>
{% endblock %}
{% block sidebar %}
<h2>Imprint</h2>
<p>
<strong>Address</strong>
</p>
<p>
Martin Mahner<br/>
Lauterbacher Str. 4<br/>
DE-18581 Putbus<br/>
Germany
</p>
<p>
<strong>Jabber/E-Mail:</strong>
</p>
<p>
<a href="mailto:martin@mahner.org">martin@mahner.org</a>
</p>
<p>
<strong>Phone:</strong>
</p>
<p>
+49 38301 890(770+8)<sup>1</sup><br/><br/>
<small style="font-size:0.9em;"><sup>1</sup> Yes, that's math!</small>
</p>
<hr/>
<h3>Imprint</h3>
<p><strong>Address:</strong></p>
<p>
Martin Mahner<br/>
Lauterbacher Str. 4<br/>
DE-18581 Putbus<br/>
Germany
</p>
<p><strong>Jabber/E-Mail:</strong></p>
<p><a href="mailto:martin@mahner.org">martin@mahner.org</a></p>
{% endblock %}

View file

@ -1,39 +1,53 @@
{% load i18n %}
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
{% load i18n staticfiles %}<!DOCTYPE html>
<html>
<head>
<title>dpaste.de: {% block title %}{% trans "New snippet" %}{% endblock %}</title>
<link rel="stylesheet" media="screen, projection" href="{{ STATIC_URL }}dpaste/theme.css"/>
<link href="{% static "dpaste/bootstrap/css/bootstrap.min.css" %}" rel="stylesheet" media="screen">
<link href="{% static "dpaste/theme.css" %}" rel="stylesheet" media="screen">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block extrahead %}{% endblock %}
</head>
<body>
<div id="header">
<span class="new_snippet"><a href="{% url "snippet_new" %}">{% trans "New snippet" %} &rarr;</a></span>
{% block headline %}{% endblock %}
<div class="container-fluid">
<header>
<ul class="nav nav-pills pull-right">
<li class="{% block dpaste_nav_about %}{% endblock %}"><a href="{% url "about" %}">{% trans "About" %}</a></li>
<li class="{% block dpaste_nav_history %}{% endblock %}"><a href="{% url "snippet_history" %}">{% trans "History" %}</a></li>
<li class="{% block dpaste_nav_new %}{% endblock %}"><a href="{% url "snippet_new" %}">{% trans "New snippet" %} &rarr;</a></li>
</ul>
<h3 class="headline">{% block headline %}{% endblock %}</h3>
</header>
<hr>
{% block page %}
PAGE MISSING
{% endblock %}
</div>
<div id="sidebar">
{% block sidebar %}{% endblock %}
</div>
<div id="content">
{% block content %}{% endblock %}
</div>
<div id="footer">
<a href="{% url "snippet_userlist" %}">{% trans "Recent snippets" %}</a>
<a href="{% url "snippet_userprefs" %}">{% trans "Settings" %}</a>
<a href="{% url "about" %}">{% trans "About" %}</a>
</div>
{% block script_footer %}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="{% static "dpaste/bootstrap/js/bootstrap.min.js" %}"></script>
<script type="text/javascript">
$(document).ready(function(){
{% if request.session.userprefs.display_all_lexer %}
$('#guess_lexer_btn').click(function(){
$.getJSON('{% url "snippet_guess_lexer" %}',
{'codestring': $('#id_content').val()},
function(data){
if(data.lexer == "unknown"){
$('#guess_lexer_btn').css('color', 'red');
}else{
$('#id_lexer').val(data.lexer);
$('#guess_lexer_btn').css('color', 'inherit');
}
});
});
{% endif %}
});
</script>
{% endblock %}
</body>

View file

@ -3,114 +3,89 @@
{% load i18n %}
{% load dpaste_tags %}
{% block extrahead %}
{% if request.session.userprefs %}
<style type="text/css" media="all">
.code{
{% ifnotequal request.session.userprefs.font_family "None" %}font-family: {{ request.session.userprefs.font_family }} !important;{% endifnotequal %}
{% ifnotequal request.session.userprefs.font_size "None" %}font-size: {{ request.session.userprefs.font_size }}px !important;{% endifnotequal %}
{% ifnotequal request.session.userprefs.line_height "None" %}line-height: {{ request.session.userprefs.line_height }}px !important;{% endifnotequal %}
}
</style>
{% endif %}
{% endblock %}
{% block title %}{% trans "Snippet" %} #{{ snippet.pk }}{% endblock %}
{% block headline %}
<h1>
{% trans "Snippet" %} #{{ snippet.pk }}
{% if snippet.parent_id %}
{% blocktrans with snippet.parent.get_absolute_url as parent_url and snippet.parent.id as parent_id %}(Copy of <a href="{{ parent_url }}">snippet #{{ parent_id }}</a>){% endblocktrans %}
{% endif %}
<span class="date">{{ snippet.published|date:_("DATETIME_FORMAT") }} ({% trans "UTC" %})</span>
</h1>
{% endblock %}
{% block headline %}{% trans "Snippet" %} #{{ snippet.pk }}{% endblock %}
{% block content %}
<div id="diff" style="display:none;">diff</div>
{% block page %}
<div class="accordion">
<div class="snippet-options">
<abbr title="{% trans "Time to life" %}">TTL:</abbr> {{ snippet.expires|timeuntil }}
&mdash;
{% if snippet.pk|in_list:request.session.snippet_list %}
<a onclick="return confirm('{% trans "Really delete this snippet?" %}')" href="{% url "snippet_delete" snippet.secret_id %}">Delete now!</a>
&mdash;
{% endif %}
<span id="toggleWordwrap"><input type="checkbox"/> <a href="#">{% trans "Wordwrap" %}</a></span>
</div>
<h2>
{% if snippet.title %}{{ snippet.title }}{% else %} {% trans "Snippet" %} #{{ snippet.id}}{% endif %}
<span>{% if snippet.author %}{% blocktrans with snippet.author as author %}by {{ author }}{% endblocktrans %}{% endif %}</span>
</h2>
<div class="container">
<div class="snippet">
<table>
<tr>
<th><pre class="code">{% for l in lines %}<a href="#l{{ forloop.counter }}" id="l{{ forloop.counter }}">{{ forloop.counter }}</a>{% endfor %}</pre></th>
<td><pre class="code">{% for line in snippet|highlight %}<div class="line" id="l{{ forloop.counter }}">{% if line %}{{ line|safe }}{% else %}&nbsp;{% endif %}</div>{% endfor %}</pre></td>
</tr>
</table>
<!-- ======================================================================
Snippet Diff View
======================================================================= -->
<div id="snippet-diff" class="snippet-diff container-fluid">
<div class="row-fluid">
<div class="span9">
<div id="diff" style="display:none;"></div>
</div>
<div class="span3">
<form method="get" id="diffform" action="{% url "snippet_diff" %}">
{% csrf_token %}
<div class="tree">
{% for tree_item,structure in tree|tree_info %}
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
<div>
<span class="diff">
<input type="radio" name="a" value="{{ tree_item.id }}" {% ifequal tree_item.id snippet.parent_id %}checked="checked"{% endifequal %}/>
<input type="radio" name="b" value="{{ tree_item.id }}" {% ifequal snippet tree_item %}checked="checked"{% endifequal %}/>
</span>
{% ifequal snippet tree_item %}
<strong>#{{ tree_item.id }}</strong>
{% else %}
<a href="{{ tree_item.get_absolute_url }}">#{{ tree_item.id }}</a>
{% endifequal %}
</div>
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
{% endfor %}
<div class="submit">
<input type="submit" value="{% trans "Compare" %}"/>
</div>
</div>
</form>
</div>
</div>
</div>
<h2>{% trans "Write an answer" %} &rarr;</h2>
<div class="container" style="display: none;">
<!-- ======================================================================
Snippet Options
======================================================================= -->
<div class="btn-group snippet-options">
<button disabled class="btn">Expires in: {{ snippet.expires|timeuntil }}</button>
{% if snippet.pk|in_list:request.session.snippet_list %}
<a class="btn" href="{% url "snippet_delete" snippet.secret_id %}" onclick="return confirm('{% trans "Really delete this snippet?" %}');"><i class="icon-trash"></i> {% trans "Delete Now" %}</a>
{% endif %}
<a class="btn snippet-diff-trigger" href="#snippet-diff"><i class="icon-search"></i> {% trans "Compare Snippets" %}</a>
<a class="btn" href="{% url "snippet_details_raw" snippet.secret_id %}"><i class="icon-align-left"></i> {% trans "View Raw" %}</a>
</div>
<!-- ======================================================================
Snippet
======================================================================= -->
{% include "dpaste/snippet_pre.html" %}
<!-- ======================================================================
Snippet Reply
======================================================================= -->
<hr/>
<div class="snippet-reply snippet-reply-hidden">
<h3>{% trans "Reply to this snippet" %} &rarr;</h3>
{% include "dpaste/snippet_form.html" %}
</div>
</div>
{% endblock %}
{% block sidebar %}
<h2>{% trans "History" %}</h2>
<form method="get" id="diffform" action="{% url "snippet_diff" %}">
{% csrf_token %}
<div class="tree">
{% for tree_item,structure in tree|tree_info %}
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
<div>
<span class="diff">
<input type="radio" name="a" value="{{ tree_item.id }}" {% ifequal tree_item.id snippet.parent_id %}checked="checked"{% endifequal %}/>
<input type="radio" name="b" value="{{ tree_item.id }}" {% ifequal snippet tree_item %}checked="checked"{% endifequal %}/>
</span>
{% ifequal snippet tree_item %}
<strong>{% trans "Snippet" %} #{{ tree_item.id }}</strong>
{% else %}
<a href="{{ tree_item.get_absolute_url }}">{% trans "Snippet" %} #{{ tree_item.id }}</a>
{% endifequal %}
</div>
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
{% endfor %}
<div class="submit">
<input type="submit" value="{% trans "Compare" %}"/>
</div>
</div>
</form>
<h2>{% trans "Options" %}</h2>
<p><a href="{% url "snippet_details_raw" snippet.secret_id %}">{% trans "View raw" %}</a></p>
{% endblock %}
{% block script_footer %}
{{ block.super }}
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.2/jquery-ui.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$(document).ready(function(){
$('.snippet-reply-hidden').click(function(e){
$(this).removeClass('snippet-reply-hidden');
});
curLine = document.location.hash;
if(curLine.substring(0,2) == '#l'){
$('div.snippet div.line'+curLine).addClass('marked');
}
$("div.accordion").accordion({
autoHeight: false,
header: 'h2',
animation: 'bounceslide',
duration: 2000,
$('.snippet-diff-trigger').click(function(e){
e.preventDefault();
$('#snippet-diff').slideDown('fast');
$('#snippet-diff form').submit();
});
/**
@ -126,54 +101,38 @@ jQuery(document).ready(function(){
return false;
});
/**
* Wordwrap
*/
$('#toggleWordwrap a').click(function(){
$('#toggleWordwrap input').trigger('click').trigger('change');
});
$('#toggleWordwrap input').change(function(){
if($(this).attr('checked')) {
$('div.snippet pre.code').css('white-space', 'pre-wrap');
} else {
$('div.snippet pre.code').css('white-space', 'pre');
}
});
// Activate wordwrap for text heavy lexers or if enabled in the settings
if('{{ wordwrap }}' === 'True' || '{{ request.session.userprefs.wordwrap }}' === 'True') {
$('#toggleWordwrap a').trigger('click');
}
/**
* Line Highlighting
*/
$('div.snippet th a').each(function(i){
$(this).click(function(){
var j = $(this).text();
$('div.snippet div.line.marked').removeClass('marked');
$('div.snippet div.line#l'+j).toggleClass('marked');
});
});
var curLine = document.location.hash,
hashlist;
{% if request.session.userprefs.display_all_lexer %}
/**
* Lexer Guessing
*/
$('#guess_lexer_btn').click(function(){
$.getJSON('{% url "snippet_guess_lexer" %}',
{'codestring': $('#id_content').val()},
function(data){
if(data.lexer == "unknown"){
$('#guess_lexer_btn').css('color', 'red');
}else{
$('#id_lexer').val(data.lexer);
$('#guess_lexer_btn').css('color', 'inherit');
}
if(curLine.substring(0,2) == '#L'){
hashlist = curLine.substring(2).split(',');
if (hashlist.length > 0 && hashlist[0] !== "") {
$.each(hashlist, function(index, elem){
$('.linenums li#' + elem).addClass('marked');
});
}
}
$('.linenums li').click(function(e){
var line = $(this),
hash = 'L';
if (line.hasClass('marked')) {
line.removeClass('marked');
} else {
line.addClass('marked');
}
$('.linenums li.marked').each(function (index, elem) {
if (hash !== "L") hash += ',';
hash += $(elem).attr('id');
});
window.location.hash = hash;
});
{% endif %}
});
</script>
{% endblock %}

View file

@ -1,13 +1,13 @@
{% load i18n %}
<h2>
<span style="float:right;">(<a href="#" onclick="$('#diff').slideUp('fast'); return false;">{% trans "Close" %}</a>)</span>
<h4>
{% 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
<a href="{{ filea_url }}">Snippet #{{ filea_id }}</a>
and
<a href="{{ fileb_url }}">Snippet #{{ fileb_id }}</a>
Diff between <a href="{{ filea_url }}">#{{ filea_id }}</a> and <a href="{{ fileb_url }}">#{{ fileb_id }}</a>
{% endblocktrans %}
</h2>
</h4>
<pre class="code">{{ difftext|safe }}</pre>
{% if snippet.lexer == 'diff' %}
{% include "dpaste/snippet_pre.html" %}
{% else %}
<p>{{ snippet.content }}</p>
{% endif %}

View file

@ -1,22 +1,39 @@
{% load i18n %}
<form method="post" action="." class="snippetform">
{% csrf_token %}
{{ snippet_form.non_field_errors }}
<form method="post" action="" class="form-horizontal">
{% csrf_token %}
{{ snippet_form.non_field_errors }}
<div style="display: none;">{{ snippet_form.title }}</div>
<ol>
{% for field in snippet_form %}
<li {% ifequal field.name "title" %}style="display: none"{% endifequal %}>
{{ field.errors }}
{{ field.label_tag }}
{{ field }}
{% if request.session.userprefs.display_all_lexer %}
{% ifequal field.name "lexer" %}
<input type="button" value="{% trans "Guess lexer" %}" id="guess_lexer_btn"/>
{% endifequal %}
<div class="control-group form-content">
{{ snippet_form.content }}
</div>
<div class="control-group form-options">
<div class="form-options-lexer">
{% if request.session.userprefs.display_all_lexer %}
<div class="input-append">
{{ snippet_form.lexer }}
<button class="btn" id="guess_lexer_btn" type="button">{% trans "Guess lexer" %}</button>
</div>
{% else %}
{{ snippet_form.lexer }}
{% endif %}
</div>
<div class="form-options-expire">
<div class="input-prepend">
<span class="add-on"><i class="icon-trash" title="{% trans "Expire in" %}"></i></span>
{{ snippet_form.expire_options }}
</div>
</div>
</div>
<div class="form-actions">
{% if follow_button %}
<div class="twitter-follow-button-container">
<a href="https://twitter.com/bartTC" class="twitter-follow-button" data-show-count="false" data-size="large" data-dnt="true">Follow @bartTC</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
{% endif %}
</li>
{% endfor %}
<li class="submit"><input type="submit" value="{% trans "Paste it" %}"/></li>
</ol>
</form>
<input tabindex="0" type="submit"class="btn btn-primary" value="{% trans "Paste it" %}"/>
</div>
</form>

View file

@ -2,36 +2,19 @@
{% load i18n %}
{% load dpaste_tags %}
{% block title %}{% trans "Snippet List" %}{% endblock %}
{% block headline %}
<h1>{% blocktrans %}Your latest {{ snippets_max }} snippets{% endblocktrans %}</h1>
{% endblock %}
{% block content %}
{% if snippet_list %}
{% block title %}Snippet History{% endblock %}
{% block headline %}Snippet History{% endblock %}
{% block dpaste_nav_history %}active{% endblock %}
{% block page %}
{% for snippet in snippet_list %}
<h2 class="divider">
<h4>
<a title="{{ snippet.published|date:_("DATETIME_FORMAT") }}" href="{{ snippet.get_absolute_url }}">
{{ snippet.published|timesince }} ago
{% blocktrans with snippet.published|timesince as since %}{{ since }} ago{% endblocktrans %}
</a>
</h2>
<div class="snippet">
<table>
<tr>
<th><pre class="code">{% for l in lines %}<a href="#l{{ forloop.counter }}" id="l{{ forloop.counter }}">{{ forloop.counter }}</a>{% endfor %}</pre></th>
<td><pre class="code">{% for line in snippet|highlight:5 %}<div class="line" id="l{{ forloop.counter }}">{% if line %}{{ line|safe }}{% else %}&nbsp;{% endif %}</div>{% endfor %}
<a title="{{ snippet.published|date:_("DATETIME_FORMAT") }}" href="{{ snippet.get_absolute_url }}">... see full snippet.</a></pre><td>
</tr>
</table>
</div>
{% endfor %}
{% else %}
<p>{% trans "No snippets available." %}</p>
{% endif %}
<div class="hint">
{% trans "DATA_STORED_IN_A_COOKIE_HINT" %}
</div>
</h4>
{% include "dpaste/snippet_pre.html" %}
{% if not forloop.last %}<hr/>{% endif %}
{% empty %}
<p>{% trans "No snippets saved. Either all your snippets are expired or your cookie has changed." %}</p>
{% endfor %}
{% endblock %}

View file

@ -2,37 +2,11 @@
{% load i18n %}
{% block title %}{% trans "New snippet" %}{% endblock %}
{% block headline %}<h1>{% trans "Paste a new snippet" %}</h1>{% endblock %}
{% block headline %}{% trans "New snippet" %}{% endblock %}
{% block dpaste_nav_new %}active{% endblock %}
{% block content %}
<h2>{% trans "New snippet" %}</h2>
{% include "dpaste/snippet_form.html" %}
<p class="hint"><em>Did you know:</em>
There is a <a href="https://github.com/bartTC/dpasteGUI/wiki">dpaste GUI application</a> for OSX,
a <a href="https://github.com/bartTC/SubDpaste">Sublime 2 plugin</a>
and also a <a href="/about/">rudimentary API</a>.
</p>
{% endblock %}
{% block script_footer %}
{{ block.super }}
<script type="text/javascript">
jQuery(document).ready(function(){
{% if request.session.userprefs.display_all_lexer %}
$('#guess_lexer_btn').click(function(){
$.getJSON('{% url "snippet_guess_lexer" %}',
{'codestring': $('#id_content').val()},
function(data){
if(data.lexer == "unknown"){
$('#guess_lexer_btn').css('color', 'red');
}else{
$('#id_lexer').val(data.lexer);
$('#guess_lexer_btn').css('color', 'inherit');
}
});
});
{% endif %}
});
</script>
{% endblock %}
{% block page %}
{% with 1 as follow_button %}
{% include "dpaste/snippet_form.html" %}
{% endwith %}
{% endblock %}

View file

@ -0,0 +1 @@
{% load dpaste_tags %}<pre class="prettyprint linenums"><ol class="linenums">{% for line in snippet|highlight %}<li id="{{ forloop.counter0 }}">{{ line|safe|default:"&nbsp;" }}</li>{% endfor %}</ol></pre>

View file

@ -1,28 +0,0 @@
{% extends "dpaste/base.html" %}
{% load i18n %}
{% block headline %}
<h1>{% trans "User Settings" %}</h1>
{% endblock %}
{% block content %}
{% if settings_saved %}
<div class="success">
{% trans "USER_PREFS_SAVED_SUCCESSFULLY" %}
</div>
{% endif %}
<h2>{% trans "User Settings" %}</h2>
<form class="snippetform" method="post" action=".">
{% csrf_token %}
<ol>
{{ settings_form.as_ul }}
<li class="submit"><input type="submit" value="{% trans "Save settings" %}"/></li>
</ol>
</form>
<div class="hint">
{% trans "DATA_STORED_IN_A_COOKIE_HINT" %}
</div>
{% endblock %}

View file

@ -4,8 +4,7 @@ urlpatterns = patterns('dpaste.views',
url(r'^$', 'snippet_new', name='snippet_new'),
url(r'^guess/$', 'guess_lexer', name='snippet_guess_lexer'),
url(r'^diff/$', 'snippet_diff', name='snippet_diff'),
url(r'^your-latest/$', 'snippet_userlist', name='snippet_userlist'),
url(r'^your-settings/$', 'userprefs', name='snippet_userprefs'),
url(r'^history/$', 'snippet_history', name='snippet_history'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]+)/$', 'snippet_details', name='snippet_details'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]+)/delete/$', 'snippet_delete', name='snippet_delete'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]+)/raw/$', 'snippet_details', {'template_name': 'dpaste/snippet_details_raw.html', 'is_raw': True}, name='snippet_details_raw'),

View file

@ -10,11 +10,10 @@ from django.utils import simplejson
from django.views.defaults import page_not_found as django_page_not_found, \
server_error as django_server_error
from dpaste.forms import SnippetForm, UserSettingsForm
from dpaste.forms import SnippetForm
from dpaste.models import Snippet
from dpaste.highlight import pygmentize, guess_code_lexer, \
LEXER_WORDWRAP
LEXER_WORDWRAP, LEXER_LIST_ALL, LEXER_LIST
import difflib
@ -70,6 +69,7 @@ def snippet_details(request, snippet_id, template_name='dpaste/snippet_details.h
template_context = {
'snippet_form': snippet_form,
'snippet': snippet,
'lexers': LEXER_LIST,
'lines': range(snippet.get_linecount()),
'tree': tree,
'wordwrap': snippet.lexer in LEXER_WORDWRAP and 'True' or 'False',
@ -94,11 +94,11 @@ def snippet_delete(request, snippet_id):
except KeyError:
return HttpResponseForbidden('You have no recent snippet list, cookie error?')
if not snippet.pk in snippet_list:
return HttpResponseForbidden('That\'s not your snippet, sucka!')
return HttpResponseForbidden('That\'s not your snippet!')
snippet.delete()
return HttpResponseRedirect(reverse('snippet_new'))
def snippet_userlist(request, template_name='dpaste/snippet_list.html'):
def snippet_history(request, template_name='dpaste/snippet_list.html'):
try:
snippet_list = get_list_or_404(Snippet, pk__in=request.session.get('snippet_list', None))
@ -117,28 +117,6 @@ def snippet_userlist(request, template_name='dpaste/snippet_list.html'):
)
def userprefs(request, template_name='dpaste/userprefs.html'):
if request.method == 'POST':
settings_form = UserSettingsForm(request.POST, initial=request.session.get('userprefs', None))
if settings_form.is_valid():
request.session['userprefs'] = settings_form.cleaned_data
settings_saved = True
else:
settings_form = UserSettingsForm(initial=request.session.get('userprefs', None))
settings_saved = False
template_context = {
'settings_form': settings_form,
'settings_saved': settings_saved,
}
return render_to_response(
template_name,
template_context,
RequestContext(request)
)
def snippet_diff(request, template_name='dpaste/snippet_diff.html'):
if request.GET.get('a') and request.GET.get('a').isdigit() \
@ -151,6 +129,11 @@ def snippet_diff(request, template_name='dpaste/snippet_diff.html'):
else:
return HttpResponseBadRequest(u'You must select two snippets.')
class DiffText(object):
pass
diff = DiffText()
if fileA.content != fileB.content:
d = difflib.unified_diff(
fileA.content.splitlines(),
@ -159,13 +142,15 @@ def snippet_diff(request, template_name='dpaste/snippet_diff.html'):
'Current',
lineterm=''
)
difftext = '\n'.join(d)
difftext = pygmentize(difftext, 'diff')
diff.content = '\n'.join(d).strip()
diff.lexer = 'diff'
else:
difftext = _(u'No changes were made between this two files.')
diff.content = _(u'No changes were made between this two files.')
diff.lexer = 'text'
template_context = {
'difftext': difftext,
'snippet': diff,
'fileA': fileA,
'fileB': fileB,
}

View file

@ -1,7 +1,7 @@
django==1.5
django-mptt==0.4.2
django-piston==0.2.2
pygments==1.4
pygments==1.6
raven
mysql-python==1.2.2
south==0.7.6

10
test.html Normal file
View file

@ -0,0 +1,10 @@
<div class="highlight"><pre><span class="c">#!/usr/bin/env python</span>
<span class="kn">from</span> <span class="nn">setuptools</span> <span class="kn">import</span> <span class="n">setup</span><span class="p">,</span> <span class="n">find_packages</span>
<span class="n">setup</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&#39;dpaste&#39;</span><span class="p">,</span>
<span class="n">version</span><span class="o">=</span><span class="s">&#39;0.1&#39;</span><span class="p">,</span>
<span class="n">packages</span><span class="o">=</span><span class="n">find_packages</span><span class="p">(),</span>
<span class="n">package_data</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;dpaste&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s">&#39;bin/*.*&#39;</span><span class="p">,</span> <span class="s">&#39;static/*.*&#39;</span><span class="p">,</span> <span class="s">&#39;templates/*.*&#39;</span><span class="p">]},</span>
<span class="n">exclude_package_data</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;dpaste&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s">&#39;bin/*.pyc&#39;</span><span class="p">]},</span>
<span class="n">scripts</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;dpaste/bin/manage.py&#39;</span><span class="p">])</span>
</pre></div>