Anonymous avatar Anonymous committed 97bb510

remove wrapping. As suggested on irc, you could now select code without line numbers.

Comments (0)

Files changed (5)

friendpaste/template.py

 def url_for(endpoint, _external=False, **values):
     return local.url_adapter.build(endpoint, values, force_external=_external)
 
-class SnippetHtmlFormatter(formatters.HtmlFormatter):
-    """
-    formatter to have better rendering with wrapped line.
-    Could be a better way though.
-    """
-
-    def _wrap_snippetlinenos(self, inner):
-        # need a list of lines since we need the width of a single number :(
-        lines = list(inner)
-        sp = self.linenospecial
-        st = self.linenostep
-        num = self.linenostart
-        mw = len(str(len(lines) + num - 1))
-
-        ls=''
-        if sp:
-            for t, line in lines:
-                ls+= '<tr><th class="linenos%s">%*s</th><td class="wrap">' % (
-                    num%sp == 0 and ' special' or '', mw, (num%st and ' ' or num)) + line + '</td></tr>'
-                num += 1
-        else:
-            for t, line in lines:
-                ls += '<tr><th class="linenos">%*s</th><td class="wrap">' % (
-                    mw, (num%st and ' ' or num)) + line + '</td></tr>'
-                num += 1
-
-        yield 0, ('<table class="%stable">' % self.cssclass + 
-                ls + '</table>')
-
-    def format(self, tokensource, outfile):
-        source = self._format_lines(tokensource)
-        source = self._wrap_snippetlinenos(source)
-        for t, piece in source:
-            outfile.write(piece)
 
 def highlighter(value, language):
     try:
         lexer = lexers.get_lexer_by_name(language)
     except:
         lexer = lexers.get_lexer_by_name('text')
-    formatter = SnippetHtmlFormatter(linenos='inline', cssclass='source')
+    formatter = formatters.HtmlFormatter(linenos=True, cssclass='source')
     return highlight(value, lexer,formatter)
 
 

static/css/base.css

     margin-top: 0;
     padding-top: 0;
 }
-.container {
+/*.container {
     display: block;
     margin: 0pt auto;
     width: 950px;
     min-height: 91%;
-}
+}*/
 
 * html .container {
     height: 91%;
     overflow: auto;
 }
 
+table.sourcetable td {
+     font-size: 1.1em;
+}
+/*
 
 table.sourcetable td {
     font-family: "DejaVu Sans Mono","Bitstream Vera Sans Mono", monospace;
     vertical-align: middle;
     margin: 0;
 }
+*/
+
+
+td.linenos { 
+    padding: 0 5px; 
+    color: #999; 
+    background: #eee;
+    }
+ 
+.linenos .special { 
+    font-weight: bold; color: #444;
+    }
+ 
+td.code {
+
+    padding: 0 8px;
+
+}
 
 table.difftabular {
     background: #f7f7f0;
     padding-bottom: 5px;
 }
 
+tbody.hidenos td.linenos,
 tbody.hidenos th.linenos {
     display: none;
 }
     padding: 0;
 }
 
-table.sourcetable th {
-    background: #f7f7f0;
-    border-right: 1px solid #899834;
-    font-size: 1em;
-}
-table.sourcetable th.linenos {
-    vertical-align: top;
-    width: 2.2em;
-    text-align: center;
-    padding-right: 0.4em;
-}
 
 #content #revisions {
     position: relative;

static/js/friendpaste.js

         $(".e").click(this.do_edit);
         $(".cancel").click(this.do_cancel);
         $("#show-linenos").click(this.toggleLineNumber);
-        $("#wrap-lines").click(this.wrapLines);
         $("#change-theme").change(this.setTheme);
         $(".show-history").click(this.do_history);
 
 
         /* init default */
-        is_wrap = $.cookie("nowrap-lines")
-        if (is_wrap == "yes") {
-            $("table.sourcetable tbody").addClass("wrap");
-            $("#wrap-lines").attr("checked", "")
-        }
-
         is_hide = $.cookie("hide-linenos");
         if (is_hide == "yes") {
             $("table.sourcetable tbody").addClass("hidenos");
         $("table.sourcetable tbody").toggleClass("hidenos");
     },
 
-    wrapLines: function(event) {
-        if (this.checked) {
-            $.cookie("nowrap-lines", null);
-        } else {
-            $.cookie("nowrap-lines", "yes");
-        }
-        $("table.sourcetable tbody").toggleClass("wrap");
-    },
 
     setTheme: function(event) {
         setCookie("theme", this.value, 60);

templates/paste/diff.html

                         {% endfor %}
                         </select>
                     </li>
-                    <li><input type="checkbox" id="wrap-lines" value="1" checked="checked" /> <label for="wrap-lines">Wrap long lines</label></li>
                     <li><input type="checkbox" id="show-linenos" name="linen" value="1" checked="checked" /> <label for="show-linenos">Show line numbers</label></li>
                 </ul>
             </form>

templates/paste/view.html

                         {% endfor %}
                         </select>
                     </li>
-                    <li><input type="checkbox" id="wrap-lines" value="1" checked="checked" /> <label for="wrap-lines">Wrap long lines</label></li>
                     <li><input type="checkbox" id="show-linenos" value="1" checked="checked" /> <label for="show-linenos">Show line numbers</label></li>
                 </ul>
             </form>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.