pontiac 0.1.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 +15 -0
- data/MIT-LICENSE +20 -0
- data/README.md +32 -0
- data/Rakefile +27 -0
- data/app/controllers/pontiac/application_controller.rb +7 -0
- data/app/controllers/pontiac/omniauth_callbacks_controller.rb +25 -0
- data/app/controllers/pontiac/sessions_controller.rb +24 -0
- data/app/helpers/pontiac/application_helper.rb +19 -0
- data/app/models/secret_setting.rb +5 -0
- data/app/models/shop.rb +22 -0
- data/app/views/pontiac/sessions/new.html.haml +8 -0
- data/lib/generators/pontiac/USAGE +21 -0
- data/lib/generators/pontiac/pontiac_generator.rb +39 -0
- data/lib/generators/pontiac/templates/README +18 -0
- data/lib/generators/pontiac/templates/app/assets/javascripts/application.js.coffee +17 -0
- data/lib/generators/pontiac/templates/app/assets/stylesheets/application.css.scss.erb +71 -0
- data/lib/generators/pontiac/templates/app/controllers/application_controller.rb +4 -0
- data/lib/generators/pontiac/templates/app/controllers/home_controller.rb +13 -0
- data/lib/generators/pontiac/templates/app/helpers/home_helper.rb +17 -0
- data/lib/generators/pontiac/templates/app/models/shop.rb +4 -0
- data/lib/generators/pontiac/templates/app/views/home/index.html.haml +37 -0
- data/lib/generators/pontiac/templates/app/views/layouts/application.html.haml +39 -0
- data/lib/generators/pontiac/templates/config/app_secret_config.yml.erb +33 -0
- data/lib/generators/pontiac/templates/db/migrate/create_shops.rb +11 -0
- data/lib/generators/pontiac/templates/spec/factories/shops.rb +10 -0
- data/lib/pontiac/engine.rb +49 -0
- data/lib/pontiac/helpers.rb +8 -0
- data/lib/pontiac/rails/routes.rb +19 -0
- data/lib/pontiac/version.rb +3 -0
- data/lib/pontiac.rb +15 -0
- data/lib/tasks/pontiac_tasks.rake +4 -0
- metadata +200 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZWZlZWI2M2JmYjcwZGM3MjlkYTVkNTU4YzA2OTgyMjYwMjkyOWZmNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZWM4YjY3M2E1ZGIwNjI1YzM2YjAzZmI4NDYzMTQ1N2Y1ODZlNzM0OA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDgxZTRmZWU3ZTc4MjU4Zjg3NjAwYWNhNWEzZmUxMmViNjhkYTA2ZGZlYWJh
|
10
|
+
ZWU0ODM5NzZjNTViYTY3YWE0ODVjMDQ4OWU0MWFhMjhhZWI0Y2Y0ZjI3YjE1
|
11
|
+
N2VjNDQ5YTFkOTZjNzc0OWY2YTY0OWFlMDAzMjIyODcyOGNhNjI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTE1MTc2MWRkYzc2YmZjZWI5ZDVkODQwNjNkNjMwNzc0ODdjYTI0YWQ3MmUw
|
14
|
+
MDZiMjdlMGRhZjNlZTZkOWMwOTViMmRiMTZlYWIyZjNhZjJlN2MzNDVmODJh
|
15
|
+
YzJiZGJiZjI1M2FmODA1MTY4NzYyNWVkZGZmZTNiODU3NzVkYmM=
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Pontiac
|
2
|
+
|
3
|
+
Gem engine for applications in the system PayPonty
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
$ echo "gem 'pontiac'" >> Gemfile
|
8
|
+
$ bundle
|
9
|
+
|
10
|
+
## Step 1
|
11
|
+
|
12
|
+
$ rails g pontiac client_id client_secret
|
13
|
+
$ bundle exec rake db:create db:migrate
|
14
|
+
|
15
|
+
## Step 2
|
16
|
+
|
17
|
+
Edit `config/app_secret_config.yml`
|
18
|
+
|
19
|
+
defaults: &defaults
|
20
|
+
oauth:
|
21
|
+
client_id: 'dffd069fa92096022628a1f7eb174bc85d90278b8c90ec7ebadfbd94924bd2b8'
|
22
|
+
secret: 'e1805141c81c496e4779371f41263c9f74ac2ffd3728302296b8af10b64d9c9b'
|
23
|
+
scope: 'read_products read_orders'
|
24
|
+
redirect_uri: '/callback'
|
25
|
+
|
26
|
+
## Step 3
|
27
|
+
|
28
|
+
Start server
|
29
|
+
|
30
|
+
$ rails s
|
31
|
+
|
32
|
+
[http://localhost:3000](http://localhost:3000)
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Pontiac'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Pontiac
|
2
|
+
class OmniauthCallbacksController < ApplicationController
|
3
|
+
skip_before_filter :authenticate_shop!, only: :payponty
|
4
|
+
before_filter :assert_omniauth_auth
|
5
|
+
|
6
|
+
def payponty
|
7
|
+
shop = Shop.find_for_payponty_oauth(request.env["omniauth.auth"])
|
8
|
+
sign_in_and_redirect shop
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
def assert_omniauth_auth
|
13
|
+
unless request.env['omniauth.auth']
|
14
|
+
flash[:error] = "Could not log in to store."
|
15
|
+
redirect_to main_app.login_path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def sign_in_and_redirect(shop)
|
20
|
+
cookies.permanent.signed[:shop_id] = shop.id
|
21
|
+
redirect_to main_app.root_path
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Pontiac
|
2
|
+
class SessionsController < ApplicationController
|
3
|
+
skip_before_filter :authenticate_shop!, only: [:new, :payponty_login]
|
4
|
+
|
5
|
+
def new
|
6
|
+
if params[:shop].present?
|
7
|
+
redirect_to "/auth/payponty?shop=#{params[:shop].to_s.strip}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def payponty_login
|
12
|
+
if signed_in?
|
13
|
+
redirect_to main_app.root_path
|
14
|
+
else
|
15
|
+
redirect_to main_app.login_path(shop: params[:shop])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy
|
20
|
+
cookies.delete(:shop_id)
|
21
|
+
redirect_to main_app.root_path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Pontiac
|
2
|
+
module ApplicationHelper
|
3
|
+
def authenticate_shop!
|
4
|
+
redirect_to main_app.root_path unless signed_in?
|
5
|
+
end
|
6
|
+
|
7
|
+
def signed_in?
|
8
|
+
!current_shop.nil?
|
9
|
+
end
|
10
|
+
|
11
|
+
def current_shop
|
12
|
+
@current_shop ||= (cookies.signed[:shop_id] && Shop.find_by_id(cookies.signed[:shop_id]))
|
13
|
+
end
|
14
|
+
|
15
|
+
def shop_url
|
16
|
+
"http://#{current_shop.fwm_domain}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/app/models/shop.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class Shop < ActiveRecord::Base
|
2
|
+
attr_accessible :shop_id, :name, :fwm_domain
|
3
|
+
|
4
|
+
def self.find_for_payponty_oauth(data)
|
5
|
+
shop_data = data.extra.raw_info.shop
|
6
|
+
shop = where(shop_id: shop_data.id).first_or_create! name: shop_data.name, fwm_domain: shop_data.fwm_domain
|
7
|
+
shop.access_token = data.credentials.token
|
8
|
+
shop.tap(&:save)
|
9
|
+
end
|
10
|
+
|
11
|
+
def use_kitpay
|
12
|
+
Kitpay.setup url: self.fwm_domain, access_token: self.access_token
|
13
|
+
end
|
14
|
+
|
15
|
+
def admin_url
|
16
|
+
"#{SecretSetting.fwm_domain.protocol}#{self.fwm_domain}/admin"
|
17
|
+
end
|
18
|
+
|
19
|
+
def front_url
|
20
|
+
"http://#{self.fwm_domain}"
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
.content
|
2
|
+
.page-header
|
3
|
+
%h1
|
4
|
+
Вход
|
5
|
+
%small введите URL магазина
|
6
|
+
= form_tag main_app.login_path, :class => 'form-search' do
|
7
|
+
= text_field_tag 'shop', nil, :placeholder => 'URL магазина', :class => 'btn-large', :id => 'shop'
|
8
|
+
= submit_tag 'Войти', :class => 'btn btn-primary btn-large'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Description:
|
2
|
+
Generator Pontiac files.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate pontiac client_id client_secret
|
6
|
+
|
7
|
+
This will remove:
|
8
|
+
app/assets/javascripts/application.js
|
9
|
+
app/assets/stylesheets/application_helpern.css
|
10
|
+
app/views/layouts/application.html.erb
|
11
|
+
public/index.html
|
12
|
+
|
13
|
+
This will create:
|
14
|
+
app/assets/javascripts/application.js.coffee
|
15
|
+
app/assets/stylesheets/application_helpernon.css.less.erb
|
16
|
+
app/controllers/home_controller.rb
|
17
|
+
app/helpers/home_helper.rb
|
18
|
+
app/views/home/
|
19
|
+
app/views/layouts/application.html.haml
|
20
|
+
config/app_secret_config.yml
|
21
|
+
db/migrate/create_shops.rb
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
class PontiacGenerator < Rails::Generators::Base
|
4
|
+
include Rails::Generators::Migration
|
5
|
+
namespace 'pontiac'
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
argument :client_id , type: :string, required: true
|
9
|
+
argument :client_secret, type: :string, required: true
|
10
|
+
|
11
|
+
def copy_files
|
12
|
+
directory 'app'
|
13
|
+
template 'config/app_secret_config.yml.erb', 'config/app_secret_config.yml'
|
14
|
+
end
|
15
|
+
|
16
|
+
def remove_files
|
17
|
+
remove_file 'public/index.html'
|
18
|
+
remove_file 'app/assets/javascripts/application.js'
|
19
|
+
remove_file 'app/assets/stylesheets/application.css'
|
20
|
+
remove_file 'app/views/layouts/application.html.erb'
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_routes
|
24
|
+
route "use_pontiac"
|
25
|
+
route "root :to => 'home#index'"
|
26
|
+
end
|
27
|
+
|
28
|
+
def install_migration
|
29
|
+
migration_template 'db/migrate/create_shops.rb', 'db/migrate/create_shops.rb'
|
30
|
+
end
|
31
|
+
|
32
|
+
def show
|
33
|
+
readme "README"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.next_migration_number(dirname)
|
37
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
There is something that you need to do before you use Pontiac.
|
4
|
+
|
5
|
+
Step 1.
|
6
|
+
UNCOMMENT the line below in Gemfile
|
7
|
+
gem 'therubyracer', :platforms => :ruby
|
8
|
+
|
9
|
+
Step 2.
|
10
|
+
$ bundle
|
11
|
+
|
12
|
+
Step 3.
|
13
|
+
$ rake db:create db:migrate
|
14
|
+
|
15
|
+
Step 4.
|
16
|
+
$ rails server
|
17
|
+
|
18
|
+
===============================================================================
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#= require jquery
|
2
|
+
#= require jquery_ujs
|
3
|
+
#= require_tree .
|
4
|
+
|
5
|
+
#= require bootstrap-dropdown
|
6
|
+
#= require bootstrap-transition
|
7
|
+
#= require bootstrap-collapse
|
8
|
+
###
|
9
|
+
#= require bootstrap-tooltip
|
10
|
+
###
|
11
|
+
|
12
|
+
$(document).ready ->
|
13
|
+
$('#shop').focus()
|
14
|
+
|
15
|
+
###
|
16
|
+
#$('#main').tooltip selector: "span[rel=tooltip], a[rel=tooltip]"
|
17
|
+
###
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/*
|
2
|
+
*= require_tree .
|
3
|
+
*/
|
4
|
+
|
5
|
+
// Core variables and mixins
|
6
|
+
@import "bootstrap/variables"; // Modify this for custom colors, font-sizes, etc
|
7
|
+
@import "bootstrap/mixins";
|
8
|
+
|
9
|
+
// CSS Reset
|
10
|
+
@import "bootstrap/reset";
|
11
|
+
|
12
|
+
// Grid system and page structure
|
13
|
+
@import "bootstrap/scaffolding";
|
14
|
+
@import "bootstrap/grid";
|
15
|
+
@import "bootstrap/layouts";
|
16
|
+
|
17
|
+
// Base CSS
|
18
|
+
@import "bootstrap/type";
|
19
|
+
//@import "bootstrap/code";
|
20
|
+
@import "bootstrap/forms";
|
21
|
+
@import "bootstrap/tables";
|
22
|
+
|
23
|
+
// Components: common
|
24
|
+
@import "bootstrap/sprites";
|
25
|
+
@import "bootstrap/dropdowns";
|
26
|
+
@import "bootstrap/wells";
|
27
|
+
@import "bootstrap/component-animations";
|
28
|
+
//@import "bootstrap/close";
|
29
|
+
|
30
|
+
// Components: Buttons & Alerts
|
31
|
+
@import "bootstrap/buttons";
|
32
|
+
//@import "bootstrap/button-groups";
|
33
|
+
@import "bootstrap/alerts"; // Note: alerts share common CSS with buttons and thus have styles in buttons
|
34
|
+
|
35
|
+
// Components: Nav
|
36
|
+
@import "bootstrap/navs";
|
37
|
+
@import "bootstrap/navbar";
|
38
|
+
//@import "bootstrap/breadcrumbs";
|
39
|
+
//@import "bootstrap/pagination";
|
40
|
+
//@import "bootstrap/pager";
|
41
|
+
|
42
|
+
// Components: Popovers
|
43
|
+
//@import "bootstrap/modals";
|
44
|
+
@import "bootstrap/tooltip";
|
45
|
+
//@import "bootstrap/popovers";
|
46
|
+
|
47
|
+
// Components: Misc
|
48
|
+
//@import "bootstrap/thumbnails";
|
49
|
+
@import "bootstrap/labels-badges";
|
50
|
+
//@import "bootstrap/progress-bars";
|
51
|
+
@import "bootstrap/accordion";
|
52
|
+
//@import "bootstrap/carousel";
|
53
|
+
@import "bootstrap/hero-unit";
|
54
|
+
|
55
|
+
// Utility classes
|
56
|
+
@import "bootstrap/utilities"; // Has to be last to override when necessary
|
57
|
+
|
58
|
+
body {
|
59
|
+
margin-top: 50px;
|
60
|
+
margin-bottom: 100px; }
|
61
|
+
|
62
|
+
.accordion-body {
|
63
|
+
background: #F9F9F9;
|
64
|
+
.accordion-inner {
|
65
|
+
padding: 20px; }}
|
66
|
+
|
67
|
+
.footer {
|
68
|
+
color: #333;
|
69
|
+
text-align: center;
|
70
|
+
margin-top: 45px;
|
71
|
+
padding: 35px 0 36px; }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class HomeController < ApplicationController
|
2
|
+
skip_before_filter :authenticate_shop!, only: :index
|
3
|
+
|
4
|
+
def index
|
5
|
+
if signed_in?
|
6
|
+
current_shop.use_kitpay
|
7
|
+
@orders = Kitpay.orders per_page: 3
|
8
|
+
@products = Kitpay.products per_page: 5
|
9
|
+
else
|
10
|
+
redirect_to login_path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module HomeHelper
|
2
|
+
|
3
|
+
def financial_class(financial_status)
|
4
|
+
case financial_status
|
5
|
+
when 'pending' then 'label-warning'
|
6
|
+
when 'paid' then 'label-success'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def fulfillment_class(fulfillment_status)
|
11
|
+
case fulfillment_status
|
12
|
+
when 'partial' then 'label-warning'
|
13
|
+
when 'fulfilled' then 'label-success'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
.content
|
2
|
+
%h2 Заказы
|
3
|
+
%table.table.table-striped
|
4
|
+
%thead
|
5
|
+
%tr
|
6
|
+
%th Номер заказа
|
7
|
+
%th Клиент
|
8
|
+
%th Статус оплаты
|
9
|
+
%th Статус доставки
|
10
|
+
%th Сумма
|
11
|
+
%tbody
|
12
|
+
-@orders.each do |order|
|
13
|
+
%tr
|
14
|
+
%td=link_to order['name'], "#{shop_url}/admin/orders/#{order['id']}", target: :_blank
|
15
|
+
%td=order['customer']['name']
|
16
|
+
%td
|
17
|
+
%span.label(class="#{financial_class(order['financial_status'])}")
|
18
|
+
=order['financial_status_name']
|
19
|
+
%td
|
20
|
+
%span.label(class="#{fulfillment_class(order['fulfillment_status'])}")
|
21
|
+
=order['fulfillment_status_name']
|
22
|
+
%td=order['total_price']
|
23
|
+
|
24
|
+
%h2 Товары
|
25
|
+
#product-accordion.accordion
|
26
|
+
-@products.each do |product|
|
27
|
+
.accordion-group
|
28
|
+
.accordion-heading
|
29
|
+
%a.accordion-toggle{href: "#product-#{product['id']}", data: {toggle: 'collapse', parent: '#product-accordion'}}
|
30
|
+
=product['title']
|
31
|
+
%div.accordion-body.collapse(id="product-#{product['id']}")
|
32
|
+
.accordion-inner
|
33
|
+
%p==Тип товара: #{product['product_type']}
|
34
|
+
%p==Производитель: #{product['vendor']}
|
35
|
+
=raw product['body_html']
|
36
|
+
%br/
|
37
|
+
%p=link_to "Изменить этот товар", "#{shop_url}/admin/products/#{product['id']}", class: 'btn btn-primary', target: :_blank
|
@@ -0,0 +1,39 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%title Тестовое приложение
|
5
|
+
= stylesheet_link_tag "application"
|
6
|
+
= javascript_include_tag "application"
|
7
|
+
= csrf_meta_tags
|
8
|
+
%body
|
9
|
+
.navbar.navbar-fixed-top
|
10
|
+
.navbar-inner
|
11
|
+
.container
|
12
|
+
%a.brand(href="/") Test App
|
13
|
+
-if current_shop
|
14
|
+
%ul.nav.pull-right
|
15
|
+
%li.dropdown
|
16
|
+
=link_to '#', class: 'dropdown-toggle', data: { toggle: :dropdown } do
|
17
|
+
=current_shop['fwm_domain']
|
18
|
+
%b.caret
|
19
|
+
%ul.dropdown-menu
|
20
|
+
%li
|
21
|
+
=link_to shop_url, target: :_blank do
|
22
|
+
%i.icon-home
|
23
|
+
Перейти в магазин
|
24
|
+
%li
|
25
|
+
=link_to "#{shop_url}/admin", target: :_blank do
|
26
|
+
%i.icon-cog
|
27
|
+
Перейти в админ раздел
|
28
|
+
%li.divider
|
29
|
+
%li
|
30
|
+
=link_to sign_out_path do
|
31
|
+
%i.icon-off
|
32
|
+
Выход
|
33
|
+
|
34
|
+
#main.container
|
35
|
+
= yield
|
36
|
+
#footer.footer
|
37
|
+
%p(style="padding-right:20px;")
|
38
|
+
==Copyright©#{Date.today.year}
|
39
|
+
=link_to SecretSetting.app_name, '/'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
app_name: Pontiac Test App
|
3
|
+
author:
|
4
|
+
email: payponty.info@gmail.com
|
5
|
+
oauth:
|
6
|
+
client_id: <%= client_id %>
|
7
|
+
secret: <%= client_secret %>
|
8
|
+
scope: 'read_products read_orders'
|
9
|
+
callback_path: '/callback'
|
10
|
+
domain:
|
11
|
+
host: 'testapp.payponty.com'
|
12
|
+
record: ''
|
13
|
+
fwm_domain:
|
14
|
+
protocol: 'http://'
|
15
|
+
|
16
|
+
development:
|
17
|
+
<<: *defaults
|
18
|
+
|
19
|
+
test:
|
20
|
+
<<: *defaults
|
21
|
+
|
22
|
+
production:
|
23
|
+
<<: *defaults
|
24
|
+
oauth:
|
25
|
+
client_id: <%= client_id %>
|
26
|
+
secret: <%= client_secret %>
|
27
|
+
scope: 'read_products read_orders'
|
28
|
+
callback_path: '/callback'
|
29
|
+
domain:
|
30
|
+
host: 'testapp.payponty.com'
|
31
|
+
record: ''
|
32
|
+
fwm_domain:
|
33
|
+
protocol: 'http://'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateShops < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :shops do |t|
|
4
|
+
t.integer :shop_id, unique: true, null: false
|
5
|
+
t.string :name, limit: 32 , null: false
|
6
|
+
t.string :fwm_domain, limit: 64 , null: false
|
7
|
+
t.string :access_token, limit: 64
|
8
|
+
end
|
9
|
+
add_index :shops, :shop_id, :unique => true
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Pontiac
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
isolate_namespace Pontiac
|
4
|
+
engine_name 'pontiac'
|
5
|
+
|
6
|
+
def models_dir
|
7
|
+
root.join 'app', 'models'
|
8
|
+
end
|
9
|
+
|
10
|
+
config.generators do |g|
|
11
|
+
g.template_engine :haml
|
12
|
+
g.test_framework :rspec, :views => false
|
13
|
+
g.integration_tool :rspec
|
14
|
+
end
|
15
|
+
|
16
|
+
initializer "pontiac.routes" do
|
17
|
+
Pontiac::Rails::Routes.install
|
18
|
+
end
|
19
|
+
|
20
|
+
initializer "pontiac.acronym" do
|
21
|
+
ActiveSupport::Inflector.inflections do |inflect|
|
22
|
+
inflect.acronym 'Fwm'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
initializer "pontiac.helpers" do
|
27
|
+
ActiveSupport.on_load(:action_controller) do
|
28
|
+
include Pontiac::Helpers
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
initializer "pontiac.omniauth" do |app|
|
33
|
+
app.middleware.use OmniAuth::Builder do
|
34
|
+
provider :payponty,
|
35
|
+
(SecretSetting.oauth.client_id rescue nil),
|
36
|
+
(SecretSetting.oauth.secret rescue nil),
|
37
|
+
:scope => (SecretSetting.oauth.scope rescue nil),
|
38
|
+
:callback_path => (SecretSetting.oauth.callback_path rescue nil),
|
39
|
+
:setup => lambda {|env|
|
40
|
+
params = Rack::Utils.parse_query(env['QUERY_STRING'])
|
41
|
+
site_url = "http://#{params['shop']}"
|
42
|
+
env['omniauth.strategy'].options[:client_options][:site] = site_url
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
OmniAuth.config.on_failure{|env| raise env['omniauth.error']}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Pontiac
|
2
|
+
module Rails
|
3
|
+
class Routes
|
4
|
+
module Helper
|
5
|
+
def use_pontiac(options = {}, &block)
|
6
|
+
options.reverse_merge! callbacks: 'pontiac/omniauth_callbacks'
|
7
|
+
self.match 'login' => "pontiac/sessions#new"
|
8
|
+
self.get 'callback_login' => "pontiac/sessions#payponty_login"
|
9
|
+
self.get 'callback' => "#{options[:callbacks]}#payponty"
|
10
|
+
self.get 'sign_out' => "pontiac/sessions#destroy"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.install
|
15
|
+
ActionDispatch::Routing::Mapper.send :include, Pontiac::Rails::Routes::Helper
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/pontiac.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "pontiac/engine"
|
2
|
+
require 'haml'
|
3
|
+
require 'bootstrap-sass'
|
4
|
+
require 'omniauth'
|
5
|
+
require 'settingslogic'
|
6
|
+
require 'omniauth-payponty'
|
7
|
+
require 'kitpay'
|
8
|
+
|
9
|
+
module Pontiac
|
10
|
+
autoload :Helpers, "pontiac/helpers"
|
11
|
+
|
12
|
+
module Rails
|
13
|
+
autoload :Routes, "pontiac/rails/routes"
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pontiac
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- PayPonty
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.13
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.13
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-payponty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: kitpay
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: haml
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.1.6
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.1.6
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bootstrap-sass
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.0.4.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.0.4.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: settingslogic
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.0.8
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.0.8
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sqlite3
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec-rails
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.10.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.10.1
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: factory_girl_rails
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.5.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.5.0
|
139
|
+
description: Gem engine for applications in the system PayPonty
|
140
|
+
email:
|
141
|
+
- payponty.info@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- MIT-LICENSE
|
147
|
+
- README.md
|
148
|
+
- Rakefile
|
149
|
+
- app/controllers/pontiac/application_controller.rb
|
150
|
+
- app/controllers/pontiac/omniauth_callbacks_controller.rb
|
151
|
+
- app/controllers/pontiac/sessions_controller.rb
|
152
|
+
- app/helpers/pontiac/application_helper.rb
|
153
|
+
- app/models/secret_setting.rb
|
154
|
+
- app/models/shop.rb
|
155
|
+
- app/views/pontiac/sessions/new.html.haml
|
156
|
+
- lib/generators/pontiac/USAGE
|
157
|
+
- lib/generators/pontiac/pontiac_generator.rb
|
158
|
+
- lib/generators/pontiac/templates/README
|
159
|
+
- lib/generators/pontiac/templates/app/assets/javascripts/application.js.coffee
|
160
|
+
- lib/generators/pontiac/templates/app/assets/stylesheets/application.css.scss.erb
|
161
|
+
- lib/generators/pontiac/templates/app/controllers/application_controller.rb
|
162
|
+
- lib/generators/pontiac/templates/app/controllers/home_controller.rb
|
163
|
+
- lib/generators/pontiac/templates/app/helpers/home_helper.rb
|
164
|
+
- lib/generators/pontiac/templates/app/models/shop.rb
|
165
|
+
- lib/generators/pontiac/templates/app/views/home/index.html.haml
|
166
|
+
- lib/generators/pontiac/templates/app/views/layouts/application.html.haml
|
167
|
+
- lib/generators/pontiac/templates/config/app_secret_config.yml.erb
|
168
|
+
- lib/generators/pontiac/templates/db/migrate/create_shops.rb
|
169
|
+
- lib/generators/pontiac/templates/spec/factories/shops.rb
|
170
|
+
- lib/pontiac.rb
|
171
|
+
- lib/pontiac/engine.rb
|
172
|
+
- lib/pontiac/helpers.rb
|
173
|
+
- lib/pontiac/rails/routes.rb
|
174
|
+
- lib/pontiac/version.rb
|
175
|
+
- lib/tasks/pontiac_tasks.rake
|
176
|
+
homepage: http://payponty.github.io/pontiac/
|
177
|
+
licenses: []
|
178
|
+
metadata: {}
|
179
|
+
post_install_message:
|
180
|
+
rdoc_options: []
|
181
|
+
require_paths:
|
182
|
+
- lib
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ! '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ! '>='
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
requirements: []
|
194
|
+
rubyforge_project:
|
195
|
+
rubygems_version: 2.2.2
|
196
|
+
signing_key:
|
197
|
+
specification_version: 4
|
198
|
+
summary: Gem engine for applications in the system PayPonty
|
199
|
+
test_files: []
|
200
|
+
has_rdoc:
|