Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implementando pygments

  • Loading branch information...
commit 38f68e558a3aee5131309633b14b376ef192f1f8 1 parent c6659ac
@lesthack authored
View
250 media/css/style.css
@@ -1,165 +1,233 @@
* {
- padding: 0px;
- margin: 0px;
-
+ padding: 0px;
+ margin: 0px;
+
}
html, body{
- background: #DDD;
- font-family: "Droid Sans Mono", Helvetica, serif;
- font-size: 12px;
+ background: #DDD;
+ font-family: "Droid Sans Mono", Helvetica, serif;
+ font-size: 12px;
}
a {
- text-decoration: none;
+ text-decoration: none;
}
#menu{
- position: absolute;
- top: 100px;
- left: 0px;
+ position: absolute;
+ top: 100px;
+ left: 0px;
}
#menu a{
- display: block;
- padding-left: 5px;
- padding-right: 5px;
- color: #444;
- font-weight: bold;
- background: #DDD;
- margin-top: 2px;
- margin-bottom: 2px;
-
+ display: block;
+ padding-left: 5px;
+ padding-right: 5px;
+ color: #444;
+ font-weight: bold;
+ background: #DDD;
+ margin-top: 2px;
+ margin-bottom: 2px;
+
}
#menu a:hover{
- background: #CCC;
+ background: #CCC;
}
#panel_head{
- position: absolute;
- top: 0px;
- right: 60px;
+ position: absolute;
+ top: 0px;
+ right: 60px;
}
#panel_code{
- position: absolute;
- top: 50px;
- left: 150px;
- right: 50px;
- bottom: 20px;
- background: #fff;
- -moz-border-radius: 6px;
- -webkit-border-radius: 6px;
- overflow: auto;
+ position: absolute;
+ top: 50px;
+ left: 150px;
+ right: 50px;
+ bottom: 20px;
+ background: #fff;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ overflow: auto;
}
#panel_code .code{
-
+
}
#list_form {
- margin: 15px;
- margin-top: 25px;
+ margin: 15px;
+ margin-top: 25px;
}
#list_form p{
- width: 95%;
- text-align: justify;
+ width: 95%;
+ text-align: justify;
}
#list_form table{
- font-size: 12px;
- width: 99%;
- cursor: default;
+ font-size: 12px;
+ width: 99%;
+ cursor: default;
}
#list_form table tbody tr.one{
- background: #EEE;
+ background: #EEE;
}
#list_form table tbody tr:hover{
- background: #DDD;
+ background: #DDD;
}
#list_form table tbody td{
- padding-left: 15px;
+ padding-left: 15px;
}
#list_form table tbody td a{
- color: blue;
+ color: blue;
}
#list_form table tbody tr:hover a{
- color: green;
+ color: green;
}
#paginator{
- width: 95%;
- text-align: right;
- margin-top: 10px;
- position: absolute;
- bottom: 10px;
+ width: 95%;
+ text-align: right;
+ margin-top: 10px;
+ position: absolute;
+ bottom: 10px;
}
#form_code{
- margin: 15px;
+ margin: 15px;
}
#about{
- padding: 20px;
+ padding: 20px;
}
#about .picture{
- float: left;
- margin: 10px;
+ float: left;
+ margin: 10px;
}
#about .description{
- float: left;
- margin-top: 30px;
- width: 500px;
+ float: left;
+ margin-top: 30px;
+ width: 500px;
}
#about .me{
- margin-bottom: 10px;
+ margin-bottom: 10px;
}
#about ol{
- list-style-image: none;
- list-style-type: none;
- margin-left: 10px;
- margin-bottom: 20px;
+ list-style-image: none;
+ list-style-type: none;
+ margin-left: 10px;
+ margin-bottom: 20px;
}
form label{
- display: block;
-
+ display: block;
+
}
form input.text{
- border: 1px solid #DDD;
- padding: 4px 10px;
- -moz-border-radius: 6px;
- -webkit-border-radius: 6px;
+ border: 1px solid #DDD;
+ padding: 4px 10px;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
}
form input.text:focus{
- border:1px solid #BBB;
+ border:1px solid #BBB;
}
form input.button{
- border: 1px solid #BBB;
- background: #DDD;
- margin: 5px;
- padding: 4px 15px;
+ border: 1px solid #BBB;
+ background: #DDD;
+ margin: 5px;
+ padding: 4px 15px;
}
form input.button:hover{
- background: #CCC;
+ background: #CCC;
}
form input.button:active{
- background: #AAA;
+ background: #AAA;
}
form select{
- padding: 4px 0px;
- background: #fff;
- border:1px solid #DDD;
+ padding: 4px 0px;
+ background: #fff;
+ border:1px solid #DDD;
}
form select:focus{
- border:1px solid #BBB;
+ border:1px solid #BBB;
}
form select optgroup option{
- margin-left: 15px;
- color: blue;
+ margin-left: 15px;
+ color: blue;
}
form textarea.textarea{
- border:1px solid #DDD;
- width: 95%;
- height: 350px;
+ border:1px solid #DDD;
+ width: 95%;
+ height: 350px;
}
form textarea:focus{
- border:1px solid #BBB;
+ border:1px solid #BBB;
}
div.row_form{
- margin-bottom: 5px;
+ margin-bottom: 5px;
}
-div.row_form .errors{
- color: red;
+div.row_form .errors{
+ color: red;
}
div.info{
- margin-left: 20px;
- margin-top: 10px;
-}
+ margin-left: 20px;
+ margin-top: 10px;
+}
+.highlight{
+ padding: 5px 10px;
+ margin-top: 10px;
+ border-top: 1px solid #999;
+ border-bottom: 1px solid #999;
+}
+.highlight .hll { background-color: #ffffcc }
+.highlight { background: #f8f8f8; }
+.highlight .c { color: #408080; font-style: italic } /* Comment */
+.highlight .err { border: 1px solid #FF0000 } /* Error */
+.highlight .k { color: #008000; font-weight: bold } /* Keyword */
+.highlight .o { color: #666666 } /* Operator */
+.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
+.highlight .cp { color: #BC7A00 } /* Comment.Preproc */
+.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
+.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
+.highlight .gd { color: #A00000 } /* Generic.Deleted */
+.highlight .ge { font-style: italic } /* Generic.Emph */
+.highlight .gr { color: #FF0000 } /* Generic.Error */
+.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.highlight .gi { color: #00A000 } /* Generic.Inserted */
+.highlight .go { color: #808080 } /* Generic.Output */
+.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
+.highlight .gs { font-weight: bold } /* Generic.Strong */
+.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.highlight .gt { color: #0040D0 } /* Generic.Traceback */
+.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
+.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
+.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
+.highlight .kp { color: #008000 } /* Keyword.Pseudo */
+.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
+.highlight .kt { color: #B00040 } /* Keyword.Type */
+.highlight .m { color: #666666 } /* Literal.Number */
+.highlight .s { color: #BA2121 } /* Literal.String */
+.highlight .na { color: #7D9029 } /* Name.Attribute */
+.highlight .nb { color: #008000 } /* Name.Builtin */
+.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
+.highlight .no { color: #880000 } /* Name.Constant */
+.highlight .nd { color: #AA22FF } /* Name.Decorator */
+.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
+.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
+.highlight .nf { color: #0000FF } /* Name.Function */
+.highlight .nl { color: #A0A000 } /* Name.Label */
+.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
+.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
+.highlight .nv { color: #19177C } /* Name.Variable */
+.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
+.highlight .w { color: #bbbbbb } /* Text.Whitespace */
+.highlight .mf { color: #666666 } /* Literal.Number.Float */
+.highlight .mh { color: #666666 } /* Literal.Number.Hex */
+.highlight .mi { color: #666666 } /* Literal.Number.Integer */
+.highlight .mo { color: #666666 } /* Literal.Number.Oct */
+.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
+.highlight .sc { color: #BA2121 } /* Literal.String.Char */
+.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
+.highlight .s2 { color: #BA2121 } /* Literal.String.Double */
+.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
+.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
+.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
+.highlight .sx { color: #008000 } /* Literal.String.Other */
+.highlight .sr { color: #BB6688 } /* Literal.String.Regex */
+.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
+.highlight .ss { color: #19177C } /* Literal.String.Symbol */
+.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
+.highlight .vc { color: #19177C } /* Name.Variable.Class */
+.highlight .vg { color: #19177C } /* Name.Variable.Global */
+.highlight .vi { color: #19177C } /* Name.Variable.Instance */
+.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
View
57 pub/models.py
@@ -4,36 +4,37 @@
from time import strftime
class language(models.Model):
- name = models.CharField(max_length=50)
- def __str__(self):
- return self.name
+ name = models.CharField(max_length=50)
+ complete_name = models.CharField(max_length=100)
+ def __str__(self):
+ return self.complete_name
-class codes(models.Model):
- owner = models.CharField(max_length=100, blank=True)
- name = models.CharField(max_length=200, blank=True)
- description = models.CharField(max_length=500, blank=True)
- code = models.TextField()
- date = models.DateTimeField(default=strftime("%Y-%m-%d %H:%M:%S"))
- language = models.ForeignKey(language)
+class codes(models.Model):
+ owner = models.CharField(max_length=100, blank=True)
+ name = models.CharField(max_length=200, blank=True)
+ description = models.CharField(max_length=500, blank=True)
+ code = models.TextField()
+ date = models.DateTimeField(default=strftime("%Y-%m-%d %H:%M:%S"))
+ language = models.ForeignKey(language)
- def __str__(self):
- return self.name
+ def __str__(self):
+ return self.name
class codesForm(ModelForm):
- class Meta:
- model = codes
- fields = ('owner', 'name', 'description', 'code', 'language')
- widgets = {
- 'name': TextInput(attrs={'class':'text', 'size':'20'}),
- 'owner': TextInput(attrs={'class':'text', 'size':'20'}),
- 'description': TextInput(attrs={'class':'text', 'size':'50'}),
- 'code': Textarea(attrs={'class':'textarea'}),
- }
-
- def clean_date(self):
- return strftime("%Y-%m-%d %H:%M:%S")
-
+ class Meta:
+ model = codes
+ fields = ('owner', 'name', 'description', 'code', 'language')
+ widgets = {
+ 'name': TextInput(attrs={'class':'text', 'size':'20'}),
+ 'owner': TextInput(attrs={'class':'text', 'size':'20'}),
+ 'description': TextInput(attrs={'class':'text', 'size':'50'}),
+ 'code': Textarea(attrs={'class':'textarea'}),
+ }
+
+ def clean_date(self):
+ return strftime("%Y-%m-%d %H:%M:%S")
+
class languageForm(ModelForm):
- class Meta:
- model = language
-
+ class Meta:
+ model = language
+
View
BIN  pub/models.pyc
Binary file not shown
View
32 templates/code.html
@@ -3,23 +3,17 @@
{% block title %} code {% endblock %}
{% block content %}
- <div class="code">
- <div class="info">
- <p><b>Name:</b> {% if codigo.name|length > 0 %} {{ codigo.name }} {% else %} untitled {% endif %}</p>
- <p><b>Author:</b> {% if codigo.owner|length > 0 %} {{ codigo.owner }} {% else %} untitled {% endif %}</p>
- <p><b>Description:</b> {{ codigo.description }}</p>
- <p><b>Language:</b> {{ codigo.language }}</p>
- <p><b>Link:</b> <a href="{{ url }}">{{ url }}</a></p>
- <p><b>Fork:</b> <a href="/fork/{{ codigo.id }}/">Create Fork</a></p>
- </div>
- <pre name="code" class="{{ codigo.language }}">{{ codigo.code }}</pre>
- </div>
- <script class="javascript" src="/media/javascript/{{ language }}"></script>
- <script class="javascript">
- if(window.isBloggerMode == true)
- dp.SyntaxHighlighter.BloggerMode();
-
- dp.SyntaxHighlighter.ClipboardSwf = 'Scripts/clipboard.swf';
- dp.SyntaxHighlighter.HighlightAll('code');
- </script>
+ <div class="code">
+ <div class="info">
+ <p><b>Name:</b> {% if codigo.name|length > 0 %} {{ codigo.name }} {% else %} untitled {% endif %}</p>
+ <p><b>Author:</b> {% if codigo.owner|length > 0 %} {{ codigo.owner }} {% else %} untitled {% endif %}</p>
+ <p><b>Description:</b> {{ codigo.description }}</p>
+ <p><b>Language:</b> {{ codigo.language }}</p>
+ <p><b>Link:</b> <a href="{{ url }}">{{ url }}</a></p>
+ <p><b>Fork:</b> <a href="/fork/{{ codigo.id }}/">Create Fork</a></p>
+ </div>
+
+ {{ codigo.code|safe }}
+
+ </div>
{% endblock %}
View
10 view.py
@@ -9,6 +9,9 @@
from django.http import HttpResponse
from django.template import RequestContext
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
+from pygments import highlight
+from pygments.lexers import get_lexer_by_name
+from pygments.formatters import HtmlFormatter
from pub.models import *
from time import strftime
@@ -77,9 +80,14 @@ def code(request, request_id):
global language
try:
+
current_site = request.build_absolute_uri()
codigo = codes.objects.get(id=request_id)
- return render_to_response('code.html', {"codigo":codigo, "language": lenguajes[codigo.language.name], "url":current_site})
+ lexer = get_lexer_by_name(codigo.language.name, stripall=True)
+ formatter = HtmlFormatter()
+ codigo.code = highlight(codigo.code, lexer, formatter)
+
+ return render_to_response('code.html', {"codigo":codigo , "url":current_site})
except:
return render_to_response('list.html', {'codigos': codes.objects.all()})

0 comments on commit 38f68e5

Please sign in to comment.
Something went wrong with that request. Please try again.