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 'mongoid', github: 'mongoid/mongoid'
|
||||||
gem 'bson_ext'
|
gem 'bson_ext'
|
||||||
gem 'mongoid-elasticsearch'
|
gem 'mongoid-elasticsearch'
|
||||||
|
gem 'httparty'
|
||||||
|
|
||||||
gem 'devise'
|
gem 'devise'
|
||||||
gem 'warden'
|
gem 'warden'
|
||||||
|
|
|
@ -121,6 +121,9 @@ GEM
|
||||||
faraday (0.8.9)
|
faraday (0.8.9)
|
||||||
multipart-post (~> 1.2.0)
|
multipart-post (~> 1.2.0)
|
||||||
hike (1.2.3)
|
hike (1.2.3)
|
||||||
|
httparty (0.12.0)
|
||||||
|
json (~> 1.8)
|
||||||
|
multi_xml (>= 0.5.2)
|
||||||
i18n (0.6.9)
|
i18n (0.6.9)
|
||||||
jbuilder (1.5.3)
|
jbuilder (1.5.3)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
|
@ -142,6 +145,7 @@ GEM
|
||||||
connection_pool (~> 1.2)
|
connection_pool (~> 1.2)
|
||||||
optionable (~> 0.2.0)
|
optionable (~> 0.2.0)
|
||||||
multi_json (1.8.2)
|
multi_json (1.8.2)
|
||||||
|
multi_xml (0.5.5)
|
||||||
multipart-post (1.2.0)
|
multipart-post (1.2.0)
|
||||||
optionable (0.2.0)
|
optionable (0.2.0)
|
||||||
origin (2.0.0)
|
origin (2.0.0)
|
||||||
|
@ -216,6 +220,7 @@ DEPENDENCIES
|
||||||
devise
|
devise
|
||||||
doorkeeper!
|
doorkeeper!
|
||||||
font-awesome-rails!
|
font-awesome-rails!
|
||||||
|
httparty
|
||||||
jbuilder (~> 1.2)
|
jbuilder (~> 1.2)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
mongoid!
|
mongoid!
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
class ExtensionsController < ApplicationController
|
class ExtensionsController < ApplicationController
|
||||||
doorkeeper_for :all
|
# doorkeeper_for :all
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
class TemplatesController < ApplicationController
|
class TemplatesController < ApplicationController
|
||||||
doorkeeper_for :all, :scopes => [:public]
|
# doorkeeper_for :all, :scopes => [:public]
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -29,6 +29,7 @@ class ExtensionsController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @extension.save
|
if @extension.save
|
||||||
|
@extension.get_version_number
|
||||||
format.html { redirect_to @extension, notice: 'Extension was successfully created.' }
|
format.html { redirect_to @extension, notice: 'Extension was successfully created.' }
|
||||||
format.json { render action: 'show', status: :created, location: @extension }
|
format.json { render action: 'show', status: :created, location: @extension }
|
||||||
else
|
else
|
||||||
|
@ -43,6 +44,8 @@ class ExtensionsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @extension.update(extension_params)
|
if @extension.update(extension_params)
|
||||||
|
@extension.get_version_number
|
||||||
|
|
||||||
format.html { redirect_to @extension, notice: 'Extension was successfully updated.' }
|
format.html { redirect_to @extension, notice: 'Extension was successfully updated.' }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
else
|
else
|
||||||
|
@ -70,6 +73,7 @@ class ExtensionsController < ApplicationController
|
||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def extension_params
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,9 @@ class Extension
|
||||||
field :extension, type: String
|
field :extension, type: String
|
||||||
field :description, type: String
|
field :description, type: String
|
||||||
field :category_id, type: String
|
field :category_id, type: String
|
||||||
|
field :repository, type: String
|
||||||
|
field :key, type: String
|
||||||
|
field :version, type: String
|
||||||
|
|
||||||
slug :title, history: true
|
slug :title, history: true
|
||||||
|
|
||||||
|
@ -21,4 +24,15 @@ class Extension
|
||||||
mount_uploader :extension, ProductUploader
|
mount_uploader :extension, ProductUploader
|
||||||
|
|
||||||
elasticsearch!
|
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
|
end
|
||||||
|
|
|
@ -25,6 +25,16 @@
|
||||||
<%= f.text_area :description %>
|
<%= f.text_area :description %>
|
||||||
</div>
|
</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>
|
<label>Preview</label>
|
||||||
<%= f.file_field :preview %>
|
<%= f.file_field :preview %>
|
||||||
<%= f.hidden_field :preview_cache %>
|
<%= f.hidden_field :preview_cache %>
|
||||||
|
|
|
@ -9,6 +9,11 @@
|
||||||
<%= @extension.author %>
|
<%= @extension.author %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<strong>Version: </strong>
|
||||||
|
<%= @extension.version %>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong>Description: </strong>
|
<strong>Description: </strong>
|
||||||
<%= @extension.description.html_safe %>
|
<%= @extension.description.html_safe %>
|
||||||
|
|
Loading…
Reference in New Issue