diff --git a/media/css/style.less b/media/css/style.less index 220c09f..00cafdf 100644 --- a/media/css/style.less +++ b/media/css/style.less @@ -1,5 +1,17 @@ // Fonts @Helvetica: 'Helvetica Neue', Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif; +@Inconsolata: 'InconsolataMedium', Consolas, Menlo, "Courier New", monospace; +@font-face { + font-family: 'InconsolataMedium'; + src: url('/media/fonts/Inconsolata-webfont.eot'); + src: url('/media/fonts/Inconsolata-webfont.eot?#iefix') format('embedded-opentype'), + url('/media/fonts/Inconsolata-webfont.woff') format('woff'), + url('/media/fonts/Inconsolata-webfont.ttf') format('truetype'), + url('/media/fonts/Inconsolata-webfont.svg#InconsolataMedium') format('svg'); + font-weight: normal; + font-style: normal; + +} // Focus *:focus { @@ -370,8 +382,36 @@ article.snipt { } section.code { height: 200px; - margin: 20px; overflow: hidden; + position: relative; + + div.highlight { + pre { + font: normal 14px @Inconsolata; + overflow-x: auto; + margin: 0 15px; + padding: 13px 0; + } + } + a.shade { + background: #FFF url('/media/images/expand.png') 15px 18px no-repeat; + border-top: 1px solid #EEE; + bottom: 0; + color: #999999; + display: block; + font: bold 12px @Helvetica; + padding: 15px 40px 15px 40px; + position: absolute; + text-decoration: none; + text-transform: uppercase; + width: 100%; + .box-shadow(0, -25px, 25px, #FFF); + + &:hover { + color: #3BAAF3; + font-weight: bold; + } + } } } aside { diff --git a/media/css/themes.css b/media/css/themes.css new file mode 100644 index 0000000..64cf659 --- /dev/null +++ b/media/css/themes.css @@ -0,0 +1,153 @@ +.autumn { background-color: #FFF; } +.autumn .hll { background-color: #ffffcc } +.autumn .c { color: #aaaaaa; font-style: italic } /* Comment */ +.autumn .err { color: #F00000; background-color: #F0A0A0 } /* Error */ +.autumn .k { color: #0000aa } /* Keyword */ +.autumn .cm { color: #aaaaaa; font-style: italic } /* Comment.Multiline */ +.autumn .cp { color: #4c8317 } /* Comment.Preproc */ +.autumn .c1 { color: #aaaaaa; font-style: italic } /* Comment.Single */ +.autumn .cs { color: #0000aa; font-style: italic } /* Comment.Special */ +.autumn .gd { color: #aa0000 } /* Generic.Deleted */ +.autumn .ge { font-style: italic } /* Generic.Emph */ +.autumn .gr { color: #aa0000 } /* Generic.Error */ +.autumn .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.autumn .gi { color: #00aa00 } /* Generic.Inserted */ +.autumn .go { color: #888888 } /* Generic.Output */ +.autumn .gp { color: #555555 } /* Generic.Prompt */ +.autumn .gs { font-weight: bold } /* Generic.Strong */ +.autumn .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.autumn .gt { color: #aa0000 } /* Generic.Traceback */ +.autumn .kc { color: #0000aa } /* Keyword.Constant */ +.autumn .kd { color: #0000aa } /* Keyword.Declaration */ +.autumn .kn { color: #0000aa } /* Keyword.Namespace */ +.autumn .kp { color: #0000aa } /* Keyword.Pseudo */ +.autumn .kr { color: #0000aa } /* Keyword.Reserved */ +.autumn .kt { color: #00aaaa } /* Keyword.Type */ +.autumn .m { color: #009999 } /* Literal.Number */ +.autumn .s { color: #aa5500 } /* Literal.String */ +.autumn .na { color: #1e90ff } /* Name.Attribute */ +.autumn .nb { color: #00aaaa } /* Name.Builtin */ +.autumn .nc { color: #00aa00; text-decoration: underline } /* Name.Class */ +.autumn .no { color: #aa0000 } /* Name.Constant */ +.autumn .nd { color: #888888 } /* Name.Decorator */ +.autumn .ni { color: #800000; font-weight: bold } /* Name.Entity */ +.autumn .nf { color: #00aa00 } /* Name.Function */ +.autumn .nn { color: #00aaaa; text-decoration: underline } /* Name.Namespace */ +.autumn .nt { color: #1e90ff; font-weight: bold } /* Name.Tag */ +.autumn .nv { color: #aa0000 } /* Name.Variable */ +.autumn .ow { color: #0000aa } /* Operator.Word */ +.autumn .w { color: #bbbbbb } /* Text.Whitespace */ +.autumn .mf { color: #009999 } /* Literal.Number.Float */ +.autumn .mh { color: #009999 } /* Literal.Number.Hex */ +.autumn .mi { color: #009999 } /* Literal.Number.Integer */ +.autumn .mo { color: #009999 } /* Literal.Number.Oct */ +.autumn .sb { color: #aa5500 } /* Literal.String.Backtick */ +.autumn .sc { color: #aa5500 } /* Literal.String.Char */ +.autumn .sd { color: #aa5500 } /* Literal.String.Doc */ +.autumn .s2 { color: #aa5500 } /* Literal.String.Double */ +.autumn .se { color: #aa5500 } /* Literal.String.Escape */ +.autumn .sh { color: #aa5500 } /* Literal.String.Heredoc */ +.autumn .si { color: #aa5500 } /* Literal.String.Interpol */ +.autumn .sx { color: #aa5500 } /* Literal.String.Other */ +.autumn .sr { color: #009999 } /* Literal.String.Regex */ +.autumn .s1 { color: #aa5500 } /* Literal.String.Single */ +.autumn .ss { color: #0000aa } /* Literal.String.Symbol */ +.autumn .bp { color: #00aaaa } /* Name.Builtin.Pseudo */ +.autumn .vc { color: #aa0000 } /* Name.Variable.Class */ +.autumn .vg { color: #aa0000 } /* Name.Variable.Global */ +.autumn .vi { color: #aa0000 } /* Name.Variable.Instance */ +.autumn .il { color: #009999 } /* Literal.Number.Integer.Long */ + +.borland + +.bw + +.colorful + +.default + +.emacs .hll { background-color: #ffffcc } +.emacs .c { color: #008800; font-style: italic } /* Comment */ +.emacs .err { border: 1px solid #FF0000 } /* Error */ +.emacs .k { color: #AA22FF; font-weight: bold } /* Keyword */ +.emacs .o { color: #666666 } /* Operator */ +.emacs .cm { color: #008800; font-style: italic } /* Comment.Multiline */ +.emacs .cp { color: #008800 } /* Comment.Preproc */ +.emacs .c1 { color: #008800; font-style: italic } /* Comment.Single */ +.emacs .cs { color: #008800; font-weight: bold } /* Comment.Special */ +.emacs .gd { color: #A00000 } /* Generic.Deleted */ +.emacs .ge { font-style: italic } /* Generic.Emph */ +.emacs .gr { color: #FF0000 } /* Generic.Error */ +.emacs .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.emacs .gi { color: #00A000 } /* Generic.Inserted */ +.emacs .go { color: #808080 } /* Generic.Output */ +.emacs .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +.emacs .gs { font-weight: bold } /* Generic.Strong */ +.emacs .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.emacs .gt { color: #0040D0 } /* Generic.Traceback */ +.emacs .kc { color: #AA22FF; font-weight: bold } /* Keyword.Constant */ +.emacs .kd { color: #AA22FF; font-weight: bold } /* Keyword.Declaration */ +.emacs .kn { color: #AA22FF; font-weight: bold } /* Keyword.Namespace */ +.emacs .kp { color: #AA22FF } /* Keyword.Pseudo */ +.emacs .kr { color: #AA22FF; font-weight: bold } /* Keyword.Reserved */ +.emacs .kt { color: #00BB00; font-weight: bold } /* Keyword.Type */ +.emacs .m { color: #666666 } /* Literal.Number */ +.emacs .s { color: #BB4444 } /* Literal.String */ +.emacs .na { color: #BB4444 } /* Name.Attribute */ +.emacs .nb { color: #AA22FF } /* Name.Builtin */ +.emacs .nc { color: #0000FF } /* Name.Class */ +.emacs .no { color: #880000 } /* Name.Constant */ +.emacs .nd { color: #AA22FF } /* Name.Decorator */ +.emacs .ni { color: #999999; font-weight: bold } /* Name.Entity */ +.emacs .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ +.emacs .nf { color: #00A000 } /* Name.Function */ +.emacs .nl { color: #A0A000 } /* Name.Label */ +.emacs .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ +.emacs .nt { color: #008000; font-weight: bold } /* Name.Tag */ +.emacs .nv { color: #B8860B } /* Name.Variable */ +.emacs .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ +.emacs .w { color: #bbbbbb } /* Text.Whitespace */ +.emacs .mf { color: #666666 } /* Literal.Number.Float */ +.emacs .mh { color: #666666 } /* Literal.Number.Hex */ +.emacs .mi { color: #666666 } /* Literal.Number.Integer */ +.emacs .mo { color: #666666 } /* Literal.Number.Oct */ +.emacs .sb { color: #BB4444 } /* Literal.String.Backtick */ +.emacs .sc { color: #BB4444 } /* Literal.String.Char */ +.emacs .sd { color: #BB4444; font-style: italic } /* Literal.String.Doc */ +.emacs .s2 { color: #BB4444 } /* Literal.String.Double */ +.emacs .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ +.emacs .sh { color: #BB4444 } /* Literal.String.Heredoc */ +.emacs .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ +.emacs .sx { color: #008000 } /* Literal.String.Other */ +.emacs .sr { color: #BB6688 } /* Literal.String.Regex */ +.emacs .s1 { color: #BB4444 } /* Literal.String.Single */ +.emacs .ss { color: #B8860B } /* Literal.String.Symbol */ +.emacs .bp { color: #AA22FF } /* Name.Builtin.Pseudo */ +.emacs .vc { color: #B8860B } /* Name.Variable.Class */ +.emacs .vg { color: #B8860B } /* Name.Variable.Global */ +.emacs .vi { color: #B8860B } /* Name.Variable.Instance */ +.emacs .il { color: #666666 } /* Literal.Number.Integer.Long */ + +.friendly + +.fruity + +.manni + +.monokai + +.murphy + +.native + +.pastie + +.perldoc + +.tango + +.trac + +.vim + +.vs diff --git a/media/fonts/Inconsolata-webfont.eot b/media/fonts/Inconsolata-webfont.eot new file mode 100755 index 0000000..eabeb69 Binary files /dev/null and b/media/fonts/Inconsolata-webfont.eot differ diff --git a/media/fonts/Inconsolata-webfont.svg b/media/fonts/Inconsolata-webfont.svg new file mode 100755 index 0000000..f079d08 --- /dev/null +++ b/media/fonts/Inconsolata-webfont.svg @@ -0,0 +1,147 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Created by Raph Levien using his own tools and FontForge Copyright 2006 Raph Levien Released under the SIL Open Font License httpscriptssilorgOFL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/media/fonts/Inconsolata-webfont.ttf b/media/fonts/Inconsolata-webfont.ttf new file mode 100755 index 0000000..9246862 Binary files /dev/null and b/media/fonts/Inconsolata-webfont.ttf differ diff --git a/media/fonts/Inconsolata-webfont.woff b/media/fonts/Inconsolata-webfont.woff new file mode 100755 index 0000000..ad76430 Binary files /dev/null and b/media/fonts/Inconsolata-webfont.woff differ diff --git a/media/fonts/SIL Open Font License 1.1.txt b/media/fonts/SIL Open Font License 1.1.txt new file mode 100755 index 0000000..e4b0c4f --- /dev/null +++ b/media/fonts/SIL Open Font License 1.1.txt @@ -0,0 +1,91 @@ +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. \ No newline at end of file diff --git a/media/images/expand.png b/media/images/expand.png new file mode 100644 index 0000000..9b41580 Binary files /dev/null and b/media/images/expand.png differ diff --git a/snipts/admin.py b/snipts/admin.py index 70a5c0a..55df371 100644 --- a/snipts/admin.py +++ b/snipts/admin.py @@ -9,9 +9,10 @@ class CommentInline(admin.TabularInline): allow_add = False class SniptAdmin(admin.ModelAdmin): - readonly_fields = ('user',) + # TODO: Make user readonly + #readonly_fields = ('user',) list_display = ('title', 'slug', 'user', 'lexer', 'public', 'created', 'modified',) - search_fields = ('title', 'user__username', 'tags', 'lexer', 'id',) + search_fields = ('title', 'user__username', 'lexer', 'id',) ordering = ('created',) prepopulated_fields = {'slug': ('title',)} inlines = [CommentInline] @@ -19,7 +20,7 @@ class SniptAdmin(admin.ModelAdmin): admin.site.register(Snipt, SniptAdmin) class CommentAdmin(admin.ModelAdmin): - #readonly_fields = ('user', 'snipt',) + readonly_fields = ('user', 'snipt',) list_display = ('comment', 'user', 'snipt', 'created', 'modified',) search_fields = ('comment', 'user__username',) ordering = ('created',) diff --git a/snipts/migrations/0015_auto__del_taggedsnipt__add_field_snipt_line_count.py b/snipts/migrations/0015_auto__del_taggedsnipt__add_field_snipt_line_count.py new file mode 100644 index 0000000..2b62044 --- /dev/null +++ b/snipts/migrations/0015_auto__del_taggedsnipt__add_field_snipt_line_count.py @@ -0,0 +1,110 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Deleting model 'TaggedSnipt' + db.delete_table('snipts_taggedsnipt') + + # Adding field 'Snipt.line_count' + db.add_column('snipts_snipt', 'line_count', self.gf('django.db.models.fields.IntegerField')(default=None, null=True, blank=True), keep_default=False) + + + def backwards(self, orm): + + # Adding model 'TaggedSnipt' + db.create_table('snipts_taggedsnipt', ( + ('count', self.gf('django.db.models.fields.IntegerField')()), + ('content_object', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['snipts.Snipt'])), + ('tag', self.gf('django.db.models.fields.related.ForeignKey')(related_name='snipts_taggedsnipt_items', to=orm['taggit.Tag'])), + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + )) + db.send_create_signal('snipts', ['TaggedSnipt']) + + # Deleting field 'Snipt.line_count' + db.delete_column('snipts_snipt', 'line_count') + + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'snipts.comment': { + 'Meta': {'object_name': 'Comment'}, + 'comment': ('django.db.models.fields.TextField', [], {}), + 'created': ('django.db.models.fields.DateTimeField', [], {}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {}), + 'snipt': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['snipts.Snipt']"}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) + }, + 'snipts.snipt': { + 'Meta': {'object_name': 'Snipt'}, + 'code': ('django.db.models.fields.TextField', [], {}), + 'created': ('django.db.models.fields.DateTimeField', [], {}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'lexer': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'line_count': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {}), + 'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'slug': ('django.db.models.fields.SlugField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), + 'stylized': ('django.db.models.fields.TextField', [], {}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) + }, + 'taggit.tag': { + 'Meta': {'object_name': 'Tag'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'}) + }, + 'taggit.taggeditem': { + 'Meta': {'object_name': 'TaggedItem'}, + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'taggit_taggeditem_tagged_items'", 'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'object_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}), + 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'taggit_taggeditem_items'", 'to': "orm['taggit.Tag']"}) + } + } + + complete_apps = ['snipts'] diff --git a/snipts/models.py b/snipts/models.py index 04d9a4d..afaeac8 100644 --- a/snipts/models.py +++ b/snipts/models.py @@ -26,6 +26,7 @@ class Snipt(models.Model): lexer = models.CharField(max_length=50) code = models.TextField() stylized = models.TextField() + line_count = models.IntegerField(blank=True, null=True, default=None) key = models.CharField(max_length=100) public = models.BooleanField(default=False) @@ -50,14 +51,22 @@ class Snipt(models.Model): def get_stylized(self): if self.stylized == '': self.stylized = highlight(self.code, - get_lexer_by_name(self.lexer, - encoding='UTF-8'), + get_lexer_by_name(self.lexer, encoding='UTF-8'), HtmlFormatter()) self.save() return self.stylized else: return self.stylized + #TODO This needs to be deprecated - render line count on save + def get_line_count(self): + if not self.line_count: + self.line_count = len(self.code.split('\n')) + self.save() + return self.line_count + else: + return self.line_count + def get_embed_url(self): return 'http%s://%s/embed/%s/' % ('s' if settings.USE_HTTPS else '', site.domain, diff --git a/snipts/templates/snipts/snipt-list.html b/snipts/templates/snipts/snipt-list.html index 23a2235..a41358c 100644 --- a/snipts/templates/snipts/snipt-list.html +++ b/snipts/templates/snipts/snipt-list.html @@ -8,7 +8,14 @@

{{ snipt.lexer_name }}

{{ snipt.title }}

-
{{ snipt.get_stylized|safe }}
+
+ {{ snipt.get_stylized|safe }} + {% if snipt.get_line_count > 9 %} + + Expand + + {% endif %} +
diff --git a/templates/base.html b/templates/base.html index 6ed6744..7cf550a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -9,6 +9,7 @@ {% compress css %} + {% if not debug %} {% endif %}