aweplug 1.0.0.a9 → 1.0.0.a10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c04c6ec9e220206a3579c3973bd7dd1b06696780
4
+ data.tar.gz: 12d68c7c2e2170dc143f8ab25c142e3cdfa64519
5
+ SHA512:
6
+ metadata.gz: 8f96a65b787979b3c99e2bc47a43c9cd4628b88eb6078cbe75b6b948739782af9531f5561162292bbb7910981af19cd625eec641a72cbbac3d419b966725ae8b
7
+ data.tar.gz: 76e11caad4592d9d3393cc73ab21515d1ea3d83730983960ad3fcf5fcc0e84e163b706738e7b0dd993bfd77163ce9fea39bd48f7004c442e229b342bd33efa11
data/aweplug.gemspec CHANGED
@@ -21,8 +21,10 @@ Gem::Specification.new do |gem|
21
21
 
22
22
  #gem.add_dependency 'awestruct', '>= 0.5.1'
23
23
  gem.add_dependency 'octokit', '>= 1.24.0'
24
- gem.add_dependency 'faraday', '>= 0.8.7'
24
+ gem.add_dependency 'faraday', '>= 0.8.7', '< 0.9.0'
25
25
  gem.add_dependency 'faraday_middleware', '>= 0.9.0'
26
+ gem.add_dependency 'curb', '~> 0.8.5'
27
+ gem.add_dependency 'oauth', '~> 0.3.6'
26
28
 
27
29
  gem.add_development_dependency 'guard-rspec', '~> 3.0.0'
28
30
  gem.add_development_dependency 'rake', '~> 10.0.4'
@@ -1,25 +1,73 @@
1
1
  require 'pathname'
2
2
  require 'asciidoctor'
3
- require 'aweplug/helpers/git_commit_metadata'
3
+ require 'aweplug/helpers/git_metadata'
4
4
  require 'aweplug/helpers/searchisko'
5
5
  require 'json'
6
6
  require 'pry'
7
7
 
8
8
  module Aweplug::Extensions
9
+ # Public: An awestruct extension for guides / examples written in AsciiDoc.
10
+ # Files with the .asciidoc or .adoc extension are considered to be
11
+ # AsciiDoc files. This extension makes use of asciidoctor to
12
+ # render the files.
13
+ #
14
+ # Example
15
+ #
16
+ # extension Aweplug::Extensions::AsciidocExample({...})
9
17
  class AsciidocExample
10
18
  include Aweplug::Helper::Git::Commit::Metadata
19
+ include Aweplug::Helper::Git::Repository
11
20
 
12
- def initialize(repository, directory, layout, output_dir, additional_excludes = [],
13
- recurse_subdirectories = true, additional_metadata_keys = [])
14
- @repo = repository
15
- @output_dir = Pathname.new output_dir
16
- @layout = layout
17
- @recurse_subdirectories = recurse_subdirectories
18
- @additional_metadata_keys = additional_metadata_keys
19
- @additional_excludes = additional_excludes
20
- @directory = File.join repository, directory
21
+ # Public: Initialization method, used in the awestruct pipeline.
22
+ #
23
+ # opts - A Hash of options, some being required, some not (default: {}).
24
+ # :repository - The String name of the directory
25
+ # containing the repository (required).
26
+ # :directory - The String directory name, within the
27
+ # :respository, containing the files
28
+ # (required).
29
+ # :layout - The String name of the layout to use,
30
+ # omitting the extension (required).
31
+ # :output_dir - The String or Pathname of the output
32
+ # directory for the files (required).
33
+ # :additional_excludes - An Array of Strings containing
34
+ # additional base file names to exclude
35
+ # (default: []).
36
+ # :recurse_subdirectories - Boolean flag indicating to continue
37
+ # searching subdirectories (default:
38
+ # true).
39
+ # :additional_metadata_keys - An Array of String keys from the
40
+ # AsciiDoc metadata to include in the
41
+ # searchisko payload (default: []).
42
+ # :site_variable - String name of the key within the site
43
+ # containing additional metadata about
44
+ # the guide (default: value of
45
+ # :output_dir).
46
+ # Returns the created extension.
47
+ def initialize(opts = {})
48
+ required_keys = [:repository, :directory, :layout, :output_dir, :site_variable]
49
+ opts = {additional_excludes: [], recurse_subdirectories: true,
50
+ additional_metadata_keys: [], site_variable: opts[:output_dir]}.merge opts
51
+ missing_required_keys = required_keys - opts.keys
52
+
53
+ raise ArgumentError.new "Missing required arguments #{missing_required_keys.join ', '}" unless missing_required_keys.empty?
54
+
55
+ @repo = opts[:repository]
56
+ @output_dir = Pathname.new opts[:output_dir]
57
+ @layout = opts[:layout]
58
+ @recurse_subdirectories = opts[:recurse_subdirectories]
59
+ @additional_metadata_keys = opts[:additional_metadata_keys]
60
+ @additional_excludes = opts[:additional_excludes]
61
+ @directory = File.join opts[:repository], opts[:directory]
62
+ @site_variable = opts[:site_variable]
21
63
  end
22
64
 
65
+ # Internal: Execute method required by awestruct. Called during the
66
+ # pipeline execution. No return.
67
+ #
68
+ # site - The site instance from awestruct.
69
+ #
70
+ # Returns nothing.
23
71
  def execute site
24
72
  searchisko = Aweplug::Helpers::Searchisko.new({:base_url => site.dcp_base_url,
25
73
  :authenticate => true,
@@ -41,6 +89,7 @@ module Aweplug::Extensions
41
89
  metadata = {:author => doc.author, :commits => commit_info(@repo, path),
42
90
  :title => doc.doctitle, :tags => doc.attributes['tags'],
43
91
  :toc => doc.sections.inject([]) {|result, elm| result << {:id => elm.id, :text => elm.title}; result},
92
+ :github_repo_url => repository_url(@repo),
44
93
  # Will need to strip html tags for summary
45
94
  :summary => doc.sections.first.render}
46
95
 
@@ -1,6 +1,6 @@
1
1
  require 'pathname'
2
2
  require 'kramdown'
3
- require 'aweplug/helpers/git_commit_metadata'
3
+ require 'aweplug/helpers/git_metadata'
4
4
  require 'aweplug/helpers/kramdown_metadata'
5
5
  require 'aweplug/helpers/searchisko'
6
6
  require 'json'
@@ -8,15 +8,49 @@ require 'json'
8
8
  module Aweplug
9
9
  module Extensions
10
10
  module Kramdown
11
+ # Public: An awestruct extension for guides / examples written in AsciiDoc.
12
+ # Files with the .asciidoc or .adoc extension are considered to be
13
+ # AsciiDoc files. This extension makes use of asciidoctor to
14
+ # render the files.
15
+ #
16
+ # Example
17
+ #
18
+ # extension Aweplug::Extensions::AsciidocExample({...})
11
19
  class Quickstart
12
20
  include Aweplug::Helper::Git::Commit::Metadata
21
+ include Aweplug::Helper::Git::Repository
13
22
 
14
- def initialize repository, layout, output_dir
15
- @repo = repository
16
- @output_dir = Pathname.new output_dir
17
- @layout = layout
23
+ # Public: Initialization method, used in the awestruct pipeline.
24
+ #
25
+ # opts - A Hash of options, some being required, some not (default: {}).
26
+ # :repository - The String name of the directory containing
27
+ # the repository (required).
28
+ # :layout - The String name of the layout to use,
29
+ # omitting the extension (required).
30
+ # :output_dir - The String or Pathname of the output
31
+ # directory for the files (required).
32
+ # :site_variable - String name of the key within the site
33
+ # containing additional metadata about
34
+ # the guide (default: value of
35
+ # :output_dir).
36
+ # Returns the created extension.
37
+ def initialize opts = {}
38
+ required_keys = [:repository, :layout, :output_dir, :site_variable]
39
+ missing_required_keys = required_keys - opts.keys
40
+
41
+ raise ArgumentError.new "Missing required arguments #{missing_required_keys.join ', '}" unless missing_required_keys.empty?
42
+ @repo = opts[:repository]
43
+ @output_dir = Pathname.new opts[:output_dir]
44
+ @layout = opts[:layout]
45
+ @site_variable = opts[:site_variable] || opts[:output_dir]
18
46
  end
19
47
 
48
+ # Internal: Execute method required by awestruct. Called during the
49
+ # pipeline execution. No return.
50
+ #
51
+ # site - The Site instance from awestruct.
52
+ #
53
+ # Returns nothing.
20
54
  def execute site
21
55
  # Not sure if it's better to do this once per class,
22
56
  # once per site, or once per invocation
@@ -30,6 +64,7 @@ module Aweplug
30
64
 
31
65
  metadata = extract_metadata(file)
32
66
  metadata[:commits] = commit_info @repo, Pathname.new(file)
67
+ metadata[:github_repo_url] = repository_url @repo
33
68
  converted_html = metadata.delete :converted
34
69
 
35
70
  page.send 'metadata=', metadata
@@ -62,6 +97,15 @@ module Aweplug
62
97
  end
63
98
  end
64
99
 
100
+
101
+ private
102
+
103
+ # Private: Makes use of the sepcial Kramdown parser in aweplug to pull
104
+ # out metadata from the README files.
105
+ #
106
+ # file - The String file path (relative or absolute) to parse.
107
+ #
108
+ # Returns a Hash of the metadata retrieved.
65
109
  def extract_metadata(file)
66
110
  document = parse_kramdown(file)
67
111
  toc = ::Kramdown::Converter::Toc.convert(document.root)
@@ -75,6 +119,12 @@ module Aweplug
75
119
  metadata
76
120
  end
77
121
 
122
+ # Private: Adds the Page to the site.
123
+ #
124
+ # site - The Site from awestruct.
125
+ # file - The String file path (relative or absolute) to parse.
126
+ #
127
+ # Returns the newly constructed Page
78
128
  def add_to_site(site, file)
79
129
  page_path = Pathname.new file
80
130
  page = site.engine.load_site_page file
@@ -84,8 +134,11 @@ module Aweplug
84
134
  page
85
135
  end
86
136
 
87
- private
88
-
137
+ # Private: Parses the file through Kramdown.
138
+ #
139
+ # file - The String file path (relative or absolute) to parse.
140
+ #
141
+ # Returns the parsed Kramdown Document.
89
142
  def parse_kramdown(file)
90
143
  ::Kramdown::Document.new File.readlines(file).join, :input => 'QuickStartParser'
91
144
  end
@@ -2,10 +2,24 @@ require 'awestruct/handlers/base_handler'
2
2
  require 'pathname'
3
3
 
4
4
  module Aweplug
5
+ # Public: Additional handlers for awestruct. Any handler here must extend
6
+ # Awestruct::Handlers::BaseHandler.
5
7
  module Handlers
8
+ # Public: An awestruct handler used to create a page which has no file
9
+ # backing it.
10
+ #
11
+ # Examples
12
+ #
13
+ # Aweplug::Handlers::SyntheticHandler(site, content, output_path)
14
+ # # => <Aweplug::Handlers::Synthetic:0x...>"
6
15
  class SyntheticHandler < Awestruct::Handlers::BaseHandler
7
16
  attr_reader :path
8
17
 
18
+ # Public: Initializer for the handler.
19
+ #
20
+ # site - awestruct Site object.
21
+ # content - Content for the page, must respond to t_s.
22
+ # path - output Path or String location for the generated page.
9
23
  def initialize site, content, path
10
24
  super(site)
11
25
  @content = content
@@ -19,18 +33,35 @@ module Aweplug
19
33
  end
20
34
  end
21
35
 
36
+ # Public: Returns the mtime for this instance
37
+ #
38
+ # page - Ignored, kept for compat with other handlers.
39
+ #
40
+ # Returns the Integer timestamp of when this object was created.
22
41
  def input_mtime(page)
23
42
  @input_mtime
24
43
  end
25
44
 
45
+ # Public: Returns the rendered verison of @content.
46
+ #
47
+ # context - Ignored, kept for compatibility.
48
+ # with_layouts - Ignored, kept for compatibility.
49
+ #
50
+ # Returns @content.to_s.
26
51
  def rendered_content(context, with_layouts)
27
- @content
52
+ @content.to_s
28
53
  end
29
54
 
55
+ # Public: Returns @content.to_s.
56
+ #
57
+ # Returns @content.to_s.
30
58
  def raw_content
31
- @content
59
+ @content.to_s
32
60
  end
33
61
 
62
+ # Public: Calculates and returns the path of @path relative to site.dir.
63
+ #
64
+ # Returns String path of @path calculated relative to site.dir.
34
65
  def relative_source_path
35
66
  # Copied from file_handler.rb in awestruct
36
67
  begin
@@ -4,11 +4,23 @@ require 'json'
4
4
  module Aweplug
5
5
  module Helper
6
6
  module Git
7
+ module Repository
8
+ # Public: Returns the URL for the git repository.
9
+ #
10
+ # repo_root - The directory (relative to the site base) containing the
11
+ # git repository.
12
+ # remote_name - Name of the remote to retrieve, defaults to 'origin'
13
+ #
14
+ # Returns a string containing the URL of the git remote repository
15
+ def repository_url(repo_root, remote_name='origin')
16
+ Open3.capture2(%Q[git --git-dir=#{repo_root}/.git config --get remote.#{remote_name}.url]).first.chomp[0..-5]
17
+ end
18
+ end
7
19
  module Commit
8
20
  module Metadata
9
21
  # Public: Retrieves commit information from the git repo containing the file.
10
22
  #
11
- # repo_root - The directory (relative to the site base) containing the git repo
23
+ # repo_root - The directory (relative to the site base) containing the git repo
12
24
  # file_path - Path to the file being processed, relative to the site base
13
25
  #
14
26
  # Returns an array of commit info as json values
@@ -21,3 +33,4 @@ module Aweplug
21
33
  end
22
34
  end
23
35
  end
36
+
@@ -3,7 +3,16 @@ require 'kramdown/parser/kramdown'
3
3
 
4
4
  module Kramdown
5
5
  module Parser
6
+ # Public: A Kramdown parser specific for the JBoss Quickstart format. See
7
+ # http://kramdown.gettalong.org/parser/kramdown.html for more information.
6
8
  class QuickStartParser < Kramdown::Parser::Kramdown
9
+
10
+ # Private: Initializer for the Parser.
11
+ #
12
+ # source - String source of the document.
13
+ # options - Hash of options, see
14
+ # http://kramdown.gettalong.org/parser/kramdown.html for list
15
+ # of supported options.
7
16
  def initialize source, options
8
17
  super
9
18
  @block_parsers.unshift :author_metadata
@@ -23,6 +32,7 @@ module Kramdown
23
32
  HEADER_ID=/(?:[ \t]+\{#([A-Za-z][\w:-]*)\})?/
24
33
  SETEXT_HEADER_START = /^(#{OPT_SPACE}[^ \t].*?)#{HEADER_ID}[ \t]*?\n(=)+\s*?\n/
25
34
 
35
+ # Internal: Parses the title to add to the metadata Hash.
26
36
  def parse_title_hack_metadata
27
37
  return false if !after_block_boundary?
28
38
 
@@ -40,42 +50,49 @@ module Kramdown
40
50
  end
41
51
  define_parser(:title_hack_metadata, SETEXT_HEADER_START)
42
52
 
53
+ # Internal: Parses the author to add to the metadata Hash.
43
54
  def parse_author_metadata
44
55
  @src.pos += @src.matched_size
45
56
  @root.options[:metadata][:author] = @src[2].rstrip
46
57
  end
47
58
  define_parser(:author_metadata, /^(Author:)#{OPT_SPACE}(.*?)\s*?\n/)
48
59
 
60
+ # Internal: Parses the level to add to the metadata Hash.
49
61
  def parse_level_metadata
50
62
  @src.pos += @src.matched_size
51
63
  @root.options[:metadata][:level] = @src[2].rstrip
52
64
  end
53
65
  define_parser(:level_metadata, /^(Level:)#{OPT_SPACE}(.*?)\s*?\n/)
54
66
 
67
+ # Internal: Parses the technologies to add to the metadata Hash.
55
68
  def parse_technologies_metadata
56
69
  @src.pos += @src.matched_size
57
70
  @root.options[:metadata][:technologies] = @src[2].rstrip
58
71
  end
59
72
  define_parser(:technologies_metadata, /^(Technologies:)#{OPT_SPACE}(.*?)\s*?\n/)
60
73
 
74
+ # Internal: Parses the target_product to add to the metadata Hash.
61
75
  def parse_target_product_metadata
62
76
  @src.pos += @src.matched_size
63
77
  @root.options[:metadata][:target_product] = @src[2].rstrip
64
78
  end
65
79
  define_parser(:target_product_metadata, /^(Target Product:)#{OPT_SPACE}(.*?)\s*?\n/)
66
80
 
81
+ # Internal: Parses the source URL to add to the metadata Hash.
67
82
  def parse_source_metadata
68
83
  @src.pos += @src.matched_size
69
84
  @root.options[:metadata][:source] = @src[2][1..-2].rstrip
70
85
  end
71
86
  define_parser(:source_metadata, /^(Source:)#{OPT_SPACE}(.*?)\s*?\n/)
72
87
 
88
+ # Internal: Parses the summary to add to the metadata Hash.
73
89
  def parse_summary_metadata
74
90
  @src.pos += @src.matched_size
75
91
  @root.options[:metadata][:summary] = @src[2].rstrip
76
92
  end
77
93
  define_parser(:summary_metadata, /^(Summary:)#{OPT_SPACE}(.*?)\s*?\n/)
78
94
 
95
+ # Internal: Parses the product to add to the metadata Hash.
79
96
  def parse_product_metadata
80
97
  @src.pos += @src.matched_size
81
98
  @root.options[:metadata][:product] = @src[2].rstrip
@@ -14,6 +14,8 @@ module Aweplug::Helpers
14
14
  # :logging - Boolean to log responses
15
15
  # :raise_error - Boolean flag if 404 and 500 should raise exceptions
16
16
  # :adapter - faraday adapter to use, defaults to :net_http
17
+ #
18
+ # Returns a new instance of Searchisko.
17
19
  def initialize opts={}
18
20
  @faraday = Faraday.new(:url => opts[:base_url]) do |builder|
19
21
  if opts[:authenticate]
@@ -30,18 +32,65 @@ module Aweplug::Helpers
30
32
  end
31
33
  end
32
34
 
35
+ # Public: Performs a GET search against the Searchisko instance using
36
+ # provided parameters.
37
+ #
38
+ # params - Hash of parameters to use as query string. See
39
+ # http://docs.jbossorg.apiary.io/#searchapi for more information
40
+ # about parameters and how they affect the search.
41
+ #
42
+ # Example
43
+ #
44
+ # searchisko.search {:query => 'Search query'}
45
+ # # => {...}
46
+ #
47
+ # Returns the String result of the search.
33
48
  def search params = {}
34
49
  get '/search', params
35
50
  end
36
51
 
52
+ # Public: Makes an HTTP GET to host/v1/rest/#{path} and returns the
53
+ # result from the Faraday request.
54
+ #
55
+ # path - String containing the rest of the path.
56
+ # params - Hash containing query string parameters.
57
+ #
58
+ # Example
59
+ #
60
+ # searchisko.get 'feed', {:query => 'Search Query'}
61
+ # # => Faraday Response Object
62
+ #
63
+ # Returns the Faraday Response for the request.
37
64
  def get path, params = {}
38
65
  @faraday.get "/v1/rest/" + path, params
39
66
  end
40
67
 
68
+ # Public: Posts content to Searchisko.
69
+ #
70
+ # content_type - String of the Searchisko sys_content_type for the content
71
+ # being posted.
72
+ # content_id - String of the Searchisko sys_content_id for the content.
73
+ # params - Hash containing the content to push.
74
+ #
75
+ # Examples
76
+ #
77
+ # searchisko.push_content 'jbossdeveloper_bom', id, content_hash
78
+ # # => Faraday Response
79
+ #
80
+ # Returns a Faraday Response from the POST.
41
81
  def push_content content_type, content_id, params = {}
42
82
  post "/content/#{content_type}/#{content_id}", params
43
83
  end
44
84
 
85
+ # Public: Perform an HTTP POST to Searchisko.
86
+ #
87
+ # path - String containing the rest of the path.
88
+ # params - Hash containing the POST body.
89
+ #
90
+ # Examples
91
+ #
92
+ # searchisko.post "rating/#{searchisko_document_id}", {rating: 3}
93
+ # # => Faraday Response
45
94
  def post path, params = {}
46
95
  @faraday.post do |req|
47
96
  req.url "/v1/rest/" + path
@@ -0,0 +1,127 @@
1
+ require 'oauth'
2
+
3
+ module Aweplug
4
+ module Helpers
5
+ module Vimeo
6
+
7
+ # Public: Embeds videos from vimeo inside a div. Retrieves the title
8
+ # and video cast from vimeo using the authenticated API.
9
+ # TODO Builds follow links (blog, facebook, twitter, linkedin) for any
10
+ # video cast, using the DCP .
11
+ #
12
+ # url - the URL of the vimeo page for the video to display
13
+ #
14
+ # Returns the html snippet
15
+ #
16
+ def vimeo(url)
17
+ id = video_id(url)
18
+ title = video_title(id)
19
+ out = %Q[<div class="embedded-media">] +
20
+ %Q[<h4>#{title}</h4>] +
21
+ %Q[<iframe src="//player.vimeo.com/video/#{id}\?title=0&byline=0&portrait=0&badge=0&color=2664A2" width="500" height="313" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen}></iframe>]
22
+ cast = video_cast(id)
23
+ cast.each do |c|
24
+ out += %Q[<div class="follow-links">] +
25
+ %Q[<span class="title">Follow #{first_name(c.realname)}</span>] +
26
+ %Q[<a><i class="icon-rss"></i></a>] +
27
+ %Q[<a><i class="icon-facebook"></i></a>] +
28
+ %Q[<a><i class="icon-twitter"></i></a>] +
29
+ %Q[<a><i class="icon-linkedin"></i></a>] +
30
+ %Q[</div>]
31
+ end
32
+ out + %Q[</div>]
33
+ end
34
+
35
+ # Internal: Extracts a firstname from a full name
36
+ #
37
+ # full_name - the full name, e.g. Pete Muir
38
+ def first_name(full_name)
39
+ full_name.split[0]
40
+ end
41
+
42
+ # Internal: Extracts a Vimeo video id from a Vimeo video URL
43
+ #
44
+ # url - the url of the video
45
+ def video_id(url)
46
+ url.match(/^.*\/(\d*)$/)[1]
47
+ end
48
+
49
+ # Internal: Retrieves a video title using the Vimeo API
50
+ #
51
+ # video_id - the id of the video to fetch the title for
52
+ def video_title(video_id)
53
+ body = exec_method "vimeo.videos.getInfo", video_id
54
+ if body
55
+ JSON.parse(body)["video"][0]["title"]
56
+ else
57
+ "Unable to fetch video info from vimeo"
58
+ end
59
+ end
60
+
61
+ # Internal: Retrieves the cast of a video using the Vimeo API
62
+ #
63
+ # video_id - the id of the video to fetch the title for
64
+ def video_cast(video_id)
65
+ body = exec_method "vimeo.videos.getCast", video_id
66
+ cast = []
67
+ if body
68
+ JSON.parse(body)["cast"]["member"].each do |c|
69
+ cast << OpenStruct.new(c)
70
+ end
71
+ end
72
+ cast
73
+ end
74
+
75
+ # Internal: Execute a method against the Vimeo API
76
+ #
77
+ # method - the API method to execute
78
+ # video_id - the id of the video to execute the method for
79
+ #
80
+ # Returns JSON retreived from the Vimeo API
81
+ def exec_method(method, video_id)
82
+ if access_token
83
+ query = "http://vimeo.com/api/rest/v2?method=#{method}&video_id=#{video_id}&format=json"
84
+ access_token.get(query).body
85
+ end
86
+ end
87
+
88
+ # Internal: Obtains an OAuth::AcccessToken for the Vimeo API, using the
89
+ # vimeo_client_id and vimeo_access_token defined in site/config.yml and
90
+ # vimeo_client_secret and vimeo_access_token_secret defined in environment
91
+ # variables
92
+ #
93
+ # Returns an OAuth::AccessToken for the Vimeo API
94
+ def access_token
95
+ if @access_token
96
+ @access_token
97
+ else
98
+ if not ENV['vimeo_client_secret']
99
+ puts 'Cannot fetch video info from vimeo, vimeo_client_secret is missing from environment variables'
100
+ return
101
+ end
102
+ if not site.vimeo_client_id
103
+ puts 'Cannot fetch video info vimeo, vimeo_client_id is missing from _config/site.yml'
104
+ return
105
+ end
106
+ if not ENV['vimeo_access_token_secret']
107
+ puts 'Cannot fetch video info from vimeo, vimeo_access_token_secret is missing from environment variables'
108
+ return
109
+ end
110
+ if not site.vimeo_access_token
111
+ puts 'Cannot fetch video info from vimeo, vimeo_access_token is missing from _config/site.yml'
112
+ return
113
+ end
114
+ consumer = OAuth::Consumer.new(site.vimeo_client_id, ENV['vimeo_client_secret'],
115
+ { :site => "https://vimeo.com",
116
+ :scheme => :header
117
+ })
118
+ # now create the access token object from passed values
119
+ token_hash = { :oauth_token => site.vimeo_access_token,
120
+ :oauth_token_secret => ENV['vimeo_access_token_secret']
121
+ }
122
+ OAuth::AccessToken.from_hash(consumer, token_hash )
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
@@ -1,4 +1,4 @@
1
1
  module Aweplug
2
- VERSION='1.0.0.a9'
2
+ VERSION='1.0.0.a10'
3
3
  end
4
4
 
data/lib/aweplug.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "aweplug/version"
2
2
 
3
+ # Public: Main namespace for the Aweplug extensions for awestruct
3
4
  module Aweplug
4
5
  # Your code goes here...
5
6
  end