From 42125bd099650152ea9b8f2681e1e9fa842bd40b Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Fri, 6 Oct 2017 21:31:56 +0900 Subject: [PATCH 01/27] Add Social Login Features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add daemon.js fix facebook login button style github認証用gem追加 omniauthから取得したhashmapの取り扱いを修正 github認証処理を追加 * provider名に応じてusernameを自動生成 * userオブジェクトを取得できれば成功、ログイン * set_flash_messageも実行し、成功した旨のメッセージを設定する。ただしlayoutに設定されていないため表示されない 「ソーシャルログイン」表示にGitHub用ボタンを追加 メールアドレスの重複等によるGithubログイン失敗時のエラー表示を実装 GitHub認証と同様のエラー表示処理をFacebook認証に追加 SNS連携時、アイコンを自動取得する add omniauth-github to Gemfile --- .env.production.sample | 10 +++ Gemfile | 6 ++ Gemfile.lock | 30 ++++++++ .../auth/omniauth_callbacks_controller.rb | 51 ++++++++------ app/javascript/images/elephant-fren.png | Bin 34530 -> 413 bytes app/javascript/styles/application.scss | 1 + app/javascript/styles/mastodon/oauth.scss | 66 ++++++++++++++++++ app/models/user.rb | 20 +++++- app/views/about/_registration.html.haml | 27 +++---- app/views/auth/sessions/new.html.haml | 15 ++-- config/initializers/devise.rb | 3 + .../20170418133143_add_omniauth_to_users.rb | 6 ++ db/schema.rb | 3 + streaming/daemon.js | 2 + 14 files changed, 196 insertions(+), 44 deletions(-) create mode 100644 app/javascript/styles/mastodon/oauth.scss create mode 100644 db/migrate/20170418133143_add_omniauth_to_users.rb create mode 100644 streaming/daemon.js diff --git a/.env.production.sample b/.env.production.sample index ebb0788781d59a..5fb6acb965b1a1 100644 --- a/.env.production.sample +++ b/.env.production.sample @@ -229,3 +229,13 @@ STREAMING_CLUSTER_NUM=1 # http_proxy=http://gateway.local:8118 # Access control for hidden service. # ALLOW_ACCESS_TO_HIDDEN_SERVICE=true + +# Facebook +FACEBOOK_APP_ID=xxxxxxxx +FACEBOOK_APP_SECRET=xxxxxxxx +FACEBOOK_CALLBACK_URL=http://example.com/auth/auth/facebook/callback +FACEBOOK_PIXEL_ID=xxxxxxxx + +#GitHub +GITHUB_KEY=xxxxxxx +GITHUB_SECRET=xxxxxxxxxxxxxx diff --git a/Gemfile b/Gemfile index 7a6e1568d28c35..24e8dbf0b5da19 100644 --- a/Gemfile +++ b/Gemfile @@ -92,6 +92,12 @@ gem 'webpush' gem 'json-ld', '~> 2.2' gem 'rdf-normalize', '~> 0.3' +# Added by Kibousoft +gem 'omniauth-github' +gem 'omniauth-facebook' +gem 'react-rails-img' +gem 'json' + group :development, :test do gem 'fabrication', '~> 2.20' gem 'fuubar', '~> 2.2' diff --git a/Gemfile.lock b/Gemfile.lock index e1929a05c83069..117117721a24d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,6 +88,10 @@ GEM aws-sdk-kms (~> 1) aws-sigv4 (~> 1.0) aws-sigv4 (1.0.2) + babel-source (5.8.35) + babel-transpiler (0.7.0) + babel-source (>= 4.0, < 6) + execjs (~> 2.0) bcrypt (3.1.12) benchmark-ips (2.7.2) better_errors (2.4.0) @@ -205,6 +209,7 @@ GEM et-orbi (1.1.0) tzinfo excon (0.62.0) + execjs (2.7.0) fabrication (2.20.1) faker (1.8.7) i18n (>= 0.7) @@ -266,6 +271,7 @@ GEM domain_name (~> 0.5) http-form_data (2.1.0) http_accept_language (2.1.1) + httpauth (0.2.1) httplog (1.0.2) colorize (~> 0.8) rack (>= 1.0) @@ -356,6 +362,10 @@ GEM concurrent-ruby (~> 1.0.0) sidekiq (>= 3.5.0) statsd-ruby (~> 1.2.0) + oauth2 (0.6.1) + faraday (~> 0.7) + httpauth (~> 0.1) + multi_json (~> 1.3) oj (3.5.1) omniauth (1.8.1) hashie (>= 3.4.6, < 3.6.0) @@ -364,6 +374,14 @@ GEM addressable (~> 2.3) nokogiri (~> 1.5) omniauth (~> 1.2) + omniauth-facebook (1.4.0) + omniauth-oauth2 (~> 1.0.2) + omniauth-github (1.0.1) + omniauth (~> 1.0) + omniauth-oauth2 (~> 1.0) + omniauth-oauth2 (1.0.2) + oauth2 (~> 0.6.0) + omniauth (~> 1.0) omniauth-saml (1.10.0) omniauth (~> 1.3, >= 1.3.2) ruby-saml (~> 1.7) @@ -468,6 +486,14 @@ GEM link_header (~> 0.0, >= 0.0.8) rdf-normalize (0.3.3) rdf (>= 2.2, < 4.0) + react-rails (2.4.6) + babel-transpiler (>= 0.7.0) + connection_pool + execjs + railties (>= 3.2) + tilt + react-rails-img (0.1.6) + react-rails redis (4.0.1) redis-actionpack (5.0.2) actionpack (>= 4.0, < 6) @@ -691,6 +717,7 @@ DEPENDENCIES i18n-tasks (~> 0.9) idn-ruby iso-639 + json json-ld (~> 2.2) kaminari (~> 1.1) letter_opener (~> 1.4) @@ -707,6 +734,8 @@ DEPENDENCIES oj (~> 3.5) omniauth (~> 1.2) omniauth-cas (~> 1.1) + omniauth-facebook + omniauth-github omniauth-saml (~> 1.10) ostatus2 (~> 2.0) ox (~> 2.9) @@ -730,6 +759,7 @@ DEPENDENCIES rails-i18n (~> 5.1) rails-settings-cached (~> 0.6) rdf-normalize (~> 0.3) + react-rails-img redis (~> 4.0) redis-namespace (~> 1.5) redis-rails (~> 5.0) diff --git a/app/controllers/auth/omniauth_callbacks_controller.rb b/app/controllers/auth/omniauth_callbacks_controller.rb index bbf63bed304f9e..6372781cfd1751 100644 --- a/app/controllers/auth/omniauth_callbacks_controller.rb +++ b/app/controllers/auth/omniauth_callbacks_controller.rb @@ -1,33 +1,42 @@ # frozen_string_literal: true class Auth::OmniauthCallbacksController < Devise::OmniauthCallbacksController - skip_before_action :verify_authenticity_token + def facebook + # You need to implement the method below in your model (e.g. app/models/user.rb) + @user = User.from_omniauth(request.env["omniauth.auth"]) - def self.provides_callback_for(provider) - provider_id = provider.to_s.chomp '_oauth2' - - define_method provider do - @user = User.find_for_oauth(request.env['omniauth.auth'], current_user) + if @user.errors.any? + reason = @user.errors.full_messages.join(' / ') + set_flash_message(:alert, :failure, kind: "Facebook", reason: reason) + redirect_to new_user_session_path and return + end - if @user.persisted? - sign_in_and_redirect @user, event: :authentication - set_flash_message(:notice, :success, kind: provider_id.capitalize) if is_navigational_format? - else - session["devise.#{provider}_data"] = request.env['omniauth.auth'] - redirect_to new_user_registration_url - end + if @user.present? + p "Login Success" + sign_in @user + redirect_to root_path + set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format? + else + session["devise.facebook_data"] = request.env["omniauth.auth"] + redirect_to root_path end end - Devise.omniauth_configs.each_key do |provider| - provides_callback_for provider - end + def github + @user = User.from_omniauth(request.env["omniauth.auth"]) - def after_sign_in_path_for(resource) - if resource.email_verified? - root_path - else - finish_signup_path + if @user.present? + sign_in @user + set_flash_message(:notice, :success, :kind => "GitHub") if is_navigational_format? + redirect_to root_path and return end + + failure_reason = if @user.errors.any? @user.errors.full_messages.join(' / '); else nil end + set_flash_message(:notice, :failure, kind: "GitHub", reason: failure_reason) + redirect_to new_user_session_path + end + + def failure + redirect_to root_path end end diff --git a/app/javascript/images/elephant-fren.png b/app/javascript/images/elephant-fren.png index 38b1e3cba5a677da3cc109e3a149112b8d940b5f..40535007c530bed052bf4ea48f4163dfc000f465 100644 GIT binary patch literal 413 zcmeAS@N?(olHy`uVBq!ia0y~yVDtjAzi_Yt$-ndRw*V>50*}aI1_o|n5N2eUHAe!d z%HPw)F{EP7+k=LTKqZG3eD%-e^j`pEjsh}5phEg}05Iggm>7dJd%F6$taD0e0szB4 B7}x*+ literal 34530 zcmaHSbyQnlur*Q&#X|Ao?pj=n6bMk%dJp~mnq^-P{R8W)EF}iJ zG{oc&{qWvMR_ZIv+rOWj_Toh7Hy<2;TFx*qC|LhqurO&E_|PvAU8LnC5VsIfV5zxA z?4?X$V8V=~zly4QET3i~dL->9H=34togNWSS#h&&`bGN0hz1F3-N^?6B4InuG-3N0}#z=0A`fy;f{qe3kZh6;RBNg4@ zE&s*MZMr}@kwz|!)AIj(BP4AN=P8<*%L1aE{r0y3_-{!6vS_kg8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qU;jLrP zN@xbuLF*aGHj>6QZ>?9p0=f#AeZd7hLeCMM2*{e?rLrzV_eWQ=7_>CQX9VPIF~1QVY*4Xg*X9RcgO3fO4V9&>%Za z8&8PVQ*ExzTj?ah_;f?`w%QQA1lkH6x6|Z+U( t('simple_form.labels.defaults.username'), :autocomplete => 'off' } - .append - = "@#{site_hostname}" - - = f.input :email, placeholder: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email'), :autocomplete => 'off' } - = f.input :password, placeholder: t('simple_form.labels.defaults.password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.password'), :autocomplete => 'off' } - = f.input :password_confirmation, placeholder: t('simple_form.labels.defaults.confirm_password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_password'), :autocomplete => 'off' } - - .actions - = f.button :button, t('auth.register'), type: :submit, class: 'button button-primary' +.oauth-signup + %h3= t 'auth.register' + %div.login-buttons-box + %ul.login-button-list + %li + = link_to button_tag(t('activerecord.attributes.user.email'), class: "email-login-button"), new_user_registration_path + %li + = link_to button_tag("facebook", class: "facebook-login-button") , user_facebook_omniauth_authorize_path + %li + = link_to button_tag("github", class: "github-login-button") , user_github_omniauth_authorize_path + %p + 認証するだけで、自動で会員登録できます。 + %br + タイムラインに無断で投稿することはありません。 %p.hint.subtle-hint=t('auth.agreement_html', rules_path: about_more_path, terms_path: terms_path) diff --git a/app/views/auth/sessions/new.html.haml b/app/views/auth/sessions/new.html.haml index 0c9f9d5fe8fa9c..812ae8cb876435 100644 --- a/app/views/auth/sessions/new.html.haml +++ b/app/views/auth/sessions/new.html.haml @@ -14,13 +14,12 @@ .actions = f.button :button, t('auth.login'), type: :submit -- if devise_mapping.omniauthable? and resource_class.omniauth_providers.any? - .simple_form.alternative-login - %h4= t('auth.or_log_in_with') - - .actions - - resource_class.omniauth_providers.each do |provider| - = link_to omniauth_authorize_path(resource_name, provider), class: "button button-#{provider}" do - = t("auth.providers.#{provider}", default: provider.to_s.chomp("_oauth2").capitalize) +%div.oauth-signin + %h3= "ソーシャルログイン" + %ul.login-button-list + %li + = link_to button_tag("Log in with facebook", class: "facebook-login-button") , user_facebook_omniauth_authorize_path + %li + = link_to button_tag("Log in with github", class: "github-login-button") , user_github_omniauth_authorize_path .form-footer= render 'auth/shared/links' diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index e0d263f16f6cc1..cbd21f34922e65 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -315,6 +315,9 @@ def valid? # Add a new OmniAuth provider. Check the wiki for more information on setting # up on your models and hooks. # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' + config.omniauth :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'], + callback_url: ENV['FACEBOOK_CALLBACK_URL'] + config.omniauth :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: 'user:email' # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or diff --git a/db/migrate/20170418133143_add_omniauth_to_users.rb b/db/migrate/20170418133143_add_omniauth_to_users.rb new file mode 100644 index 00000000000000..63c42e443ab896 --- /dev/null +++ b/db/migrate/20170418133143_add_omniauth_to_users.rb @@ -0,0 +1,6 @@ +class AddOmniauthToUsers < ActiveRecord::Migration[5.0] + def change + add_column :users, :provider, :string + add_column :users, :uid, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 02032c54826b47..1b768c451a2004 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -458,6 +458,7 @@ t.bigint "account_id", null: false t.bigint "application_id" t.bigint "in_reply_to_account_id" + t.json "enquete" t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc } t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id" t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id" @@ -529,6 +530,8 @@ t.boolean "otp_required_for_login", default: false, null: false t.datetime "last_emailed_at" t.string "otp_backup_codes", array: true + t.string "provider" + t.string "uid" t.string "filtered_languages", default: [], null: false, array: true t.bigint "account_id", null: false t.boolean "disabled", default: false, null: false diff --git a/streaming/daemon.js b/streaming/daemon.js new file mode 100644 index 00000000000000..2a34d402ab76fc --- /dev/null +++ b/streaming/daemon.js @@ -0,0 +1,2 @@ +require('babel-register'); +require('./index.js'); From d80487eb87cd1336d426de4f1ffbe0bede9753e7 Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Sun, 18 Feb 2018 20:13:38 +0900 Subject: [PATCH 02/27] Add BBCode features --- Gemfile | 1 + Gemfile.lock | 3 + .../mastodon/features/emoji/emoji.js | 7 +- app/javascript/styles/application.scss | 1 + app/javascript/styles/mastodon/bbcode.scss | 102 ++++++++++++++++++ app/lib/formatter.rb | 92 +++++++++++++++- app/lib/sanitize_config.rb | 1 + 7 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 app/javascript/styles/mastodon/bbcode.scss diff --git a/Gemfile b/Gemfile index 24e8dbf0b5da19..e0c5032443cc15 100644 --- a/Gemfile +++ b/Gemfile @@ -93,6 +93,7 @@ gem 'json-ld', '~> 2.2' gem 'rdf-normalize', '~> 0.3' # Added by Kibousoft +gem 'ruby-bbcode' gem 'omniauth-github' gem 'omniauth-facebook' gem 'react-rails-img' diff --git a/Gemfile.lock b/Gemfile.lock index 117117721a24d9..bed454c834f14e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -549,6 +549,8 @@ GEM rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) + ruby-bbcode (2.0.2) + activesupport (>= 3.2.3) ruby-progressbar (1.9.0) ruby-saml (1.7.2) nokogiri (>= 1.5.10) @@ -767,6 +769,7 @@ DEPENDENCIES rspec-rails (~> 3.7) rspec-sidekiq (~> 3.0) rubocop (~> 0.55) + ruby-bbcode ruby-progressbar (~> 1.4) sanitize (~> 4.6) scss_lint (~> 0.57) diff --git a/app/javascript/mastodon/features/emoji/emoji.js b/app/javascript/mastodon/features/emoji/emoji.js index 0f005dd5040d13..64405511cbdd13 100644 --- a/app/javascript/mastodon/features/emoji/emoji.js +++ b/app/javascript/mastodon/features/emoji/emoji.js @@ -69,7 +69,12 @@ const emojify = (str, customEmojis = {}) => { return rtn + str; }; -export default emojify; +const emojify_bbcode = (str, customEmojis = {}) => [ + { re: / { const emojis = []; diff --git a/app/javascript/styles/application.scss b/app/javascript/styles/application.scss index 16def729347ab5..e155e3b57c8c7f 100644 --- a/app/javascript/styles/application.scss +++ b/app/javascript/styles/application.scss @@ -24,3 +24,4 @@ @import 'mastodon/rtl'; @import 'mastodon/accessibility'; @import 'mastodon/oauth'; +@import 'mastodon/bbcode'; diff --git a/app/javascript/styles/mastodon/bbcode.scss b/app/javascript/styles/mastodon/bbcode.scss new file mode 100644 index 00000000000000..0c5a98cf0bbd0a --- /dev/null +++ b/app/javascript/styles/mastodon/bbcode.scss @@ -0,0 +1,102 @@ +$bbcode1: $classic-highlight-color !default; +$bbcode2: lighten($black, 15%) !default; + +.faicon_FTL { + display: none; +} + +.bbcode { + &__pulse { + animation: pulse 1s ease-in-out infinite; + animation-direction: alternate; + } + + &__spin { + display: inline-block; + -webkit-animation: fa-spin 2s infinite linear; + animation: fa-spin 2s infinite linear; + } + + &__b { + font-family: 'kozuka-gothic-pro', sans-serif; + font-weight: 900; + } + + &__i { + font-family: 'kozuka-gothic-pro', sans-serif; + font-style: italic; + -moz-font-feature-settings: 'ital'; + -webkit-font-feature-settings: 'ital'; + font-feature-settings: 'ital'; + } + + &__flip-horizontal { + display: inline-block; + -webkit-transform: scale(-1, 1); + -ms-transform: scale(-1, 1); + transform: scale(-1, 1); + } + + &__flip-vertical { + display: inline-block; + -webkit-transform: scale(1, -1); + -ms-transform: scale(1, -1); + transform: scale(1, -1); + } + + @for $i from 2 through 5 { + &__large-#{$i}x { + font-size: #{$i}em; + + & .emojione { + width: #{18 * $i}px !important; + height: #{18 * $i}px !important; + } + } + } + + /* attr color is not supported!!! + &__color { + color: attr(data-bbcodecolor color); + } + */ + + &__faicon { + display: inline-block !important; + } + + &__quote { + padding: 10px 10px; + border-left: 5px solid $bbcode1; + } + + &__code { + display: block; + padding: 9px; + line-height: 1.42857143; + color: $white; + word-break: break-all; + word-wrap: break-word; + background-color: $bbcode2; + border: 1px solid $bbcode2; + border-radius: 4px; + overflow-x: scroll; + } + + &__u { + text-decoration: underline; + } + + &__s { + text-decoration: line-through; + } +} + +@keyframes pulse { + 0% { + opacity: 1; + } + 100% { + opacity: 0.5; + } +} diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index e1ab05cc0bf769..4d3ec114d3d968 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -24,6 +24,7 @@ def format(status, **options) unless status.local? html = reformat(raw_content) html = encode_custom_emojis(html, status.emojis) if options[:custom_emojify] + html = format_bbcode(html) return html.html_safe # rubocop:disable Rails/OutputSafety end @@ -36,12 +37,14 @@ def format(status, **options) html = encode_custom_emojis(html, status.emojis) if options[:custom_emojify] html = simple_format(html, {}, sanitize: false) html = html.delete("\n") + html = format_bbcode(html) html.html_safe # rubocop:disable Rails/OutputSafety end def reformat(html) - sanitize(html, Sanitize::Config::MASTODON_STRICT) + html = sanitize(html, Sanitize::Config::MASTODON_STRICT) + format_bbcode(html) end def plaintext(status) @@ -84,6 +87,7 @@ def linkify(text) html = encode_and_link_urls(text) html = simple_format(html, {}, sanitize: false) html = html.delete("\n") + html = format_bbcode(html) html.html_safe # rubocop:disable Rails/OutputSafety end @@ -241,4 +245,90 @@ def hashtag_html(tag) def mention_html(account) "@#{account.username}" end + + def format_bbcode(html) + begin + html = html.bbcode_to_html(false, { + :spin => { + :html_open => '', :html_close => '', + :description => 'Make text spin', + :example => 'This is [spin]spin[/spin].'}, + :pulse => { + :html_open => '', :html_close => '', + :description => 'Make text pulse', + :example => 'This is [pulse]pulse[/pulse].'}, + :b => { + :html_open => '', :html_close => '', + :description => 'Make text bold', + :example => 'This is [b]bold[/b].'}, + :i => { + :html_open => '', :html_close => '', + :description => 'Make text italic', + :example => 'This is [i]italic[/i].'}, + :flip => { + :html_open => '', :html_close => '', + :description => 'Flip text', + :example => '[flip=horizontal]This is flip[/flip]', + :allow_quick_param => true, :allow_between_as_param => false, + :quick_param_format => /(horizontal|vertical)/, + :quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', + :param_tokens => [{:token => :direction}]}, + :large => { + :html_open => '', :html_close => '', + :description => 'Large text', + :example => '[large=2x]Large text[/large]', + :allow_quick_param => true, :allow_between_as_param => false, + :quick_param_format => /(2x|3x|4x|5x)/, + :quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', + :param_tokens => [{:token => :size}]}, + :size => { + :html_open => '', :html_close => '', + :description => 'Change the size of the text', + :example => '[size=32]This is 32px[/size]', + :allow_quick_param => true, :allow_between_as_param => false, + :quick_param_format => /(\d+)/, + :quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', + :param_tokens => [{:token => :size}]}, + :color => { + :html_open => '', :html_close => '', + :description => 'Use color', + :example => '[color=red]This is red[/color]', + :allow_quick_param => true, :allow_between_as_param => false, + :quick_param_format => /([a-z]+)/i, + :param_tokens => [{:token => :color}]}, + :colorhex => { + :html_open => '', :html_close => '', + :description => 'Use color code', + :example => '[colorhex=ffffff]White text[/colorhex]', + :allow_quick_param => true, :allow_between_as_param => false, + :quick_param_format => /([0-9a-fA-F]{6})/, + :quick_param_format_description => 'The size parameter \'%param%\' is incorrect', + :param_tokens => [{:token => :colorcode}]}, + :faicon => { + :html_open => '%between%', :html_close => '', + :description => 'Use Font Awesome Icons', + :example => '[faicon]users[/faicon]', + :only_allow => [], + :require_between => true}, + :quote => { + :html_open => '
', :html_close => '
', + :description => 'Quote', + :example => 'This is [quote]quote[/quote].'}, + :code => { + :html_open => '
', :html_close => '
', + :description => 'Code', + :example => 'This is [code]Code[/code].'}, + :u => { + :html_open => '', :html_close => '', + :description => 'Under line', + :example => 'This is [u]Under line[/u].'}, + :s => { + :html_open => '', :html_close => '', + :description => 'line through', + :example => 'This is [s]line through[/s].'}, + }, :enable, :i, :b, :color, :quote, :code, :size, :u, :s, :spin, :pulse, :flip, :large, :colorhex, :faicon) + rescue Exception => e + end + html + end end diff --git a/app/lib/sanitize_config.rb b/app/lib/sanitize_config.rb index c2b4669245af23..89d2e2fae6a33b 100644 --- a/app/lib/sanitize_config.rb +++ b/app/lib/sanitize_config.rb @@ -14,6 +14,7 @@ module Config next true if e =~ /^(h|p|u|dt|e)-/ # microformats classes next true if e =~ /^(mention|hashtag)$/ # semantic classes next true if e =~ /^(ellipsis|invisible)$/ # link formatting classes + next true if e =~ /^bbcode__([a-z2-5\-]+)$/ # bbcode end node['class'] = class_list.join(' ') From b028ec3dc45c65714ed0cbe81d1c09aff82ae7fb Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Sun, 18 Feb 2018 20:22:01 +0900 Subject: [PATCH 03/27] Allow 4096 characters --- .../mastodon/features/compose/components/compose_form.js | 6 +++--- app/validators/status_length_validator.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js index 6eb01123e46da9..88095d54d9ef4a 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.js +++ b/app/javascript/mastodon/features/compose/components/compose_form.js @@ -80,7 +80,7 @@ export default class ComposeForm extends ImmutablePureComponent { const { is_submitting, is_uploading, anyMedia } = this.props; const fulltext = [this.props.spoiler_text, countableText(this.props.text)].join(''); - if (is_submitting || is_uploading || length(fulltext) > 500 || (fulltext.length !== 0 && fulltext.trim().length === 0 && !anyMedia)) { + if (is_submitting || is_uploading || length(fulltext) > 4096 || (fulltext.length !== 0 && fulltext.trim().length === 0 && !anyMedia)) { return; } @@ -156,7 +156,7 @@ export default class ComposeForm extends ImmutablePureComponent { const { intl, onPaste, showSearch, anyMedia } = this.props; const disabled = this.props.is_submitting; const text = [this.props.spoiler_text, countableText(this.props.text)].join(''); - const disabledButton = disabled || this.props.is_uploading || length(text) > 500 || (text.length !== 0 && text.trim().length === 0 && !anyMedia); + const disabledButton = disabled || this.props.is_uploading || length(text) > 4096 || (text.length !== 0 && text.trim().length === 0 && !anyMedia); let publishText = ''; if (this.props.privacy === 'private' || this.props.privacy === 'direct') { @@ -208,7 +208,7 @@ export default class ComposeForm extends ImmutablePureComponent { -
+
diff --git a/app/validators/status_length_validator.rb b/app/validators/status_length_validator.rb index ed5563f64f1d1b..5ed97de25a5a7b 100644 --- a/app/validators/status_length_validator.rb +++ b/app/validators/status_length_validator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class StatusLengthValidator < ActiveModel::Validator - MAX_CHARS = 500 + MAX_CHARS = 4096 def validate(status) return unless status.local? && !status.reblog? From 1f6427b549d468107584aa5eba67ceb07781391c Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Sun, 18 Feb 2018 20:24:23 +0900 Subject: [PATCH 04/27] Change github urls --- app/javascript/mastodon/features/getting_started/index.js | 2 +- .../mastodon/features/ui/components/onboarding_modal.js | 2 +- spec/views/about/show.html.haml_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/javascript/mastodon/features/getting_started/index.js b/app/javascript/mastodon/features/getting_started/index.js index 99642c911578b6..e5c78f4bc8523d 100644 --- a/app/javascript/mastodon/features/getting_started/index.js +++ b/app/javascript/mastodon/features/getting_started/index.js @@ -149,7 +149,7 @@ export default class GettingStarted extends ImmutablePureComponent { tootsuite/mastodon }} + values={{ github: kibousoft/mastodon }} />

diff --git a/app/javascript/mastodon/features/ui/components/onboarding_modal.js b/app/javascript/mastodon/features/ui/components/onboarding_modal.js index 9b713cf9ee5951..cecb2b5e57cf58 100644 --- a/app/javascript/mastodon/features/ui/components/onboarding_modal.js +++ b/app/javascript/mastodon/features/ui/components/onboarding_modal.js @@ -159,7 +159,7 @@ const PageSix = ({ admin, domain }) => {

{adminSection} -

GitHub }} />

+

GitHub }} />

}} />

diff --git a/spec/views/about/show.html.haml_spec.rb b/spec/views/about/show.html.haml_spec.rb index cbe5aa93b68923..540cab4509c52b 100644 --- a/spec/views/about/show.html.haml_spec.rb +++ b/spec/views/about/show.html.haml_spec.rb @@ -13,7 +13,7 @@ site_title: 'something', site_description: 'something', version_number: '1.0', - source_url: 'https://github.com/tootsuite/mastodon', + source_url: 'https://github.com/kibousoft/mastodon', open_registrations: false, thumbnail: nil, hero: nil, From 62c344da4ccbba870d924c70abf961e27be076a5 Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Sun, 18 Feb 2018 21:48:21 +0900 Subject: [PATCH 05/27] rm failed migrates --- ...604144747_add_foreign_keys_for_accounts.rb | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 db/migrate/20170604144747_add_foreign_keys_for_accounts.rb diff --git a/db/migrate/20170604144747_add_foreign_keys_for_accounts.rb b/db/migrate/20170604144747_add_foreign_keys_for_accounts.rb deleted file mode 100644 index 76a836ca08d17d..00000000000000 --- a/db/migrate/20170604144747_add_foreign_keys_for_accounts.rb +++ /dev/null @@ -1,41 +0,0 @@ -class AddForeignKeysForAccounts < ActiveRecord::Migration[5.1] - def change - add_foreign_key :statuses, :accounts, on_delete: :cascade - add_foreign_key :statuses, :accounts, column: :in_reply_to_account_id, on_delete: :nullify - add_foreign_key :statuses, :statuses, column: :in_reply_to_id, on_delete: :nullify - add_foreign_key :account_domain_blocks, :accounts, on_delete: :cascade - add_foreign_key :conversation_mutes, :accounts, on_delete: :cascade - add_foreign_key :conversation_mutes, :conversations, on_delete: :cascade - add_foreign_key :favourites, :accounts, on_delete: :cascade - add_foreign_key :favourites, :statuses, on_delete: :cascade - add_foreign_key :blocks, :accounts, on_delete: :cascade - add_foreign_key :blocks, :accounts, column: :target_account_id, on_delete: :cascade - add_foreign_key :follow_requests, :accounts, on_delete: :cascade - add_foreign_key :follow_requests, :accounts, column: :target_account_id, on_delete: :cascade - add_foreign_key :follows, :accounts, on_delete: :cascade - add_foreign_key :follows, :accounts, column: :target_account_id, on_delete: :cascade - add_foreign_key :mutes, :accounts, on_delete: :cascade - add_foreign_key :mutes, :accounts, column: :target_account_id, on_delete: :cascade - add_foreign_key :imports, :accounts, on_delete: :cascade - add_foreign_key :media_attachments, :accounts, on_delete: :nullify - add_foreign_key :media_attachments, :statuses, on_delete: :nullify - add_foreign_key :mentions, :accounts, on_delete: :cascade - add_foreign_key :mentions, :statuses, on_delete: :cascade - add_foreign_key :notifications, :accounts, on_delete: :cascade - add_foreign_key :notifications, :accounts, column: :from_account_id, on_delete: :cascade - add_foreign_key :preview_cards, :statuses, on_delete: :cascade - add_foreign_key :reports, :accounts, on_delete: :cascade - add_foreign_key :reports, :accounts, column: :target_account_id, on_delete: :cascade - add_foreign_key :reports, :accounts, column: :action_taken_by_account_id, on_delete: :nullify - add_foreign_key :statuses_tags, :statuses, on_delete: :cascade - add_foreign_key :statuses_tags, :tags, on_delete: :cascade - add_foreign_key :stream_entries, :accounts, on_delete: :cascade - add_foreign_key :subscriptions, :accounts, on_delete: :cascade - add_foreign_key :users, :accounts, on_delete: :cascade - add_foreign_key :web_settings, :users, on_delete: :cascade - add_foreign_key :oauth_access_grants, :users, column: :resource_owner_id, on_delete: :cascade - add_foreign_key :oauth_access_grants, :oauth_applications, column: :application_id, on_delete: :cascade - add_foreign_key :oauth_access_tokens, :users, column: :resource_owner_id, on_delete: :cascade - add_foreign_key :oauth_access_tokens, :oauth_applications, column: :application_id, on_delete: :cascade - end -end From 988cb5a9948c0e4cc458b36aadcac6d5704e3c79 Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Sun, 18 Feb 2018 22:09:04 +0900 Subject: [PATCH 06/27] add omniauth methods --- app/models/user.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 7b0a35b8b72f71..379f3c83fd7a07 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -346,6 +346,35 @@ def needs_feed_update? last_sign_in_at < ACTIVE_DURATION.ago end + def self.from_omniauth(auth) + uid = auth['uid'] + provider = auth['provider'] + email = auth['info']['email'] || '' + avator_url = auth['info']['image'] || '' + + username = omniauth_username provider, uid + display_name = auth['info']['name'] || auth['info']['nickname'] || username + + user = find_or_create_by(provider: provider, uid: uid) do |user| + password = Devise.friendly_token[0,20] + user.email = email + user.password = password + user.password_confirmation = password + user.skip_confirmation! + user.create_account(username: username, display_name: display_name) + user.account.avatar_remote_url = avator_url if avator_url + end + user + end + + def self.new_with_session(params, session) + super.tap do |user| + if data = session["devise.facebook_data"] && session["devise.facebook_data"]["extra"]["raw_info"] + user.email = data["email"] if user.email.blank? + end + end + end + private_class_method def self.omniauth_username(provider, uid) From 16e74aab416a6a2f35fcccded6bec73f33b3ccb9 Mon Sep 17 00:00:00 2001 From: imbsky Date: Sat, 31 Mar 2018 19:32:25 +0900 Subject: [PATCH 07/27] Fix bbcode (#28) --- .../mastodon/features/emoji/emoji.js | 7 +- app/javascript/styles/mastodon/bbcode.scss | 78 +++++-------------- app/lib/formatter.rb | 39 +--------- app/lib/sanitize_config.rb | 6 +- 4 files changed, 31 insertions(+), 99 deletions(-) diff --git a/app/javascript/mastodon/features/emoji/emoji.js b/app/javascript/mastodon/features/emoji/emoji.js index 64405511cbdd13..0f005dd5040d13 100644 --- a/app/javascript/mastodon/features/emoji/emoji.js +++ b/app/javascript/mastodon/features/emoji/emoji.js @@ -69,12 +69,7 @@ const emojify = (str, customEmojis = {}) => { return rtn + str; }; -const emojify_bbcode = (str, customEmojis = {}) => [ - { re: / { const emojis = []; diff --git a/app/javascript/styles/mastodon/bbcode.scss b/app/javascript/styles/mastodon/bbcode.scss index 0c5a98cf0bbd0a..aa6a9332d1e8da 100644 --- a/app/javascript/styles/mastodon/bbcode.scss +++ b/app/javascript/styles/mastodon/bbcode.scss @@ -29,67 +29,31 @@ $bbcode2: lighten($black, 15%) !default; -webkit-font-feature-settings: 'ital'; font-feature-settings: 'ital'; } +} - &__flip-horizontal { - display: inline-block; - -webkit-transform: scale(-1, 1); - -ms-transform: scale(-1, 1); - transform: scale(-1, 1); - } - - &__flip-vertical { - display: inline-block; - -webkit-transform: scale(1, -1); - -ms-transform: scale(1, -1); - transform: scale(1, -1); - } - - @for $i from 2 through 5 { - &__large-#{$i}x { - font-size: #{$i}em; - - & .emojione { - width: #{18 * $i}px !important; - height: #{18 * $i}px !important; - } - } - } - - /* attr color is not supported!!! - &__color { - color: attr(data-bbcodecolor color); - } - */ - - &__faicon { - display: inline-block !important; - } - - &__quote { - padding: 10px 10px; - border-left: 5px solid $bbcode1; - } - - &__code { - display: block; - padding: 9px; - line-height: 1.42857143; - color: $white; - word-break: break-all; - word-wrap: break-word; - background-color: $bbcode2; - border: 1px solid $bbcode2; - border-radius: 4px; - overflow-x: scroll; +@for $i from 2 through 5 { + .fa-#{$i}x .emojione { + width: #{18 * $i}px !important; + height: #{18 * $i}px !important; } +} - &__u { - text-decoration: underline; - } +div.quote { + padding: 10px 10px; + border-left: 5px solid $bbcode1; +} - &__s { - text-decoration: line-through; - } +pre { + display: block; + padding: 9px; + line-height: 1.42857143; + color: $white; + word-break: break-all; + word-wrap: break-word; + background-color: $bbcode2; + border: 1px solid $bbcode2; + border-radius: 4px; + overflow-x: scroll; } @keyframes pulse { diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 4d3ec114d3d968..f9af1f93865174 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -266,7 +266,7 @@ def format_bbcode(html) :description => 'Make text italic', :example => 'This is [i]italic[/i].'}, :flip => { - :html_open => '', :html_close => '', + :html_open => '', :html_close => '', :description => 'Flip text', :example => '[flip=horizontal]This is flip[/flip]', :allow_quick_param => true, :allow_between_as_param => false, @@ -274,30 +274,15 @@ def format_bbcode(html) :quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', :param_tokens => [{:token => :direction}]}, :large => { - :html_open => '', :html_close => '', + :html_open => '', :html_close => '', :description => 'Large text', :example => '[large=2x]Large text[/large]', :allow_quick_param => true, :allow_between_as_param => false, :quick_param_format => /(2x|3x|4x|5x)/, :quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', :param_tokens => [{:token => :size}]}, - :size => { - :html_open => '', :html_close => '', - :description => 'Change the size of the text', - :example => '[size=32]This is 32px[/size]', - :allow_quick_param => true, :allow_between_as_param => false, - :quick_param_format => /(\d+)/, - :quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', - :param_tokens => [{:token => :size}]}, - :color => { - :html_open => '', :html_close => '', - :description => 'Use color', - :example => '[color=red]This is red[/color]', - :allow_quick_param => true, :allow_between_as_param => false, - :quick_param_format => /([a-z]+)/i, - :param_tokens => [{:token => :color}]}, :colorhex => { - :html_open => '', :html_close => '', + :html_open => '', :html_close => '', :description => 'Use color code', :example => '[colorhex=ffffff]White text[/colorhex]', :allow_quick_param => true, :allow_between_as_param => false, @@ -305,27 +290,11 @@ def format_bbcode(html) :quick_param_format_description => 'The size parameter \'%param%\' is incorrect', :param_tokens => [{:token => :colorcode}]}, :faicon => { - :html_open => '%between%', :html_close => '', + :html_open => '%between%', :html_close => '', :description => 'Use Font Awesome Icons', :example => '[faicon]users[/faicon]', :only_allow => [], :require_between => true}, - :quote => { - :html_open => '
', :html_close => '
', - :description => 'Quote', - :example => 'This is [quote]quote[/quote].'}, - :code => { - :html_open => '
', :html_close => '
', - :description => 'Code', - :example => 'This is [code]Code[/code].'}, - :u => { - :html_open => '', :html_close => '', - :description => 'Under line', - :example => 'This is [u]Under line[/u].'}, - :s => { - :html_open => '', :html_close => '', - :description => 'line through', - :example => 'This is [s]line through[/s].'}, }, :enable, :i, :b, :color, :quote, :code, :size, :u, :s, :spin, :pulse, :flip, :large, :colorhex, :faicon) rescue Exception => e end diff --git a/app/lib/sanitize_config.rb b/app/lib/sanitize_config.rb index 89d2e2fae6a33b..0268527ecfd7ad 100644 --- a/app/lib/sanitize_config.rb +++ b/app/lib/sanitize_config.rb @@ -14,7 +14,11 @@ module Config next true if e =~ /^(h|p|u|dt|e)-/ # microformats classes next true if e =~ /^(mention|hashtag)$/ # semantic classes next true if e =~ /^(ellipsis|invisible)$/ # link formatting classes - next true if e =~ /^bbcode__([a-z2-5\-]+)$/ # bbcode + next true if e =~ /^fa$/ # font awesome + next true if e =~ /^fa-flip-(horizontal|vertical)$/ # font awesome + next true if e =~ /^fa-(2x|3x|4x|5x)$/ # font awesome + next true if e =~ /^bbcode__(spin|pulse|b|i)$/ # bbcode + next true if e =~ /^faicon_FTL$/ # bbcode end node['class'] = class_list.join(' ') From 51bd7733f39322ab89ff86240b24c0f6c60332c6 Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 17:05:17 +0900 Subject: [PATCH 08/27] Add ICO Models --- app/models/ico_event.rb | 16 +++++++++++ app/models/ico_request.rb | 17 +++++++++++ app/models/ico_token.rb | 13 +++++++++ app/models/status.rb | 1 + app/models/user.rb | 2 ++ .../20180514075904_create_ico_tokens.rb | 10 +++++++ .../20180514080029_create_ico_events.rb | 13 +++++++++ .../20180514080302_create_ico_requests.rb | 14 ++++++++++ db/schema.rb | 28 +++++++++++++++++++ spec/fabricators/ico_event_fabricator.rb | 6 ++++ spec/fabricators/ico_request_fabricator.rb | 8 ++++++ spec/fabricators/ico_token_fabricator.rb | 4 +++ spec/models/ico_event_spec.rb | 5 ++++ spec/models/ico_request_spec.rb | 5 ++++ spec/models/ico_token_spec.rb | 5 ++++ 15 files changed, 147 insertions(+) create mode 100644 app/models/ico_event.rb create mode 100644 app/models/ico_request.rb create mode 100644 app/models/ico_token.rb create mode 100644 db/migrate/20180514075904_create_ico_tokens.rb create mode 100644 db/migrate/20180514080029_create_ico_events.rb create mode 100644 db/migrate/20180514080302_create_ico_requests.rb create mode 100644 spec/fabricators/ico_event_fabricator.rb create mode 100644 spec/fabricators/ico_request_fabricator.rb create mode 100644 spec/fabricators/ico_token_fabricator.rb create mode 100644 spec/models/ico_event_spec.rb create mode 100644 spec/models/ico_request_spec.rb create mode 100644 spec/models/ico_token_spec.rb diff --git a/app/models/ico_event.rb b/app/models/ico_event.rb new file mode 100644 index 00000000000000..e44e531a5ed676 --- /dev/null +++ b/app/models/ico_event.rb @@ -0,0 +1,16 @@ +# == Schema Information +# +# Table name: ico_events +# +# id :bigint(8) not null, primary key +# ico_token_id :integer +# begin_at :datetime +# end_at :datetime +# sale_limit :float +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# + +class IcoEvent < ApplicationRecord +end diff --git a/app/models/ico_request.rb b/app/models/ico_request.rb new file mode 100644 index 00000000000000..cb1f3e412eaab7 --- /dev/null +++ b/app/models/ico_request.rb @@ -0,0 +1,17 @@ +# == Schema Information +# +# Table name: ico_requests +# +# id :bigint(8) not null, primary key +# user_id :integer +# ico_event_id :integer +# amount :float +# email :string +# eth_wallet_address :string +# token_wallet_address :string +# created_at :datetime not null +# updated_at :datetime not null +# + +class IcoRequest < ApplicationRecord +end diff --git a/app/models/ico_token.rb b/app/models/ico_token.rb new file mode 100644 index 00000000000000..177ab1a2cbdd61 --- /dev/null +++ b/app/models/ico_token.rb @@ -0,0 +1,13 @@ +# == Schema Information +# +# Table name: ico_tokens +# +# id :bigint(8) not null, primary key +# name :string +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# + +class IcoToken < ApplicationRecord +end diff --git a/app/models/status.rb b/app/models/status.rb index e7dd0df29e0d66..0bb48e9bdf0226 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -23,6 +23,7 @@ # account_id :bigint(8) not null # application_id :bigint(8) # in_reply_to_account_id :bigint(8) +# enquete :json # class Status < ApplicationRecord diff --git a/app/models/user.rb b/app/models/user.rb index 379f3c83fd7a07..bd612bedf8bfff 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -29,6 +29,8 @@ # otp_required_for_login :boolean default(FALSE), not null # last_emailed_at :datetime # otp_backup_codes :string is an Array +# provider :string +# uid :string # filtered_languages :string default([]), not null, is an Array # account_id :bigint(8) not null # disabled :boolean default(FALSE), not null diff --git a/db/migrate/20180514075904_create_ico_tokens.rb b/db/migrate/20180514075904_create_ico_tokens.rb new file mode 100644 index 00000000000000..33923b8b384ce4 --- /dev/null +++ b/db/migrate/20180514075904_create_ico_tokens.rb @@ -0,0 +1,10 @@ +class CreateIcoTokens < ActiveRecord::Migration[5.1] + def change + create_table :ico_tokens do |t| + t.string :name + t.string :url + + t.timestamps + end + end +end diff --git a/db/migrate/20180514080029_create_ico_events.rb b/db/migrate/20180514080029_create_ico_events.rb new file mode 100644 index 00000000000000..fbbce621e5cee2 --- /dev/null +++ b/db/migrate/20180514080029_create_ico_events.rb @@ -0,0 +1,13 @@ +class CreateIcoEvents < ActiveRecord::Migration[5.1] + def change + create_table :ico_events do |t| + t.integer :ico_token_id + t.datetime :begin_at + t.datetime :end_at + t.float :sale_limit + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20180514080302_create_ico_requests.rb b/db/migrate/20180514080302_create_ico_requests.rb new file mode 100644 index 00000000000000..564dd8ce13fe0e --- /dev/null +++ b/db/migrate/20180514080302_create_ico_requests.rb @@ -0,0 +1,14 @@ +class CreateIcoRequests < ActiveRecord::Migration[5.1] + def change + create_table :ico_requests do |t| + t.integer :user_id + t.integer :ico_event_id + t.float :amount + t.string :email + t.string :eth_wallet_address + t.string :token_wallet_address + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1b768c451a2004..0dc6771cc296c6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -201,6 +201,34 @@ t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true end + create_table "ico_events", force: :cascade do |t| + t.integer "ico_token_id" + t.datetime "begin_at" + t.datetime "end_at" + t.float "sale_limit" + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "ico_requests", force: :cascade do |t| + t.integer "user_id" + t.integer "ico_event_id" + t.float "amount" + t.string "email" + t.string "eth_wallet_address" + t.string "token_wallet_address" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "ico_tokens", force: :cascade do |t| + t.string "name" + t.string "url" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "identities", id: :serial, force: :cascade do |t| t.integer "user_id" t.string "provider", default: "", null: false diff --git a/spec/fabricators/ico_event_fabricator.rb b/spec/fabricators/ico_event_fabricator.rb new file mode 100644 index 00000000000000..9197518a4d5980 --- /dev/null +++ b/spec/fabricators/ico_event_fabricator.rb @@ -0,0 +1,6 @@ +Fabricator(:ico_event) do + ico_token_id 1 + begin_at "2018-05-14 17:00:29" + end_at "2018-05-14 17:00:29" + name "MyString" +end diff --git a/spec/fabricators/ico_request_fabricator.rb b/spec/fabricators/ico_request_fabricator.rb new file mode 100644 index 00000000000000..6fc89eade14b8e --- /dev/null +++ b/spec/fabricators/ico_request_fabricator.rb @@ -0,0 +1,8 @@ +Fabricator(:ico_request) do + user_id 1 + ico_event_id 1 + amount 1.5 + email "MyString" + eth_wallet_address "MyString" + token_wallet_address "MyString" +end diff --git a/spec/fabricators/ico_token_fabricator.rb b/spec/fabricators/ico_token_fabricator.rb new file mode 100644 index 00000000000000..748b1afde30ef2 --- /dev/null +++ b/spec/fabricators/ico_token_fabricator.rb @@ -0,0 +1,4 @@ +Fabricator(:ico_token) do + name "MyString" + url "MyString" +end diff --git a/spec/models/ico_event_spec.rb b/spec/models/ico_event_spec.rb new file mode 100644 index 00000000000000..ee1b039161c46a --- /dev/null +++ b/spec/models/ico_event_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe IcoEvent, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/ico_request_spec.rb b/spec/models/ico_request_spec.rb new file mode 100644 index 00000000000000..953ddc68e5c031 --- /dev/null +++ b/spec/models/ico_request_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe IcoRequest, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/ico_token_spec.rb b/spec/models/ico_token_spec.rb new file mode 100644 index 00000000000000..bbe7af801f01c9 --- /dev/null +++ b/spec/models/ico_token_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe IcoToken, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From a7fb0d1ab8638527c3ef9f0fd6cfd5c31f8a3f36 Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 17:15:43 +0900 Subject: [PATCH 09/27] Add bootstrap --- Gemfile | 3 +++ Gemfile.lock | 25 +++++++++++++++++++ app/assets/javascripts/application.js | 10 ++++++++ app/assets/javascripts/bootstrap.js | 4 +++ app/assets/stylesheets/application.css | 7 ++++++ .../stylesheets/bootstrap_and_overrides.css | 6 +++++ config/locales/en.bootstrap.yml | 23 +++++++++++++++++ 7 files changed, 78 insertions(+) create mode 100644 app/assets/javascripts/application.js create mode 100644 app/assets/javascripts/bootstrap.js create mode 100644 app/assets/stylesheets/application.css create mode 100644 app/assets/stylesheets/bootstrap_and_overrides.css create mode 100644 config/locales/en.bootstrap.yml diff --git a/Gemfile b/Gemfile index e0c5032443cc15..97fe017060fcdf 100644 --- a/Gemfile +++ b/Gemfile @@ -98,6 +98,9 @@ gem 'omniauth-github' gem 'omniauth-facebook' gem 'react-rails-img' gem 'json' +gem 'twitter-bootstrap-rails' +gem 'therubyracer' +gem 'jquery-rails' group :development, :test do gem 'fabrication', '~> 2.20' diff --git a/Gemfile.lock b/Gemfile.lock index bed454c834f14e..fb87feb058c430 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -150,6 +150,7 @@ GEM climate_control (>= 0.0.3, < 1.0) coderay (1.1.2) colorize (0.8.1) + commonjs (0.2.7) concurrent-ruby (1.0.5) connection_pool (2.2.1) crack (0.4.3) @@ -291,6 +292,10 @@ GEM ipaddress (0.8.3) iso-639 (0.2.8) jmespath (1.4.0) + jquery-rails (4.3.3) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) json (2.1.0) json-ld (2.2.1) multi_json (~> 1.12) @@ -311,12 +316,20 @@ GEM kaminari-core (1.1.1) launchy (2.4.3) addressable (~> 2.3) + less (2.6.0) + commonjs (~> 0.2.7) + less-rails (2.8.0) + actionpack (>= 4.0) + less (~> 2.6.0) + sprockets (> 2, < 4) + tilt letter_opener (1.6.0) launchy (~> 2.2) letter_opener_web (1.3.4) actionmailer (>= 3.2) letter_opener (~> 1.0) railties (>= 3.2) + libv8 (3.16.14.19) link_header (0.0.8) lograge (0.10.0) actionpack (>= 4) @@ -513,6 +526,7 @@ GEM redis-store (>= 1.2, < 2) redis-store (1.5.0) redis (>= 2.2, < 5) + ref (2.0.0) request_store (1.4.1) rack (>= 1.4) responders (2.4.0) @@ -617,6 +631,9 @@ GEM unicode-display_width (~> 1.1, >= 1.1.1) terrapin (0.6.0) climate_control (>= 0.0.3, < 1.0) + therubyracer (0.12.3) + libv8 (~> 3.16.14.15) + ref thor (0.20.0) thread (0.2.2) thread_safe (0.3.6) @@ -638,6 +655,11 @@ GEM tty-screen (~> 0.6.4) wisper (~> 2.0.0) tty-screen (0.6.4) + twitter-bootstrap-rails (4.0.0) + actionpack (~> 5.0, >= 5.0.1) + execjs (~> 2.7) + less-rails (~> 2.8, >= 2.8.0) + railties (~> 5.0, >= 5.0.1) twitter-text (1.14.7) unf (~> 0.1.0) tzinfo (1.2.5) @@ -719,6 +741,7 @@ DEPENDENCIES i18n-tasks (~> 0.9) idn-ruby iso-639 + jquery-rails json json-ld (~> 2.2) kaminari (~> 1.1) @@ -785,8 +808,10 @@ DEPENDENCIES stoplight (~> 2.1.3) streamio-ffmpeg (~> 3.0) strong_migrations (~> 0.2) + therubyracer tty-command (~> 0.8) tty-prompt (~> 0.16) + twitter-bootstrap-rails twitter-text (~> 1.14) tzinfo-data (~> 1.2018) webmock (~> 3.3) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 00000000000000..1732ea338140ad --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,10 @@ +// This is a manifest file that'll be compiled into including all the files listed below. +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +// be included in the compiled file accessible from http://example.com/assets/application.js +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +//= require jquery +//= require jquery_ujs +//= require twitter/bootstrap +//= require_tree . diff --git a/app/assets/javascripts/bootstrap.js b/app/assets/javascripts/bootstrap.js new file mode 100644 index 00000000000000..1c4a1f79411baf --- /dev/null +++ b/app/assets/javascripts/bootstrap.js @@ -0,0 +1,4 @@ +jQuery(function() { + $("a[rel~=popover], .has-popover").popover(); + $("a[rel~=tooltip], .has-tooltip").tooltip(); +}); diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 00000000000000..db803ee40a4ba6 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,7 @@ +/* + * This is a manifest file that'll automatically include all the stylesheets available in this directory + * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at + * the top of the compiled file, but it's generally better to create a new file per style scope. + *= require_self + *= require_tree . +*/ diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css b/app/assets/stylesheets/bootstrap_and_overrides.css new file mode 100644 index 00000000000000..5b887c7b5eace2 --- /dev/null +++ b/app/assets/stylesheets/bootstrap_and_overrides.css @@ -0,0 +1,6 @@ +/* + =require twitter-bootstrap-static/bootstrap + + Static version of css will use Glyphicons sprites by default + =require twitter-bootstrap-static/sprites +*/ \ No newline at end of file diff --git a/config/locales/en.bootstrap.yml b/config/locales/en.bootstrap.yml new file mode 100644 index 00000000000000..8d7511904c1655 --- /dev/null +++ b/config/locales/en.bootstrap.yml @@ -0,0 +1,23 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + breadcrumbs: + application: + root: "Index" + pages: + pages: "Pages" + helpers: + actions: "Actions" + links: + back: "Back" + cancel: "Cancel" + confirm: "Are you sure?" + destroy: "Delete" + new: "New" + edit: "Edit" + titles: + edit: "Edit %{model}" + save: "Save %{model}" + new: "New %{model}" + delete: "Delete %{model}" From fd939b8537765e484b858b9a523d3c5b04619064 Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 17:33:50 +0900 Subject: [PATCH 10/27] Add IcoRequest Scaffold Controller --- app/controllers/ico_requests_controller.rb | 58 +++++++ app/helpers/ico_requests_helper.rb | 2 + app/views/ico_requests/_form.html.haml | 11 ++ app/views/ico_requests/edit.html.haml | 7 + app/views/ico_requests/index.html.haml | 27 ++++ app/views/ico_requests/new.html.haml | 5 + app/views/ico_requests/show.html.haml | 18 +++ config/routes.rb | 3 + .../ico_requests_controller_spec.rb | 141 ++++++++++++++++++ spec/helpers/ico_requests_helper_spec.rb | 15 ++ spec/requests/ico_requests_spec.rb | 10 ++ spec/routing/ico_requests_routing_spec.rb | 39 +++++ .../views/ico_requests/edit.html.haml_spec.rb | 27 ++++ .../ico_requests/index.html.haml_spec.rb | 28 ++++ spec/views/ico_requests/new.html.haml_spec.rb | 27 ++++ .../views/ico_requests/show.html.haml_spec.rb | 20 +++ 16 files changed, 438 insertions(+) create mode 100644 app/controllers/ico_requests_controller.rb create mode 100644 app/helpers/ico_requests_helper.rb create mode 100644 app/views/ico_requests/_form.html.haml create mode 100644 app/views/ico_requests/edit.html.haml create mode 100644 app/views/ico_requests/index.html.haml create mode 100644 app/views/ico_requests/new.html.haml create mode 100644 app/views/ico_requests/show.html.haml create mode 100644 spec/controllers/ico_requests_controller_spec.rb create mode 100644 spec/helpers/ico_requests_helper_spec.rb create mode 100644 spec/requests/ico_requests_spec.rb create mode 100644 spec/routing/ico_requests_routing_spec.rb create mode 100644 spec/views/ico_requests/edit.html.haml_spec.rb create mode 100644 spec/views/ico_requests/index.html.haml_spec.rb create mode 100644 spec/views/ico_requests/new.html.haml_spec.rb create mode 100644 spec/views/ico_requests/show.html.haml_spec.rb diff --git a/app/controllers/ico_requests_controller.rb b/app/controllers/ico_requests_controller.rb new file mode 100644 index 00000000000000..1ceabdca371f6f --- /dev/null +++ b/app/controllers/ico_requests_controller.rb @@ -0,0 +1,58 @@ +class IcoRequestsController < ApplicationController + before_action :set_ico_request, only: [:show, :edit, :update, :destroy] + + # GET /ico_requests + def index + @ico_requests = IcoRequest.all + end + + # GET /ico_requests/1 + def show + end + + # GET /ico_requests/new + def new + @ico_request = IcoRequest.new + end + + # GET /ico_requests/1/edit + def edit + end + + # POST /ico_requests + def create + @ico_request = IcoRequest.new(ico_request_params) + + if @ico_request.save + redirect_to @ico_request, notice: 'Ico request was successfully created.' + else + render :new + end + end + + # PATCH/PUT /ico_requests/1 + def update + if @ico_request.update(ico_request_params) + redirect_to @ico_request, notice: 'Ico request was successfully updated.' + else + render :edit + end + end + + # DELETE /ico_requests/1 + def destroy + @ico_request.destroy + redirect_to ico_requests_url, notice: 'Ico request was successfully destroyed.' + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_ico_request + @ico_request = IcoRequest.find(params[:id]) + end + + # Only allow a trusted parameter "white list" through. + def ico_request_params + params.require(:ico_request).permit(:amount, :email, :eth_wallet_address, :token_wallet_address) + end +end diff --git a/app/helpers/ico_requests_helper.rb b/app/helpers/ico_requests_helper.rb new file mode 100644 index 00000000000000..69bf533e1a29ac --- /dev/null +++ b/app/helpers/ico_requests_helper.rb @@ -0,0 +1,2 @@ +module IcoRequestsHelper +end diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml new file mode 100644 index 00000000000000..59640cac14e89b --- /dev/null +++ b/app/views/ico_requests/_form.html.haml @@ -0,0 +1,11 @@ += simple_form_for(@ico_request) do |f| + = f.error_notification + + .form-inputs + = f.input :amount + = f.input :email + = f.input :eth_wallet_address + = f.input :token_wallet_address + + .form-actions + = f.button :submit diff --git a/app/views/ico_requests/edit.html.haml b/app/views/ico_requests/edit.html.haml new file mode 100644 index 00000000000000..ec4f7f367b4056 --- /dev/null +++ b/app/views/ico_requests/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing ico_request + += render 'form' + += link_to 'Show', @ico_request +\| += link_to 'Back', ico_requests_path diff --git a/app/views/ico_requests/index.html.haml b/app/views/ico_requests/index.html.haml new file mode 100644 index 00000000000000..6daf020bb8a6ad --- /dev/null +++ b/app/views/ico_requests/index.html.haml @@ -0,0 +1,27 @@ +%h1 Listing ico_requests + +%table + %thead + %tr + %th Amount + %th Email + %th Eth wallet address + %th Token wallet address + %th + %th + %th + + %tbody + - @ico_requests.each do |ico_request| + %tr + %td= ico_request.amount + %td= ico_request.email + %td= ico_request.eth_wallet_address + %td= ico_request.token_wallet_address + %td= link_to 'Show', ico_request + %td= link_to 'Edit', edit_ico_request_path(ico_request) + %td= link_to 'Destroy', ico_request, :method => :delete, :data => { :confirm => 'Are you sure?' } + +%br + += link_to 'New Ico request', new_ico_request_path diff --git a/app/views/ico_requests/new.html.haml b/app/views/ico_requests/new.html.haml new file mode 100644 index 00000000000000..37ff141f256538 --- /dev/null +++ b/app/views/ico_requests/new.html.haml @@ -0,0 +1,5 @@ +%h1 New ico_request + += render 'form' + += link_to 'Back', ico_requests_path diff --git a/app/views/ico_requests/show.html.haml b/app/views/ico_requests/show.html.haml new file mode 100644 index 00000000000000..d5718e2b5d3d43 --- /dev/null +++ b/app/views/ico_requests/show.html.haml @@ -0,0 +1,18 @@ +%p#notice= notice + +%p + %b Amount: + = @ico_request.amount +%p + %b Email: + = @ico_request.email +%p + %b Eth wallet address: + = @ico_request.eth_wallet_address +%p + %b Token wallet address: + = @ico_request.token_wallet_address + += link_to 'Edit', edit_ico_request_path(@ico_request) +\| += link_to 'Back', ico_requests_path diff --git a/config/routes.rb b/config/routes.rb index fd26b4aa74cac3..259b629df42920 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,6 +74,9 @@ get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status + # ICO Request + resource :ico_requests, only: [:new, :create] + namespace :settings do resource :profile, only: [:show, :update] resource :preferences, only: [:show, :update] diff --git a/spec/controllers/ico_requests_controller_spec.rb b/spec/controllers/ico_requests_controller_spec.rb new file mode 100644 index 00000000000000..9cf815dc28301f --- /dev/null +++ b/spec/controllers/ico_requests_controller_spec.rb @@ -0,0 +1,141 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. +# +# Also compared to earlier versions of this generator, there are no longer any +# expectations of assigns and templates rendered. These features have been +# removed from Rails core in Rails 5, but can be added back in via the +# `rails-controller-testing` gem. + +RSpec.describe IcoRequestsController, type: :controller do + + # This should return the minimal set of attributes required to create a valid + # IcoRequest. As you add validations to IcoRequest, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # IcoRequestsController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET #index" do + it "returns a success response" do + ico_request = IcoRequest.create! valid_attributes + get :index, params: {}, session: valid_session + expect(response).to be_success + end + end + + describe "GET #show" do + it "returns a success response" do + ico_request = IcoRequest.create! valid_attributes + get :show, params: {id: ico_request.to_param}, session: valid_session + expect(response).to be_success + end + end + + describe "GET #new" do + it "returns a success response" do + get :new, params: {}, session: valid_session + expect(response).to be_success + end + end + + describe "GET #edit" do + it "returns a success response" do + ico_request = IcoRequest.create! valid_attributes + get :edit, params: {id: ico_request.to_param}, session: valid_session + expect(response).to be_success + end + end + + describe "POST #create" do + context "with valid params" do + it "creates a new IcoRequest" do + expect { + post :create, params: {ico_request: valid_attributes}, session: valid_session + }.to change(IcoRequest, :count).by(1) + end + + it "redirects to the created ico_request" do + post :create, params: {ico_request: valid_attributes}, session: valid_session + expect(response).to redirect_to(IcoRequest.last) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'new' template)" do + post :create, params: {ico_request: invalid_attributes}, session: valid_session + expect(response).to be_success + end + end + end + + describe "PUT #update" do + context "with valid params" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested ico_request" do + ico_request = IcoRequest.create! valid_attributes + put :update, params: {id: ico_request.to_param, ico_request: new_attributes}, session: valid_session + ico_request.reload + skip("Add assertions for updated state") + end + + it "redirects to the ico_request" do + ico_request = IcoRequest.create! valid_attributes + put :update, params: {id: ico_request.to_param, ico_request: valid_attributes}, session: valid_session + expect(response).to redirect_to(ico_request) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'edit' template)" do + ico_request = IcoRequest.create! valid_attributes + put :update, params: {id: ico_request.to_param, ico_request: invalid_attributes}, session: valid_session + expect(response).to be_success + end + end + end + + describe "DELETE #destroy" do + it "destroys the requested ico_request" do + ico_request = IcoRequest.create! valid_attributes + expect { + delete :destroy, params: {id: ico_request.to_param}, session: valid_session + }.to change(IcoRequest, :count).by(-1) + end + + it "redirects to the ico_requests list" do + ico_request = IcoRequest.create! valid_attributes + delete :destroy, params: {id: ico_request.to_param}, session: valid_session + expect(response).to redirect_to(ico_requests_url) + end + end + +end diff --git a/spec/helpers/ico_requests_helper_spec.rb b/spec/helpers/ico_requests_helper_spec.rb new file mode 100644 index 00000000000000..df2d57145271cd --- /dev/null +++ b/spec/helpers/ico_requests_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the IcoRequestsHelper. For example: +# +# describe IcoRequestsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe IcoRequestsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/ico_requests_spec.rb b/spec/requests/ico_requests_spec.rb new file mode 100644 index 00000000000000..4ab5617d4ea159 --- /dev/null +++ b/spec/requests/ico_requests_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +RSpec.describe "IcoRequests", type: :request do + describe "GET /ico_requests" do + it "works! (now write some real specs)" do + get ico_requests_path + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/routing/ico_requests_routing_spec.rb b/spec/routing/ico_requests_routing_spec.rb new file mode 100644 index 00000000000000..7be169c61576ad --- /dev/null +++ b/spec/routing/ico_requests_routing_spec.rb @@ -0,0 +1,39 @@ +require "rails_helper" + +RSpec.describe IcoRequestsController, type: :routing do + describe "routing" do + + it "routes to #index" do + expect(:get => "/ico_requests").to route_to("ico_requests#index") + end + + it "routes to #new" do + expect(:get => "/ico_requests/new").to route_to("ico_requests#new") + end + + it "routes to #show" do + expect(:get => "/ico_requests/1").to route_to("ico_requests#show", :id => "1") + end + + it "routes to #edit" do + expect(:get => "/ico_requests/1/edit").to route_to("ico_requests#edit", :id => "1") + end + + it "routes to #create" do + expect(:post => "/ico_requests").to route_to("ico_requests#create") + end + + it "routes to #update via PUT" do + expect(:put => "/ico_requests/1").to route_to("ico_requests#update", :id => "1") + end + + it "routes to #update via PATCH" do + expect(:patch => "/ico_requests/1").to route_to("ico_requests#update", :id => "1") + end + + it "routes to #destroy" do + expect(:delete => "/ico_requests/1").to route_to("ico_requests#destroy", :id => "1") + end + + end +end diff --git a/spec/views/ico_requests/edit.html.haml_spec.rb b/spec/views/ico_requests/edit.html.haml_spec.rb new file mode 100644 index 00000000000000..ea770bff634c86 --- /dev/null +++ b/spec/views/ico_requests/edit.html.haml_spec.rb @@ -0,0 +1,27 @@ +require 'rails_helper' + +RSpec.describe "ico_requests/edit", type: :view do + before(:each) do + @ico_request = assign(:ico_request, IcoRequest.create!( + :amount => 1.5, + :email => "MyString", + :eth_wallet_address => "MyString", + :token_wallet_address => "MyString" + )) + end + + it "renders the edit ico_request form" do + render + + assert_select "form[action=?][method=?]", ico_request_path(@ico_request), "post" do + + assert_select "input[name=?]", "ico_request[amount]" + + assert_select "input[name=?]", "ico_request[email]" + + assert_select "input[name=?]", "ico_request[eth_wallet_address]" + + assert_select "input[name=?]", "ico_request[token_wallet_address]" + end + end +end diff --git a/spec/views/ico_requests/index.html.haml_spec.rb b/spec/views/ico_requests/index.html.haml_spec.rb new file mode 100644 index 00000000000000..0b4faefd218eaa --- /dev/null +++ b/spec/views/ico_requests/index.html.haml_spec.rb @@ -0,0 +1,28 @@ +require 'rails_helper' + +RSpec.describe "ico_requests/index", type: :view do + before(:each) do + assign(:ico_requests, [ + IcoRequest.create!( + :amount => 2.5, + :email => "Email", + :eth_wallet_address => "Eth Wallet Address", + :token_wallet_address => "Token Wallet Address" + ), + IcoRequest.create!( + :amount => 2.5, + :email => "Email", + :eth_wallet_address => "Eth Wallet Address", + :token_wallet_address => "Token Wallet Address" + ) + ]) + end + + it "renders a list of ico_requests" do + render + assert_select "tr>td", :text => 2.5.to_s, :count => 2 + assert_select "tr>td", :text => "Email".to_s, :count => 2 + assert_select "tr>td", :text => "Eth Wallet Address".to_s, :count => 2 + assert_select "tr>td", :text => "Token Wallet Address".to_s, :count => 2 + end +end diff --git a/spec/views/ico_requests/new.html.haml_spec.rb b/spec/views/ico_requests/new.html.haml_spec.rb new file mode 100644 index 00000000000000..01de4e70bb47b8 --- /dev/null +++ b/spec/views/ico_requests/new.html.haml_spec.rb @@ -0,0 +1,27 @@ +require 'rails_helper' + +RSpec.describe "ico_requests/new", type: :view do + before(:each) do + assign(:ico_request, IcoRequest.new( + :amount => 1.5, + :email => "MyString", + :eth_wallet_address => "MyString", + :token_wallet_address => "MyString" + )) + end + + it "renders new ico_request form" do + render + + assert_select "form[action=?][method=?]", ico_requests_path, "post" do + + assert_select "input[name=?]", "ico_request[amount]" + + assert_select "input[name=?]", "ico_request[email]" + + assert_select "input[name=?]", "ico_request[eth_wallet_address]" + + assert_select "input[name=?]", "ico_request[token_wallet_address]" + end + end +end diff --git a/spec/views/ico_requests/show.html.haml_spec.rb b/spec/views/ico_requests/show.html.haml_spec.rb new file mode 100644 index 00000000000000..b8618b6a22b5e0 --- /dev/null +++ b/spec/views/ico_requests/show.html.haml_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe "ico_requests/show", type: :view do + before(:each) do + @ico_request = assign(:ico_request, IcoRequest.create!( + :amount => 2.5, + :email => "Email", + :eth_wallet_address => "Eth Wallet Address", + :token_wallet_address => "Token Wallet Address" + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/2.5/) + expect(rendered).to match(/Email/) + expect(rendered).to match(/Eth Wallet Address/) + expect(rendered).to match(/Token Wallet Address/) + end +end From 836d2255d34104a9d7382794d7b908fc1252239c Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 17:35:20 +0900 Subject: [PATCH 11/27] IcoRequest bootstrap:themed --- app/views/ico_requests/_form.html.haml | 26 +++++++++-------- app/views/ico_requests/edit.html.haml | 11 +++----- app/views/ico_requests/index.html.haml | 39 +++++++++++++++----------- app/views/ico_requests/new.html.haml | 9 +++--- app/views/ico_requests/show.html.haml | 31 ++++++++++++++------ 5 files changed, 68 insertions(+), 48 deletions(-) diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml index 59640cac14e89b..f33eed58f8fae6 100644 --- a/app/views/ico_requests/_form.html.haml +++ b/app/views/ico_requests/_form.html.haml @@ -1,11 +1,15 @@ -= simple_form_for(@ico_request) do |f| - = f.error_notification - - .form-inputs - = f.input :amount - = f.input :email - = f.input :eth_wallet_address - = f.input :token_wallet_address - - .form-actions - = f.button :submit += simple_form_for @ico_request, :html => { :class => 'form-horizontal' } do |f| + = f.input :user_id + = f.error_span :user_id + = f.input :ico_event_id + = f.error_span :ico_event_id + = f.input :amount + = f.error_span :amount + = f.input :email + = f.error_span :email + = f.input :eth_wallet_address + = f.error_span :eth_wallet_address + = f.input :token_wallet_address + = f.error_span :token_wallet_address + = f.button :submit, :class => 'btn-primary' + = link_to t('.cancel', :default => t("helpers.links.cancel")), ico_requests_path, :class => 'btn btn-default' diff --git a/app/views/ico_requests/edit.html.haml b/app/views/ico_requests/edit.html.haml index ec4f7f367b4056..886cd0d47a7718 100644 --- a/app/views/ico_requests/edit.html.haml +++ b/app/views/ico_requests/edit.html.haml @@ -1,7 +1,4 @@ -%h1 Editing ico_request - -= render 'form' - -= link_to 'Show', @ico_request -\| -= link_to 'Back', ico_requests_path +- model_class = IcoRequest +.page-header + %h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize += render :partial => "form" diff --git a/app/views/ico_requests/index.html.haml b/app/views/ico_requests/index.html.haml index 6daf020bb8a6ad..ad2e046d3199f9 100644 --- a/app/views/ico_requests/index.html.haml +++ b/app/views/ico_requests/index.html.haml @@ -1,27 +1,32 @@ -%h1 Listing ico_requests - -%table +- model_class = IcoRequest +.page-header + %h1=t '.title', :default => model_class.model_name.human.pluralize.titleize +%table.table.table-striped %thead %tr - %th Amount - %th Email - %th Eth wallet address - %th Token wallet address - %th - %th - %th - + %th= model_class.human_attribute_name(:id) + %th= model_class.human_attribute_name(:user_id) + %th= model_class.human_attribute_name(:ico_event_id) + %th= model_class.human_attribute_name(:amount) + %th= model_class.human_attribute_name(:email) + %th= model_class.human_attribute_name(:eth_wallet_address) + %th= model_class.human_attribute_name(:token_wallet_address) + %th= model_class.human_attribute_name(:created_at) + %th=t '.actions', :default => t("helpers.actions") %tbody - @ico_requests.each do |ico_request| %tr + %td= link_to ico_request.id, ico_request_path(ico_request) + %td= ico_request.user_id + %td= ico_request.ico_event_id %td= ico_request.amount %td= ico_request.email %td= ico_request.eth_wallet_address %td= ico_request.token_wallet_address - %td= link_to 'Show', ico_request - %td= link_to 'Edit', edit_ico_request_path(ico_request) - %td= link_to 'Destroy', ico_request, :method => :delete, :data => { :confirm => 'Are you sure?' } - -%br + %td=l ico_request.created_at + %td + = link_to t('.show', :default => t("helpers.links.show")), ico_request_path(ico_request), :class => 'btn btn-default btn-xs' + = link_to t('.edit', :default => t("helpers.links.edit")), edit_ico_request_path(ico_request), :class => 'btn btn-default btn-xs' + = link_to t('.destroy', :default => t("helpers.links.destroy")), ico_request_path(ico_request), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-xs btn-danger' -= link_to 'New Ico request', new_ico_request_path += link_to t('.new', :default => t("helpers.links.new")), new_ico_request_path, :class => 'btn btn-primary' diff --git a/app/views/ico_requests/new.html.haml b/app/views/ico_requests/new.html.haml index 37ff141f256538..ed84afc3334a9c 100644 --- a/app/views/ico_requests/new.html.haml +++ b/app/views/ico_requests/new.html.haml @@ -1,5 +1,4 @@ -%h1 New ico_request - -= render 'form' - -= link_to 'Back', ico_requests_path +- model_class = IcoRequest +.page-header + %h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize += render :partial => "form" diff --git a/app/views/ico_requests/show.html.haml b/app/views/ico_requests/show.html.haml index d5718e2b5d3d43..cbc0bb16845efd 100644 --- a/app/views/ico_requests/show.html.haml +++ b/app/views/ico_requests/show.html.haml @@ -1,18 +1,33 @@ -%p#notice= notice +- model_class = IcoRequest +.page-header + %h1=t '.title', :default => model_class.model_name.human.titleize %p - %b Amount: + %strong= model_class.human_attribute_name(:user_id) + ':' + %br + = @ico_request.user_id +%p + %strong= model_class.human_attribute_name(:ico_event_id) + ':' + %br + = @ico_request.ico_event_id +%p + %strong= model_class.human_attribute_name(:amount) + ':' + %br = @ico_request.amount %p - %b Email: + %strong= model_class.human_attribute_name(:email) + ':' + %br = @ico_request.email %p - %b Eth wallet address: + %strong= model_class.human_attribute_name(:eth_wallet_address) + ':' + %br = @ico_request.eth_wallet_address %p - %b Token wallet address: + %strong= model_class.human_attribute_name(:token_wallet_address) + ':' + %br = @ico_request.token_wallet_address -= link_to 'Edit', edit_ico_request_path(@ico_request) -\| -= link_to 'Back', ico_requests_path + += link_to t('.back', :default => t("helpers.links.back")), ico_requests_path, :class => 'btn btn-default' += link_to t('.edit', :default => t("helpers.links.edit")), edit_ico_request_path(@ico_request), :class => 'btn btn-default' += link_to t('.destroy', :default => t("helpers.links.destroy")), ico_request_path(@ico_request), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger' From 8a3ce5319a9cb095ea68f96b7425dd9ecfb1346d Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 18:30:48 +0900 Subject: [PATCH 12/27] ICO Request Page Design --- app/javascript/styles/application.scss | 1 + app/javascript/styles/ico/requests.scss | 8 ++++ app/views/ico_requests/_form.html.haml | 48 ++++++++++++++++-------- app/views/ico_requests/new.html.haml | 2 - config/locales/ico_request.ja.yml | 6 +++ public/photon/logo.png | Bin 0 -> 5168 bytes 6 files changed, 48 insertions(+), 17 deletions(-) create mode 100644 app/javascript/styles/ico/requests.scss create mode 100644 config/locales/ico_request.ja.yml create mode 100755 public/photon/logo.png diff --git a/app/javascript/styles/application.scss b/app/javascript/styles/application.scss index e155e3b57c8c7f..28c94b6c24e390 100644 --- a/app/javascript/styles/application.scss +++ b/app/javascript/styles/application.scss @@ -25,3 +25,4 @@ @import 'mastodon/accessibility'; @import 'mastodon/oauth'; @import 'mastodon/bbcode'; +@import 'ico/requests'; diff --git a/app/javascript/styles/ico/requests.scss b/app/javascript/styles/ico/requests.scss new file mode 100644 index 00000000000000..c94fde15ab5814 --- /dev/null +++ b/app/javascript/styles/ico/requests.scss @@ -0,0 +1,8 @@ +.ico-request { + h1 { + font-size: 2.5em; + font-weight: bold; + margin: 20px; + text-align: center; + } +} diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml index f33eed58f8fae6..d47084679c0b34 100644 --- a/app/views/ico_requests/_form.html.haml +++ b/app/views/ico_requests/_form.html.haml @@ -1,15 +1,33 @@ -= simple_form_for @ico_request, :html => { :class => 'form-horizontal' } do |f| - = f.input :user_id - = f.error_span :user_id - = f.input :ico_event_id - = f.error_span :ico_event_id - = f.input :amount - = f.error_span :amount - = f.input :email - = f.error_span :email - = f.input :eth_wallet_address - = f.error_span :eth_wallet_address - = f.input :token_wallet_address - = f.error_span :token_wallet_address - = f.button :submit, :class => 'btn-primary' - = link_to t('.cancel', :default => t("helpers.links.cancel")), ico_requests_path, :class => 'btn btn-default' +%div.ico-request + = image_tag '/photon/logo.png' + %h1 Pre-ICO Request + + - model_class = IcoRequest + = simple_form_for @ico_request, :html => { :class => 'form-horizontal' } do |f| + = model_class.human_attribute_name(:amount) + = f.input :amount + = f.error_span :amount + = model_class.human_attribute_name(:email) + = f.input :email + = f.error_span :email + = model_class.human_attribute_name(:eth_wallet_address) + = f.input :eth_wallet_address + = f.error_span :eth_wallet_address + = model_class.human_attribute_name(:token_wallet_address) + = f.input :token_wallet_address + = f.error_span :token_wallet_address + + %div.checkboxes + = check_box_tag :check_1 + = I18n.t('ico_request.check_1') + %br + = check_box_tag :check_2 + = I18n.t('ico_request.check_2') + %br + = check_box_tag :check_3 + = I18n.t('ico_request.check_3') + %br + = check_box_tag :check_4 + = I18n.t('ico_request.check_4') + + = f.button :submit, :class => 'button', id: 'ico-request-submit' diff --git a/app/views/ico_requests/new.html.haml b/app/views/ico_requests/new.html.haml index ed84afc3334a9c..56b2a5f15afff9 100644 --- a/app/views/ico_requests/new.html.haml +++ b/app/views/ico_requests/new.html.haml @@ -1,4 +1,2 @@ - model_class = IcoRequest -.page-header - %h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize = render :partial => "form" diff --git a/config/locales/ico_request.ja.yml b/config/locales/ico_request.ja.yml new file mode 100644 index 00000000000000..75320779693239 --- /dev/null +++ b/config/locales/ico_request.ja.yml @@ -0,0 +1,6 @@ +ja: + ico_request: + check_1: Whitepaperをよく読み、ICOの内容を理解しています + check_2: (Japan User Only) PHOTON GOLD は 法定通貨との交換や商品売買には利用できません(前払式発行手段ではありません) + check_3: 居住している地域でICOの参加は認められています(中国、アメリカ合衆国には居住していません) + check_4: マネーロンダリングに利用しません diff --git a/public/photon/logo.png b/public/photon/logo.png new file mode 100755 index 0000000000000000000000000000000000000000..8d6dda83d2c6ff97d985460e4f9d216e17d3b061 GIT binary patch literal 5168 zcmaJ_c|25Y`=7|ju8qhtp%jgo!C1yRmKgh1LSf7d1~Y>h`<|jGCA;idMn$sAPT5J8 z>|4sdgd|&j)AKw%zxR*#^PbP=ocq47bA7+pe*QQQj108cn0c82000|GTf>C5deCl> z6F}Ot;*-Z3ZQ-G4-lUk4>?vMocN_qTCE4LXC<596XM#gxecak{iU0t87~bqA<)*$K z0z)E5pnvN~coSS{XaGP_#oHB)amG%ocN_>VAp^$1q@f^Lc?p;dR2mMu3X+7vWFb&E1S$iD!Vpk7gd_~~&m}~&=8m;T zm}p%4#}@6RB;-h;xFR4BFE1|%FDVIE9s`T=n(;B_@*pNfa$*5O1_A1SSE65D35H`b(Qk zF~R-68~;_CZ06&NgP7pRBoB8CtseHmf55cd{cl6R6=~ie4BhdxqM%(gNEinZ8g%kP*kNuAf{@tlG2`v)WKMo-z zrO+}^S$SD7TviSTrorvN^73dJCDvXJ1C_Od%0nfEAT$>tznkYjn(2>-)}g<*|BeRj z@b7Tph_s1vr;Sc*=H(3lfKwHvfi&|TUAg7wdUnX?sAnx;!5Vc!M1)5K3bK{}HApwf zoP(ZwX3OzLcigtx?b58=_Cx+9fTtpX$*4l#O7GHxJmNDq7Xfx}C)p?kOzVIujN}w{ zTo`)hNyCZIyM?`0J7s=*`#ov3UK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iV$&TH*Xy^%jrTgb5{sXY%P45?`WVvf_w-gRfyS%(n;Ix+JiV_GdP^5-b89HZ7 zNm+dt4z9GZIXa*E$^XvsyV(tM4?dTP>FT_WveXO?Pt0O)8`1$v5&sRH|Js4R;rNg+|2Xxd0N;&NxdhJzyTfu-G6g{b9T+H_d6m!ip z2xV`Z*?l^jXP|x`{4OXM<#qe5{@j?=tL59DWSW77nLf}zxy(Tt~_yb zR>J9i>k|5u>;r$)4tOy`VV-j3^~mjqEp^C7Q2wa-cB)^YnySjDxxT02`F345I*5n5 z3)Qft8*Oxan>zl@1Jjl4sl66zpN6Z~B0lnay>lEY#{YnQ>5od{BwWnEr=%PW>N z@al?+{y-9rC-Vuz<)`P*WM@Cgy?r+7d@t1Mo`}`BS3B{LAP_*#$_XfL4caTfehFG5`y_gFt^FQw_QCk#H&zVo77LiH0;`Gzw;pWJjlh9Q*5if;g18vngYjv3nyWWDrybth)2L zthe|ImD7&l`?DTyQZyG*zdP#98DHM+%v(!b?9mr$7n=<5eWYV69L8@uwKZ?_^!bbH z*3;+Zn|KvgbH{dwxn12+2>!vkx9^-WXxv*4GITD1aryG<%d71*V`kcS#L~l$m0bLA zIYrdLcOj2D_H&nNf+Z}eh9v7DB45ylRJ!{Pcu6#E-IM)@o8AxAP<(TCNRVE$hraD= zr8QtWlsIZA(r=T#T%3qDW&yS^#ICmNUTR~i%Qc_#+Rqx7D$v&@=Gh%T+j2_yeKQ~YEWtNMt4E_OvrNczetzRZO|%&=~X ztZmRqk0{Jh$n=*xo58rfW%7r5plkiL1XZ|7&^4~OK;n^T13(jGld!?OZ1(#f9!k?d KqfpKE&i?@*V0v)? literal 0 HcmV?d00001 From 4661284be75e2bc13d368c15ba3fb452ab86a3d6 Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 18:44:39 +0900 Subject: [PATCH 13/27] Verify checkbox --- app/controllers/ico_requests_controller.rb | 8 ++++++-- app/javascript/styles/ico/requests.scss | 5 +++++ app/views/ico_requests/_form.html.haml | 10 ++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/controllers/ico_requests_controller.rb b/app/controllers/ico_requests_controller.rb index 1ceabdca371f6f..512f43a881a379 100644 --- a/app/controllers/ico_requests_controller.rb +++ b/app/controllers/ico_requests_controller.rb @@ -21,10 +21,14 @@ def edit # POST /ico_requests def create + unless ico_request_params[:check_1] && ico_request_params[:check_2] && ico_request_params[:check_3] && ico_request_params[:check_4] + redirect_to new_ico_requests_path, notice: 'Please check confirm items' + return + end @ico_request = IcoRequest.new(ico_request_params) if @ico_request.save - redirect_to @ico_request, notice: 'Ico request was successfully created.' + redirect_to 'https://photon.gold/' else render :new end @@ -53,6 +57,6 @@ def set_ico_request # Only allow a trusted parameter "white list" through. def ico_request_params - params.require(:ico_request).permit(:amount, :email, :eth_wallet_address, :token_wallet_address) + params.require(:ico_request).permit(:amount, :email, :eth_wallet_address, :token_wallet_address, :check_1, :check_2, :check_3, :check_4) end end diff --git a/app/javascript/styles/ico/requests.scss b/app/javascript/styles/ico/requests.scss index c94fde15ab5814..a7e9200400601c 100644 --- a/app/javascript/styles/ico/requests.scss +++ b/app/javascript/styles/ico/requests.scss @@ -5,4 +5,9 @@ margin: 20px; text-align: center; } + .alert { + background-color: palevioletred; + margin: 10px; + font-weight: bold; + } } diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml index d47084679c0b34..f346fdfac1e531 100644 --- a/app/views/ico_requests/_form.html.haml +++ b/app/views/ico_requests/_form.html.haml @@ -1,4 +1,6 @@ %div.ico-request + - flash.each do |key, value| + = content_tag :div, value, class: "alert" = image_tag '/photon/logo.png' %h1 Pre-ICO Request @@ -18,16 +20,16 @@ = f.error_span :token_wallet_address %div.checkboxes - = check_box_tag :check_1 + = check_box_tag "ico_request[check_1]" = I18n.t('ico_request.check_1') %br - = check_box_tag :check_2 + = check_box_tag "ico_request[check_2]" = I18n.t('ico_request.check_2') %br - = check_box_tag :check_3 + = check_box_tag "ico_request[check_3]" = I18n.t('ico_request.check_3') %br - = check_box_tag :check_4 + = check_box_tag "ico_request[check_4]" = I18n.t('ico_request.check_4') = f.button :submit, :class => 'button', id: 'ico-request-submit' From ce44c7503c76c09849b59430214bd5f253bc72be Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 19:17:37 +0900 Subject: [PATCH 14/27] Request form design --- app/javascript/styles/ico/requests.scss | 3 +++ app/views/ico_requests/_form.html.haml | 7 +++++++ config/locales/ico_request.ja.yml | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/app/javascript/styles/ico/requests.scss b/app/javascript/styles/ico/requests.scss index a7e9200400601c..2c6eb7df1b6e51 100644 --- a/app/javascript/styles/ico/requests.scss +++ b/app/javascript/styles/ico/requests.scss @@ -10,4 +10,7 @@ margin: 10px; font-weight: bold; } + .required-mark { + color: red; + } } diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml index f346fdfac1e531..b1333729d035e8 100644 --- a/app/views/ico_requests/_form.html.haml +++ b/app/views/ico_requests/_form.html.haml @@ -7,12 +7,15 @@ - model_class = IcoRequest = simple_form_for @ico_request, :html => { :class => 'form-horizontal' } do |f| = model_class.human_attribute_name(:amount) + %span.required-mark * = f.input :amount = f.error_span :amount = model_class.human_attribute_name(:email) + %span.required-mark * = f.input :email = f.error_span :email = model_class.human_attribute_name(:eth_wallet_address) + %span.required-mark * = f.input :eth_wallet_address = f.error_span :eth_wallet_address = model_class.human_attribute_name(:token_wallet_address) @@ -22,14 +25,18 @@ %div.checkboxes = check_box_tag "ico_request[check_1]" = I18n.t('ico_request.check_1') + %span.required-mark * %br = check_box_tag "ico_request[check_2]" = I18n.t('ico_request.check_2') + %span.required-mark * %br = check_box_tag "ico_request[check_3]" = I18n.t('ico_request.check_3') + %span.required-mark * %br = check_box_tag "ico_request[check_4]" = I18n.t('ico_request.check_4') + %span.required-mark * = f.button :submit, :class => 'button', id: 'ico-request-submit' diff --git a/config/locales/ico_request.ja.yml b/config/locales/ico_request.ja.yml index 75320779693239..0388fc0151518f 100644 --- a/config/locales/ico_request.ja.yml +++ b/config/locales/ico_request.ja.yml @@ -4,3 +4,10 @@ ja: check_2: (Japan User Only) PHOTON GOLD は 法定通貨との交換や商品売買には利用できません(前払式発行手段ではありません) check_3: 居住している地域でICOの参加は認められています(中国、アメリカ合衆国には居住していません) check_4: マネーロンダリングに利用しません + activerecord: + attributes: + ico_request: + amount: 購入数(1PHOTON GOLD = 0.000011ETH) + email: メールアドレス + eth_wallet_address: 入金元Etheriumアドレス + token_wallet_address: PHOTON GOLD保存先ウォレットアドレス From 223913997694a8cd77df49d63a84a328d9ea141e Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 19:31:47 +0900 Subject: [PATCH 15/27] Add ICO Request Localize --- app/controllers/ico_requests_controller.rb | 2 +- app/views/ico_requests/_form.html.haml | 1 - config/locales/ico_request.en.yml | 14 ++++++++++++++ config/locales/ico_request.zh-HK.yml | 13 +++++++++++++ config/locales/ico_request.zh-TW.yml | 13 +++++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 config/locales/ico_request.en.yml create mode 100644 config/locales/ico_request.zh-HK.yml create mode 100644 config/locales/ico_request.zh-TW.yml diff --git a/app/controllers/ico_requests_controller.rb b/app/controllers/ico_requests_controller.rb index 512f43a881a379..6e36e0945bfbd5 100644 --- a/app/controllers/ico_requests_controller.rb +++ b/app/controllers/ico_requests_controller.rb @@ -21,7 +21,7 @@ def edit # POST /ico_requests def create - unless ico_request_params[:check_1] && ico_request_params[:check_2] && ico_request_params[:check_3] && ico_request_params[:check_4] + unless ico_request_params[:check_1] && ico_request_params[:check_3] && ico_request_params[:check_4] redirect_to new_ico_requests_path, notice: 'Please check confirm items' return end diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml index b1333729d035e8..842070c353de6a 100644 --- a/app/views/ico_requests/_form.html.haml +++ b/app/views/ico_requests/_form.html.haml @@ -29,7 +29,6 @@ %br = check_box_tag "ico_request[check_2]" = I18n.t('ico_request.check_2') - %span.required-mark * %br = check_box_tag "ico_request[check_3]" = I18n.t('ico_request.check_3') diff --git a/config/locales/ico_request.en.yml b/config/locales/ico_request.en.yml new file mode 100644 index 00000000000000..6dfa72cad444ba --- /dev/null +++ b/config/locales/ico_request.en.yml @@ -0,0 +1,14 @@ +en: + ico_request: + check_1: I carefully read whitepaper and understand the contents of ICO + check_2: (Japan User Only) PHOTON GOLD は 法定通貨との交換や商品売買には利用できません(前払式発行手段ではありません) + check_3: Participation in ICO is permitted in the country or region where you reside. + (You don’t reside in China or the United States of America.) + check_4: I do not use ICO for money laundering. + activerecord: + attributes: + ico_request: + amount: Amount(1PHOTON GOLD = 0.000011ETH) + email: E-mail address + eth_wallet_address: Entry source ETH address + token_wallet_address: Wallet address for saving PHOTON GOLD diff --git a/config/locales/ico_request.zh-HK.yml b/config/locales/ico_request.zh-HK.yml new file mode 100644 index 00000000000000..af8cb34ec71753 --- /dev/null +++ b/config/locales/ico_request.zh-HK.yml @@ -0,0 +1,13 @@ +zh-HK: + ico_request: + check_1: 請詳閱白皮書與ICO內容。 + check_2: (Japan User Only) PHOTON GOLD は 法定通貨との交換や商品売買には利用できません(前払式発行手段ではありません) + check_3: 確認居住區域核准參與ICO事項(非住在中國大陸、美國) + check_4: 杜絕洗錢之相關行為 + activerecord: + attributes: + ico_request: + amount: 購買數量(1PHOTON GOLD = 0.000011ETH) + email: E-Mail地址 + eth_wallet_address: 輸入源ETH地址 + token_wallet_address: PHOTON GOLD保存目的地錢包地址 diff --git a/config/locales/ico_request.zh-TW.yml b/config/locales/ico_request.zh-TW.yml new file mode 100644 index 00000000000000..79b6803ae3a335 --- /dev/null +++ b/config/locales/ico_request.zh-TW.yml @@ -0,0 +1,13 @@ +zh-TW: + ico_request: + check_1: 請詳閱白皮書與ICO內容。 + check_2: (Japan User Only) PHOTON GOLD は 法定通貨との交換や商品売買には利用できません(前払式発行手段ではありません) + check_3: 確認居住區域核准參與ICO事項(非住在中國大陸、美國) + check_4: 杜絕洗錢之相關行為 + activerecord: + attributes: + ico_request: + amount: 購買數量(1PHOTON GOLD = 0.000011ETH) + email: E-Mail地址 + eth_wallet_address: 輸入源ETH地址 + token_wallet_address: PHOTON GOLD保存目的地錢包地址 From a92578c636b7f9c29401803894a9f1dbc5501a3d Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 20:06:25 +0900 Subject: [PATCH 16/27] Add ICO Request validation --- app/controllers/ico_requests_controller.rb | 13 +++++++++---- app/models/ico_request.rb | 6 ++++++ app/views/ico_requests/_form.html.haml | 15 +++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/controllers/ico_requests_controller.rb b/app/controllers/ico_requests_controller.rb index 6e36e0945bfbd5..c1c61dc9303514 100644 --- a/app/controllers/ico_requests_controller.rb +++ b/app/controllers/ico_requests_controller.rb @@ -21,16 +21,17 @@ def edit # POST /ico_requests def create - unless ico_request_params[:check_1] && ico_request_params[:check_3] && ico_request_params[:check_4] + unless ico_request_check_params[:check_1] && ico_request_check_params[:check_3] && ico_request_check_params[:check_4] redirect_to new_ico_requests_path, notice: 'Please check confirm items' - return + return end @ico_request = IcoRequest.new(ico_request_params) + @ico_request.user = current_user if current_user.present? if @ico_request.save redirect_to 'https://photon.gold/' else - render :new + render :new, notice: 'Validation failed' end end @@ -57,6 +58,10 @@ def set_ico_request # Only allow a trusted parameter "white list" through. def ico_request_params - params.require(:ico_request).permit(:amount, :email, :eth_wallet_address, :token_wallet_address, :check_1, :check_2, :check_3, :check_4) + params.require(:ico_request).permit(:amount, :email, :eth_wallet_address, :token_wallet_address) + end + + def ico_request_check_params + params.permit(:check_1, :check_2, :check_3, :check_4) end end diff --git a/app/models/ico_request.rb b/app/models/ico_request.rb index cb1f3e412eaab7..ac576c2bd94fbe 100644 --- a/app/models/ico_request.rb +++ b/app/models/ico_request.rb @@ -14,4 +14,10 @@ # class IcoRequest < ApplicationRecord + belongs_to :user + belongs_to :ico_event + + validates :amount, presence: true, numericality: {greater_than_or_equal_to: 1, less_than_or_equal_to: 2147483647} + validates :email, presence: true + validates :eth_wallet_address, presence: true end diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml index 842070c353de6a..9f971168ede943 100644 --- a/app/views/ico_requests/_form.html.haml +++ b/app/views/ico_requests/_form.html.haml @@ -9,32 +9,31 @@ = model_class.human_attribute_name(:amount) %span.required-mark * = f.input :amount - = f.error_span :amount + = model_class.human_attribute_name(:email) %span.required-mark * = f.input :email - = f.error_span :email + = model_class.human_attribute_name(:eth_wallet_address) %span.required-mark * = f.input :eth_wallet_address - = f.error_span :eth_wallet_address + = model_class.human_attribute_name(:token_wallet_address) = f.input :token_wallet_address - = f.error_span :token_wallet_address %div.checkboxes - = check_box_tag "ico_request[check_1]" + = check_box_tag "check_1" = I18n.t('ico_request.check_1') %span.required-mark * %br - = check_box_tag "ico_request[check_2]" + = check_box_tag "check_2" = I18n.t('ico_request.check_2') %br - = check_box_tag "ico_request[check_3]" + = check_box_tag "check_3" = I18n.t('ico_request.check_3') %span.required-mark * %br - = check_box_tag "ico_request[check_4]" + = check_box_tag "check_4" = I18n.t('ico_request.check_4') %span.required-mark * From 7819069cbb69bdf4078d9e9cf086f91c0defac83 Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 20:13:22 +0900 Subject: [PATCH 17/27] Validation settings changed --- app/models/ico_request.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/ico_request.rb b/app/models/ico_request.rb index ac576c2bd94fbe..93926200426ccc 100644 --- a/app/models/ico_request.rb +++ b/app/models/ico_request.rb @@ -14,10 +14,10 @@ # class IcoRequest < ApplicationRecord - belongs_to :user - belongs_to :ico_event + belongs_to :user, optional: true + belongs_to :ico_event, optional: true - validates :amount, presence: true, numericality: {greater_than_or_equal_to: 1, less_than_or_equal_to: 2147483647} + validates :amount, presence: true, numericality: {greater_than_or_equal_to: 1, less_than_or_equal_to: 1000000000} validates :email, presence: true validates :eth_wallet_address, presence: true end From 3b3b591095e813bb807500bf9a6a9e56d3049b8a Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 20:32:48 +0900 Subject: [PATCH 18/27] When Login, Redirect to share --- app/controllers/ico_requests_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/ico_requests_controller.rb b/app/controllers/ico_requests_controller.rb index c1c61dc9303514..4e6c9490ae8abe 100644 --- a/app/controllers/ico_requests_controller.rb +++ b/app/controllers/ico_requests_controller.rb @@ -29,7 +29,11 @@ def create @ico_request.user = current_user if current_user.present? if @ico_request.save - redirect_to 'https://photon.gold/' + if current_user.present? + redirect_to '/share?text=I%20participated%20in%20the%20pre-ICO%20of%20PHOTON%20GOLD.%0Ahttps%3A%2F%2Fphoton.gold%2F' + else + redirect_to 'https://photon.gold/' + end else render :new, notice: 'Validation failed' end From 4cd58dc7bab8faf9d55194344e7f206b898b663c Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 20:33:53 +0900 Subject: [PATCH 19/27] Add ico_event_id --- app/controllers/ico_requests_controller.rb | 1 + app/models/ico_request.rb | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/ico_requests_controller.rb b/app/controllers/ico_requests_controller.rb index 4e6c9490ae8abe..aa8007c4cea28a 100644 --- a/app/controllers/ico_requests_controller.rb +++ b/app/controllers/ico_requests_controller.rb @@ -27,6 +27,7 @@ def create end @ico_request = IcoRequest.new(ico_request_params) @ico_request.user = current_user if current_user.present? + @ico_request.ico_event_id = 1 if @ico_request.save if current_user.present? diff --git a/app/models/ico_request.rb b/app/models/ico_request.rb index 93926200426ccc..a3ae801292c7dc 100644 --- a/app/models/ico_request.rb +++ b/app/models/ico_request.rb @@ -15,7 +15,6 @@ class IcoRequest < ApplicationRecord belongs_to :user, optional: true - belongs_to :ico_event, optional: true validates :amount, presence: true, numericality: {greater_than_or_equal_to: 1, less_than_or_equal_to: 1000000000} validates :email, presence: true From 3474c28e926d039a6052ce8233e4b8f726fdaa5d Mon Sep 17 00:00:00 2001 From: ANNotunzdY Date: Mon, 14 May 2018 20:58:56 +0900 Subject: [PATCH 20/27] Add tokusho link --- app/javascript/styles/ico/requests.scss | 9 +++++++++ app/views/ico_requests/_form.html.haml | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/app/javascript/styles/ico/requests.scss b/app/javascript/styles/ico/requests.scss index 2c6eb7df1b6e51..4b881da66c3550 100644 --- a/app/javascript/styles/ico/requests.scss +++ b/app/javascript/styles/ico/requests.scss @@ -13,4 +13,13 @@ .required-mark { color: red; } + a:link { + color: white; + } + a:hover { + color: white; + } + a:visited { + color: white; + } } diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml index 9f971168ede943..83d3e47c020735 100644 --- a/app/views/ico_requests/_form.html.haml +++ b/app/views/ico_requests/_form.html.haml @@ -38,3 +38,7 @@ %span.required-mark * = f.button :submit, :class => 'button', id: 'ico-request-submit' + + %hr + %address + = link_to "特定商取引法に基づく表示", "https://ja.photon.gold/tokusho.pdf" From 2228921df5c83b2748937d0a769100b0f8176b0c Mon Sep 17 00:00:00 2001 From: yudetamago Date: Tue, 17 Jul 2018 15:11:35 +0900 Subject: [PATCH 21/27] Add campaign name --- app/controllers/ico_requests_controller.rb | 5 +++-- app/models/ico_request.rb | 1 + app/views/ico_requests/_form.html.haml | 3 +++ .../20180717052800_add_campaign_name_to_ico_requests.rb | 5 +++++ db/schema.rb | 3 ++- 5 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20180717052800_add_campaign_name_to_ico_requests.rb diff --git a/app/controllers/ico_requests_controller.rb b/app/controllers/ico_requests_controller.rb index aa8007c4cea28a..3efcf278a81b0c 100644 --- a/app/controllers/ico_requests_controller.rb +++ b/app/controllers/ico_requests_controller.rb @@ -13,6 +13,7 @@ def show # GET /ico_requests/new def new @ico_request = IcoRequest.new + @ico_request.campaign_name = params[:campaign] end # GET /ico_requests/1/edit @@ -22,7 +23,7 @@ def edit # POST /ico_requests def create unless ico_request_check_params[:check_1] && ico_request_check_params[:check_3] && ico_request_check_params[:check_4] - redirect_to new_ico_requests_path, notice: 'Please check confirm items' + redirect_to new_ico_requests_path(campaign: ico_request_params[:campaign_name]), notice: 'Please check confirm items' return end @ico_request = IcoRequest.new(ico_request_params) @@ -63,7 +64,7 @@ def set_ico_request # Only allow a trusted parameter "white list" through. def ico_request_params - params.require(:ico_request).permit(:amount, :email, :eth_wallet_address, :token_wallet_address) + params.require(:ico_request).permit(:amount, :email, :eth_wallet_address, :token_wallet_address, :campaign_name) end def ico_request_check_params diff --git a/app/models/ico_request.rb b/app/models/ico_request.rb index a3ae801292c7dc..39a0a0dcfa7773 100644 --- a/app/models/ico_request.rb +++ b/app/models/ico_request.rb @@ -11,6 +11,7 @@ # token_wallet_address :string # created_at :datetime not null # updated_at :datetime not null +# campaign_name :string(100) # class IcoRequest < ApplicationRecord diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml index 83d3e47c020735..9478db3224f172 100644 --- a/app/views/ico_requests/_form.html.haml +++ b/app/views/ico_requests/_form.html.haml @@ -37,6 +37,9 @@ = I18n.t('ico_request.check_4') %span.required-mark * + - if @ico_request.campaign_name.present? + = f.hidden_field :campaign_name + = f.button :submit, :class => 'button', id: 'ico-request-submit' %hr diff --git a/db/migrate/20180717052800_add_campaign_name_to_ico_requests.rb b/db/migrate/20180717052800_add_campaign_name_to_ico_requests.rb new file mode 100644 index 00000000000000..2293ae6611aff0 --- /dev/null +++ b/db/migrate/20180717052800_add_campaign_name_to_ico_requests.rb @@ -0,0 +1,5 @@ +class AddCampaignNameToIcoRequests < ActiveRecord::Migration[5.1] + def change + add_column :ico_requests, :campaign_name, :string, limit: 100 + end +end diff --git a/db/schema.rb b/db/schema.rb index 0dc6771cc296c6..4fb8ec4f00eb52 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_07_07_154237) do +ActiveRecord::Schema.define(version: 20180717052800) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -220,6 +220,7 @@ t.string "token_wallet_address" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "campaign_name", limit: 100 end create_table "ico_tokens", force: :cascade do |t| From 1c294a0fdb4b0edc31ba47acefad841e0ad346e0 Mon Sep 17 00:00:00 2001 From: yudetamago Date: Tue, 17 Jul 2018 16:49:57 +0900 Subject: [PATCH 22/27] Add language --- app/controllers/ico_requests_controller.rb | 9 +++++++-- app/models/ico_request.rb | 1 + app/views/ico_requests/_form.html.haml | 3 +++ .../20180717073631_add_language_to_ico_requests.rb | 5 +++++ db/schema.rb | 3 ++- 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20180717073631_add_language_to_ico_requests.rb diff --git a/app/controllers/ico_requests_controller.rb b/app/controllers/ico_requests_controller.rb index 3efcf278a81b0c..ebad725a0fea68 100644 --- a/app/controllers/ico_requests_controller.rb +++ b/app/controllers/ico_requests_controller.rb @@ -14,6 +14,7 @@ def show def new @ico_request = IcoRequest.new @ico_request.campaign_name = params[:campaign] + @ico_request.language = params[:language] end # GET /ico_requests/1/edit @@ -23,7 +24,11 @@ def edit # POST /ico_requests def create unless ico_request_check_params[:check_1] && ico_request_check_params[:check_3] && ico_request_check_params[:check_4] - redirect_to new_ico_requests_path(campaign: ico_request_params[:campaign_name]), notice: 'Please check confirm items' + request_params = { + campaign: ico_request_params[:campaign_name], + language: ico_request_params[:language] + } + redirect_to new_ico_requests_path(request_params), notice: 'Please check confirm items' return end @ico_request = IcoRequest.new(ico_request_params) @@ -64,7 +69,7 @@ def set_ico_request # Only allow a trusted parameter "white list" through. def ico_request_params - params.require(:ico_request).permit(:amount, :email, :eth_wallet_address, :token_wallet_address, :campaign_name) + params.require(:ico_request).permit(:amount, :email, :eth_wallet_address, :token_wallet_address, :campaign_name, :language) end def ico_request_check_params diff --git a/app/models/ico_request.rb b/app/models/ico_request.rb index 39a0a0dcfa7773..4d94c85a23cddc 100644 --- a/app/models/ico_request.rb +++ b/app/models/ico_request.rb @@ -12,6 +12,7 @@ # created_at :datetime not null # updated_at :datetime not null # campaign_name :string(100) +# language :string(10) # class IcoRequest < ApplicationRecord diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml index 9478db3224f172..6e7cb1502197e9 100644 --- a/app/views/ico_requests/_form.html.haml +++ b/app/views/ico_requests/_form.html.haml @@ -40,6 +40,9 @@ - if @ico_request.campaign_name.present? = f.hidden_field :campaign_name + - if @ico_request.language.present? + = f.hidden_field :language + = f.button :submit, :class => 'button', id: 'ico-request-submit' %hr diff --git a/db/migrate/20180717073631_add_language_to_ico_requests.rb b/db/migrate/20180717073631_add_language_to_ico_requests.rb new file mode 100644 index 00000000000000..d4e77b1783da45 --- /dev/null +++ b/db/migrate/20180717073631_add_language_to_ico_requests.rb @@ -0,0 +1,5 @@ +class AddLanguageToIcoRequests < ActiveRecord::Migration[5.1] + def change + add_column :ico_requests, :language, :string, limit: 10 + end +end diff --git a/db/schema.rb b/db/schema.rb index 4fb8ec4f00eb52..a51635c803b29c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180717052800) do +ActiveRecord::Schema.define(version: 20180717073631) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -221,6 +221,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "campaign_name", limit: 100 + t.string "language", limit: 10 end create_table "ico_tokens", force: :cascade do |t| From 6e783bbf4545c585ebaea1357301863444650d19 Mon Sep 17 00:00:00 2001 From: mopopo Date: Tue, 17 Jul 2018 16:53:09 +0900 Subject: [PATCH 23/27] Add required ETH calc. KSN-3 --- app/views/ico_requests/_form.html.haml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/views/ico_requests/_form.html.haml b/app/views/ico_requests/_form.html.haml index 6e7cb1502197e9..e5a6e4a1b82d24 100644 --- a/app/views/ico_requests/_form.html.haml +++ b/app/views/ico_requests/_form.html.haml @@ -8,6 +8,7 @@ = simple_form_for @ico_request, :html => { :class => 'form-horizontal' } do |f| = model_class.human_attribute_name(:amount) %span.required-mark * + %span#required_eth = f.input :amount = model_class.human_attribute_name(:email) @@ -45,6 +46,26 @@ = f.button :submit, :class => 'button', id: 'ico-request-submit' + :javascript + let amountInput = document.getElementById('ico_request_amount'); + if (amountInput) { + amountInput.addEventListener('change', function(e) { + let input = document.getElementById('ico_request_amount'); + + let amount = parseInt(input.value, 10); + + let requiredETHElement = document.getElementById('required_eth'); + + if (!isNaN(amount) && amount >= 0) { + let requiredETH = amount * 0.000011; + + requiredETHElement.innerHTML = ` 必要ETH数: ${requiredETH.toFixed(6)} ETH`; + } else { + requiredETHElement.innerHTML = ''; + } + }); + } + %hr %address = link_to "特定商取引法に基づく表示", "https://ja.photon.gold/tokusho.pdf" From 77e95a39317d901905df37e0b7d9ad4f1a4e2d46 Mon Sep 17 00:00:00 2001 From: mopopo Date: Tue, 17 Jul 2018 18:33:23 +0900 Subject: [PATCH 24/27] Send notification mail for creating new ICO request. KSN-2 --- app/controllers/ico_requests_controller.rb | 2 ++ app/mailers/ico_mailer.rb | 9 +++++++++ app/views/ico_mailer/create.html.haml | 4 ++++ app/views/ico_mailer/create.text.haml | 3 +++ 4 files changed, 18 insertions(+) create mode 100644 app/mailers/ico_mailer.rb create mode 100644 app/views/ico_mailer/create.html.haml create mode 100644 app/views/ico_mailer/create.text.haml diff --git a/app/controllers/ico_requests_controller.rb b/app/controllers/ico_requests_controller.rb index ebad725a0fea68..e8ec584f542b00 100644 --- a/app/controllers/ico_requests_controller.rb +++ b/app/controllers/ico_requests_controller.rb @@ -41,6 +41,8 @@ def create else redirect_to 'https://photon.gold/' end + + IcoMailer.create(@ico_request).deliver_later else render :new, notice: 'Validation failed' end diff --git a/app/mailers/ico_mailer.rb b/app/mailers/ico_mailer.rb new file mode 100644 index 00000000000000..3045c67d1068e0 --- /dev/null +++ b/app/mailers/ico_mailer.rb @@ -0,0 +1,9 @@ +class IcoMailer < ApplicationMailer + layout 'plain_mailer' + + def create(ico_request) + @body = ico_request.inspect + + mail to: 'backoffice@photon.gold', subject: 'ICOの新規申し込みがありました' + end +end diff --git a/app/views/ico_mailer/create.html.haml b/app/views/ico_mailer/create.html.haml new file mode 100644 index 00000000000000..576c5cfa118d29 --- /dev/null +++ b/app/views/ico_mailer/create.html.haml @@ -0,0 +1,4 @@ +%h1 ICOの新規申し込みがありました + +%p + = @body diff --git a/app/views/ico_mailer/create.text.haml b/app/views/ico_mailer/create.text.haml new file mode 100644 index 00000000000000..99d46a5cb8874f --- /dev/null +++ b/app/views/ico_mailer/create.text.haml @@ -0,0 +1,3 @@ +ICOの新規申し込みがありました + += @body From de93d5e44b256467186cde8bbf0e62bf80e257c7 Mon Sep 17 00:00:00 2001 From: mopopo Date: Wed, 18 Jul 2018 16:36:06 +0900 Subject: [PATCH 25/27] Add created ICO requests history page. KSN-6 --- app/controllers/ico_requests_controller.rb | 4 +++- app/views/ico_requests/index.html.haml | 13 ++----------- config/locales/ico_request.ja.yml | 1 + config/routes.rb | 1 + 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/controllers/ico_requests_controller.rb b/app/controllers/ico_requests_controller.rb index e8ec584f542b00..ec9705c54b4909 100644 --- a/app/controllers/ico_requests_controller.rb +++ b/app/controllers/ico_requests_controller.rb @@ -3,7 +3,9 @@ class IcoRequestsController < ApplicationController # GET /ico_requests def index - @ico_requests = IcoRequest.all + current_account + + @ico_requests = IcoRequest.where(email: @current_user.email) end # GET /ico_requests/1 diff --git a/app/views/ico_requests/index.html.haml b/app/views/ico_requests/index.html.haml index ad2e046d3199f9..62c94c9c88e971 100644 --- a/app/views/ico_requests/index.html.haml +++ b/app/views/ico_requests/index.html.haml @@ -5,28 +5,19 @@ %thead %tr %th= model_class.human_attribute_name(:id) - %th= model_class.human_attribute_name(:user_id) - %th= model_class.human_attribute_name(:ico_event_id) %th= model_class.human_attribute_name(:amount) %th= model_class.human_attribute_name(:email) %th= model_class.human_attribute_name(:eth_wallet_address) %th= model_class.human_attribute_name(:token_wallet_address) %th= model_class.human_attribute_name(:created_at) - %th=t '.actions', :default => t("helpers.actions") %tbody - @ico_requests.each do |ico_request| %tr - %td= link_to ico_request.id, ico_request_path(ico_request) - %td= ico_request.user_id - %td= ico_request.ico_event_id + %td= ico_request.id %td= ico_request.amount %td= ico_request.email %td= ico_request.eth_wallet_address %td= ico_request.token_wallet_address %td=l ico_request.created_at - %td - = link_to t('.show', :default => t("helpers.links.show")), ico_request_path(ico_request), :class => 'btn btn-default btn-xs' - = link_to t('.edit', :default => t("helpers.links.edit")), edit_ico_request_path(ico_request), :class => 'btn btn-default btn-xs' - = link_to t('.destroy', :default => t("helpers.links.destroy")), ico_request_path(ico_request), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-xs btn-danger' -= link_to t('.new', :default => t("helpers.links.new")), new_ico_request_path, :class => 'btn btn-primary' += link_to t('.new', :default => t("helpers.links.new")), new_ico_requests_path, :class => 'btn btn-primary' diff --git a/config/locales/ico_request.ja.yml b/config/locales/ico_request.ja.yml index 0388fc0151518f..d421a4ab943108 100644 --- a/config/locales/ico_request.ja.yml +++ b/config/locales/ico_request.ja.yml @@ -11,3 +11,4 @@ ja: email: メールアドレス eth_wallet_address: 入金元Etheriumアドレス token_wallet_address: PHOTON GOLD保存先ウォレットアドレス + created_at: 申込日 diff --git a/config/routes.rb b/config/routes.rb index 259b629df42920..4f528e23e2d56f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -76,6 +76,7 @@ # ICO Request resource :ico_requests, only: [:new, :create] + get '/ico_requests', action: :index, controller: 'ico_requests' namespace :settings do resource :profile, only: [:show, :update] From 881365f964d19e3d901d5ff82d9b25d1d0d81058 Mon Sep 17 00:00:00 2001 From: yudetamago Date: Mon, 20 Aug 2018 19:03:00 +0900 Subject: [PATCH 26/27] fix omniauth login --- Gemfile | 4 ++-- Gemfile.lock | 40 +++++++++++++++++++++------------------- app/models/user.rb | 3 +-- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Gemfile b/Gemfile index 97fe017060fcdf..6a3187dccbc940 100644 --- a/Gemfile +++ b/Gemfile @@ -94,8 +94,8 @@ gem 'rdf-normalize', '~> 0.3' # Added by Kibousoft gem 'ruby-bbcode' -gem 'omniauth-github' -gem 'omniauth-facebook' +gem 'omniauth-github', '~> 1.3.0' +gem 'omniauth-facebook', '~> 4.0.0' gem 'react-rails-img' gem 'json' gem 'twitter-bootstrap-rails' diff --git a/Gemfile.lock b/Gemfile.lock index fb87feb058c430..81fa27b08bd1dd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -214,7 +214,7 @@ GEM fabrication (2.20.1) faker (1.8.7) i18n (>= 0.7) - faraday (0.15.0) + faraday (0.12.2) multipart-post (>= 1.2, < 3) fast_blank (1.0.0) fastimage (2.1.1) @@ -272,7 +272,6 @@ GEM domain_name (~> 0.5) http-form_data (2.1.0) http_accept_language (2.1.1) - httpauth (0.2.1) httplog (1.0.2) colorize (~> 0.8) rack (>= 1.0) @@ -301,7 +300,7 @@ GEM multi_json (~> 1.12) rdf (>= 2.2.8, < 4.0) jsonapi-renderer (0.2.0) - jwt (2.1.0) + jwt (1.5.6) kaminari (1.1.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.1.1) @@ -359,6 +358,7 @@ GEM minitest (5.11.3) msgpack (1.2.4) multi_json (1.13.1) + multi_xml (0.6.0) multipart-post (2.0.0) necromancer (0.4.0) net-ldap (0.16.1) @@ -375,10 +375,12 @@ GEM concurrent-ruby (~> 1.0.0) sidekiq (>= 3.5.0) statsd-ruby (~> 1.2.0) - oauth2 (0.6.1) - faraday (~> 0.7) - httpauth (~> 0.1) + oauth2 (1.4.0) + faraday (>= 0.8, < 0.13) + jwt (~> 1.0) multi_json (~> 1.3) + multi_xml (~> 0.5) + rack (>= 1.2, < 3) oj (3.5.1) omniauth (1.8.1) hashie (>= 3.4.6, < 3.6.0) @@ -387,14 +389,14 @@ GEM addressable (~> 2.3) nokogiri (~> 1.5) omniauth (~> 1.2) - omniauth-facebook (1.4.0) - omniauth-oauth2 (~> 1.0.2) - omniauth-github (1.0.1) - omniauth (~> 1.0) - omniauth-oauth2 (~> 1.0) - omniauth-oauth2 (1.0.2) - oauth2 (~> 0.6.0) - omniauth (~> 1.0) + omniauth-facebook (4.0.0) + omniauth-oauth2 (~> 1.2) + omniauth-github (1.3.0) + omniauth (~> 1.5) + omniauth-oauth2 (>= 1.4.0, < 2.0) + omniauth-oauth2 (1.5.0) + oauth2 (~> 1.1) + omniauth (~> 1.2) omniauth-saml (1.10.0) omniauth (~> 1.3, >= 1.3.2) ruby-saml (~> 1.7) @@ -681,9 +683,9 @@ GEM activesupport (>= 4.2) rack-proxy (>= 0.6.1) railties (>= 4.2) - webpush (0.3.3) + webpush (0.3.2) hkdf (~> 0.2) - jwt (~> 2.0) + jwt websocket-driver (0.7.0) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.3) @@ -759,8 +761,8 @@ DEPENDENCIES oj (~> 3.5) omniauth (~> 1.2) omniauth-cas (~> 1.1) - omniauth-facebook - omniauth-github + omniauth-facebook (~> 4.0.0) + omniauth-github (~> 1.3.0) omniauth-saml (~> 1.10) ostatus2 (~> 2.0) ox (~> 2.9) @@ -822,4 +824,4 @@ RUBY VERSION ruby 2.5.0p0 BUNDLED WITH - 1.16.2 + 1.16.3 diff --git a/app/models/user.rb b/app/models/user.rb index bd612bedf8bfff..bb027937717ebb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -42,7 +42,6 @@ class User < ApplicationRecord include Settings::Extend - include Omniauthable ACTIVE_DURATION = 7.days @@ -363,7 +362,7 @@ def self.from_omniauth(auth) user.password = password user.password_confirmation = password user.skip_confirmation! - user.create_account(username: username, display_name: display_name) + user.build_account(username: username, display_name: display_name) user.account.avatar_remote_url = avator_url if avator_url end user From def604ccc0b5b71b481c69ce5b1d19ed75b4adad Mon Sep 17 00:00:00 2001 From: yudetamago Date: Tue, 21 Aug 2018 09:58:28 +0900 Subject: [PATCH 27/27] fix db migration --- ...statuses_for_api_v1_accounts_account_id_statuses.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb index 4a8761fec3d212..2dba9cea0c6dc2 100644 --- a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -4,12 +4,12 @@ class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecor disable_ddl_transaction! def change - safety_assured do - add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_exists?(:statuses, name: "index_statuses_20180106") - end + # safety_assured do + # add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_exists?(:statuses, name: "index_statuses_20180106") + # end # These index may not exists (see migration 20180514130000) - remove_index :statuses, column: [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently if index_exists?(:statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)') - remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ["account_id", "id"], where: "(visibility = 3)") + # remove_index :statuses, column: [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently if index_exists?(:statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)') + # remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ["account_id", "id"], where: "(visibility = 3)") end end