Browse files

Added rough version of ability to pull from and push to remotes for a…

… project.
  • Loading branch information...
1 parent 19caf47 commit 33d4ff3c8fc6ee43276b524c3498f1ab3245b0af @notahat committed Jun 25, 2008
View
17 app/controllers/projects_controller.rb
@@ -16,4 +16,21 @@ def destroy
flash[:notice] = "Project deleted."
redirect_to(projects_url)
end
+
+ def pull
+ @project = Project.find(params[:id])
+ @remote = params[:remote]
+ @project.git.fetch(@remote)
+ @project.git.merge("#{@remote}/master")
+ flash[:notice] = "Pull completed."
+ redirect_to(project_pages_url(@project))
+ end
+
+ def push
+ @project = Project.find(params[:id])
+ @remote = params[:remote]
+ @project.git.push(@remote)
+ flash[:notice] = "Push completed."
+ redirect_to(project_pages_url(@project))
+ end
end
View
32 app/views/pages/index.html.erb
@@ -9,11 +9,15 @@
<h1><%=h @project.name %></h1>
-<ul>
- <% for page in @pages %>
- <li><%= link_to(h(page.name), [@project, page]) %></li>
- <% end %>
-</ul>
+<% unless @pages.empty? %>
+ <table>
+ <% for page in @pages %>
+ <tr>
+ <td><%= link_to(h(page.name), [@project, page]) %></td>
+ </tr>
+ <% end %>
+ </table>
+<% end %>
<% form_for(:page, Page.new, :url => new_project_page_path(@project)) do |form| %>
<%= form.text_field(:name) %>
@@ -22,7 +26,23 @@
<script>$('page_name').focus()</script>
-<% unless @pages.length == 0 %>
+<% unless @pages.empty? %>
+ <% unless @project.git.remotes.empty? %>
+ <h2>Remotes</h2>
+
+ <table>
+ <% for remote in @project.git.remotes %>
+ <tr>
+ <td><%=h remote.name %></td>
+ <td><%= link_to("pull", pull_project_path(@project, :remote => remote.name)) %></td>
+ <td><%= link_to("push", push_project_path(@project, :remote => remote.name)) %></td>
+ </tr>
+ <% end %>
+ </table>
+ <% end %>
+
+ <h2>History</h2>
+
<table>
<thead>
<tr>
View
20 app/views/projects/index.html.erb
@@ -6,15 +6,17 @@
<h1>Projects</h1>
-<ul>
- <% for project in @projects %>
- <li>
- <%= link_to(h(project.name), project_pages_path(project)) %></td>
- <%= link_to(delete_button, project, :method => :delete, :confirm => 'Really delete?') %>
- <%= "git clone #{request.host}:#{project.path}" %>
- </li>
- <% end %>
-</ul>
+<% unless @projects.empty? %>
+ <table>
+ <% for project in @projects %>
+ <tr>
+ <td><%= link_to(h(project.name), project_pages_path(project)) %></td>
+ <td><%=h "gitjour clone #{ENV['USER']}-#{project.name}" %></td>
+ <td><%= link_to(delete_button, project, :method => :delete, :confirm => 'Really delete?') %></td>
+ </tr>
+ <% end %>
+ </table>
+<% end %>
<% form_for(Project.new) do |form| %>
<%= form.text_field(:name) %>
View
2 config/routes.rb
@@ -1,5 +1,5 @@
ActionController::Routing::Routes.draw do |map|
- map.resources :projects do |project|
+ map.resources :projects, :member => { :pull => :get, :push => :get } do |project|
project.resources :pages, :new => { :new => :any }
end
map.root :projects
View
2 public/stylesheets/application.css
@@ -5,7 +5,7 @@ hr { height: 1px; background: #cccccc; border: 0; margin: 1.5em 0; }
img.icon { margin-bottom: -4px; }
p.flash_notice { background: #ddffdd; padding: 0.75em 1.5em; border: #008800 solid 1px; }
-table { border-collapse: collapse; margin: 1.5em -0.75em; }
+table { border-collapse: collapse; margin: 1.5em 0; }
table th { font-weight: bold; text-align: left; padding: 0 0.75em; }
table td { padding: 0 0.75em; border-top: 1px solid #cccccc; border-bottom: 1px solid #cccccc; }

0 comments on commit 33d4ff3

Please sign in to comment.