aweplug 1.0.0.a6 → 1.0.0.a7
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.
| @@ -0,0 +1,80 @@ | |
| 1 | 
            +
            require 'pathname'
         | 
| 2 | 
            +
            require 'asciidoctor'
         | 
| 3 | 
            +
            require 'aweplug/helpers/git_commit_metadata'
         | 
| 4 | 
            +
            require 'aweplug/helpers/searchisko'
         | 
| 5 | 
            +
            require 'json'
         | 
| 6 | 
            +
            require 'pry'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            module Aweplug::Extensions
         | 
| 9 | 
            +
              class AsciidocExample 
         | 
| 10 | 
            +
                include Aweplug::Helper::Git::Commit::Metadata
         | 
| 11 | 
            +
             | 
| 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 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def execute site
         | 
| 24 | 
            +
                  searchisko = Aweplug::Helpers::Searchisko.new({:base_url => site.dcp_base_url, 
         | 
| 25 | 
            +
                                                                 :authenticate => true, 
         | 
| 26 | 
            +
                                                                 :searchisko_username => ENV['dcp_user'], 
         | 
| 27 | 
            +
                                                                 :searchisko_password => ENV['dcp_password'], 
         | 
| 28 | 
            +
                                                                 :logger => site.profile == 'developement'})
         | 
| 29 | 
            +
                  Find.find @directory do |path|
         | 
| 30 | 
            +
                    Find.prune if File.directory?(path) && !@recurse_subdirectories
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    next if File.directory?(path) # If it's a directory, start recursing
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                    Find.prune if File.extname(path) !~ /\.a(scii)?doc/ || @additional_excludes.include?(File.basename path)
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                    page = site.engine.load_site_page path
         | 
| 37 | 
            +
                    page.layout = @layout
         | 
| 38 | 
            +
                    page.output_path = File.join(@output_dir, File.basename(page.output_path))
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                    doc = Asciidoctor.load_file path
         | 
| 41 | 
            +
                    metadata = {:author => doc.author, :commits => commit_info(@repo, path), 
         | 
| 42 | 
            +
                                :title => doc.doctitle, :tags => doc.attributes['tags'],
         | 
| 43 | 
            +
                                :toc => doc.sections.inject([]) {|result, elm| result << {:id => elm.id, :text => elm.title}; result},
         | 
| 44 | 
            +
                                # Will need to strip html tags for summary
         | 
| 45 | 
            +
                                :summary => doc.sections.first.render}
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                    page.send('metadata=', metadata)
         | 
| 48 | 
            +
                    site.pages << page
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                    searchisko_hash = {
         | 
| 51 | 
            +
                      :sys_title => metadata[:title], 
         | 
| 52 | 
            +
                      :sys_content_id => Digest::SHA1.hexdigest(metadata[:title])[0..7], # maybe change?
         | 
| 53 | 
            +
                      :sys_description => metadata[:summary],
         | 
| 54 | 
            +
                      :sys_content => doc.render, 
         | 
| 55 | 
            +
                      :sys_url_view => "#{site.base_url}#{site.ctx_root.nil? ? '/' : '/' + site.ctx_root + '/'}#{page.output_path}",
         | 
| 56 | 
            +
                      :"sys_content_content-type" => 'text/html',
         | 
| 57 | 
            +
                      :sys_type => 'jbossdeveloper_example',
         | 
| 58 | 
            +
                      :sys_content_type => 'example',
         | 
| 59 | 
            +
                      :sys_content_provider => 'jboss-developer',
         | 
| 60 | 
            +
                      :contributors => metadata[:commits].collect { |c| c[:author] }.uniq,
         | 
| 61 | 
            +
                      :sys_created => metadata[:commits].collect { |c| DateTime.parse c[:date] }.last,
         | 
| 62 | 
            +
                      :sys_activity_dates => metadata[:commits].collect { |c| DateTime.parse c[:date] },
         | 
| 63 | 
            +
                      :sys_updated => metadata[:commits].collect { |c| DateTime.parse c[:date] }.first
         | 
| 64 | 
            +
                    } 
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                    @additional_metadata_keys.inject(searchisko_hash) do |hash, key|
         | 
| 67 | 
            +
                      hash[key.to_sym] = doc.attributes[key]
         | 
| 68 | 
            +
                      hash
         | 
| 69 | 
            +
                    end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                    unless site.profile =~ /development/
         | 
| 72 | 
            +
                      searchisko.push_content(searchisko_hash[:sys_type], 
         | 
| 73 | 
            +
                                              searchisko_hash[:sys_content_id], 
         | 
| 74 | 
            +
                                              searchisko_hash.to_json)
         | 
| 75 | 
            +
                    end
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
            end
         | 
| 80 | 
            +
             | 
| @@ -24,7 +24,6 @@ module Aweplug | |
| 24 24 | 
             
                                                                     :authenticate => true, 
         | 
| 25 25 | 
             
                                                                     :searchisko_username => ENV['dcp_user'], 
         | 
| 26 26 | 
             
                                                                     :searchisko_password => ENV['dcp_password'], 
         | 
| 27 | 
            -
                                                                     #:adapter => :excon,
         | 
| 28 27 | 
             
                                                                     :logger => site.profile == 'developement'})
         | 
| 29 28 | 
             
                      Dir["#{@repo}/**/README.md"].each do |file|
         | 
| 30 29 | 
             
                        page = add_to_site site, file
         | 
    
        data/lib/aweplug/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: aweplug
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0.0. | 
| 4 | 
            +
              version: 1.0.0.a7
         | 
| 5 5 | 
             
              prerelease: 6
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2013-12- | 
| 12 | 
            +
            date: 2013-12-21 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: octokit
         | 
| @@ -124,6 +124,7 @@ files: | |
| 124 124 | 
             
            - Rakefile
         | 
| 125 125 | 
             
            - aweplug.gemspec
         | 
| 126 126 | 
             
            - lib/aweplug.rb
         | 
| 127 | 
            +
            - lib/aweplug/extensions/asciidoc_example.rb
         | 
| 127 128 | 
             
            - lib/aweplug/extensions/identities.rb
         | 
| 128 129 | 
             
            - lib/aweplug/extensions/identity/confluence.rb
         | 
| 129 130 | 
             
            - lib/aweplug/extensions/identity/github.rb
         |