Skip to content

Commit c62720f

Browse files
committed
bookmarks and links in news: replace flags with language description in French
1 parent 8f1294c commit c62720f

9 files changed

Lines changed: 33 additions & 78 deletions

File tree

app/assets/stylesheets/common/langs.scss

Lines changed: 0 additions & 67 deletions
This file was deleted.

app/assets/stylesheets/parts/bookmark.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
display: inline-block;
1313
}
1414
.content {
15-
padding: 0;
1615
min-height: auto;
1716
line-height: 1.3em;
1817
}
@@ -36,7 +35,4 @@
3635
color: #888;
3736
}
3837
}
39-
.links {
40-
display: block; /* cancel display:grid for bookmark entries */
41-
}
4238
}

app/helpers/bookmark_helper.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# encoding: UTF-8
2+
module BookmarkHelper
3+
def lang(bookmark)
4+
detail = ""
5+
if bookmark.lang != 'fr'
6+
detail = "(en #{Lang[bookmark.lang].downcase})"
7+
end
8+
detail
9+
end
10+
end

app/helpers/link_helper.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# encoding: UTF-8
2+
module LinkHelper
3+
def lang_and_hit(link)
4+
detail = "("
5+
if link.lang != 'fr'
6+
detail += "en #{Lang[link.lang].downcase}, "
7+
end
8+
detail += "#{pluralize link.nb_clicks, 'clic'})"
9+
end
10+
end

app/models/lang.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ def self.[]=(key, value)
1212
$redis.set("lang/#{key}", value)
1313
$redis.rpush("lang", key)
1414
end
15+
16+
def self.[](key)
17+
return $redis.get("lang/#{key}")
18+
end
1519
end

app/views/bookmarks/_bookmark.html.haml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
- c.title = "#{link_to "Lien", "/liens", class: "topic"} #{link_to bookmark.title, [bookmark.owner, bookmark]}".html_safe
33
- c.image = mini_avatar_img(bookmark.owner)
44
- c.body = capture do
5-
%ul.links
6-
%li.link{lang: bookmark.lang}= "#{link_to bookmark.link, bookmark.link, hreflang: bookmark.lang}".html_safe
5+
%p
6+
= link_to bookmark.link, bookmark.link, hreflang: bookmark.lang
7+
#{lang(bookmark)}
78
- if current_account && current_account.can_update?(bookmark)
89
- c.actions = link_to("Modifier", edit_user_bookmark_path(user_id: bookmark.owner, id: bookmark), class: 'action')

app/views/bookmarks/_preview.html.haml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
- c.title = "#{link_to "Lien", "/liens", class: "topic"} #{link_to spellcheck(preview.title), "#"}".html_safe
33
- c.image = mini_avatar_img(preview.node.user)
44
- c.body = capture do
5-
%ul
6-
%li.link{lang: preview.lang}= "#{link_to preview.link, preview.link, hreflang: preview.lang}".html_safe
5+
%p
6+
= link_to preview.link, preview.link, hreflang: preview.lang
7+
#{lang(preview)}

app/views/links/_link.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
%li[link]{link_attr(link)}
22
= link_to link.title, link.url, 'data-hit' => link.id, title: link.url, hreflang: link.lang, class: 'hit_counter'
3-
(#{pluralize link.nb_clicks, 'clic'})
3+
#{lang_and_hit(link)}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
%li[link]{ lang: link.lang, "data-url" => edit_redaction_link_path(link) }
1+
%li[link]{ "lang" => link.lang, "data-url" => edit_redaction_link_path(link) }
22
= link_to link.title, link.url, 'data-hit' => link.id, title: link.url, hreflang: link.lang, class: 'hit_counter'
3-
(#{pluralize link.nb_clicks, 'clic'})
3+
#{lang_and_hit(link)}
44
.actions
55
%button.edit Modifier

0 commit comments

Comments
 (0)