Skip to content

Commit

Permalink
add suport for slim templates in consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
pelle committed Sep 24, 2013
1 parent e1f6619 commit 51c7dff
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.5.1
- Support slim templates for consumer [pelle]
- Add via argument to match routes to support 4.0 [pelle]
0.5.0
- Make compatible with Rails 4 [tomhughes]
- Added support for RefreshTokens [RubenHoms]
Expand Down
4 changes: 3 additions & 1 deletion generators/oauth_consumer/oauth_consumer_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def manifest
m.template 'controller.rb',File.join('app/controllers',"oauth_consumers_controller.rb")
m.route_entry "map.resources :oauth_consumers,:member=>{:callback=>:get}"

@template_extension= options[:haml] ? "haml" : "erb"
@template_extension= options[:haml] ? "haml" : ( options[:slim] ? "slim": "erb")

m.template "show.html.#{@template_extension}", File.join('app/views', 'oauth_consumers', "show.html.#{@template_extension}")
m.template "index.html.#{@template_extension}", File.join('app/views', 'oauth_consumers', "index.html.#{@template_extension}")
Expand All @@ -46,5 +46,7 @@ def add_options!(opt)
# "Generate the Test::Unit compatible tests instead of RSpec") { |v| options[:test_unit] = v }
opt.on("--haml",
"Templates use haml") { |v| options[:haml] = v }
opt.on("--slim",
"Templates use slim") { |v| options[:slim] = v }
end
end
15 changes: 15 additions & 0 deletions generators/oauth_consumer/templates/index.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
h1 Services

-if @consumer_tokens.empty?
p You are currently not connected to any external services.
-else
p You are connected to the following services:
ul
-@consumer_tokens.each do |token|
li = link_to token.class.service_name.to_s.humanize, oauth_consumer_path(token.class.service_name)

-unless @services.empty?
h3 You can connect to the following services:
ul
-@services.each do |service|
li = link_to service.to_s.humanize,oauth_consumer_path(service)
8 changes: 8 additions & 0 deletions generators/oauth_consumer/templates/show.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
h1
| You are already Connected to
= params[:id].humanize
- form_tag oauth_consumer_path(params[:id]),:method=>:delete do
= submit_tag "Disconnect"
| or
= submit_tag "Reconnect"
|if you experienced a problem.
2 changes: 1 addition & 1 deletion lib/generators/oauth_consumer/oauth_consumer_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def add_route
member do
get :callback
get :callback2
match 'client/*endpoint' => 'oauth_consumers#client'
match 'client/*endpoint' => 'oauth_consumers#client', :via => [:get, :post, :put, :delete]
end
end
ROUTE
Expand Down
21 changes: 21 additions & 0 deletions lib/generators/slim/oauth_consumer_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'rails/generators/erb/controller/controller_generator'

module Slim
module Generators
class OauthConsumerGenerator < Erb::Generators::Base
source_root File.expand_path('../oauth_consumer_templates', __FILE__)

argument :name, :type => :string, :default => 'Oauth'

def copy_view_files
template 'index.html.slim', File.join('app/views', class_path, 'oauth_consumers', 'index.html.slim')
template 'show.html.slim', File.join('app/views', class_path, 'oauth_consumers', 'show.html.slim')
end

protected
def handler
:slim
end
end
end
end
15 changes: 15 additions & 0 deletions lib/generators/slim/oauth_consumer_templates/index.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
h1 Services

-if @consumer_tokens.empty?
p You are currently not connected to any external services.
-else
p You are connected to the following services:
ul
-@consumer_tokens.each do |token|
li = link_to token.class.service_name.to_s.humanize, oauth_consumer_path(token.class.service_name)

-unless @services.empty?
h3 You can connect to the following services:
ul
-@services.each do |service|
li = link_to service.to_s.humanize,oauth_consumer_path(service)
8 changes: 8 additions & 0 deletions lib/generators/slim/oauth_consumer_templates/show.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
h1
| You are already Connected to
= params[:id].humanize
- form_tag oauth_consumer_path(params[:id]),:method=>:delete do
= submit_tag "Disconnect"
| or
= submit_tag "Reconnect"
|if you experienced a problem.
2 changes: 1 addition & 1 deletion lib/oauth-plugin/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Oauth
module Plugin
VERSION = "0.5.0"
VERSION = "0.5.1"
end
end

0 comments on commit 51c7dff

Please sign in to comment.