forked from saurabh/orbit4-5
Handle some exceptions
This commit is contained in:
parent
9a142e3bb6
commit
5af7e681c1
|
@ -20,3 +20,4 @@
|
||||||
app/views/frontend
|
app/views/frontend
|
||||||
/public/uploads/*
|
/public/uploads/*
|
||||||
public/assets/*
|
public/assets/*
|
||||||
|
public/import_status.yml
|
||||||
|
|
|
@ -154,10 +154,13 @@ class Admin::ImportController < OrbitAdminController
|
||||||
a = Asset.new
|
a = Asset.new
|
||||||
a.remote_data_url = url
|
a.remote_data_url = url
|
||||||
a.title_translations = {"en" => a.data.filename, "zh_tw" => a.data.filename}
|
a.title_translations = {"en" => a.data.filename, "zh_tw" => a.data.filename}
|
||||||
a.save!
|
if(a.save! rescue false)
|
||||||
|
temp.gsub!(CGI::escapeHTML(url), "#")
|
||||||
|
else
|
||||||
@user.assets << a
|
@user.assets << a
|
||||||
temp.gsub!(CGI::escapeHTML(url), a.data.to_s)
|
temp.gsub!(CGI::escapeHTML(url), a.data.to_s)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
news['Content'][locale] = temp
|
news['Content'][locale] = temp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -172,9 +175,10 @@ class Admin::ImportController < OrbitAdminController
|
||||||
bl = BulletinLink.new
|
bl = BulletinLink.new
|
||||||
bl.url = news["URL"]
|
bl.url = news["URL"]
|
||||||
bl.title_translations = {"en" => "Link", "zh_tw" => "Link"}
|
bl.title_translations = {"en" => "Link", "zh_tw" => "Link"}
|
||||||
bl.save!
|
if (bl.save! rescue false)
|
||||||
bulletin.bulletin_links << bl
|
bulletin.bulletin_links << bl
|
||||||
end
|
end
|
||||||
|
end
|
||||||
news['files'].each do |f|
|
news['files'].each do |f|
|
||||||
bf = BulletinFile.new
|
bf = BulletinFile.new
|
||||||
if f['url'].split('title=').size == 1
|
if f['url'].split('title=').size == 1
|
||||||
|
@ -192,9 +196,10 @@ class Admin::ImportController < OrbitAdminController
|
||||||
file = File.new("tmp/uploads/#{bf.title}#{file_ext}","w+b")
|
file = File.new("tmp/uploads/#{bf.title}#{file_ext}","w+b")
|
||||||
file.write(bf.file.read)
|
file.write(bf.file.read)
|
||||||
bf.file.cache!(file)
|
bf.file.cache!(file)
|
||||||
bf.save!
|
|
||||||
|
|
||||||
|
if (bf.save! rescue false)
|
||||||
bulletin.bulletin_files << bf
|
bulletin.bulletin_files << bf
|
||||||
|
end
|
||||||
|
|
||||||
File.delete(file)
|
File.delete(file)
|
||||||
end
|
end
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
}
|
}
|
||||||
.alert{
|
.alert{
|
||||||
width: 500px;
|
width: 500px;
|
||||||
margin: 0 auto;
|
margin: 20px auto 0;
|
||||||
}
|
}
|
||||||
.module-icon{
|
.module-icon{
|
||||||
font-size: 64px;
|
font-size: 64px;
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="site-url-wrapper" class="import-wrapper">
|
<div id="site-url-wrapper" class="import-wrapper">
|
||||||
<input type="text" class="import-url" name="url" placeholder="http://www.rulingcom.com">
|
<input type="text" class="import-url" name="url" value="" placeholder="http://www.rulingcom.com">
|
||||||
<button id="check-site-url" class="btn btn-primary pull-right">Next <i class="icons-arrow-right"></i></button>
|
<button id="check-site-url" class="btn btn-primary pull-right">Next <i class="icons-arrow-right"></i></button>
|
||||||
<span><a href='http://installer.tp.rulingcom.com/rss2-export-api.zip'>Download Rss2 Export API</a></span>
|
<span><a href='http://installer.tp.rulingcom.com/rss2-export-api.zip'>Download Rss2 Export API</a></span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -204,6 +204,7 @@
|
||||||
$("#import-back-btn").click(function(){
|
$("#import-back-btn").click(function(){
|
||||||
$("#import-progress").fadeOut(300,function(){
|
$("#import-progress").fadeOut(300,function(){
|
||||||
$("#import-head").fadeIn(0);
|
$("#import-head").fadeIn(0);
|
||||||
|
$('#import-start-btn').show();
|
||||||
$("#import-modules").fadeIn(300);
|
$("#import-modules").fadeIn(300);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -364,6 +365,7 @@
|
||||||
|
|
||||||
var importModule = function(m){
|
var importModule = function(m){
|
||||||
module = m;
|
module = m;
|
||||||
|
progress = 0;
|
||||||
dataList=Array();
|
dataList=Array();
|
||||||
categories=null;
|
categories=null;
|
||||||
|
|
||||||
|
@ -409,6 +411,7 @@
|
||||||
|
|
||||||
var importModuleDatas = function(){
|
var importModuleDatas = function(){
|
||||||
progress = 0;
|
progress = 0;
|
||||||
|
$('#import-start-btn').hide();
|
||||||
$("#import-progress-text").html("Start import...<br/><br/>");
|
$("#import-progress-text").html("Start import...<br/><br/>");
|
||||||
|
|
||||||
if(dataList!=null && categories!=null){
|
if(dataList!=null && categories!=null){
|
||||||
|
@ -422,6 +425,11 @@
|
||||||
if(progress>=dataList.length) return;
|
if(progress>=dataList.length) return;
|
||||||
|
|
||||||
var data = dataList[progress];
|
var data = dataList[progress];
|
||||||
|
if(data['category']==0){
|
||||||
|
progress++;
|
||||||
|
importModuleData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
var category_id = categories[data['category']]['id'];
|
var category_id = categories[data['category']]['id'];
|
||||||
var Sn = data['Sn'];
|
var Sn = data['Sn'];
|
||||||
|
|
||||||
|
@ -439,6 +447,10 @@
|
||||||
category: category_id
|
category: category_id
|
||||||
}
|
}
|
||||||
}).done(function(data){
|
}).done(function(data){
|
||||||
|
}).fail(function(data){
|
||||||
|
$("#alert-msg").html('Faild to import Sn:'+progress+'<br/>Message:'+data['status']+'-'+data['statusText']);
|
||||||
|
$(".alert").fadeIn(300).delay(5000).fadeOut(300);
|
||||||
|
}).always(function(){
|
||||||
progress++;
|
progress++;
|
||||||
percentage = parseInt((progress/dataList.length)*100)+'%';
|
percentage = parseInt((progress/dataList.length)*100)+'%';
|
||||||
$("#import-progress .bar").css('width',percentage);
|
$("#import-progress .bar").css('width',percentage);
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
---
|
|
||||||
total_images: 6
|
|
||||||
current_status: 0
|
|
||||||
success: true
|
|
||||||
current_album_id: '1'
|
|
||||||
current_album_name: "系統測試"
|
|
Loading…
Reference in New Issue