platformx 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +31 -0
- data/Rakefile +20 -0
- data/lib/platformx.rb +106 -0
- data/lib/platformx/auth.rb +74 -0
- data/lib/platformx/configuration.rb +35 -0
- data/lib/platformx/date.rb +96 -0
- data/lib/platformx/facebook.rb +16 -0
- data/lib/platformx/faker.rb +100 -0
- data/lib/platformx/form.rb +953 -0
- data/lib/platformx/google_map.rb +42 -0
- data/lib/platformx/instagram.rb +115 -0
- data/lib/platformx/layout.rb +155 -0
- data/lib/platformx/mail.rb +43 -0
- data/lib/platformx/notify.rb +45 -0
- data/lib/platformx/omniauth_helpers.rb +16 -0
- data/lib/platformx/omniauth_routes.rb +64 -0
- data/lib/platformx/pdf.rb +0 -0
- data/lib/platformx/stripe.rb +65 -0
- data/lib/platformx/template.rb +16 -0
- data/lib/platformx/text.rb +32 -0
- data/lib/platformx/timeline.rb +55 -0
- data/lib/platformx/twitter.rb +47 -0
- data/lib/platformx/version.rb +3 -0
- data/platformx.gemspec +48 -0
- data/spec/layout_spec.rb +19 -0
- data/spec/spec_helper.rb +16 -0
- metadata +426 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
module Platformx
|
2
|
+
module GooglemapHelpers
|
3
|
+
########################################################
|
4
|
+
#
|
5
|
+
# Start Helpers
|
6
|
+
#
|
7
|
+
########################################################
|
8
|
+
|
9
|
+
# Start Google Map
|
10
|
+
def x_google_map(css: "", id: "map", address: "", address_2:"", city:"", state:"", zip:"", zoom:"12", height: "400px", width: "520px")
|
11
|
+
|
12
|
+
|
13
|
+
geo=Geokit::Geocoders::GoogleGeocoder.geocode "#{address} #{address_2}, #{city} #{state} #{zip}"
|
14
|
+
#Get Lat & long
|
15
|
+
|
16
|
+
cb = <<EOS
|
17
|
+
<script src="https://maps.googleapis.com/maps/api/js"></script>
|
18
|
+
<script>
|
19
|
+
function initialize() {
|
20
|
+
var mapCanvas = document.getElementById('#{id}');
|
21
|
+
var mapOptions = {
|
22
|
+
center: new google.maps.LatLng(#{geo.ll}),
|
23
|
+
zoom: #{zoom},
|
24
|
+
mapTypeId: google.maps.MapTypeId.ROADMAP
|
25
|
+
}
|
26
|
+
var map = new google.maps.Map(mapCanvas, mapOptions)
|
27
|
+
}
|
28
|
+
google.maps.event.addDomListener(window, 'load', initialize);
|
29
|
+
</script>
|
30
|
+
|
31
|
+
<div id="#{id}" class="#{css}"></div>
|
32
|
+
|
33
|
+
EOS
|
34
|
+
|
35
|
+
end
|
36
|
+
########################################################
|
37
|
+
#
|
38
|
+
# End
|
39
|
+
#
|
40
|
+
########################################################
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
module Platformx
|
2
|
+
module InstagramHelpers
|
3
|
+
########################################################
|
4
|
+
#
|
5
|
+
# Start Helpers
|
6
|
+
#
|
7
|
+
########################################################
|
8
|
+
|
9
|
+
# def self.init
|
10
|
+
# Instagram.configure do |config|
|
11
|
+
# config.client_id = Platformx.configuration.instagram_key
|
12
|
+
# config.client_secret = Platformx.configuration.instagram_secret
|
13
|
+
# # For secured endpoints only
|
14
|
+
# #config.client_ips = '<Comma separated list of IPs>'
|
15
|
+
# end
|
16
|
+
# @client = Instagram.client(access_token: access_token)
|
17
|
+
|
18
|
+
# return @client
|
19
|
+
# end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
########################### Get Recent Feed ############################
|
24
|
+
|
25
|
+
def x_instagram_recent(access_token: "")
|
26
|
+
@client = Instagram.client(access_token: access_token)
|
27
|
+
user = @client.user
|
28
|
+
|
29
|
+
@feed = []
|
30
|
+
|
31
|
+
for media_item in @client.user_recent_media
|
32
|
+
|
33
|
+
item = {
|
34
|
+
:thumb_url => media_item.images.thumbnail.url,
|
35
|
+
:id => media_item.id,
|
36
|
+
:likes => media_item.likes[:count]
|
37
|
+
}
|
38
|
+
|
39
|
+
@feed.push(item)
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
return @feed
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
########################### Search by Location ID ############################
|
48
|
+
|
49
|
+
# def x_instagram_by_location(access_token: "", location_id: "")
|
50
|
+
# html = "<h1>Media</h1>"
|
51
|
+
|
52
|
+
# for media_item in @client.location_recent_media(location_id)
|
53
|
+
# html << "<img src='#{media_item.images.thumbnail.url}'>"
|
54
|
+
# end
|
55
|
+
# return html
|
56
|
+
|
57
|
+
# end
|
58
|
+
|
59
|
+
# ########################### Search By Lat/Long ############################
|
60
|
+
# def x_instagram_by_lat_long(access_token: "", latitude: "", longitude: "")
|
61
|
+
# html = "<h1>Get a list of media close to a given latitude and longitude</h1>"
|
62
|
+
|
63
|
+
# for media_item in @client.media_search(latitude,longitude)
|
64
|
+
# html << "<img src='#{media_item.images.thumbnail.url}'>"
|
65
|
+
# end
|
66
|
+
|
67
|
+
# return html
|
68
|
+
# end
|
69
|
+
|
70
|
+
# ########################### Nearby Locations ############################
|
71
|
+
# def x_instagram_nearby_locations(access_token: "", latitude: "", longitude: "", radius: "5000")
|
72
|
+
# html = "<h1>Search for a location by lat/lng with a radius of #{radius}m</h1>"
|
73
|
+
# for location in @client.location_search(latitude,longitude,radius)
|
74
|
+
# html << "<li> #{location.name} <a href='https://www.google.com/maps/preview/@#{location.latitude},#{location.longitude},19z'>Map</a></li>"
|
75
|
+
# end
|
76
|
+
# return html
|
77
|
+
|
78
|
+
# end
|
79
|
+
|
80
|
+
# ########################### Search by tag ############################
|
81
|
+
# def x_instagram_tag(access_token: "", tag: "")
|
82
|
+
# html = "<h1>Search for #{tag}</h1>"
|
83
|
+
# tags = @client.tag_search(tag)
|
84
|
+
# html << "<h2>Tag Name = #{tags[0].name}. Media Count = #{tags[0].media_count}. </h2><br/><br/>"
|
85
|
+
# for media_item in @client.tag_recent_media(tags[0].name)
|
86
|
+
# html << "<img src='#{media_item.images.thumbnail.url}'>"
|
87
|
+
# end
|
88
|
+
# return html
|
89
|
+
|
90
|
+
# end
|
91
|
+
|
92
|
+
# ########################### User Search ############################
|
93
|
+
# def x_instagram_user(access_token: "", user: "")
|
94
|
+
# html = "<h1>Search for #{user}</h1>"
|
95
|
+
# for user in @client.user_search(user)
|
96
|
+
# html << "<li> <img src='#{user.profile_picture}'> #{user.username} #{user.full_name}</li>"
|
97
|
+
# end
|
98
|
+
# return html
|
99
|
+
# end
|
100
|
+
|
101
|
+
# ########################### Limits ############################
|
102
|
+
# def x_instagram_limits(access_token: "")
|
103
|
+
# html = "<h1/>View API Rate Limit and calls remaining</h1>"
|
104
|
+
# response = @client.utils_raw_response
|
105
|
+
# html << "Rate Limit = #{response.headers[:x_ratelimit_limit]}. <br/>Calls Remaining = #{response.headers[:x_ratelimit_remaining]}"
|
106
|
+
|
107
|
+
# return html
|
108
|
+
# end
|
109
|
+
########################################################
|
110
|
+
#
|
111
|
+
# End
|
112
|
+
#
|
113
|
+
########################################################
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
module Platformx
|
2
|
+
module LayoutHelpers
|
3
|
+
########################################################
|
4
|
+
#
|
5
|
+
# Start Helpers
|
6
|
+
#
|
7
|
+
########################################################
|
8
|
+
########################################################
|
9
|
+
#
|
10
|
+
# Panel
|
11
|
+
#
|
12
|
+
########################################################
|
13
|
+
def x_panel_top(title: "", panel_class: "")
|
14
|
+
if title != ""
|
15
|
+
title=<<EOS
|
16
|
+
<div class="panel-heading">
|
17
|
+
<h3 class="panel-title">#{title}</h3>
|
18
|
+
</div>
|
19
|
+
EOS
|
20
|
+
end
|
21
|
+
panel =<<EOS
|
22
|
+
<div class="panel #{panel_class}">
|
23
|
+
#{title}
|
24
|
+
<div class="panel-body">
|
25
|
+
EOS
|
26
|
+
return panel
|
27
|
+
end
|
28
|
+
|
29
|
+
def x_panel_bottom
|
30
|
+
panel =<<EOS
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
EOS
|
34
|
+
return panel
|
35
|
+
end
|
36
|
+
|
37
|
+
########################################################
|
38
|
+
#
|
39
|
+
# Card
|
40
|
+
#
|
41
|
+
########################################################
|
42
|
+
def x_card_top(title: "",subtitle: "", card_class: "", header_css: "", buttons: "")
|
43
|
+
if title != ""
|
44
|
+
title=<<EOS
|
45
|
+
<div class="header #{header_css}">
|
46
|
+
<h4 class="title pull-left">#{title}</h4>
|
47
|
+
<div class="pull-right title_right">#{buttons}</div>
|
48
|
+
<div class="clearfix"></div>
|
49
|
+
<p class="category">#{subtitle}</p>
|
50
|
+
</div>
|
51
|
+
EOS
|
52
|
+
end
|
53
|
+
panel =<<EOS
|
54
|
+
<div class="card #{card_class}">
|
55
|
+
#{title}
|
56
|
+
<div class="content">
|
57
|
+
EOS
|
58
|
+
return panel
|
59
|
+
end
|
60
|
+
|
61
|
+
def x_card_bottom
|
62
|
+
panel =<<EOS
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
EOS
|
66
|
+
return panel
|
67
|
+
end
|
68
|
+
|
69
|
+
########################################################
|
70
|
+
#
|
71
|
+
# Gravitar
|
72
|
+
#
|
73
|
+
########################################################
|
74
|
+
|
75
|
+
def x_gravitar(email: "")
|
76
|
+
hash = ""
|
77
|
+
|
78
|
+
if !email.nil?
|
79
|
+
# get the email from URL-parameters or what have you and make lowercase
|
80
|
+
email_address = email.downcase
|
81
|
+
|
82
|
+
# create the md5 hash
|
83
|
+
hash = Digest::MD5.hexdigest(email_address)
|
84
|
+
end
|
85
|
+
# compile URL which can be used in <img src="RIGHT_HERE"...
|
86
|
+
image_src = "https://www.gravatar.com/avatar/#{hash}?d=mm"
|
87
|
+
|
88
|
+
return image_src
|
89
|
+
end
|
90
|
+
|
91
|
+
########################################################
|
92
|
+
#
|
93
|
+
# Student Tabs Nav
|
94
|
+
#
|
95
|
+
########################################################
|
96
|
+
def x_tabs(active: "", tabs: array)
|
97
|
+
|
98
|
+
tab_builder = ""
|
99
|
+
|
100
|
+
tabs.each do |t|
|
101
|
+
s = ""
|
102
|
+
if t[:name] == active
|
103
|
+
active_s = "active"
|
104
|
+
else
|
105
|
+
active_s = ""
|
106
|
+
end
|
107
|
+
s =<<EOS
|
108
|
+
<li class="#{active_s}">
|
109
|
+
<a href="#{t[:url]}"><i class="fa #{t[:icon]}"></i> #{t[:name]}</a>
|
110
|
+
</li>
|
111
|
+
EOS
|
112
|
+
tab_builder << s
|
113
|
+
end
|
114
|
+
|
115
|
+
tab_wrapper =<<EOS
|
116
|
+
<div class="tabs_wrapper">
|
117
|
+
<ul class="nav nav-tabs" role="tablist">
|
118
|
+
#{tab_builder}
|
119
|
+
</ul>
|
120
|
+
</div>
|
121
|
+
EOS
|
122
|
+
|
123
|
+
return tab_wrapper
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
########################################################
|
128
|
+
#
|
129
|
+
# Dashboard Number Widget
|
130
|
+
#
|
131
|
+
########################################################
|
132
|
+
def x_number_widget(label: "", value: "", icon: "")
|
133
|
+
|
134
|
+
icon_html = ""
|
135
|
+
unless icon == ""
|
136
|
+
icon_html = "<i class='fa #{icon}'></i> "
|
137
|
+
end
|
138
|
+
|
139
|
+
widget =<<EOS
|
140
|
+
<div class="x_number_widget_wrapper">
|
141
|
+
<div class="x_number_widget_value">#{value}</div>
|
142
|
+
<div class="x_number_widget_label">#{icon_html}#{label}</div>
|
143
|
+
</div>
|
144
|
+
EOS
|
145
|
+
|
146
|
+
return widget
|
147
|
+
|
148
|
+
end
|
149
|
+
########################################################
|
150
|
+
#
|
151
|
+
# End
|
152
|
+
#
|
153
|
+
########################################################
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Platformx
|
2
|
+
module Mail
|
3
|
+
|
4
|
+
########################################################
|
5
|
+
#
|
6
|
+
# Conig
|
7
|
+
#
|
8
|
+
########################################################
|
9
|
+
def self.init
|
10
|
+
#Pony Configs
|
11
|
+
Pony.options = {
|
12
|
+
:from => Platformx.configuration.mail_from,
|
13
|
+
:via => :smtp,
|
14
|
+
:via_options => {
|
15
|
+
:from => Platformx.configuration.mail_from,
|
16
|
+
:address => Platformx.configuration.mail_address,
|
17
|
+
:port => Platformx.configuration.mail_port,
|
18
|
+
:domain => Platformx.configuration.mail_domain,
|
19
|
+
:user_name => Platformx.configuration.mail_user_name,
|
20
|
+
:enable_starttls_auto => true,
|
21
|
+
:password => Platformx.configuration.mail_password,
|
22
|
+
:authentication => :login
|
23
|
+
}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
########################################################
|
28
|
+
#
|
29
|
+
# Mail
|
30
|
+
#
|
31
|
+
########################################################
|
32
|
+
def self.mail(to: "", cc: "", subject: "", html_body: "")
|
33
|
+
init
|
34
|
+
Pony.mail(
|
35
|
+
to: to,
|
36
|
+
cc: cc,
|
37
|
+
subject: subject,
|
38
|
+
html_body: html_body
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Platformx
|
2
|
+
module NotifyHelpers
|
3
|
+
########################################################
|
4
|
+
#
|
5
|
+
# Start Helpers
|
6
|
+
#
|
7
|
+
########################################################
|
8
|
+
def x_notify(flash: "", timer: 4000, align: "right", from:"top")
|
9
|
+
|
10
|
+
color = "success"
|
11
|
+
message = ""
|
12
|
+
|
13
|
+
if !flash[:success].nil?
|
14
|
+
message = flash[:success]
|
15
|
+
color = "success"
|
16
|
+
end
|
17
|
+
|
18
|
+
if !flash[:notice].nil?
|
19
|
+
message = flash[:notice]
|
20
|
+
color = "warning"
|
21
|
+
end
|
22
|
+
|
23
|
+
if !flash[:error].nil?
|
24
|
+
message = flash[:error]
|
25
|
+
color = "danger"
|
26
|
+
end
|
27
|
+
|
28
|
+
unless message == ""
|
29
|
+
cb = <<EOS
|
30
|
+
<script>
|
31
|
+
$().ready(function(){$.notify({message: "#{message}"},{type: "#{color}",timer: #{timer}, placement: {from: "#{from}",align: "#{align}"}});});
|
32
|
+
</script>
|
33
|
+
EOS
|
34
|
+
return cb
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
########################################################
|
40
|
+
#
|
41
|
+
# End
|
42
|
+
#
|
43
|
+
########################################################
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Platformx
|
2
|
+
module OmniauthHelpers
|
3
|
+
########################################################
|
4
|
+
#
|
5
|
+
# Start Helpers
|
6
|
+
#
|
7
|
+
########################################################
|
8
|
+
|
9
|
+
|
10
|
+
########################################################
|
11
|
+
#
|
12
|
+
# End
|
13
|
+
#
|
14
|
+
########################################################
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Platformx
|
2
|
+
module OmniauthRoutes
|
3
|
+
|
4
|
+
def self.registered(app)
|
5
|
+
########################################################
|
6
|
+
#
|
7
|
+
# Start Method
|
8
|
+
#
|
9
|
+
########################################################
|
10
|
+
|
11
|
+
app.get '/omniauth-test/?' do
|
12
|
+
"Yes!"
|
13
|
+
end
|
14
|
+
|
15
|
+
app.get '/auth/facebook/callback/?' do
|
16
|
+
session[:facebook_token] = request.env['omniauth.auth']['credentials']['token']
|
17
|
+
session[:facebook_token_expires_at] = request.env['omniauth.auth']['credentials']['expires_at']
|
18
|
+
session[:facebook_uid] = request.env['omniauth.auth']['uid']
|
19
|
+
redirect Platformx.configuration.facebook_callback_redirect_url
|
20
|
+
end
|
21
|
+
|
22
|
+
app.get '/auth/instagram/callback/?' do
|
23
|
+
session[:instagram_token] = request.env['omniauth.auth']['credentials']['token']
|
24
|
+
session[:instagram_image] = request.env['omniauth.auth']['info']['image']
|
25
|
+
session[:instagram_uid] = request.env['omniauth.auth']['uid']
|
26
|
+
session[:instagram_nickname] = request.env['omniauth.auth']['info']['nickname']
|
27
|
+
redirect Platformx.configuration.instagram_callback_redirect_url
|
28
|
+
end
|
29
|
+
|
30
|
+
app.get '/auth/twitter/callback/?' do
|
31
|
+
session[:twitter_token] = request.env['omniauth.auth']['credentials']['token']
|
32
|
+
session[:twitter_secret] = request.env['omniauth.auth']['credentials']['secret']
|
33
|
+
session[:twitter_uid] = request.env['omniauth.auth']['uid']
|
34
|
+
session[:twitter_screenname] = request.env['omniauth.auth']['extra']['raw_info']['screen_name']
|
35
|
+
session[:twitter_followers] = request.env['omniauth.auth']['extra']['raw_info']['followers_count']
|
36
|
+
session[:twitter_friends] = request.env['omniauth.auth']['extra']['raw_info']['friends_count']
|
37
|
+
session[:twitter_background] = request.env['omniauth.auth']['extra']['raw_info']['profile_background_image_url_https']
|
38
|
+
session[:twitter_image] = request.env['omniauth.auth']['extra']['raw_info']['profile_image_url_https']
|
39
|
+
session[:twitter_description] = request.env['omniauth.auth']['info']['description']
|
40
|
+
session[:twitter_url] = request.env['omniauth.auth']['info']['urls']['Twitter']
|
41
|
+
redirect Platformx.configuration.twitter_callback_redirect_url
|
42
|
+
end
|
43
|
+
|
44
|
+
app.get '/auth/failure' do
|
45
|
+
erb "<br><br><br><br><h1>Authentication Failed:</h1><h3>message:<h3> <pre>#{params}</pre>"
|
46
|
+
end
|
47
|
+
|
48
|
+
app.get '/auth/:provider/deauthorized' do
|
49
|
+
erb "#{params[:provider]} has deauthorized this app."
|
50
|
+
end
|
51
|
+
|
52
|
+
app.get '/logout' do
|
53
|
+
session[:authenticated] = false
|
54
|
+
redirect '/'
|
55
|
+
end
|
56
|
+
|
57
|
+
########################################################
|
58
|
+
#
|
59
|
+
# End Methods
|
60
|
+
#
|
61
|
+
########################################################
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|