Skip to content

Commit

Permalink
Merge pull request #6 from betacraft/development
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
rtdp authored Aug 7, 2019
2 parents 9ecdb1b + c286721 commit 4b855a2
Show file tree
Hide file tree
Showing 17 changed files with 232 additions and 103 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ config/database.yml
.rvmrc
.idea
.env
.generators
.byebug_history
.ruby-version
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ gem 'listen', '~> 3.1', '>= 3.1.5'
gem 'uglifier', '>= 1.0.3'
#end

gem 'byebug', '~>11.0.1'
gem 'puma', '~> 4.0.1'
gem 'twitter', '~> 6.2.0'
#gem 'jquery-rails'
gem "devise", "~> 4.6.2"
gem "omniauth-twitter", "~> 0.0.8"
gem "omniauth", "~>1.9.0"
gem "omniauth-twitter", "~> 1.4.0"
gem "haml-rails", "~> 2.0.1"
gem "twitter-bootstrap-rails", "~> 4.0.0"
gem "redcarpet", "~> 1.17.2"
Expand Down
77 changes: 59 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
arbre (1.2.1)
activesupport (>= 3.0.0)
arel (9.0.0)
Expand All @@ -64,7 +66,9 @@ GEM
bcrypt (3.1.13)
bootsnap (1.4.4)
msgpack (~> 1.0)
buftok (0.2.0)
builder (3.2.3)
byebug (11.0.1)
commonjs (0.2.7)
concurrent-ruby (1.1.5)
crass (1.0.4)
Expand All @@ -74,10 +78,13 @@ GEM
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
dotenv (2.7.4)
dotenv-rails (2.7.4)
dotenv (= 2.7.4)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.5)
dotenv-rails (2.7.5)
dotenv (= 2.7.5)
railties (>= 3.2, < 6.1)
equalizer (0.0.11)
erubi (1.8.0)
erubis (2.7.0)
execjs (2.7.0)
Expand Down Expand Up @@ -105,13 +112,22 @@ GEM
haml (>= 4.0, < 6)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
http (3.3.0)
addressable (~> 2.3)
http-cookie (~> 1.0)
http-form_data (~> 2.0)
http_parser.rb (~> 0.6.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
http-form_data (2.1.1)
http_parser.rb (0.6.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
inherited_resources (1.10.0)
actionpack (>= 5.0, < 6.0)
inherited_resources (1.11.0)
actionpack (>= 5.0, < 6.1)
has_scope (~> 0.6)
railties (>= 5.0, < 6.0)
responders (~> 2.0)
railties (>= 5.0, < 6.1)
responders (>= 2, < 4)
jquery-rails (4.3.5)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand Down Expand Up @@ -146,13 +162,16 @@ GEM
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
msgpack (1.3.0)
multi_json (1.13.1)
msgpack (1.3.1)
multipart-post (2.1.1)
naught (1.1.0)
newrelic_rpm (6.5.0.357)
nio4r (2.4.0)
nokogiri (1.10.3)
Expand All @@ -164,11 +183,14 @@ GEM
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
omniauth-twitter (0.0.18)
multi_json (~> 1.3)
omniauth-oauth (~> 1.0)
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
orm_adapter (0.5.0)
pg (1.1.4)
public_suffix (3.1.1)
puma (4.0.1)
nio4r (~> 2.0)
pygmentize (0.0.3)
rack (2.0.7)
rack-test (1.1.0)
Expand All @@ -189,7 +211,7 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
rails-html-sanitizer (1.1.0)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.3)
actionpack (= 5.2.3)
Expand All @@ -207,9 +229,9 @@ GEM
rb-inotify (0.10.0)
ffi (~> 1.0)
redcarpet (1.17.2)
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
ruby_dep (1.5.0)
ruby_parser (3.13.1)
sexp_processor (~> 4.9)
Expand All @@ -223,6 +245,7 @@ GEM
sprockets-rails
tilt
sexp_processor (4.12.1)
simple_oauth (0.3.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -238,6 +261,17 @@ GEM
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.9)
twitter (6.2.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
equalizer (~> 0.0.11)
http (~> 3.0)
http-form_data (~> 2.0)
http_parser.rb (~> 0.6.0)
memoizable (~> 0.4.0)
multipart-post (~> 2.0)
naught (~> 1.0)
simple_oauth (~> 0.3.0)
twitter-bootstrap-rails (4.0.0)
actionpack (~> 5.0, >= 5.0.1)
execjs (~> 2.7)
Expand All @@ -247,6 +281,9 @@ GEM
thread_safe (~> 0.1)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
warden (1.2.8)
rack (>= 2.0.6)
websocket-driver (0.7.1)
Expand All @@ -259,22 +296,26 @@ PLATFORMS
DEPENDENCIES
activeadmin (~> 2.2.0)
bootsnap (~> 1.4, >= 1.4.4)
byebug (~> 11.0.1)
devise (~> 4.6.2)
dotenv-rails (~> 2.7, >= 2.7.4)
haml-rails (~> 2.0.1)
listen (~> 3.1, >= 3.1.5)
newrelic_rpm
nokogiri (~> 1.10.3)
omniauth-twitter (~> 0.0.8)
omniauth (~> 1.9.0)
omniauth-twitter (~> 1.4.0)
pg
puma (~> 4.0.1)
pygmentize (~> 0.0.3)
rails (= 5.2.3)
redcarpet (~> 1.17.2)
twitter (~> 6.2.0)
twitter-bootstrap-rails (~> 4.0.0)
uglifier (>= 1.0.3)

RUBY VERSION
ruby 2.4.0p0

BUNDLED WITH
1.17.3
2.0.2
98 changes: 54 additions & 44 deletions app/admin/dashboards.rb
Original file line number Diff line number Diff line change
@@ -1,44 +1,54 @@
# ActiveAdmin::Dashboards.build do
#
# # Define your dashboard sections here. Each block will be
# # rendered on the dashboard in the context of the view. So just
# # return the content which you would like to display.
#
# # == Simple Dashboard Section
# # Here is an example of a simple dashboard section
# #
# # section "Recent Posts" do
# # ul do
# # Post.recent(5).collect do |post|
# # li link_to(post.title, admin_post_path(post))
# # end
# # end
# # end
#
# # == Render Partial Section
# # The block is rendered within the context of the view, so you can
# # easily render a partial rather than build content in ruby.
# #
# # section "Recent Posts" do
# # div do
# # render 'recent_posts' # => this will render /app/views/admin/dashboard/_recent_posts.html.erb
# # end
# # end
#
# # == Section Ordering
# # The dashboard sections are ordered by a given priority from top left to
# # bottom right. The default priority is 10. By giving a section numerically lower
# # priority it will be sorted higher. For example:
# #
# # section "Recent Posts", :priority => 10
# # section "Recent User", :priority => 1
# #
# # Will render the "Recent Users" then the "Recent Posts" sections on the dashboard.
#
# # == Conditionally Display
# # Provide a method name or Proc object to conditionally render a section at run time.
# #
# # section "Membership Summary", :if => :memberships_enabled?
# # section "Membership Summary", :if => Proc.new { current_admin_user.account.memberships.any? }
#
# end
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }

content title: proc { I18n.t("active_admin.dashboard") } do
div class: "blank_slate_container", id: "dashboard_default_message" do
span class: "blank_slate" do
span I18n.t("active_admin.dashboard_welcome.welcome")
small I18n.t("active_admin.dashboard_welcome.call_to_action")
end
end

# Define your dashboard sections here. Each block will be
# rendered on the dashboard in the context of the view. So just
# return the content which you would like to display.

# == Simple Dashboard Section
# Here is an example of a simple dashboard section
#
# section "Recent Posts" do
# ul do
# Post.recent(5).collect do |post|
# li link_to(post.title, admin_post_path(post))
# end
# end
# end

# == Render Partial Section
# The block is rendered within the context of the view, so you can
# easily render a partial rather than build content in ruby.
#
# section "Recent Posts" do
# div do
# render 'recent_posts' # => this will render /app/views/admin/dashboard/_recent_posts.html.erb
# end
# end

# == Section Ordering
# The dashboard sections are ordered by a given priority from top left to
# bottom right. The default priority is 10. By giving a section numerically lower
# priority it will be sorted higher. For example:
#
# section "Recent Posts", :priority => 10
# section "Recent User", :priority => 1
#
# Will render the "Recent Users" then the "Recent Posts" sections on the dashboard.

# == Conditionally Display
# Provide a method name or Proc object to conditionally render a section at run time.
#
# section "Membership Summary", :if => :memberships_enabled?
# section "Membership Summary", :if => Proc.new { current_admin_user.account.memberships.any? }

end
end
2 changes: 1 addition & 1 deletion app/admin/letter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
l.likes.count
end
column :created_at
default_actions
actions
end

end
2 changes: 1 addition & 1 deletion app/admin/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
column :likes do |user|
user.likes.count
end
default_actions
actions
end

end
8 changes: 7 additions & 1 deletion app/controllers/letters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class LettersController < ApplicationController
before_action :authenticate_user!, :except => [:show]

def create
@letter = current_user.letters.new(params[:letter])
@letter = current_user.letters.new(letter_params)
if @letter.save
flash[:notice] = t('flash.saved_letter_successfully')
redirect_to letter_path(@letter)
Expand Down Expand Up @@ -42,4 +42,10 @@ def like
render :json => { success: false, message: 'Error saving like ..' }
end
end

private

def letter_params
params.require(:letter).permit(:description)
end
end
3 changes: 2 additions & 1 deletion app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController

def twitter
# You need to implement the method below in your model

@user = User.find_for_twitter_oauth(request.env["omniauth.auth"])

if @user.persisted?
Expand All @@ -12,5 +13,5 @@ def twitter
flash[:error] = t('flash.error_signing_in')
redirect_to root_path
end
end
end
end
7 changes: 5 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :registerable, :rememberable, :trackable, :omniauthable, :database_authenticatable
devise :registerable, :rememberable, :trackable, :database_authenticatable, :omniauthable,
omniauth_providers: [:twitter]

# Setup accessible (or protected) attributes for your model
# attr_accessible :remember_me, :name, :twitter_handle, :twitter_description, :twitter_description, :twitter_oauth, :website, :image
Expand All @@ -11,12 +12,14 @@ class User < ActiveRecord::Base

class << self
def find_for_twitter_oauth(auth)
user = User.find_by_twitter_oauth(auth["credentials"]["token"])
user = User.where(uid: auth.uid, provider: auth.provider).first

if user
user
else
User.create(
uid: auth["uid"],
provider: auth["provider"],
name: auth["info"]["name"],
twitter_handle: auth["info"]["nickname"],
twitter_description: auth["info"]["description"],
Expand Down
Loading

0 comments on commit 4b855a2

Please sign in to comment.