Skip to content

Commit

Permalink
Merge pull request #1946 from cloudnativedaysjp/add-twitter-share-button
Browse files Browse the repository at this point in the history
Add twitter share button
  • Loading branch information
takaishi authored Jun 15, 2023
2 parents 9340647 + c9a153e commit b06da7c
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 33 deletions.
19 changes: 19 additions & 0 deletions app/controllers/attendee_dashboards_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class AttendeeDashboardsController < ApplicationController
include Secured
include SponsorHelper
before_action :set_profile, :set_speaker

def show
@conference = Conference.includes(:talks).find_by(abbr: event_name)
if @conference.opened?
redirect_to(tracks_path)
end

@announcements = @conference.announcements.published
@speaker_announcements = @conference.speaker_announcements.find_by_speaker(@speaker.id) unless @speaker.nil?
@talks = @conference.talks.eager_load(:talk_category, :talk_difficulty).all
@talk_categories = @conference.talk_categories
@talk_difficulties = @conference.talk_difficulties
@booths = @conference.booths.published
end
end
14 changes: 0 additions & 14 deletions app/controllers/tracks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@ def index
@booths = @conference.booths.published
end

def waiting
@conference = Conference.includes(:talks).find_by(abbr: event_name)
if @conference.opened?
redirect_to(tracks_path)
end

@announcements = @conference.announcements.published
@speaker_announcements = @conference.speaker_announcements.find_by_speaker(@speaker.id) unless @speaker.nil?
@talks = @conference.talks.eager_load(:talk_category, :talk_difficulty).all
@talk_categories = @conference.talk_categories
@talk_difficulties = @conference.talk_difficulties
@booths = @conference.booths.published
end

def reload
ActionCable.server.broadcast('waiting_channel', 'aaa');
render(plain: 'OK')
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/packs/attendee_dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$(document).on('click', '#twitter_share', function(event) {
const content = document.getElementById("tweet_content")
window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(content.value)}`);
});
1 change: 1 addition & 0 deletions app/javascript/packs/cndf2023.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import './contents.js'
import './speaker_form.js'
import './cropbox.js'
import './timetable.js'
import './attendee_dashboard.js'

require.context('images', true, /\.(png|jpg|jpeg|svg)$/)

Expand Down
8 changes: 4 additions & 4 deletions app/models/conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
# id :bigint not null, primary key
# abbr :string(255)
# about :text(65535)
# attendee_entry :integer
# attendee_entry :integer default("attendee_entry_disabled")
# brief :string(255)
# cfp_result_visible :boolean default(FALSE)
# coc :text(65535)
# committee_name :string(255) default("CloudNative Days Committee"), not null
# conference_status :string(255) default(NULL)
# conference_status :string(255) default("registered")
# copyright :string(255)
# name :string(255)
# privacy_policy :text(65535)
# privacy_policy_for_speaker :text(65535)
# show_sponsors :boolean default(FALSE)
# show_timetable :integer
# speaker_entry :integer
# show_timetable :integer default("show_timetable_disabled")
# speaker_entry :integer default("speaker_entry_disabled")
# theme :text(65535)
# created_at :datetime not null
# updated_at :datetime not null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,24 @@
<b>チケット</b>
</div>
<div class="card-body">
<div class="card-text">あなたは <%= @profile.active_order.tickets.first.title %> です</div>
<div class="card-text">
あなたは <%= @profile.active_order.tickets.first.title %> です</div>
<div class="card-text">チケットの変更は <%= link_to 'こちら', new_cancel_order_path(order_id: @profile.active_order.id) %> から</div>
<div class="card-text">
<div class="card">
<div class="card-body">
<div class="card-text">
Twitterでシェアしよう!
</div>
<div class="card-text">
<input type="text" id="tweet_content" class="form-control" value="<%= "##{@conference.abbr.upcase}#{@profile.active_order.tickets.first.title} で参加申し込みしました! https://event.cloudnativedays.jp/#{@conference.abbr}" %>" />
</div>
</div>
<div class="card-text text-center mb-3">
<button type="button" id="twitter_share" class="btn btn-secondary">Twitterでシェア</button>
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
resources :talks, only: [:show, :index]
get 'timetables' => 'timetable#index'
get 'timetables/:date' => 'timetable#index'
get 'dashboard' => 'tracks#waiting'
get 'dashboard' => 'attendee_dashboards#show'
get 'tracks/blank' => 'tracks#blank'
get 'kontest' => 'contents#kontest'
get 'discussion' => 'contents#discussion'
Expand Down
8 changes: 8 additions & 0 deletions db/migrate/20230611015850_add_default_values_to_conference.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class AddDefaultValuesToConference < ActiveRecord::Migration[7.0]
def change
change_column :conferences, :conference_status, :string, default: Conference::STATUS_REGISTERED
change_column :conferences, :speaker_entry, :integer, default: 0
change_column :conferences, :attendee_entry, :integer, default: 0
change_column :conferences, :show_timetable, :integer, default: 0
end
end
10 changes: 5 additions & 5 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_05_28_051104) do
ActiveRecord::Schema[7.0].define(version: 2023_06_11_015850) do
create_table "access_logs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name"
t.string "sub"
Expand Down Expand Up @@ -124,14 +124,14 @@
t.text "coc"
t.string "copyright"
t.text "privacy_policy_for_speaker"
t.integer "speaker_entry"
t.integer "attendee_entry"
t.integer "show_timetable"
t.integer "speaker_entry", default: 0
t.integer "attendee_entry", default: 0
t.integer "show_timetable", default: 0
t.boolean "cfp_result_visible", default: false
t.boolean "show_sponsors", default: false
t.string "brief"
t.string "committee_name", default: "CloudNative Days Committee", null: false
t.string "conference_status", default: ""
t.string "conference_status", default: "registered"
t.index ["abbr", "conference_status"], name: "index_conferences_on_abbr_and_conference_status"
t.index ["abbr"], name: "index_conferences_on_abbr"
end
Expand Down
8 changes: 4 additions & 4 deletions spec/factories/conferences.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
# id :bigint not null, primary key
# abbr :string(255)
# about :text(65535)
# attendee_entry :integer
# attendee_entry :integer default("attendee_entry_disabled")
# brief :string(255)
# cfp_result_visible :boolean default(FALSE)
# coc :text(65535)
# committee_name :string(255) default("CloudNative Days Committee"), not null
# conference_status :string(255) default(NULL)
# conference_status :string(255) default("registered")
# copyright :string(255)
# name :string(255)
# privacy_policy :text(65535)
# privacy_policy_for_speaker :text(65535)
# show_sponsors :boolean default(FALSE)
# show_timetable :integer
# speaker_entry :integer
# show_timetable :integer default("show_timetable_disabled")
# speaker_entry :integer default("speaker_entry_disabled")
# theme :text(65535)
# created_at :datetime not null
# updated_at :datetime not null
Expand Down
8 changes: 4 additions & 4 deletions spec/models/conference_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
# id :bigint not null, primary key
# abbr :string(255)
# about :text(65535)
# attendee_entry :integer
# attendee_entry :integer default("attendee_entry_disabled")
# brief :string(255)
# cfp_result_visible :boolean default(FALSE)
# coc :text(65535)
# committee_name :string(255) default("CloudNative Days Committee"), not null
# conference_status :string(255) default(NULL)
# conference_status :string(255) default("registered")
# copyright :string(255)
# name :string(255)
# privacy_policy :text(65535)
# privacy_policy_for_speaker :text(65535)
# show_sponsors :boolean default(FALSE)
# show_timetable :integer
# speaker_entry :integer
# show_timetable :integer default("show_timetable_disabled")
# speaker_entry :integer default("speaker_entry_disabled")
# theme :text(65535)
# created_at :datetime not null
# updated_at :datetime not null
Expand Down

0 comments on commit b06da7c

Please sign in to comment.