• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révisionbfb19baeb0ba10b0f4cea26855675f2b5d6d5c6d (tree)
l'heure2017-09-05 23:25:21
AuteurHMML <hmml3939@gmai...>
CommiterHMML

Message de Log

Add user settings and profile page.

Change Summary

Modification

--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -4,4 +4,21 @@ class User < ApplicationRecord
44 # :database_authenticatable, :registerable,
55 # :recoverable, :rememberable, :validatable,
66 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
724 end
--- a/app/views/layouts/_topnav.html.haml
+++ b/app/views/layouts/_topnav.html.haml
@@ -21,10 +21,11 @@
2121 - if user_signed_in?
2222 %li.nav-item.dropdown
2323 %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
2525 = current_user.name
2626 %b.caret
2727 .dropdown-menu.dropdown-menu-right
28+ = link_to t('user_profile'), user_path(current_user), class: 'dropdown-item'
2829 = link_to t('user_settings'), edit_user_path(current_user), class: 'dropdown-item'
2930 = link_to t('logout'), logout_path, class: 'dropdown-item'
3031 - else
--- a/app/views/themes/show.html.haml
+++ b/app/views/themes/show.html.haml
@@ -29,6 +29,11 @@
2929 orig_theme_path(@theme), class: 'btn btn-secondary', 'data-turbolinks' => 'false'
3030 .row
3131 .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'
3237 %h5= t 'activerecord.attributes.theme.created_at'
3338 %p= l @theme.created_at
3439 %h5= t 'license'
--- a/app/views/users/_form.html.haml
+++ b/app/views/users/_form.html.haml
@@ -1,8 +1,8 @@
11 = simple_form_for(@user) do |f|
22 .form-inputs
33 = 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
66
77 .form-actions
88 = f.button :submit
--- a/app/views/users/edit.html.haml
+++ b/app/views/users/edit.html.haml
@@ -1,3 +1,3 @@
1-%h1 Editing user
1+%h1= t '.title'
22
33 = render 'form'
--- a/app/views/users/show.html.haml
+++ b/app/views/users/show.html.haml
@@ -1,10 +1,27 @@
1-%p#notice= notice
1+- content_for(:title) { @user.name + ' - ' + t('.title') }
22
3-%p
4- %b Name:
3+%h2
4+ = @user.icon_tag size: '48x48'
55 = @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'
98
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'
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1,4 +1,10 @@
11 en:
2+ date:
3+ formats:
4+ default: "%d/%m/%Y"
5+ time:
6+ formats:
7+ default: "%d/%m/%Y %H:%M:%S"
28 activerecord:
39 models:
410 theme: Theme
@@ -19,6 +25,13 @@ en:
1925 title: Theme index
2026 new:
2127 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
2235
2336 simple_formn:
2437 placeholders:
@@ -127,3 +140,10 @@ en:
127140 choose_license: Choose License
128141 publish: Publish
129142 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
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -2,6 +2,7 @@ ja:
22 activerecord:
33 models:
44 theme: テーマ
5+ user: ユーザ
56 attributes:
67 theme:
78 name: 名称
@@ -9,6 +10,10 @@ ja:
910 url: リンクURL
1011 short_desc: 短い説明
1112 created_at: 公開日時
13+ user:
14+ name: 表示名
15+ lang: 言語
16+ timezone: タイムゾーン
1217 drafts:
1318 show:
1419 title: テーマのプレビュー
@@ -19,6 +24,13 @@ ja:
1924 title: テーマ一覧
2025 new:
2126 title: 新規テーマの作成
27+ users:
28+ show:
29+ title: ユーザプロフィール
30+ registered_themes: 登録したテーマ
31+ no_registered_themes: このユーザによって登録されたテーマはありません。
32+ edit:
33+ title: ユーザ設定
2234
2335 simple_formn:
2436 placeholders:
@@ -129,4 +141,10 @@ ja:
129141 choose_license: ライセンス選択
130142 publish: 公開
131143 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: プロフィール