summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2009-06-10 15:32:03 +0200
committerJohan Sørensen <johan@johansorensen.com>2009-06-10 15:32:03 +0200
commit78fa25e94e7d88269394fb568102e1b9c96b7060 (patch)
treefa9118a66af039f921303f2d2dad17ddee29c1ef
parent208632b7fb3977cd127c4d3ae1e933f6ef474b0a (diff)
downloadgitorious-mainline-outdated-78fa25e94e7d88269394fb568102e1b9c96b7060.zip
gitorious-mainline-outdated-78fa25e94e7d88269394fb568102e1b9c96b7060.tar.gz
gitorious-mainline-outdated-78fa25e94e7d88269394fb568102e1b9c96b7060.tar.bz2
Unify rendering of git clone and push urls in a partial and restyle it a bit
-rw-r--r--app/helpers/application_helper.rb15
-rw-r--r--app/helpers/repositories_helper.rb22
-rw-r--r--app/views/repositories/_clone_urls.html.erb75
-rw-r--r--app/views/repositories/_infobox.html.erb58
-rw-r--r--app/views/repositories/_overview.html.erb50
-rw-r--r--app/views/repositories/_statistics.html.erb45
-rw-r--r--config/locales/en.rb5
-rw-r--r--public/stylesheets/base.css4
8 files changed, 95 insertions, 179 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 44b39d9..424ed8b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -258,10 +258,17 @@ module ApplicationHelper
project_repository_blob_path(repository.project, repository, branch_with_tree(head, filename))
end
- def link_to_help_toggle(dom_id)
- link_to_function(image_tag("help_grey.png", {
- :alt => t("application_helper.more_info")
- }), "$('#{dom_id}').toggle()", :class => "more_info")
+ def link_to_help_toggle(dom_id, style = :image)
+ if style == :image
+ link_to_function(image_tag("help_grey.png", {
+ :alt => t("application_helper.more_info")
+ }), "$('#{dom_id}').toggle()", :class => "more_info")
+ else
+ %Q{<span class="hint">(} +
+ link_to_function("?", "$('#{dom_id}').toggle()", :class => "more_info") +
+ ")</span>"
+ end
+
end
FILE_EXTN_MAPPINGS = {
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb
index ebe803b..7bada46 100644
--- a/app/helpers/repositories_helper.rb
+++ b/app/helpers/repositories_helper.rb
@@ -69,28 +69,6 @@ module RepositoriesHelper
end
end
- def toggle_more_repository_urls(repository)
- js = <<-eos
- <script type="text/javascript" charset="utf-8">
- $('repo-#{repository.id}-url-toggle').observe('click', function(event) {
- $('repo-#{repository.id}-http-url').toggle();
- if ($('repo-#{repository.id}-push-url'))
- $('repo-#{repository.id}-push-url').toggle();
- Event.stop(event);
- });
- </script>
- eos
- if logged_in? && current_user.can_write_to?(repository)
- text = "Show HTTP clone url &amp; SSH push url"
- else
- text = "Show HTTP clone url"
- end
- img = image_tag("silk/database_key.png", :alt => text, :title => text)
- content_tag(:a, img, :href => "#more-urls",
- :id => "repo-#{repository.id}-url-toggle",
- :class => "hint") + js
- end
-
def render_branch_list_items(branches)
sorted_git_heads(branches).map do |branch|
content_tag(:li,
diff --git a/app/views/repositories/_clone_urls.html.erb b/app/views/repositories/_clone_urls.html.erb
new file mode 100644
index 0000000..b55ae1b
--- /dev/null
+++ b/app/views/repositories/_clone_urls.html.erb
@@ -0,0 +1,75 @@
+<%
+#--
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#++
+%>
+
+<ul>
+ <li>
+ <strong><%= t("views.repos.clone_this_repo") -%></strong>
+ <%- if repository.http_cloning? -%>
+ <small class="alt-clone-links">
+ (<a href ="#more-urls" class="hint" id="repo-<%= repository.id -%>-git-toggle">Git</a> /
+ <a href ="#more-urls" class="hint" id="repo-<%= repository.id -%>-http-toggle">HTTP</a>)
+ </small><%- end -%>:
+
+ <span id="repo-<%= repository.id -%>-git-url">
+ <code>
+ git clone <a href="<%= h(repository.clone_url) -%>" class="link_noop"><%= h(repository.clone_url) -%></a>
+ </code>
+ </span>
+
+ <% if repository.http_cloning? -%>
+ <span id="repo-<%= repository.id -%>-http-url" style="display:none">
+ <code>git clone <a href="<%= h(repository.http_clone_url) -%>" class="link_noop">
+ <%= h(repository.http_clone_url) -%></a>
+ </code>
+ </span>
+ <% end -%>
+ </li>
+
+ <% if logged_in? && current_user.can_write_to?(repository) -%>
+ <li>
+ <strong><%= t("views.repos.push_url") -%>:</strong>
+ <code><%= h(repository.push_url) -%></code>
+ <small><%= link_to_help_toggle("detailed_push_info_#{dom_id(repository)}", :text) -%></small>
+ <div id="detailed_push_info_<%= dom_id(repository) -%>" class="info_hint" style="display:none">
+ <%= t("views.repos.help_push", :repo => repository.push_url) %>
+<pre>
+git remote add origin <%= repository.push_url %>
+# to push the master branch to the origin remote we added above:
+git push origin master
+# after that you can just do:
+git push
+</pre>
+ </div>
+ </li>
+ <% end -%>
+</ul>
+
+<script type="text/javascript" charset="utf-8">
+ $('repo-<%= repository.id -%>-git-toggle').observe('click', function(event) {
+ $('repo-<%= repository.id -%>-git-url').show();
+ if ($('repo-<%= repository.id -%>-http-url'))
+ $('repo-<%= repository.id -%>-http-url').hide();
+ Event.stop(event);
+ });
+ $('repo-<%= repository.id -%>-http-toggle').observe('click', function(event) {
+ $('repo-<%= repository.id -%>-http-url').show();
+ $('repo-<%= repository.id -%>-git-url').hide();
+ Event.stop(event);
+ });
+</script> \ No newline at end of file
diff --git a/app/views/repositories/_infobox.html.erb b/app/views/repositories/_infobox.html.erb
deleted file mode 100644
index a9639fb..0000000
--- a/app/views/repositories/_infobox.html.erb
+++ /dev/null
@@ -1,58 +0,0 @@
-<%
-#--
-# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
-# Copyright (C) 2008 Johan Sørensen <johan@johansorensen.com>
-# Copyright (C) 2008 David A. Cuadrado <krawek@gmail.com>
-# Copyright (C) 2008 Tor Arne Vestbø <tavestbo@trolltech.com>
-# Copyright (C) 2009 Fabio Akita <fabio.akita@gmail.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#++
-%>
-
-<ul class="infobox">
- <li>
- <strong><%= t("views.repos.public_url") %>:</strong> <code><%=h @repository.clone_url -%></code>
- <small><%= link_to_function t("views.repos.more_info"), "$('detailed_clone_info').toggle()" -%></small>
- <div id="detailed_clone_info" class="info_hint" style="display:none">
- <%= t("views.repos.help_clone") %>:<br />
- <code>git clone <%= @repository.clone_url -%></code>
- </div>
- </li>
- <li>
- <strong><%= t("views.repos.http_url") %>:</strong> <code><%=h @repository.http_clone_url -%></code>
- <small><%= link_to_function t("views.repos.more_info"), "$('detailed_http_clone_info').toggle()" -%></small>
- <div id="detailed_http_clone_info" class="info_hint" style="display:none">
- <%= t("views.repos.help_clone") %>:<br />
- <code>git clone <%= @repository.http_clone_url -%></code><br />
- <small>(<%= t("views.repos.help_clone_http") %>)</small>
- </div>
- </li>
- <% if logged_in? && current_user.can_write_to?(@repository) -%>
- <li>
- <strong><%= t("views.repos.push_url") %>:</strong> <code><%=h @repository.push_url -%></code>
- <small><%= link_to_function t("views.repos.more_info"), "$('detailed_push_info').toggle()" -%></small>
- <div id="detailed_push_info" class="info_hint" style="display:none">
- <%= t("views.repos.help_push", :repo => @repository.push_url) %>
-<pre>
-git remote add origin <%= @repository.push_url %>
-# to push the master branch to the origin remote we added above:
-git push origin master
-# after that you can just do:
-git push
-</pre>
- </div>
- </li>
- <% end -%>
-</ul> \ No newline at end of file
diff --git a/app/views/repositories/_overview.html.erb b/app/views/repositories/_overview.html.erb
index cfac610..308d57f 100644
--- a/app/views/repositories/_overview.html.erb
+++ b/app/views/repositories/_overview.html.erb
@@ -47,55 +47,7 @@
<% end -%>
<tr>
<td colspan="3" class="infobox">
- <ul>
- <li>
- <strong><%= t("views.repos.public_url") %>:</strong>
- <a href="<%= repository.clone_url-%>" class="link_noop"><code><%=h repository.clone_url -%></code></a>
- <small>
- <%= link_to_help_toggle("detailed_clone_info_#{dom_id(repository)}") -%>
- <%= toggle_more_repository_urls(repository) -%>
-
- </small>
- <div id="detailed_clone_info_<%= dom_id(repository) -%>" class="info_hint" style="display:none">
- <%= t("views.repos.help_clone") %>:<br />
- <code>git clone <%= repository.clone_url -%></code>
- </div>
- </li>
- <% if logged_in? && repository.writable_by?(current_user) -%>
- <li>
- <strong><%= t("views.repos.your_clone_url") %>:</strong>
- <code><%=h repository.push_url -%></code>
- </li>
- <% end -%>
- <li id="repo-<%= repository.id -%>-http-url" style="display:none">
- <% if repository.http_cloning? -%>
- <strong><%= t("views.repos.http_url") %>:</strong>
- <a href="<%= repository.http_clone_url-%>" class="link_noop"><code><%=h repository.http_clone_url -%></code></a>
- <small><%= link_to_help_toggle("detailed_http_clone_info_#{dom_id(repository)}") -%></small>
- <div id="detailed_http_clone_info_<%= dom_id(repository) -%>" class="info_hint" style="display:none">
- <%= t("views.repos.help_clone") %>:<br />
- <code>git clone <%= repository.http_clone_url -%></code><br />
- <small>(<%= t("views.repos.help_clone_http") %>)</small>
- </div>
- <% end -%>
- </li>
- <% if logged_in? && current_user.can_write_to?(repository) -%>
- <li id="repo-<%= repository.id -%>-push-url" style="display:none">
- <strong><%= t("views.repos.push_url") %>:</strong> <code><%=h repository.push_url -%></code>
- <small><%= link_to_help_toggle("detailed_push_info_#{dom_id(repository)}") -%></small>
- <div id="detailed_push_info_<%= dom_id(repository) -%>" class="info_hint" style="display:none">
- <%= t("views.repos.help_push", :repo => repository.push_url) %>
- <pre>
- git remote add origin <%= repository.push_url %>
- # to push the master branch to the origin remote we added above:
- git push origin master
- # after that you can just do:
- git push
- </pre>
- </div>
- </li>
- <% end -%>
- </ul>
+ <%= render :partial => "repositories/clone_urls", :locals => {:repository => repository} -%>
</td>
</tr>
</table> \ No newline at end of file
diff --git a/app/views/repositories/_statistics.html.erb b/app/views/repositories/_statistics.html.erb
index b8a5415..0977321 100644
--- a/app/views/repositories/_statistics.html.erb
+++ b/app/views/repositories/_statistics.html.erb
@@ -48,45 +48,7 @@
<% end -%>
<tr>
<td colspan="3" class="infobox">
- <ul>
- <li>
- <strong><%= t("views.repos.public_url") %>:</strong>
- <a href="<%= repository.clone_url-%>" class="link_noop"><code><%=h repository.clone_url -%></code></a>
- <small><%= link_to_help_toggle('detailed_clone_info') -%></small>
- <div id="detailed_clone_info" class="info_hint" style="display:none">
- <%= t("views.repos.help_clone") %>:<br />
- <code>git clone <%= repository.clone_url -%></code>
- </div>
- </li>
- <% if repository.http_cloning? -%>
- <li>
- <strong><%= t("views.repos.http_url") %>:</strong>
- <a href="<%= repository.http_clone_url-%>" class="link_noop"><code><%=h repository.http_clone_url -%></code></a>
- <small><%= link_to_help_toggle('detailed_http_clone_info') -%></small>
- <div id="detailed_http_clone_info" class="info_hint" style="display:none">
- <%= t("views.repos.help_clone") %>:<br />
- <code>git clone <%= repository.http_clone_url -%></code><br />
- <small>(<%= t("views.repos.help_clone_http") %>)</small>
- </div>
- </li>
- <% end -%>
- <% if logged_in? && current_user.can_write_to?(repository) -%>
- <li>
- <strong><%= t("views.repos.push_url") %>:</strong> <code><%=h repository.push_url -%></code>
- <small><%= link_to_help_toggle('detailed_push_info') -%></small>
- <div id="detailed_push_info" class="info_hint" style="display:none">
- <%= t("views.repos.help_push", :repo => repository.push_url) %>
- <pre>
- git remote add origin <%= repository.push_url %>
- # to push the master branch to the origin remote we added above:
- git push origin master
- # after that you can just do:
- git push
- </pre>
- </div>
- </li>
- <% end -%>
- </ul>
+ <%= render :partial => "repositories/clone_urls", :locals => {:repository => repository} -%>
</td>
</tr>
<% if repository.has_commits? && !repository.git.heads.blank? -%>
@@ -99,9 +61,4 @@
</td>
</tr>
<% end -%>
- <% if false -%>
- <tr class="graph">
- <td colspan="3"><%= commit_graph_tag(repository) %></td>
- </tr>
- <% end -%>
</table> \ No newline at end of file
diff --git a/config/locales/en.rb b/config/locales/en.rb
index 4bc6787..36bf432 100644
--- a/config/locales/en.rb
+++ b/config/locales/en.rb
@@ -332,11 +332,12 @@
:comments => "Comments ({{count}})",
:requests => "Merge requests ({{count}})",
:public_url => "Public clone url",
- :your_clone_url => "Your clone url",
+ :your_clone_url => "Your push url",
+ :clone_this_repo => "Clone this repository",
:more_info => "More info…",
:help_clone => "You can clone this repository with the following command",
:help_clone_http => "note that cloning over HTTP is slightly slower, but useful if you're behind a firewall",
- :http_url => "HTTP clone url",
+ :http_url => "Public HTTP clone url",
:push_url => "Push url",
:help_push => "You can run <code>git push {{repo}} master</code><br /> Or you can setup a remote like this:",
:owner => "Owner",
diff --git a/public/stylesheets/base.css b/public/stylesheets/base.css
index 468d674..90bcc4c 100644
--- a/public/stylesheets/base.css
+++ b/public/stylesheets/base.css
@@ -931,6 +931,10 @@ table.repository_meta .infobox ul {
margin: 0;
}
+.infobox .alt-clone-links {
+ color: #666;
+}
+
/* commit info boxes*/
.commit-infobox {