From bd072264ef6af70a6bc2a6f30c2205199d110f2e Mon Sep 17 00:00:00 2001 From: Daniel Kimsey Date: Thu, 8 Nov 2012 18:48:24 -0500 Subject: [PATCH 1/6] Line-ending fix for _styles.css --- .../frontend/public/gollum/css/_styles.css | 242 +++++++++--------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/lib/gollum/frontend/public/gollum/css/_styles.css b/lib/gollum/frontend/public/gollum/css/_styles.css index 092263c4..fdd1d2a3 100644 --- a/lib/gollum/frontend/public/gollum/css/_styles.css +++ b/lib/gollum/frontend/public/gollum/css/_styles.css @@ -1,121 +1,121 @@ -*, html { - font-family: Verdana, Arial, Helvetica, sans-serif; -} - -#results a:hover { - background-color: #4c4c4c; -} - -#home_button { - position: absolute; - top: 10px; - left: 50%; -} - -#home_button .minibutton { - font-size: 1em; - text-align: center; -} - -#results { - position: absolute; - top: 60px; - left: 10px; -} - -body, form, ul, li, p, h1, h2, h3, h4, h5 { - margin: 0; - padding: 0; -} - -body { - background-color: #606061; - color: #ffffff; - margin: 0; -} - -img { - border: none; -} - -p { - font-size: 1em; - margin: 0 0 1em 0; -} - -html { font-size: 100%; /* IE hack */ } -body { font-size: 1em; /* Sets base font size to 16px */ } -table { font-size: 100%; /* IE hack */ } -input, select, textarea, th, td { font-size: 1em; } - -/* Prevent wrapping on large file names. */ -li.file { - white-space: nowrap; -} - -/* CSS Tree menu styles */ -ol.tree -{ - padding: 0 0 0 30px; - width: 300px; -} - li - { - position: relative; - margin-left: -15px; - list-style: none; - } - li.file - { - margin-left: -1px !important; - height: 1.5em; - } - li.file a - { - background: url(../images/fileview/document.png) 0 0 no-repeat; - color: #fff; - padding-left: 21px; - text-decoration: none; - display: block; - } - li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li input - { - position: absolute; - left: 0; - margin-left: 0; - opacity: 0; - z-index: 2; - cursor: pointer; - height: 1em; - width: 1em; - top: 0; - } - li input + ol - { - background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat; - margin: -1.188em 0 0 -44px; /* 15px */ - height: 1.5em; - } - li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; } - li label - { - background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat; - cursor: pointer; - display: block; - padding-left: 37px; - } - - li input:checked + ol - { - background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat; - margin: -1.5em 0 0 -44px; /* 20px */ - padding: 1.563em 0 0 80px; - height: auto; - } - li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */} - li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ } - +*, html { + font-family: Verdana, Arial, Helvetica, sans-serif; +} + +#results a:hover { + background-color: #4c4c4c; +} + +#home_button { + position: absolute; + top: 10px; + left: 50%; +} + +#home_button .minibutton { + font-size: 1em; + text-align: center; +} + +#results { + position: absolute; + top: 60px; + left: 10px; +} + +body, form, ul, li, p, h1, h2, h3, h4, h5 { + margin: 0; + padding: 0; +} + +body { + background-color: #606061; + color: #ffffff; + margin: 0; +} + +img { + border: none; +} + +p { + font-size: 1em; + margin: 0 0 1em 0; +} + +html { font-size: 100%; /* IE hack */ } +body { font-size: 1em; /* Sets base font size to 16px */ } +table { font-size: 100%; /* IE hack */ } +input, select, textarea, th, td { font-size: 1em; } + +/* Prevent wrapping on large file names. */ +li.file { + white-space: nowrap; +} + +/* CSS Tree menu styles */ +ol.tree +{ + padding: 0 0 0 30px; + width: 300px; +} + li + { + position: relative; + margin-left: -15px; + list-style: none; + } + li.file + { + margin-left: -1px !important; + height: 1.5em; + } + li.file a + { + background: url(../images/fileview/document.png) 0 0 no-repeat; + color: #fff; + padding-left: 21px; + text-decoration: none; + display: block; + } + li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li input + { + position: absolute; + left: 0; + margin-left: 0; + opacity: 0; + z-index: 2; + cursor: pointer; + height: 1em; + width: 1em; + top: 0; + } + li input + ol + { + background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat; + margin: -1.188em 0 0 -44px; /* 15px */ + height: 1.5em; + } + li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; } + li label + { + background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat; + cursor: pointer; + display: block; + padding-left: 37px; + } + + li input:checked + ol + { + background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat; + margin: -1.5em 0 0 -44px; /* 20px */ + padding: 1.563em 0 0 80px; + height: auto; + } + li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */} + li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ } + From 34e0b49d7216797c8dde946c4fa9325bba5a243a Mon Sep 17 00:00:00 2001 From: Daniel Kimsey Date: Thu, 8 Nov 2012 18:49:29 -0500 Subject: [PATCH 2/6] Refactored the template generator to use new_page method --- lib/gollum/file_view.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/gollum/file_view.rb b/lib/gollum/file_view.rb index cf88dea4..8b242a8f 100644 --- a/lib/gollum/file_view.rb +++ b/lib/gollum/file_view.rb @@ -85,13 +85,11 @@ module Gollum # Handle special case of only one folder. if (count - folder_start == 1) page = @pages[ folder_start ] - name = page.name - url = url_for_page page html += <<-HTML
    1. -
    2. #{name}
    3. + #{new_page page}
  • HTML From c5631f5b7d1199dbe4a5ff72ff30a5a26767e46d Mon Sep 17 00:00:00 2001 From: Daniel Kimsey Date: Thu, 8 Nov 2012 18:50:38 -0500 Subject: [PATCH 3/6] Fixed a:hover not highlighting the a block correctly --- lib/gollum/file_view.rb | 4 ++-- .../frontend/public/gollum/css/_styles.css | 21 ++++++++++++------- test/file_view/1_file.txt | 4 ++-- test/file_view/1_file_1_folder.txt | 4 ++-- test/file_view/1_folder.txt | 4 ++-- test/file_view/2_files_2_folders.txt | 6 +++--- test/file_view/2_files_2_folders_1_root.txt | 8 +++---- test/file_view/nested_folders.txt | 8 +++---- 8 files changed, 33 insertions(+), 26 deletions(-) diff --git a/lib/gollum/file_view.rb b/lib/gollum/file_view.rb index 8b242a8f..0d2379b9 100644 --- a/lib/gollum/file_view.rb +++ b/lib/gollum/file_view.rb @@ -22,7 +22,7 @@ module Gollum def new_page page name = page.name url = url_for_page page - %Q(
  • #{name}
  • \n) + %Q(
  • #{name}
  • \n) end def new_folder folder_path @@ -89,7 +89,7 @@ module Gollum
    1. - #{new_page page} + #{new_page page}
  • HTML diff --git a/lib/gollum/frontend/public/gollum/css/_styles.css b/lib/gollum/frontend/public/gollum/css/_styles.css index fdd1d2a3..c058fa2b 100644 --- a/lib/gollum/frontend/public/gollum/css/_styles.css +++ b/lib/gollum/frontend/public/gollum/css/_styles.css @@ -72,16 +72,23 @@ ol.tree } li.file a { - background: url(../images/fileview/document.png) 0 0 no-repeat; color: #fff; - padding-left: 21px; text-decoration: none; - display: block; + display: inline-block; } - li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a span.icon + { + width: 14px; + height: 18px; + background: url(../images/fileview/document.png) 0 0 no-repeat; + display: inline-block; + margin-right: 7px; + vertical-align: text-top; + } + li.file a[href *= '.pdf'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href *= '.html'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href $= '.css'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href $= '.js'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; } li input { position: absolute; diff --git a/test/file_view/1_file.txt b/test/file_view/1_file.txt index 6f65a3a3..30d1ec1d 100644 --- a/test/file_view/1_file.txt +++ b/test/file_view/1_file.txt @@ -1,3 +1,3 @@
      -
    1. 0
    2. -
    \ No newline at end of file +
  • 0
  • + diff --git a/test/file_view/1_file_1_folder.txt b/test/file_view/1_file_1_folder.txt index 9f803328..33a3e47b 100644 --- a/test/file_view/1_file_1_folder.txt +++ b/test/file_view/1_file_1_folder.txt @@ -2,7 +2,7 @@
    1. -
    2. 0
    3. +
    4. 0
  • - \ No newline at end of file + diff --git a/test/file_view/1_folder.txt b/test/file_view/1_folder.txt index f960bee7..323443b3 100644 --- a/test/file_view/1_folder.txt +++ b/test/file_view/1_folder.txt @@ -2,7 +2,7 @@
    1. -
    2. folder0
    3. +
    4. folder0
  • - \ No newline at end of file + diff --git a/test/file_view/2_files_2_folders.txt b/test/file_view/2_files_2_folders.txt index 05a8799a..1011235e 100644 --- a/test/file_view/2_files_2_folders.txt +++ b/test/file_view/2_files_2_folders.txt @@ -2,11 +2,11 @@
    1. -
    2. 0
    3. +
    4. 0
    1. -
    2. 1
    3. -
    \ No newline at end of file +
  • 1
  • + diff --git a/test/file_view/2_files_2_folders_1_root.txt b/test/file_view/2_files_2_folders_1_root.txt index f6e1e8f3..76b551f7 100644 --- a/test/file_view/2_files_2_folders_1_root.txt +++ b/test/file_view/2_files_2_folders_1_root.txt @@ -1,13 +1,13 @@
      -
    1. root
    2. +
    3. root
      1. -
      2. 0
      3. +
      4. 0
      1. -
      2. 1
      3. -
      \ No newline at end of file +
    4. 1
    5. +
    diff --git a/test/file_view/nested_folders.txt b/test/file_view/nested_folders.txt index 5094929d..39bf4ba6 100644 --- a/test/file_view/nested_folders.txt +++ b/test/file_view/nested_folders.txt @@ -8,13 +8,13 @@
    1. -
    2. 0
    3. +
    4. 0
    1. -
    2. 1
    3. +
    4. 1
  • @@ -24,5 +24,5 @@
    1. -
    2. 2
    3. -
    \ No newline at end of file +
  • 2
  • + From 6888420cc648aa1a95adcdb9985cdce0b024fe54 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 10 Nov 2012 12:08:05 -0700 Subject: [PATCH 4/6] Update file_view output --- lib/gollum/file_view.rb | 7 ++----- test/file_view/1_file.txt | 3 +-- test/file_view/1_file_1_folder.txt | 2 +- test/file_view/1_folder.txt | 2 +- test/file_view/2_files_2_folders.txt | 7 ++----- test/file_view/2_files_2_folders_1_root.txt | 10 +++------- test/file_view/nested_folders.txt | 17 +++++------------ test/test_file_view.rb | 4 ++++ 8 files changed, 19 insertions(+), 33 deletions(-) diff --git a/lib/gollum/file_view.rb b/lib/gollum/file_view.rb index 0d2379b9..79ab67b6 100644 --- a/lib/gollum/file_view.rb +++ b/lib/gollum/file_view.rb @@ -22,7 +22,7 @@ module Gollum def new_page page name = page.name url = url_for_page page - %Q(
  • #{name}
  • \n) + %Q(
  • #{name}
  • ) end def new_folder folder_path @@ -38,10 +38,7 @@ module Gollum end def end_folder - <<-HTML - - - HTML + "\n" end def url_for_page page diff --git a/test/file_view/1_file.txt b/test/file_view/1_file.txt index 30d1ec1d..6b87ac96 100644 --- a/test/file_view/1_file.txt +++ b/test/file_view/1_file.txt @@ -1,3 +1,2 @@
      -
    1. 0
    2. -
    +
  • 0
  • \ No newline at end of file diff --git a/test/file_view/1_file_1_folder.txt b/test/file_view/1_file_1_folder.txt index 33a3e47b..10255983 100644 --- a/test/file_view/1_file_1_folder.txt +++ b/test/file_view/1_file_1_folder.txt @@ -5,4 +5,4 @@
  • 0
  • - + \ No newline at end of file diff --git a/test/file_view/1_folder.txt b/test/file_view/1_folder.txt index 323443b3..69b71a6d 100644 --- a/test/file_view/1_folder.txt +++ b/test/file_view/1_folder.txt @@ -5,4 +5,4 @@
  • folder0
  • - + \ No newline at end of file diff --git a/test/file_view/2_files_2_folders.txt b/test/file_view/2_files_2_folders.txt index 1011235e..289c7053 100644 --- a/test/file_view/2_files_2_folders.txt +++ b/test/file_view/2_files_2_folders.txt @@ -2,11 +2,8 @@
    1. -
    2. 0
    3. -
    -
  • +
  • 0
    1. -
    2. 1
    3. -
    +
  • 1
  • \ No newline at end of file diff --git a/test/file_view/2_files_2_folders_1_root.txt b/test/file_view/2_files_2_folders_1_root.txt index 76b551f7..40b2cdb9 100644 --- a/test/file_view/2_files_2_folders_1_root.txt +++ b/test/file_view/2_files_2_folders_1_root.txt @@ -1,13 +1,9 @@
      -
    1. root
    2. -
    3. +
    4. root
      1. -
      2. 0
      3. -
      -
    5. +
    6. 0
    1. -
    2. 1
    3. -
    +
  • 1
  • \ No newline at end of file diff --git a/test/file_view/nested_folders.txt b/test/file_view/nested_folders.txt index 39bf4ba6..a767869e 100644 --- a/test/file_view/nested_folders.txt +++ b/test/file_view/nested_folders.txt @@ -8,21 +8,14 @@
    1. -
    2. 0
    3. -
    -
  • +
  • 0
    1. -
    2. 1
    3. -
    -
  • - - - - +
  • 1
  • + +
    1. -
    2. 2
    3. -
    +
  • 2
  • \ No newline at end of file diff --git a/test/test_file_view.rb b/test/test_file_view.rb index b943f52a..c3bcd9e3 100644 --- a/test/test_file_view.rb +++ b/test/test_file_view.rb @@ -72,6 +72,10 @@ def check name, pages_array pages = FakePages.new pages_array expected = read name actual = view pages + + # Uncomment when updating tests + # write name, actual + assert_equal expected, actual end From f6245c53ddf2420f9797912a486754a9ef0e5e5d Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 10 Nov 2012 12:14:20 -0700 Subject: [PATCH 5/6] Add .gitattributes --- .gitattributes | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .gitattributes diff --git a/ .gitattributes b/ .gitattributes new file mode 100644 index 00000000..57a806c2 --- /dev/null +++ b/ .gitattributes @@ -0,0 +1,25 @@ +# https://help.github.com/articles/dealing-with-line-endings +# Set default behaviour, in case users don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files we want to always be normalized and converted +# to native line endings on checkout. +*.txt text +*.md text +*.rb text +*.js text +*.html text +*.yml text +*.mustache text +*.css text +Rakefile text +Gemfile text +LICENSE text +COPYRIGHT text +gollum text +.gitattributes text +.gitignore text + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary From ca7d82278cedb3f1686c7c6ce6467a1b0b1244c6 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 10 Nov 2012 16:34:37 -0700 Subject: [PATCH 6/6] Pretty print with nokogiri --- test/file_view/1_file.txt | 5 +- test/file_view/1_file_1_folder.txt | 17 ++++--- test/file_view/1_folder.txt | 17 ++++--- test/file_view/2_files_2_folders.txt | 27 +++++++--- test/file_view/2_files_2_folders_1_root.txt | 30 ++++++++--- test/file_view/nested_folders.txt | 56 ++++++++++++++------- test/test_file_view.rb | 14 +++++- 7 files changed, 116 insertions(+), 50 deletions(-) diff --git a/test/file_view/1_file.txt b/test/file_view/1_file.txt index 6b87ac96..d74f47ce 100644 --- a/test/file_view/1_file.txt +++ b/test/file_view/1_file.txt @@ -1,2 +1,5 @@
      -
    1. 0
    \ No newline at end of file +
  • + 0 +
  • + diff --git a/test/file_view/1_file_1_folder.txt b/test/file_view/1_file_1_folder.txt index 10255983..54a50980 100644 --- a/test/file_view/1_file_1_folder.txt +++ b/test/file_view/1_file_1_folder.txt @@ -1,8 +1,11 @@
      -
    1. - -
        -
      1. 0
      2. -
      -
    2. -
    \ No newline at end of file +
  • + + +
      +
    1. + 0 +
    2. +
    +
  • + diff --git a/test/file_view/1_folder.txt b/test/file_view/1_folder.txt index 69b71a6d..04066def 100644 --- a/test/file_view/1_folder.txt +++ b/test/file_view/1_folder.txt @@ -1,8 +1,11 @@
      -
    1. - -
        -
      1. folder0
      2. -
      -
    2. -
    \ No newline at end of file +
  • + + +
      +
    1. + folder0 +
    2. +
    +
  • + diff --git a/test/file_view/2_files_2_folders.txt b/test/file_view/2_files_2_folders.txt index 289c7053..49cb39ee 100644 --- a/test/file_view/2_files_2_folders.txt +++ b/test/file_view/2_files_2_folders.txt @@ -1,9 +1,20 @@
      -
    1. - -
        -
      1. 0
    2. -
    3. - -
        -
      1. 1
      \ No newline at end of file +
    4. + + +
        +
      1. + 0 +
      2. +
      +
    5. +
    6. + + +
        +
      1. + 1 +
      2. +
      +
    7. +
    diff --git a/test/file_view/2_files_2_folders_1_root.txt b/test/file_view/2_files_2_folders_1_root.txt index 40b2cdb9..1ee732b2 100644 --- a/test/file_view/2_files_2_folders_1_root.txt +++ b/test/file_view/2_files_2_folders_1_root.txt @@ -1,9 +1,23 @@
      -
    1. root
    2. - -
        -
      1. 0
    3. -
    4. - -
        -
      1. 1
      \ No newline at end of file +
    5. + root +
    6. +
    7. + + +
        +
      1. + 0 +
      2. +
      +
    8. +
    9. + + +
        +
      1. + 1 +
      2. +
      +
    10. +
    diff --git a/test/file_view/nested_folders.txt b/test/file_view/nested_folders.txt index a767869e..5cb0703f 100644 --- a/test/file_view/nested_folders.txt +++ b/test/file_view/nested_folders.txt @@ -1,21 +1,41 @@
      +
    1. + + +
      1. - + +
          -
        1. - -
            -
          1. - -
              -
            1. 0
          2. -
          3. - -
              -
            1. 1
          4. -
        2. -
      2. -
      3. - -
          -
        1. 2
        \ No newline at end of file +
      4. + + +
          +
        1. + 0 +
        2. +
        +
      5. +
      6. + + +
          +
        1. + 1 +
        2. +
        +
      7. +
      +
    2. +
    + +
  • + + +
      +
    1. + 2 +
    2. +
    +
  • + diff --git a/test/test_file_view.rb b/test/test_file_view.rb index c3bcd9e3..76747bde 100644 --- a/test/test_file_view.rb +++ b/test/test_file_view.rb @@ -68,10 +68,22 @@ def write file, content end end +@@format_xslt = File.expand_path(File.join(File.dirname(__FILE__), 'format.xslt')) + +def to_html html + # Remove blank nodes for proper formatting + doc = Nokogiri.XML(html) do |cfg| + cfg.default_xml.noblanks + end + + # Save as XHTML + doc.to_xml( { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML, :indent => 2, :encoding => 'UTF-8' } ) +end + def check name, pages_array pages = FakePages.new pages_array expected = read name - actual = view pages + actual = to_html view pages # Uncomment when updating tests # write name, actual