template_store and some changes for the store..

This commit is contained in:
Harry Bomrah 2014-01-06 12:17:44 +05:30 committed by saurabhbhatia
parent db86d5248f
commit 1a90990311
5 changed files with 68 additions and 71 deletions

View File

@ -1,7 +1,5 @@
class Admin::ModuleStoreController < OrbitBackendController
layout "back_end"
def index
end

View File

@ -1,19 +1,24 @@
class Admin::TemplateStoreController < ApplicationController
class Admin::TemplateStoreController < OrbitBackendController
layout "back_end"
@@store_domain = "http://store.tp.rulingcom.com"
def index
@store = @@store_domain
@templates = JSON.parse(get_templates)
end
def show
@store = @@store_domain
@template = JSON.parse(get_template(params[:id])) rescue nil
end
def download_theme
render :json => {"success"=>true}.to_json
end
protected
def get_template(id)
uri = URI.parse("http://#{APP_CONFIG['store_ip']}/store/design/#{id}")
uri = URI.parse("#{@@store_domain}/api/templates/#{id}")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
@ -21,11 +26,13 @@ class Admin::TemplateStoreController < ApplicationController
end
def get_templates
uri = URI.parse("http://#{APP_CONFIG['store_ip']}/store/designs")
uri = URI.parse("#{@@store_domain}/api/templates")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
response.body
end
end

View File

@ -1,13 +1,3 @@
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %>
<% end %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag 'normalize' %>
<%= stylesheet_link_tag 'bootstrap-responsive' %>
<%= stylesheet_link_tag 'rulingorbit' %>
<%= stylesheet_link_tag 'template-store' %>
<% end %>
<div class="wrapper">
@ -27,22 +17,7 @@
</ul>
</div>
</div>
<div class="filter fn">
<span class="label">Color</span>
<div class="select single-select" id="color-filter">
<ul class="option-list">
<li><a href="" class="ui btn option-default">All</a></li>
<li><a class="ui btn" href=""><span class="color-tag red"></span></a></li>
<li><a class="ui btn" href=""><span class="color-tag yellow"></span></a></li>
<li><a class="ui btn" href=""><span class="color-tag green"></span></a></li>
<li><a class="ui btn" href=""><span class="color-tag blue"></span></a></li>
<li><a class="ui btn" href=""><span class="color-tag purple"></span></a></li>
<li><a class="ui btn" href=""><span class="color-tag white"></span></a></li>
<li><a class="ui btn" href=""><span class="color-tag gray"></span></a></li>
<li><a class="ui btn" href=""><span class="color-tag black"></span></a></li>
</ul>
</div>
</div>
<div class="filter fn">
<span class="label">Category</span>
<div class="drop-menu ui">
@ -78,28 +53,39 @@
<ul class="clearfix">
<% @templates.each do |template| %>
<li>
<%= link_to admin_template_store_template_path(template['id']) do %>
<%= image_tag "http://#{APP_CONFIG['store_ip']}#{template['thumb']}", :class => "item-thumb" %>
<span class="item-info">
<a href="<%= admin_template_store_template_path(template["_slugs"][0]) %>">
<img src="<%= @store + template['preview']['preview']['thumb']['url'] %>" class="item-thumb" />
<span class="item-info">
<b class="item-name"><%= template['title'] %></b>
<span class="item-price">Free</span>
</span>
<% end %>
</a>
<%= link_to "Download", "javascript:void(0);", "data-url" => template['template']['template']['url'], :class=> 'btn btn-primary download-link' %>
</li>
<% end %>
<% (12-@templates.size).times do |i| %>
<li>
<%= link_to admin_template_store_template_path('show', :t => i + 1) do %>
<img src="/assets/template/thumb/tb<%= i + 1 %>.jpg" alt="" class="item-thumb">
<span class="item-info">
<b class="item-name">Template <%= i + 1 %></b>
<span class="item-price">Free</span>
</span>
<% end %>
</li>
<% end %>
</ul>
</div>
</div>
<script type="text/javascript">
(function(){
$("a.download-link").on(clickEvent,function(){
var el = $(this),
downloadurl = $(this).data("url");
el.removeClass("btn-primary").addClass("btn-info").text("Installing").attr('disabled',"disabled");
$.ajax({
url : "<%= admin_template_store_download_theme_path %>",
data : {"url" : downloadurl},
dataType : "json",
type : "post",
success : function(data){
if(data.success){
el.removeClass('btn-info').addClass('btn-success').text("Installed");
}
}
})
})
})()
</script>

View File

@ -1,18 +1,3 @@
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %>
<% end %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag 'normalize' %>
<%= stylesheet_link_tag 'bootstrap-responsive' %>
<%= stylesheet_link_tag 'rulingorbit' %>
<%= stylesheet_link_tag 'template-store' %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "jquery.cycle" %>
<%= javascript_include_tag "rulingorbit" %>
<% end %>
<% if @template %>
<div class="wrapper">
<div id="toolbar">
@ -21,9 +6,9 @@
<div id="content" class="clearfix">
<div class="side">
<div id="item-info">
<%= image_tag "http://#{APP_CONFIG['store_ip']}#{@template['thumb']}", :class => "item-thumb" %>
<%= image_tag "#{@store}#{@template['preview']['preview']['thumb']['url']}", :class => "item-thumb" %>
<h2 class="item-name"><%= @template['title'] %></h2>
<%= link_to 'free download', buy_template_admin_purchase_path(@template['id']), :id => "download" %>
<%= link_to "Download", "javascript:void(0);", "data-url" => @template['template']['template']['url'], :class=> 'btn btn-primary download-link' %>
<ul class="item-extra-info">
<li><span class="title">views</span><span class="count"><%= Random.new.rand(10..100) %></span></li>
<!-- <li><span class="title">color</span><span class="color-tag green"></span></li> -->
@ -32,13 +17,11 @@
</div>
<div class="main clearfix">
<h3>description</h3>
<div id="desc-holder" class="paragraph"><%= @template['intro'] %></div>
<div id="desc-holder" class="paragraph"><%#= @template['intro'] %></div>
<h3>screen shot</h3>
<div id="screen-shot">
<div class="holder">
<% @template['screenshots'].each do |screenshot| %>
<%= image_tag "http://#{APP_CONFIG['store_ip']}#{screenshot}", :class => "preview item-thumb" %>
<% end %>
</div>
</div>
</div>
@ -78,3 +61,24 @@
</div>
</div>
<% end %>
<script type="text/javascript">
(function(){
$("a.download-link").on(clickEvent,function(){
var el = $(this),
downloadurl = $(this).data("url");
el.removeClass("btn-primary").addClass("btn-info").text("Installing").attr('disabled',"disabled");
$.ajax({
url : "<%= admin_template_store_download_theme_path %>",
data : {"url" : downloadurl},
dataType : "json",
type : "post",
success : function(data){
if(data.success){
el.removeClass('btn-info').addClass('btn-success').text("Installed");
}
}
})
})
})()
</script>

View File

@ -258,7 +258,9 @@ Orbit::Application.routes.draw do
match 'module_store' => 'module_store#index'
match 'module_store/show' => 'module_store#show'
match 'template_store' => 'template_store#index'
match 'template_store/download_theme' => "template_store#download_theme"
match 'template_store/template/:id' => 'template_store#show', :as => :template_store_template
# match 'template_store/cool_method' => "template_store#cool_method"
end
# end admin