versacommerce_app 1.0.24 → 1.0.25

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,6 +10,15 @@ The generator creates a basic SessionsController for authenticating with your sh
10
10
 
11
11
  *Note: It's recommended to use this on a new Rails project, so that the generator won't overwrite/delete some of your files.*
12
12
 
13
+ ## Register your app first
14
+
15
+ To use the VersaCommerce API you will need an application registration for your store.
16
+
17
+ 1. SignUp as an developer: http://app.versacommerce.de/developer/signup
18
+ 2. Login to your developer account: http://app.versacommerce.de/developer
19
+ 3. Register your app.
20
+
21
+
13
22
  ## Installation
14
23
 
15
24
  ``` sh
@@ -19,4 +19,10 @@ class ApplicationController < ActionController::Base
19
19
  Rails.application.routes.default_url_options[:locale]= I18n.locale
20
20
  end
21
21
 
22
+ # prepare variable for the views
23
+ def set_installed_shops
24
+ @installed_shops = session[:installed_shops]
25
+ end
26
+
27
+
22
28
  end
@@ -34,6 +34,10 @@ class SessionsController < ApplicationController
34
34
  # https://github.com/versacommerce/versacommerce_api (see sample code)
35
35
  #
36
36
  session[:versacommerce] = current_session
37
+
38
+ # save current shop to array in session, to allow switching between shops
39
+ save_installed_shop
40
+
37
41
  flash[:success] = t('sessions.controller.finalize_ok')
38
42
  redirect_to return_address
39
43
  else
@@ -65,4 +69,13 @@ class SessionsController < ApplicationController
65
69
  u.host.ends_with?("versacommerce.de") ? u.host : nil
66
70
  end
67
71
 
72
+
73
+ def save_installed_shop
74
+ session[:installed_shops] ||= []
75
+ unless session[:installed_shops].include?(current_shop.url)
76
+ session[:installed_shops].push(current_shop.url)
77
+ end
78
+ end
79
+
80
+
68
81
  end
@@ -94,7 +94,7 @@
94
94
  </thead>
95
95
  <% @orders.each do |order| %>
96
96
  <tr>
97
- <td><%= link_to order.code, "https://#{current_shop.url}/admin/orders/#{order.id}", :target => 'blank' %></td>
97
+ <td><%= link_to order.code, "http://#{current_shop.url}/admin/sales/orders/#{order.id}", :target => 'blank' %></td>
98
98
  <td><%= "#{order.billing_address.firstname} #{order.billing_address.lastname}" %></td>
99
99
  <td>
100
100
  <%= order.status %>
@@ -5,12 +5,12 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <meta name="description" content="">
7
7
  <meta name="author" content="">
8
- <link rel="shortcut icon" href="../assets/favicon.png">
9
- <link rel="apple-touch-icon" href="../assets/versacommerce-57.png">
10
- <link rel="apple-touch-icon" sizes="72x72" href="../assets/versacommerce-72.png">
11
- <link rel="apple-touch-icon" sizes="114x114" href="../assets/versacommerce-114.png">
8
+ <link rel="shortcut icon" href="<%= asset_path("favicon.png") %>">
9
+ <link rel="apple-touch-icon" href="<%= asset_path("versacommerce-57.png") %>">
10
+ <link rel="apple-touch-icon" sizes="72x72" href="<%= asset_path("versacommerce-72.png") %>">
11
+ <link rel="apple-touch-icon" sizes="114x114" href="<%= asset_path("versacommerce-114.png") %>">
12
12
 
13
- <title>VersaCommerce Sample App</title>
13
+ <title><%= t(:app_title, default: "VersaCommerce Example App") %></title>
14
14
 
15
15
  <!-- Bootstrap core CSS -->
16
16
  <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
@@ -63,12 +63,17 @@
63
63
  code {
64
64
  font-size: 80%;
65
65
  }
66
+
67
+ .dropdown-menu>li>a.switch-shop-current {
68
+ font-weight: bold;
69
+ cursor: default;
70
+ }
66
71
  </style>
67
72
 
68
73
  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
69
74
  <!--[if lt IE 9]>
70
- <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
71
- <!-- <script src="../../assets/js/respond.min.js"></script> -->
75
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
76
+ <script src="/respond.min.js"></script>
72
77
  <![endif]-->
73
78
  <%= csrf_meta_tags %>
74
79
  </head>
@@ -86,7 +91,7 @@
86
91
  <span class="icon-bar"></span>
87
92
  <span class="icon-bar"></span>
88
93
  </button>
89
- <%= link_to 'VersaCommerce App', '/', :class => 'navbar-brand' %>
94
+ <%= link_to t(:app_title, default: "VersaCommerce Example App"), "/", class: "navbar-brand" %>
90
95
  </div>
91
96
  <% if current_shop %>
92
97
  <div class="collapse navbar-collapse">
@@ -96,13 +101,30 @@
96
101
  <li class="dropdown">
97
102
  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= current_shop.url %> <b class="caret"></b></a>
98
103
  <ul class="dropdown-menu">
99
- <li><%= link_to raw('<i class="icon-home"></i> Shop'), "http://"+current_shop.url, :target => 'blank' %></li>
100
- <li><%= link_to raw('<i class="icon-cog"></i> Admin'), "http://"+current_shop.url+"/admin", :target => 'blank' %></li>
104
+ <li><%= link_to raw('<i class="icon-home"></i> Shop'), "http://#{current_shop.url}", :target => 'blank' %></li>
105
+ <li><%= link_to raw('<i class="icon-cog"></i> Admin'), "http://#{current_shop.url}/admin", :target => 'blank' %></li>
101
106
  <li class="divider"></li>
102
107
  <li><%= link_to raw('<i class="icon-off"></i> Logout'), logout_path, :method => :delete %></li>
103
108
  </ul>
104
109
  </li>
105
110
  </ul>
111
+
112
+ <!-- switch between shops, change event handled by js -->
113
+ <%- unless @installed_shops.blank? %>
114
+ <ul class="nav navbar-nav pull-right">
115
+ <li class="dropdown">
116
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= t('sessions.views.switch_shop') %> <b class="caret"></b></a>
117
+ <ul class="dropdown-menu">
118
+ <%- @installed_shops.each do |shop| %>
119
+ <li><%= link_to shop.split('.').first.titleize, 'javascript:void(0);', class: (current_shop.url == shop ? 'switch-shop-current' : 'switch-shop'), rel: (current_shop.url == shop ? nil : shop)%></li>
120
+ <%- end %>
121
+ <li><%= link_to t('layout.add_new_shop'), login_path %></li>
122
+ </ul>
123
+ </li>
124
+ </ul>
125
+ <%- end %>
126
+ <!-- end of shops switch -->
127
+
106
128
  </div><!--/.nav-collapse -->
107
129
  <% end %>
108
130
  </div>
@@ -113,17 +135,31 @@
113
135
  <% flash.each do |type, message| %>
114
136
  <div class="alert alert-<%= type %>"><%= message %></div>
115
137
  <% end %>
138
+
116
139
  <%= yield %>
117
140
  </div>
118
141
  </div>
119
142
 
120
143
  <div id="footer">
121
144
  <div class="container">
122
- <p class="text-muted credit">VersaCommerce Example App. Created by <a href="http://www.versacommerce.de" target="_blank">versacommerce.de</a></p>
145
+ <p class="text-muted credit"><%= t(:app_title, default: "VersaCommerce Example App") %>. <%= t(:created_by_html, link: link_to("versacommerce.de", "http://www.versacommerce.de", target: "_blank")) %></p>
123
146
  </div>
124
147
  </div>
125
148
 
126
149
  <%= javascript_include_tag 'application' %>
127
150
  <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
151
+
152
+ <script type="text/javascript">
153
+ $(function() {
154
+ return $('a.switch-shop').on('click', function(e) {
155
+ var shop_url;
156
+ e.preventDefault();
157
+ shop_url = $(e.target).prop('rel');
158
+ if (shop_url) {
159
+ return window.location = '/login/?shop=' + shop_name;
160
+ }
161
+ });
162
+ });
163
+ </script>
128
164
  </body>
129
165
  </html>
@@ -16,6 +16,8 @@
16
16
  # available at http://guides.rubyonrails.org/i18n.html.
17
17
 
18
18
  de:
19
+ app_title: "VersaCommerce Example App"
20
+ created_by_html: "Erstellt von %{link}"
19
21
  sessions:
20
22
  views:
21
23
  new:
@@ -20,8 +20,11 @@
20
20
  # available at http://guides.rubyonrails.org/i18n.html.
21
21
 
22
22
  en:
23
+ app_title: "VersaCommerce Example App"
24
+ created_by_html: "Created by %{link}"
23
25
  sessions:
24
26
  views:
27
+ switch_shop: 'Switch shop'
25
28
  new:
26
29
  title: "Register this app with your shop."
27
30
  subtitle: "This app requires you to login to start using it."
@@ -0,0 +1,6 @@
1
+ /*! Respond.js v1.4.2: min/max-width media query polyfill
2
+ * Copyright 2013 Scott Jehl
3
+ * Licensed under MIT
4
+ * http://j.mp/respondjs */
5
+
6
+ !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='&shy;<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){v(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))},g=function(a){return a.replace(c.regex.minmaxwh,"").match(c.regex.other)};if(c.ajax=f,c.queue=d,c.unsupportedmq=g,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var h,i,j,k=a.document,l=k.documentElement,m=[],n=[],o=[],p={},q=30,r=k.getElementsByTagName("head")[0]||l,s=k.getElementsByTagName("base")[0],t=r.getElementsByTagName("link"),u=function(){var a,b=k.createElement("div"),c=k.body,d=l.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=k.createElement("body"),c.style.background="none"),l.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&l.insertBefore(c,l.firstChild),a=b.offsetWidth,f?l.removeChild(c):c.removeChild(b),l.style.fontSize=d,e&&(c.style.fontSize=e),a=j=parseFloat(a)},v=function(b){var c="clientWidth",d=l[c],e="CSS1Compat"===k.compatMode&&d||k.body[c]||d,f={},g=t[t.length-1],p=(new Date).getTime();if(b&&h&&q>p-h)return a.clearTimeout(i),i=a.setTimeout(v,q),void 0;h=p;for(var s in m)if(m.hasOwnProperty(s)){var w=m[s],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?j||u():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?j||u():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(n[w.rules]))}for(var C in o)o.hasOwnProperty(C)&&o[C]&&o[C].parentNode===r&&r.removeChild(o[C]);o.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=k.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,r.insertBefore(E,g.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(k.createTextNode(F)),o.push(E)}},w=function(a,b,d){var e=a.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var h=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},i=!f&&d;b.length&&(b+="/"),i&&(f=1);for(var j=0;f>j;j++){var k,l,o,p;i?(k=d,n.push(h(a))):(k=e[j].match(c.regex.findStyles)&&RegExp.$1,n.push(RegExp.$2&&h(RegExp.$2))),o=k.split(","),p=o.length;for(var q=0;p>q;q++)l=o[q],g(l)||m.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:n.length-1,hasquery:l.indexOf("(")>-1,minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}v()},x=function(){if(d.length){var b=d.shift();f(b.href,function(c){w(c,b.href,b.media),p[b.href]=!0,a.setTimeout(function(){x()},0)})}},y=function(){for(var b=0;b<t.length;b++){var c=t[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!p[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(w(c.styleSheet.rawCssText,e,f),p[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!s||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}x()};y(),c.update=y,c.getEmValue=u,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this);
@@ -27,7 +27,7 @@ module VersacommerceApp::EnsureApiSession
27
27
  protected
28
28
 
29
29
  def close_session
30
- session[versacommerce] = nil
30
+ session[:versacommerce] = nil
31
31
  redirect_to login_path
32
32
  end
33
33
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module VersacommerceApp
3
- VERSION = "1.0.24"
3
+ VERSION = "1.0.25"
4
4
  end
metadata CHANGED
@@ -1,20 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versacommerce_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.24
4
+ version: 1.0.25
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - VersaCommerce
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
12
+ date: 2014-01-23 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '3.1'
20
22
  - - <
@@ -23,8 +25,9 @@ dependencies:
23
25
  type: :runtime
24
26
  prerelease: false
25
27
  version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
26
29
  requirements:
27
- - - '>='
30
+ - - ! '>='
28
31
  - !ruby/object:Gem::Version
29
32
  version: '3.1'
30
33
  - - <
@@ -33,6 +36,7 @@ dependencies:
33
36
  - !ruby/object:Gem::Dependency
34
37
  name: versacommerce_api
35
38
  requirement: !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ~>
38
42
  - !ruby/object:Gem::Version
@@ -40,6 +44,7 @@ dependencies:
40
44
  type: :runtime
41
45
  prerelease: false
42
46
  version_requirements: !ruby/object:Gem::Requirement
47
+ none: false
43
48
  requirements:
44
49
  - - ~>
45
50
  - !ruby/object:Gem::Version
@@ -82,10 +87,7 @@ files:
82
87
  - lib/generators/versacommerce_app/templates/public/404.html
83
88
  - lib/generators/versacommerce_app/templates/public/422.html
84
89
  - lib/generators/versacommerce_app/templates/public/500.html
85
- - lib/generators/versacommerce_app/templates/public/favicon.png
86
- - lib/generators/versacommerce_app/templates/public/versacommerce-114.png
87
- - lib/generators/versacommerce_app/templates/public/versacommerce-57.png
88
- - lib/generators/versacommerce_app/templates/public/versacommerce-72.png
90
+ - lib/generators/versacommerce_app/templates/public/javascripts/respond.min.js
89
91
  - lib/generators/versacommerce_app/versacommerce_app_generator.rb
90
92
  - lib/versacommerce_app.rb
91
93
  - lib/versacommerce_app/configuration.rb
@@ -95,25 +97,27 @@ files:
95
97
  - versacommerce_app.gemspec
96
98
  homepage: http://www.versacommerce.de
97
99
  licenses: []
98
- metadata: {}
99
100
  post_install_message:
100
101
  rdoc_options: []
101
102
  require_paths:
102
103
  - lib
103
104
  required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
104
106
  requirements:
105
- - - '>='
107
+ - - ! '>='
106
108
  - !ruby/object:Gem::Version
107
109
  version: '0'
108
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
109
112
  requirements:
110
- - - '>='
113
+ - - ! '>='
111
114
  - !ruby/object:Gem::Version
112
115
  version: '0'
113
116
  requirements: []
114
117
  rubyforge_project:
115
- rubygems_version: 2.0.3
118
+ rubygems_version: 1.8.25
116
119
  signing_key:
117
- specification_version: 4
120
+ specification_version: 3
118
121
  summary: This gem is used to get quickly started with the VersaCommerce API
119
122
  test_files: []
123
+ has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 62705fc9128b5e4d629987e1b5eeede07edf66fd
4
- data.tar.gz: 6ac10203db08b806ddba31cfe8580a22a8a447cf
5
- SHA512:
6
- metadata.gz: 3731e607a25d4881d3e10e82b629d9819c4aa89b0cfa5c3f9038152f0c0b019d1889db51f98715021629a4ede70d0e42756c0c84e0a7e929f0467371600e0a03
7
- data.tar.gz: b19646e51f33f7d4b71acbb17c233475b9f36012a769088b6617e0a47e51619d3d32bfa8af93da44cbc52e95cc4f9f6a1dd6e8a4efbecd28847bcd3c4117ee88