From 5bdcd370301720e3dd4df8cc9323e90aeb577d2b Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Mon, 23 Apr 2012 17:29:03 -0700 Subject: [PATCH] initial version of commands index using the related data --- TODO.txt | 3 ++- app/controllers/doc_controller.rb | 29 +++++++++++++++++++++++++++++ app/views/doc/book.html.erb | 8 +++----- app/views/doc/commands.html.erb | 24 ++++++++++++++++++++++++ app/views/doc/index.html.haml | 2 +- config/routes.rb | 1 + lib/tasks/related.rake | 15 --------------- 7 files changed, 60 insertions(+), 22 deletions(-) create mode 100644 app/views/doc/commands.html.erb diff --git a/TODO.txt b/TODO.txt index 00884f756a..27473ce5a6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -7,7 +7,8 @@ Initial Launch (3.0): * "admonition block" (eg. NOTE at the end of git-blame) * Book content - * commands.html + - remote fill + - commands.html * Sidebar related content - book sections diff --git a/app/controllers/doc_controller.rb b/app/controllers/doc_controller.rb index 8c1fa221da..d99f499100 100644 --- a/app/controllers/doc_controller.rb +++ b/app/controllers/doc_controller.rb @@ -74,6 +74,35 @@ def book_section @related = @content.get_related(8) end + CMD_GROUPS = [ + ['Setup and Config', [ 'config', 'help' ]], + ['Getting and Creating Projects', [ 'init', 'clone']], + ['Basic Snapshotting', [ 'add', 'status', 'diff', 'commit', 'reset', 'rm', 'mv']], + ['Branching and Merging', [ 'branch', 'checkout', 'merge', 'mergetool', 'log', 'stash', 'tag' ]], + ['Sharing and Updating Projects', [ 'fetch', 'pull', 'push', 'remote', 'submodule' ]], + ['Inspection and Comparison', [ 'show', 'log', 'diff', 'shortlog', 'describe' ]], + ['Patching', ['am', 'apply', 'cherry-pick', 'rebase']], + ['Debugging', [ 'bisect', 'blame' ]], + ['Email', ['am', 'apply', 'format-patch', 'send-email', 'request-pull']], + ['External Sytems', ['svn', 'fast-import']], + ['Administration', [ 'gc', 'fsck', 'reflog', 'filter-branch', 'instaweb', 'archive' ]], + ['Server Admin', [ 'daemon', 'update-server-info' ]], + ] + + # commands index + def commands + @related = {} + ri = RelatedItem.where(:content_type => 'reference', :related_type => 'book') + ri.each do |item| + cmd = item.name.gsub('git-', '') + if s = Section.where(:slug => item.related_id).first + @related[cmd] ||= [] + @related[cmd] << [s.cs_number, s.slug, item.score] + end + end + @groups = CMD_GROUPS + end + # so we can display urls old progit.org style def progit chapter = params[:chapter].to_i diff --git a/app/views/doc/book.html.erb b/app/views/doc/book.html.erb index 73e1897f08..b2ccd5f61b 100644 --- a/app/views/doc/book.html.erb +++ b/app/views/doc/book.html.erb @@ -27,11 +27,9 @@ <% end %> - +
  • +

    Index of Commands

    +
  • diff --git a/app/views/doc/commands.html.erb b/app/views/doc/commands.html.erb new file mode 100644 index 0000000000..e7234a6f6c --- /dev/null +++ b/app/views/doc/commands.html.erb @@ -0,0 +1,24 @@ +<% @section = 'documentation' %> +<% @subsection = 'book' %> + +
    +

    Index of Commands

    + + <% @groups.each do |title, commands| %> + + + + <% commands.each do |cmd| %> + + + + <% if @related[cmd] %> + <% @related[cmd].each do |number, slug, score| %> + + <% end %> + <% end %> + + <% end %> + <% end %> +

    <%= title %>

     <%= cmd %><%= number %>(<%= score %>)
    +
    diff --git a/app/views/doc/index.html.haml b/app/views/doc/index.html.haml index 5534e953d4..a3c2f2af43 100644 --- a/app/views/doc/index.html.haml +++ b/app/views/doc/index.html.haml @@ -60,7 +60,7 @@ = chapter.number.to_s + '.' %a{:href=>"/book/#{@book.code}/#{chapter.sections.first.slug}"}= chapter.title %li.chapter - %h2 Index of Commands + %h2 Index of Commands %h2 Videos diff --git a/config/routes.rb b/config/routes.rb index 00ae202029..639b049fce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,7 @@ match "/doc/ext" => "doc#ext" match "/book" => "doc#book" + match "/book/commands" => "doc#commands" match "/book/ch:chapter-:section.html" => "doc#progit" match "/book/:lang/ch:chapter-:section.html" => "doc#progit" match "/book/:lang" => "doc#book" diff --git a/lib/tasks/related.rake b/lib/tasks/related.rake index fdaaf2e209..2f2ec090d1 100644 --- a/lib/tasks/related.rake +++ b/lib/tasks/related.rake @@ -19,21 +19,6 @@ CMD_IGNORE = ['aware', 'binaries', 'ci', 'co', 'com', 'directory', 'feature', 'mygrit', 'project', 'prune', 'rack', 'repository', 'stash-unapply', 'tarball', 'that', 'user', 'visual', 'will', 'world', 'unstage'] -CMD_GROUPS = [ - ['Setup and Config', [ 'config', 'help' ]], - ['Getting and Creating Projects', [ 'init', 'clone']], - ['Basic Snapshotting', [ 'add', 'status', 'diff', 'commit', 'reset', 'rm', 'mv']], - ['Branching and Merging', [ 'branch', 'checkout', 'merge', 'mergetool', 'log', 'stash', 'tag' ]], - ['Sharing and Updating Projects', [ 'fetch', 'pull', 'push', 'remote', 'submodule' ]], - ['Inspection and Comparison', [ 'show', 'log', 'diff', 'shortlog', 'describe' ]], - ['Patching', ['am', 'apply', 'cherry-pick', 'rebase']], - ['Debugging', [ 'bisect', 'blame' ]], - ['Email', ['am', 'apply', 'format-patch', 'send-email', 'request-pull']], - ['External Sytems', ['svn', 'fast-import']], - ['Administration', [ 'gc', 'fsck', 'reflog', 'filter-branch', 'instaweb', 'archive' ]], - ['Server Admin', [ 'daemon', 'update-server-info' ]], -] - # book content # - reference calls def find_book_links