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 diff --git a/lib/gollum/file_view.rb b/lib/gollum/file_view.rb index cf88dea4..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 @@ -85,13 +82,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 diff --git a/lib/gollum/frontend/public/gollum/css/_styles.css b/lib/gollum/frontend/public/gollum/css/_styles.css index 092263c4..c058fa2b 100644 --- a/lib/gollum/frontend/public/gollum/css/_styles.css +++ b/lib/gollum/frontend/public/gollum/css/_styles.css @@ -1,121 +1,128 @@ -*, 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 + { + color: #fff; + text-decoration: none; + display: inline-block; + } + 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; + 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 */ } + diff --git a/test/file_view/1_file.txt b/test/file_view/1_file.txt index 6f65a3a3..d74f47ce 100644 --- a/test/file_view/1_file.txt +++ b/test/file_view/1_file.txt @@ -1,3 +1,5 @@
      -
    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..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 f960bee7..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 05a8799a..49cb39ee 100644 --- a/test/file_view/2_files_2_folders.txt +++ b/test/file_view/2_files_2_folders.txt @@ -1,12 +1,20 @@
      -
    1. - -
        -
      1. 0
      2. -
      +
    2. + + +
        +
      1. + 0
      2. -
      3. - -
          -
        1. 1
        2. -
        \ No newline at end of file +
      +
    3. +
    4. + + +
        +
      1. + 1 +
      2. +
      +
    5. +
    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..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,13 +1,23 @@
      -
    1. root
    2. -
    3. - -
        -
      1. 0
      2. -
      +
    4. + root +
    5. +
    6. + + +
        +
      1. + 0
      2. -
      3. - -
          -
        1. 1
        2. -
        \ No newline at end of file +
      +
    7. +
    8. + + +
        +
      1. + 1 +
      2. +
      +
    9. +
    diff --git a/test/file_view/nested_folders.txt b/test/file_view/nested_folders.txt index 5094929d..5cb0703f 100644 --- a/test/file_view/nested_folders.txt +++ b/test/file_view/nested_folders.txt @@ -1,28 +1,41 @@
      +
    1. + + +
      1. - + +
          -
        1. - -
            -
          1. - -
              -
            1. 0
            2. +
            3. + + +
                +
              1. + 0 +
              2. +
              +
            4. +
            5. + + +
                +
              1. + 1 +
              2. +
              +
          2. -
          3. - -
              -
            1. 1
            2. -
            +
          +
        2. +
        3. + + +
            +
          1. + 2
          2. -
          -
        4. -
        -
      2. -
      3. - -
          -
        1. 2
        2. -
        \ No newline at end of file +
      +
    2. +
    diff --git a/test/test_file_view.rb b/test/test_file_view.rb index b943f52a..76747bde 100644 --- a/test/test_file_view.rb +++ b/test/test_file_view.rb @@ -68,10 +68,26 @@ 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 + assert_equal expected, actual end