Révision | bfb19baeb0ba10b0f4cea26855675f2b5d6d5c6d (tree) |
---|---|
l'heure | 2017-09-05 23:25:21 |
Auteur | HMML <hmml3939@gmai...> |
Commiter | HMML |
Add user settings and profile page.
@@ -4,4 +4,21 @@ class User < ApplicationRecord | ||
4 | 4 | # :database_authenticatable, :registerable, |
5 | 5 | # :recoverable, :rememberable, :validatable, |
6 | 6 | devise :trackable, :omniauthable |
7 | + | |
8 | + has_many :themes | |
9 | + | |
10 | + def tw_url? | |
11 | + !tw_url.blank? | |
12 | + end | |
13 | + | |
14 | + def tw_url | |
15 | + tw_nick or return nil | |
16 | + "https://twitter.com/#{tw_nick}" | |
17 | + end | |
18 | + | |
19 | + def icon_tag(opts = {}) | |
20 | + tw_img_url or return ''.html_safe | |
21 | + opts = {size: '20x20', class: 'user-icon d-inline-block'}.merge(opts) | |
22 | + ActionController::Base.helpers.image_tag tw_img_url, opts | |
23 | + end | |
7 | 24 | end |
@@ -21,10 +21,11 @@ | ||
21 | 21 | - if user_signed_in? |
22 | 22 | %li.nav-item.dropdown |
23 | 23 | %a.nav-link.dropdown-toggle{href: '#', data: {toggle: 'dropdown'}} |
24 | - = image_tag current_user.tw_img_url, size: '20x20', class: 'd-inline-block' | |
24 | + = current_user.icon_tag | |
25 | 25 | = current_user.name |
26 | 26 | %b.caret |
27 | 27 | .dropdown-menu.dropdown-menu-right |
28 | + = link_to t('user_profile'), user_path(current_user), class: 'dropdown-item' | |
28 | 29 | = link_to t('user_settings'), edit_user_path(current_user), class: 'dropdown-item' |
29 | 30 | = link_to t('logout'), logout_path, class: 'dropdown-item' |
30 | 31 | - else |
@@ -29,6 +29,11 @@ | ||
29 | 29 | orig_theme_path(@theme), class: 'btn btn-secondary', 'data-turbolinks' => 'false' |
30 | 30 | .row |
31 | 31 | .col-xl-3.col-lg-4.col-md-5 |
32 | + %h5= t 'registerd_by' | |
33 | + - if @theme.user.present? | |
34 | + %p= link_to @theme.user.icon_tag + @theme.user.name, @theme.user | |
35 | + - else | |
36 | + %p= t 'anonymous' | |
32 | 37 | %h5= t 'activerecord.attributes.theme.created_at' |
33 | 38 | %p= l @theme.created_at |
34 | 39 | %h5= t 'license' |
@@ -1,8 +1,8 @@ | ||
1 | 1 | = simple_form_for(@user) do |f| |
2 | 2 | .form-inputs |
3 | 3 | = f.input :name |
4 | - = f.input :lang | |
5 | - = f.input :timezone | |
4 | + = f.input :lang, collection: Hash[Rails.configuration.i18n.available_locales.map {|l| [t("langs.#{l}"), l]}], include_blank: false | |
5 | + = f.input :timezone, collection: Hash[ActiveSupport::TimeZone.all.map{|z| [z.to_s, z.name] }], include_blank: false | |
6 | 6 | |
7 | 7 | .form-actions |
8 | 8 | = f.button :submit |
@@ -1,3 +1,3 @@ | ||
1 | -%h1 Editing user | |
1 | +%h1= t '.title' | |
2 | 2 | |
3 | 3 | = render 'form' |
@@ -1,10 +1,27 @@ | ||
1 | -%p#notice= notice | |
1 | +- content_for(:title) { @user.name + ' - ' + t('.title') } | |
2 | 2 | |
3 | -%p | |
4 | - %b Name: | |
3 | +%h2 | |
4 | + = @user.icon_tag size: '48x48' | |
5 | 5 | = @user.name |
6 | -%p | |
7 | - %b Lang: | |
8 | - = @user.lang | |
6 | + - if @user.tw_url? | |
7 | + = link_to fa_icon(:twitter) + ' Twitter', @user.tw_url, class: 'btn btn-sm btn-secondary' | |
9 | 8 | |
10 | -= link_to 'Edit', edit_user_path(@user) | |
9 | +%h3= t '.registered_themes' | |
10 | + | |
11 | +- if @user.themes.size > 0 | |
12 | + .card-columns.theme-index | |
13 | + - @user.themes.each do |theme| | |
14 | + .card{class: theme.day_frame_white? ? 'frame-white' : ''} | |
15 | + .card-block.p-1 | |
16 | + .icons | |
17 | + - 3.times do |idx| | |
18 | + .day-frame.day-frame-80 | |
19 | + = link_to image_tag(theme.public_send("preview#{idx+2}").url(:png100)), theme | |
20 | + .clearfix | |
21 | + %h4= link_to theme.name, theme | |
22 | + .author= link_to theme.author, theme | |
23 | + .short-desc | |
24 | + = theme.short_desc | |
25 | + .clip | |
26 | +- else | |
27 | + .alert.alert-warning= t '.no_registered_themes' |
@@ -1,4 +1,10 @@ | ||
1 | 1 | en: |
2 | + date: | |
3 | + formats: | |
4 | + default: "%d/%m/%Y" | |
5 | + time: | |
6 | + formats: | |
7 | + default: "%d/%m/%Y %H:%M:%S" | |
2 | 8 | activerecord: |
3 | 9 | models: |
4 | 10 | theme: Theme |
@@ -19,6 +25,13 @@ en: | ||
19 | 25 | title: Theme index |
20 | 26 | new: |
21 | 27 | title: Create new theme |
28 | + users: | |
29 | + show: | |
30 | + title: User profile | |
31 | + registered_themes: Registerd themes | |
32 | + no_registered_themes: No themes are registered by this user. | |
33 | + edit: | |
34 | + title: User settings | |
22 | 35 | |
23 | 36 | simple_formn: |
24 | 37 | placeholders: |
@@ -127,3 +140,10 @@ en: | ||
127 | 140 | choose_license: Choose License |
128 | 141 | publish: Publish |
129 | 142 | no_themes_published: No themes has been published yet. |
143 | + registerd_by: Registered by | |
144 | + anonymous: (anonymous) | |
145 | + langs: | |
146 | + en: English | |
147 | + ja: 日本語 (Japanese) | |
148 | + user_settings: User Settings | |
149 | + user_profile: Profile |
@@ -2,6 +2,7 @@ ja: | ||
2 | 2 | activerecord: |
3 | 3 | models: |
4 | 4 | theme: テーマ |
5 | + user: ユーザ | |
5 | 6 | attributes: |
6 | 7 | theme: |
7 | 8 | name: 名称 |
@@ -9,6 +10,10 @@ ja: | ||
9 | 10 | url: リンクURL |
10 | 11 | short_desc: 短い説明 |
11 | 12 | created_at: 公開日時 |
13 | + user: | |
14 | + name: 表示名 | |
15 | + lang: 言語 | |
16 | + timezone: タイムゾーン | |
12 | 17 | drafts: |
13 | 18 | show: |
14 | 19 | title: テーマのプレビュー |
@@ -19,6 +24,13 @@ ja: | ||
19 | 24 | title: テーマ一覧 |
20 | 25 | new: |
21 | 26 | title: 新規テーマの作成 |
27 | + users: | |
28 | + show: | |
29 | + title: ユーザプロフィール | |
30 | + registered_themes: 登録したテーマ | |
31 | + no_registered_themes: このユーザによって登録されたテーマはありません。 | |
32 | + edit: | |
33 | + title: ユーザ設定 | |
22 | 34 | |
23 | 35 | simple_formn: |
24 | 36 | placeholders: |
@@ -129,4 +141,10 @@ ja: | ||
129 | 141 | choose_license: ライセンス選択 |
130 | 142 | publish: 公開 |
131 | 143 | no_themes_published: まだ公開されたテーマはありません |
132 | - | |
\ No newline at end of file | ||
144 | + registerd_by: 登録ユーザ | |
145 | + anonymous: (匿名) | |
146 | + langs: | |
147 | + en: 英語 (English) | |
148 | + ja: 日本語 | |
149 | + user_settings: ユーザ設定 | |
150 | + user_profile: プロフィール |