Skip to content

Commit

Permalink
initial version of commands index using the related data
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed May 2, 2012
1 parent 5f8fa17 commit 5bdcd37
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 22 deletions.
3 changes: 2 additions & 1 deletion TODO.txt
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions app/controllers/doc_controller.rb
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions app/views/doc/book.html.erb
Expand Up @@ -27,11 +27,9 @@
</ol>
</li>
<% end %>
<!--
<li class='chapter'>
<h2><a href="#">Index of Commands</a></h2>
</li>
-->
<li class='chapter'>
<h2><a href="/book/commands">Index of Commands</a></h2>
</li>
</ol>
</div>

24 changes: 24 additions & 0 deletions app/views/doc/commands.html.erb
@@ -0,0 +1,24 @@
<% @section = 'documentation' %>
<% @subsection = 'book' %>

<div id='main'>
<h1>Index of Commands</h1>
<table>
<% @groups.each do |title, commands| %>
<tr>
<td colspan="10"><h2><%= title %></h2></td>
</tr>
<% commands.each do |cmd| %>
<tr>
<th>&nbsp;</th>
<th><%= cmd %></th>
<% if @related[cmd] %>
<% @related[cmd].each do |number, slug, score| %>
<td nowrap><a href="/book/en/<%= slug %>"><%= number %></a>(<%= score %>)</td>
<% end %>
<% end %>
</tr>
<% end %>
<% end %>
</table>
</div>
2 changes: 1 addition & 1 deletion app/views/doc/index.html.haml
Expand Up @@ -60,7 +60,7 @@
= chapter.number.to_s + '.'
%a{:href=>"/book/#{@book.code}/#{chapter.sections.first.slug}"}= chapter.title
%li.chapter
%h2 <a href="#">Index of Commands</a>
%h2 <a href="/book/commands">Index of Commands</a>

%h2 Videos

Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -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"
Expand Down
15 changes: 0 additions & 15 deletions lib/tasks/related.rake
Expand Up @@ -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
Expand Down

0 comments on commit 5bdcd37

Please sign in to comment.