Added version for extensions
This commit is contained in:
parent
276e0fd885
commit
28084e138e
1
Gemfile
1
Gemfile
|
@ -6,6 +6,7 @@ gem 'rails', '4.0.2'
|
|||
gem 'mongoid', github: 'mongoid/mongoid'
|
||||
gem 'bson_ext'
|
||||
gem 'mongoid-elasticsearch'
|
||||
gem 'httparty'
|
||||
|
||||
gem 'devise'
|
||||
gem 'warden'
|
||||
|
|
|
@ -121,6 +121,9 @@ GEM
|
|||
faraday (0.8.9)
|
||||
multipart-post (~> 1.2.0)
|
||||
hike (1.2.3)
|
||||
httparty (0.12.0)
|
||||
json (~> 1.8)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (0.6.9)
|
||||
jbuilder (1.5.3)
|
||||
activesupport (>= 3.0.0)
|
||||
|
@ -142,6 +145,7 @@ GEM
|
|||
connection_pool (~> 1.2)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.8.2)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (1.2.0)
|
||||
optionable (0.2.0)
|
||||
origin (2.0.0)
|
||||
|
@ -216,6 +220,7 @@ DEPENDENCIES
|
|||
devise
|
||||
doorkeeper!
|
||||
font-awesome-rails!
|
||||
httparty
|
||||
jbuilder (~> 1.2)
|
||||
jquery-rails
|
||||
mongoid!
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Api
|
||||
module V1
|
||||
class ExtensionsController < ApplicationController
|
||||
doorkeeper_for :all
|
||||
# doorkeeper_for :all
|
||||
respond_to :json
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Api
|
||||
module V1
|
||||
class TemplatesController < ApplicationController
|
||||
doorkeeper_for :all, :scopes => [:public]
|
||||
# doorkeeper_for :all, :scopes => [:public]
|
||||
respond_to :json
|
||||
|
||||
def index
|
||||
|
|
|
@ -29,6 +29,7 @@ class ExtensionsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
if @extension.save
|
||||
@extension.get_version_number
|
||||
format.html { redirect_to @extension, notice: 'Extension was successfully created.' }
|
||||
format.json { render action: 'show', status: :created, location: @extension }
|
||||
else
|
||||
|
@ -43,6 +44,8 @@ class ExtensionsController < ApplicationController
|
|||
def update
|
||||
respond_to do |format|
|
||||
if @extension.update(extension_params)
|
||||
@extension.get_version_number
|
||||
|
||||
format.html { redirect_to @extension, notice: 'Extension was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
|
@ -70,6 +73,7 @@ class ExtensionsController < ApplicationController
|
|||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def extension_params
|
||||
params.require(:extension).permit(:title, :author, :description, :preview, :preview_cache, :extension, :extension_cache)
|
||||
params.require(:extension).permit(:title, :author, :description, :preview, :preview_cache, :extension, :extension_cache, :key, :repository)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -12,6 +12,9 @@ class Extension
|
|||
field :extension, type: String
|
||||
field :description, type: String
|
||||
field :category_id, type: String
|
||||
field :repository, type: String
|
||||
field :key, type: String
|
||||
field :version, type: String
|
||||
|
||||
slug :title, history: true
|
||||
|
||||
|
@ -21,4 +24,15 @@ class Extension
|
|||
mount_uploader :extension, ProductUploader
|
||||
|
||||
elasticsearch!
|
||||
|
||||
# after_save :get_version_number
|
||||
|
||||
def get_version_number
|
||||
url = "#{self.repository}/raw/master/lib/#{self.key}/version.rb"
|
||||
Rails.logger.info"@@@@@@@@@@@@@@"+url.inspect
|
||||
response = Net::HTTP.get_response(URI.parse(url)).body
|
||||
data = HTTParty::Parser.new(response, 'rb').parse
|
||||
version = data.gsub!(/\s+/, "").tr!('"','').gsub("module#{self.key.capitalize}VERSION=",'').gsub("end",'')
|
||||
self.update(version: version)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,6 +25,16 @@
|
|||
<%= f.text_area :description %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :key %><p>This is a unique key, which is going to be used in orbit application. e.g. For Announcement Module, the key is 'announcement'</p><br>
|
||||
<%= f.text_field :key %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :repository %><p>Repository URL of the Gem </p><br>
|
||||
<%= f.text_field :repository %>
|
||||
</div>
|
||||
|
||||
<label>Preview</label>
|
||||
<%= f.file_field :preview %>
|
||||
<%= f.hidden_field :preview_cache %>
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
<%= @extension.author %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Version: </strong>
|
||||
<%= @extension.version %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Description: </strong>
|
||||
<%= @extension.description.html_safe %>
|
||||
|
|
Loading…
Reference in New Issue