forked from saurabh/orbit4-5
counter added and also some changes for store
This commit is contained in:
parent
aac9135149
commit
4575fce2a9
2
Gemfile
2
Gemfile
|
@ -34,7 +34,7 @@ gem 'mongoid', github: "mongoid/mongoid"
|
||||||
gem "mini_magick", "3.5.0"
|
gem "mini_magick", "3.5.0"
|
||||||
gem 'carrierwave'
|
gem 'carrierwave'
|
||||||
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
|
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
|
||||||
|
gem 'zip-zip'
|
||||||
gem 'kaminari'
|
gem 'kaminari'
|
||||||
gem "impressionist"
|
gem "impressionist"
|
||||||
gem "chartkick"
|
gem "chartkick"
|
||||||
|
|
|
@ -25,7 +25,10 @@ var FormValidator = function(form){
|
||||||
nospace : function(value){
|
nospace : function(value){
|
||||||
return (/\s/.test(value) ? false : true);
|
return (/\s/.test(value) ? false : true);
|
||||||
},
|
},
|
||||||
email : function(value){
|
lowercase : function(value){
|
||||||
|
return (value == value.toLowerCase() ? true : false);
|
||||||
|
},
|
||||||
|
email : function(){
|
||||||
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
return re.test(value);
|
return re.test(value);
|
||||||
}
|
}
|
||||||
|
@ -40,35 +43,39 @@ var FormValidator = function(form){
|
||||||
|
|
||||||
var _attachSubmitHandler = function(){
|
var _attachSubmitHandler = function(){
|
||||||
fv.form.on("submit",function(){
|
fv.form.on("submit",function(){
|
||||||
failed_elements = [];
|
return fv.isFormValidated();
|
||||||
$.each(elements_data,function(key,element){
|
})
|
||||||
var validators = element.validators,
|
}
|
||||||
messages = element.messages,
|
|
||||||
el = fv.form.find("#" + key);
|
this.isFormValidated = function(){
|
||||||
for(i = 0; i < validators.length; i++){
|
failed_elements = [];
|
||||||
var error_span = (fv.form.find("div[for=" + key + "]").length ? $("div[for=" + key + "]") : $("<div class='validator_error_class text-error' for='" + key + "'></div>"));
|
$.each(elements_data,function(key,element){
|
||||||
if(typeof fv.validate_functions[validators[i]] == "function"){
|
var validators = element.validators,
|
||||||
if(!fv.validate_functions[validators[i]](el.val(),el)){
|
messages = element.messages,
|
||||||
error_span.text(messages[i]);
|
el = fv.form.find("#" + key);
|
||||||
el.after(error_span);
|
for(i = 0; i < validators.length; i++){
|
||||||
failed_elements.push(el);
|
var error_span = (fv.form.find("div[for=" + key + "]").length ? $("div[for=" + key + "]") : $("<div class='validator_error_class text-error' for='" + key + "'></div>"));
|
||||||
break;
|
if(typeof fv.validate_functions[validators[i]] == "function"){
|
||||||
}else{
|
if(!fv.validate_functions[validators[i]](el.val(),el)){
|
||||||
error_span.remove();
|
error_span.text(messages[i]);
|
||||||
}
|
el.after(error_span);
|
||||||
|
failed_elements.push(el);
|
||||||
|
break;
|
||||||
}else{
|
}else{
|
||||||
console.info("Not validating for " + validators[i] + ". Skipping.");
|
error_span.remove();
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
console.info("Not validating for " + validators[i] + ". Skipping.");
|
||||||
}
|
}
|
||||||
})
|
|
||||||
if(failed_elements.length){
|
|
||||||
var offset = failed_elements[0].offset().top - fv.form.offset().top + fv.form.scrollTop();
|
|
||||||
fv.form.parent().animate({scrollTop:offset-50}, '300', 'swing');
|
|
||||||
return false;
|
|
||||||
}else{
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if(failed_elements.length){
|
||||||
|
var offset = failed_elements[0].offset().top - fv.form.offset().top + fv.form.scrollTop();
|
||||||
|
fv.form.parent().animate({scrollTop:offset-50}, '300', 'swing');
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _putFieldsValidatorAndMessage = function(){
|
var _putFieldsValidatorAndMessage = function(){
|
||||||
|
|
|
@ -106,7 +106,9 @@ class Admin::SitesController < OrbitAdminController
|
||||||
else
|
else
|
||||||
result = "success"
|
result = "success"
|
||||||
# Bundler.with_clean_env { `cd #{Rails.root} && bundle update` }
|
# Bundler.with_clean_env { `cd #{Rails.root} && bundle update` }
|
||||||
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=built_in_extensions.rb bundle update && bundle` }
|
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=built_in_extensions.rb bundle update && bundle` }
|
||||||
|
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=downloaded_extensions.rb bundle update && bundle` }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
render :text => result
|
render :text => result
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
require "net/http"
|
||||||
|
require 'open-uri'
|
||||||
|
require 'zip/zip'
|
||||||
class StoreApiController < ApplicationController
|
class StoreApiController < ApplicationController
|
||||||
def confirmation
|
def confirmation
|
||||||
site_token = params[:site_token]
|
site_token = params[:site_token]
|
||||||
|
@ -11,4 +14,49 @@ class StoreApiController < ApplicationController
|
||||||
render :json => {"success" => false}.to_json
|
render :json => {"success" => false}.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def install_module
|
||||||
|
file = File.join(Rails.root,"downloaded_extensions.rb")
|
||||||
|
g = "gem '#{params[:module_key]}', git: '#{params[:git_path]}'"
|
||||||
|
File.open(file,"a+") { |f| f.puts(g) }
|
||||||
|
if !directory_exists?(File.join(Rails.root,"app","templates","#{Site.first.template}","modules","#{params[:module_key]}"))
|
||||||
|
download_template(params[:template],params[:template_filename])
|
||||||
|
end
|
||||||
|
bundle_install
|
||||||
|
render :json => {"success" => true} .to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def bundle_install
|
||||||
|
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=downloaded_extensions.rb bundle update && bundle` }
|
||||||
|
%x(kill -s USR2 `cat tmp/pids/unicorn.pid`)
|
||||||
|
sleep 5
|
||||||
|
end
|
||||||
|
|
||||||
|
def download_template(url,name)
|
||||||
|
dir = File.join(Rails.root,"public","template_cache")
|
||||||
|
destination = File.join(Rails.root,"app","templates","#{Site.first.template}","modules")
|
||||||
|
if !directory_exists?(dir)
|
||||||
|
Dir.mkdir dir
|
||||||
|
end
|
||||||
|
zipfile = File.join(Rails.root, "public" , "template_cache", name)
|
||||||
|
open(zipfile, 'wb') do |fo|
|
||||||
|
fo.print open(url).read
|
||||||
|
end
|
||||||
|
unzip_file(zipfile,destination)
|
||||||
|
end
|
||||||
|
|
||||||
|
def directory_exists?(directory)
|
||||||
|
File.directory?(directory)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unzip_file (file, destination)
|
||||||
|
Zip::ZipFile.open(file) { |zip_file|
|
||||||
|
zip_file.each { |f|
|
||||||
|
f_path=File.join(destination, f.name)
|
||||||
|
FileUtils.mkdir_p(File.dirname(f_path))
|
||||||
|
zip_file.extract(f, f_path) unless File.exist?(f_path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -64,6 +64,8 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
site_footer = site_footer.nil? ? "" : site_footer
|
site_footer = site_footer.nil? ? "" : site_footer
|
||||||
html = html.gsub("{{footer-data}}",site_footer)
|
html = html.gsub("{{footer-data}}",site_footer)
|
||||||
|
counter = Page.root.view_count.to_s rescue ""
|
||||||
|
html = html.gsub("{{site-counter}}",counter)
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<footer class="layout-footer">
|
<footer class="layout-footer">
|
||||||
<div class="container layout-footer-inner">
|
<div class="container layout-footer-inner">
|
||||||
<div class="layout-footer-content">{{footer-data}}</div>
|
<div class="layout-footer-content">{{footer-data}}</div>
|
||||||
|
<div>{{site-counter}}</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
|
@ -27,6 +27,7 @@ Orbit::Application.routes.draw do
|
||||||
get "/module/:name" => "home#index"
|
get "/module/:name" => "home#index"
|
||||||
get "/module/:name/show" => "home#show"
|
get "/module/:name/show" => "home#show"
|
||||||
post "/store/confirmation" => "store_api#confirmation"
|
post "/store/confirmation" => "store_api#confirmation"
|
||||||
|
post "/store/install_module" => "store_api#install_module"
|
||||||
|
|
||||||
# The priority is based upon order of creation: first created -> highest priority.
|
# The priority is based upon order of creation: first created -> highest priority.
|
||||||
# See how all your routes lay out with "rake routes".
|
# See how all your routes lay out with "rake routes".
|
||||||
|
|
Loading…
Reference in New Issue