diff options
author | 2016-07-20 14:37:49 +0200 | |
---|---|---|
committer | 2016-07-20 14:37:49 +0200 | |
commit | b145840323316610dd5a958cad89bbb84712ca5b (patch) | |
tree | ddfd7996d65feeccf927900131482842df3253f1 /app/helpers/links_helper.rb | |
download | packages-5-b145840323316610dd5a958cad89bbb84712ca5b.tar.gz packages-5-b145840323316610dd5a958cad89bbb84712ca5b.tar.bz2 packages-5-b145840323316610dd5a958cad89bbb84712ca5b.zip |
Initial commit w/currently running code
Diffstat (limited to 'app/helpers/links_helper.rb')
-rw-r--r-- | app/helpers/links_helper.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/app/helpers/links_helper.rb b/app/helpers/links_helper.rb new file mode 100644 index 0000000..5a28fb0 --- /dev/null +++ b/app/helpers/links_helper.rb @@ -0,0 +1,56 @@ +module LinksHelper + # Slash-in-Link-Fix + # Replaces the URLencoded slash with a proper slash + def slf(input) + input.gsub('%2F', '/') + end + + def link_to_gitweb_commit(commitid) + link_to commitid[0...8], + gitweb_commit_url(commitid), + title: commitid, + class: 'kk-commit' + end + + def gitweb_commit_url(commitid) + 'https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=%s' % commitid + end + + def link_to_gitweb_ebuild_diff(name, commitid, cat, pkg) + link_to name, 'https://gitweb.gentoo.org/repo/gentoo.git/diff/%s/%s/%s?id=%s' % [cat, pkg, name, commitid] + end + + def link_to_license_text(license) + link_to license, 'https://gitweb.gentoo.org/repo/gentoo.git/plain/licenses/%s' % license + end + + def link_to_category(category) + link_to category.name, + category_path(category), + title: category.description, + 'data-toggle' => 'tooltip', + 'data-placement' => 'right' + end + + def link_to_package(atom) + link_to atom, slf(package_path(atom)) + end + + def link_to_herd(herd) + link_to herd, 'https://www.gentoo.org/inside-gentoo/developers/herds.html#%s' % herd + end + + def link_to_bug(str, bugid) + link_to str, 'https://bugs.gentoo.org/show_bug.cgi?id=%s' % bugid + end + + def absolute_link_to_package(atom) + slf package_url(atom) + end + + def feed_icon(url) + content_tag :a, + content_tag(:span, '', class: 'fa fa-fw fa-rss-square'), + title: t(:atom_feed), href: url, class: 'kk-feed-icon' + end +end |