Commits

Yuya Nishihara committed 870b6d5

sampleapp: use paths to build incoming/outgoing menus

  • Participants
  • Parent commits 6004ae6

Comments (0)

Files changed (2)

File extra/sample_app/app.rb

 HG_VERSION = $hg.version
 
 before do
+  @paths = $hg.paths
   @tags = $hg.tags
 end
 
 # NOTE: 'incoming' and 'outgoing'  may take some time. so it should be executed
 # asynchronously in production code.
 
-get '/incoming' do
+get '/incoming/?:name?' do |name|
   @title = 'Incoming Commits'
+  args = name ? [name] : []
   begin
-    @changes = $hg.incoming.reverse
+    @changes = $hg.incoming(*args).reverse
     erubis :changesets
   rescue Hglib::CommandFailure => err
     raise unless err.exitstatus == 1
   end
 end
 
-get '/outgoing' do
+get '/outgoing/?:name?' do |name|
   @title = 'Outgoing Commits'
+  args = name ? [name] : []
   begin
-    @changes = $hg.outgoing.reverse
+    @changes = $hg.outgoing(*args).reverse
     erubis :changesets
   rescue Hglib::CommandFailure => err
     raise unless err.exitstatus == 1

File extra/sample_app/views/layout.erb

           <ul class="nav">
             <%== nav_link '/', 'Home' %>
             <%== nav_link '/changesets', 'Commits' %>
+
             <li class="dropdown">
               <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                 Tags
                 <% end %>
               </ul>
             </li>
-            <%== nav_link '/incoming', 'Incoming' %>
-            <%== nav_link '/outgoing', 'Outgoing' %>
+          </ul>
+
+          <ul class="nav pull-right">
+            <% %w|Incoming Outgoing|.each do |cmd| %>
+            <li class="dropdown">
+              <a href="#" class="dropdown-toggle" data-toggle="dropdown">
+                <%= cmd %>
+                <b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <% @paths.each do |name, u| %>
+                <li><a href="<%= url("/#{cmd.downcase}/#{name}") %>"><%= name %></a></li>
+                <% end %>
+              </ul>
+            </li>
+            <% end %>
           </ul>
         </div>
       </div>