Skip to content

Commit

Permalink
Allow free users to edit entries
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Oct 5, 2024
1 parent 6c81915 commit 688f2ce
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 17 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ gem 'file_validators'
gem 'fastimage'

# Miscellanea
gem 'google-analytics-rails'
gem 'staccato' # server side tracking for Google Analytics
gem 'tilt', '~> 2.0', '>= 2.0.10'
gem 'haml'
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ GEM
glob (0.4.1)
globalid (1.1.0)
activesupport (>= 5.0)
google-analytics-rails (1.1.1)
griddler (1.5.2)
htmlentities
rails (>= 3.2.0)
Expand Down Expand Up @@ -521,7 +520,6 @@ DEPENDENCIES
file_validators
fog-aws
gibbon
google-analytics-rails
griddler (~> 1.5.2)
griddler-mailgun (~> 1.1, >= 1.1.1)
groupdate
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def edit

def update
if current_user.is_free?
flash[:alert] = "<a href='#{subscribe_url}'' class='alert-link'>Subscribe to PRO</a> to edit entries.".html_safe
redirect_to root_path and return
params[:entry][:entry] = @entry.body
params[:entry][:image] = @entry.image
end

@existing_entry = current_user.existing_entry(params[:entry][:date].to_s)
Expand Down Expand Up @@ -312,8 +312,8 @@ def respond_to_ai

def track_ga_event(action)
if ENV['GOOGLE_ANALYTICS_ID'].present?
tracker = Staccato.tracker(ENV['GOOGLE_ANALYTICS_ID'])
tracker.event(category: 'Web Entry', action: action, label: current_user.user_key)
# tracker = Staccato.tracker(ENV['GOOGLE_ANALYTICS_ID'])
# tracker.event(category: 'Web Entry', action: action, label: current_user.user_key)
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def check_captcha
def track_ga_event
return nil unless user.id.present?
if ENV['GOOGLE_ANALYTICS_ID'].present?
tracker = Staccato.tracker(ENV['GOOGLE_ANALYTICS_ID'])
tracker.event(category: 'User', action: 'Create', label: user.user_key)
# tracker = Staccato.tracker(ENV['GOOGLE_ANALYTICS_ID'])
# tracker.event(category: 'User', action: 'Create', label: user.user_key)
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def check_captcha
def track_ga_event
return nil unless @user.id.present?
if ENV['GOOGLE_ANALYTICS_ID'].present?
tracker = Staccato.tracker(ENV['GOOGLE_ANALYTICS_ID'])
tracker.event(category: 'User', action: 'Login', label: @user.user_key)
# tracker = Staccato.tracker(ENV['GOOGLE_ANALYTICS_ID'])
# tracker.event(category: 'User', action: 'Login', label: @user.user_key)
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/lib/email_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ def respond_as_ai?

def track_ga_event(action)
if ENV['GOOGLE_ANALYTICS_ID'].present?
tracker = Staccato.tracker(ENV['GOOGLE_ANALYTICS_ID'])
tracker.event(category: 'Email Entry', action: action, label: @user.user_key)
# tracker = Staccato.tracker(ENV['GOOGLE_ANALYTICS_ID'])
# tracker.event(category: 'Email Entry', action: action, label: @user.user_key)
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/views/entries/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
to unlock the ability to edit entries.

.col-md-8.col-md-offset-2.well.s-new-edit-entry{id: "entry-#{@entry.id}"}
%div{class: add_class}
%div
.s-entry-date.s-new-entry
-if @entry.inspiration.present?
.float-left.s-edit-entry{rel: "popover", title: "#{@entry.inspiration.inspired_by}", data: { content: "#{@entry.inspiration.body.html_safe}" }}
Expand Down Expand Up @@ -39,7 +39,7 @@
= f.text_field :date, value: @entry.date_format_short, placeholder: "October 11 2014", class: "form-control pickadate"
%br

%div
%div{class: add_class}

- if @entry.image.present?
%label
Expand All @@ -54,7 +54,7 @@
= f.file_field :image, accept: "image/png,image/gif,image/jpeg,image/webp,image/heic,image/heif", multiple: true
%br

%div
%div{class: add_class}
= f.label :entry
= f.text_area :entry, class: "form-control summernote", rows: 15, value: format_body(@entry.formatted_body)

Expand Down
8 changes: 7 additions & 1 deletion app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
/[if lt IE 9]
= javascript_include_tag '//oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', 'respond.js'
= analytics_init(anonymize: true) if Rails.env.production?
= javascript_include_tag "https://www.googletagmanager.com/gtag/js?id=#{ENV['GOOGLE_ANALYTICS_4_ID']}", async: true
:javascript
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', "#{ENV['GOOGLE_ANALYTICS_4_ID']}");

- if Rails.env.production?
= javascript_include_tag "https://www.googletagmanager.com/gtag/js?id=#{ENV['GOOGLE_ANALYTICS_4_ID']}", async: true
Expand Down

0 comments on commit 688f2ce

Please sign in to comment.