diff --git a/.gitignore b/.gitignore index b8a4c577..d27ac727 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,10 @@ uploads/**/* public/panel/**/* public/index.html .DS_Store - +solr/data/**/* *.swp - +*.pid +*.lck public/assets config/application.rb diff --git a/Gemfile b/Gemfile index 3ea8359e..40270a73 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,7 @@ gem 'mongoid-tree', :require => 'mongoid/tree' gem "mongo_session_store-rails3" gem 'mysql2' gem 'nokogiri' + gem 'radius' gem 'rake' # gem 'remotipart' @@ -84,7 +85,7 @@ group :test, :development do gem "simplecov" gem "delorean" gem "watchr" - gem "spork" + gem "spork" # gem "capybara" # gem 'yard' # gem "bluecloth" diff --git a/Guardfile b/Guardfile new file mode 100644 index 00000000..4f561da0 --- /dev/null +++ b/Guardfile @@ -0,0 +1,22 @@ +guard 'livereload' do + watch(%r{app/.+\.(erb|haml)}) + watch(%r{app/helpers/.+\.rb}) + watch(%r{public/.+\.(css|js|html)}) + watch(%r{config/locales/.+\.yml}) +end + +guard 'rspec', :version => 2 do + watch(%r{^spec/.+_spec\.rb}) + watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { "spec" } + + # Rails example + watch('spec/spec_helper.rb') { "spec" } + watch('config/routes.rb') { "spec/routing" } + watch('app/controllers/application_controller.rb') { "spec/controllers" } + watch(%r{^spec/.+_spec\.rb}) + watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] } + watch(%r{^app/views/(.+)/}) { |m| "spec/requests/#{m[1]}_spec.rb" } +end \ No newline at end of file diff --git a/app/assets/javascripts/ajax_form.js.erb b/app/assets/javascripts/ajax_form.js.erb index 917c352d..9f993cd1 100644 --- a/app/assets/javascripts/ajax_form.js.erb +++ b/app/assets/javascripts/ajax_form.js.erb @@ -1,111 +1,7 @@ -<%#= encoding: utf-8 %> -$(document).on('click', '#ajax_form_submit', function(){ - // $('#ajaxForm').ajaxSubmit({ - // beforeSubmit: function(a,f,o) { - // o.dataType = 'script'; - // if (o.dataType == 'script') { - // o.url = o.url.split('?'); // split on GET params - // if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js - // o.url = o.url.join('?'); // join on GET params - // } - // }, - // success: function(response,status,xhr){ - // alert(response); - // alert(status); - // alert(xhr); - // }, - // error:function(){ - // alert("error"); - // } - // }); - - - var o = { - // dataType: 'script', - dataType: 'html', - url:$("#ajaxForm").attr("action"), - beforeSubmit: function(){ - var sub = true; - $("span.error").remove(); - $("#dyn_error").empty(); - $("#ajaxForm input").each(function(){ - if($(this).val() == ""){ - $(" *").insertAfter($(this)); - sub = false; - } - }) - if(!sub){ - $("#dyn_error").text("Cannot be empty."); - $("#dyn_error").text("<%= I18n.t('cant_empty_star') %>"); - return false; - } - }, - success: function(response,status,xhr){ - if(typeof tinyMCEPopup != "undefined"){ - var x = response.split("#"); - var returnurl = x[0], - returntitle = x[1], - returndescription = x[2]; - var win = tinyMCEPopup.getWindowArg("window"); - win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = returnurl; - win.document.getElementById(tinyMCEPopup.getWindowArg("alt")).value = returndescription; - win.document.getElementById(tinyMCEPopup.getWindowArg("title")).value = returntitle; - if (typeof(win.ImageDialog) != "undefined") { - // we are, so update image dimensions... - if (win.ImageDialog.getImageData) - win.ImageDialog.getImageData(); - - // ... and preview if necessary - if (win.ImageDialog.showPreviewImage) - win.ImageDialog.showPreviewImage(returnurl); - } - tinyMCEPopup.close(); - }else{ - //incase if we want to do something for quick edit file upload - // var modalvalues = ""; - // var r = ""; - // if(rcom.getInternetExplorerVersion() > -1){ - // r = "" + response + ""; - // r = r.replace("**",""); - // r = r.replace("**",""); - // r = $(r); - // modalvalues = r.find("span").attr("data-content").split("#"); - // r.attr("id",r.find("span").attr("for")); - // var table=document.getElementById(modalvalues[0]); - // //var tbody = table.getElementsByTagName("tbody"); - // var row = table.insertRow(table.rows.length-1); - // var c1 = row.insertCell(0), - // c2 = row.insertCell(1), - // c3 = row.insertCell(2); - // c1.innerHTML = r.find("td").eq(0).html(); - // c2.innerHTML = r.find("td").eq(1).html(); - // c3.innerHTML = r.find("td").eq(2).html(); - // var trow = $("#bulletin_files tfoot").find("tr").eq(0); - // $("#bulletin_files tbody").append(trow); - // }else{ - - // response = response.replace("**",""); - // response = response.replace("**",""); - // r = $(response); - // modalvalues = r.find("span").attr("data-content").split("#"); - // $('#' + modalvalues[0]+ ' tbody').append(r); - // } - // console.log(modalvalues[1]); - // $("#"+modalvalues[1]).modal('hide'); - //$('#bulletin_files tbody').append(r); - //$(response).fadeIn(); - } - }, - error:function(){ - alert("error"); - } - } - - if (o.dataType == 'script') { - o.url = o.url.split('?'); // split on GET params - if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js - o.url = o.url.join('?'); // join on GET params - } - $('#ajaxForm').ajaxSubmit(o); - +$('#ajaxForm').ajaxForm({ + beforeSubmit: function(a,f,o) { + o.dataType = 'script'; + }, + success: function(data) { + } }); \ No newline at end of file diff --git a/app/assets/javascripts/bulletin_form.js.erb b/app/assets/javascripts/bulletin_form.js.erb index 18e8e375..902f815d 100644 --- a/app/assets/javascripts/bulletin_form.js.erb +++ b/app/assets/javascripts/bulletin_form.js.erb @@ -10,7 +10,7 @@ $('.bulletin_files_block a.delete').live('click', function(){ }); $(document).on('click', '.action a.remove_existing_record', function(){ - if(confirm("<%= I18n.t('announcement.sure?')%>")){ + if(confirm("<%= I18n.t(:sure?)%>")){ $(this).next('.should_destroy').attr('value', 1); $("tr#" + $(this).prev().attr('value')).hide(); } diff --git a/app/assets/javascripts/inc/ajax_setting.js b/app/assets/javascripts/inc/ajax_setting.js index c23a73bf..d2f183f0 100644 --- a/app/assets/javascripts/inc/ajax_setting.js +++ b/app/assets/javascripts/inc/ajax_setting.js @@ -1,7 +1,7 @@ -jQuery(document).ajaxStart(function(){ - $('').appendTo('body'); -}); +// jQuery(document).ajaxStart(function(){ +// $('').appendTo('body'); +// }); -jQuery(document).ajaxComplete(function(){ - $("#sys_modal").hide().remove(); -}); +// jQuery(document).ajaxComplete(function(){ +// $("#sys_modal").hide().remove(); +// }); diff --git a/app/assets/javascripts/inc/modal-preview.js b/app/assets/javascripts/inc/modal-preview.js index 959f04b2..87973b55 100644 --- a/app/assets/javascripts/inc/modal-preview.js +++ b/app/assets/javascripts/inc/modal-preview.js @@ -3,6 +3,58 @@ // <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%> $(document).ready(function() { + // $(".post_preview").click(function(e){ + // $("#main-wrap").after(""); + // e.preventDefault(); + // var form = $(this).parents("form").first() + // //var cont = form["content"].value; + // // $.ajax({ + // // type: 'POST', + // // url: $(this).attr("href")+'?preview=true', + // // data: form.serialize(), + // // dataType: "script", + // // success: function (msg) { + // // $("#"+start_modal_with_id).modal('show'); }, + // // error: function(){ + // // alert("ERROR"); + // // } + // // }); + // url = "/panel/news/back_end/news_bulletins/preview?preview=true" + // // alert(url) + // form.attr("action",url); + // form.submit(); + // //return false; + // }); + $("button.post_preview").click(function(){ + var btn = document.getElementById("button_for_preview"); + var attrs = btn.attributes; + var url = attrs['url']; + // url = url.replace("url=",""); + $("form.nccu_ajax_form").ajaxSubmit({ + beforeSubmit: function(a,f,o){ + $("#main-wrap").after(""); + o.dataType = 'script'; + o.url = url.nodeValue; + o.type = 'post'; + },success: function(msg) { } + + }); + }) + // $("form.nccu_ajax_form").ajaxForm({ + // beforeSubmit: function(a,f,o) { + // // if(clicked_what.hasClass("post_preview")){ + // // $("#main-wrap").after(""); + // // o.dataType = 'script'; + // // o.url = clicked_what.attr("url"); + // // } + // }, + // success: function(data) { + // // if(!clicked_what.hasClass("post_preview")){ + // // window.location = data.redirect_url; + // // } + // } + // }) + $("a.preview_trigger").click(function(){ $("#main-wrap").after(""); $.ajax({ diff --git a/app/assets/javascripts/inc/search.js b/app/assets/javascripts/inc/search.js index 50f3835f..e8bc8405 100644 --- a/app/assets/javascripts/inc/search.js +++ b/app/assets/javascripts/inc/search.js @@ -4,33 +4,45 @@ //extended jquery to search fast. $.extend($.expr[':'], { - 'containsi': function (elem, i, match, array) { - return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; - } + 'containsi': function (elem, i, match, array) { + return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; + } }); var interval,sval; $(document).ready(function(){ - $("#user_filter").keyup(function(e){ - if((e.which>96 && e.which<123) || (e.which>64 && e.which<92) || (e.which == 32) || (e.which == 8)){ - sval = $(this).val(); - $(".checkbox").popover("hide"); - $("div.checkblock").hide(); - clearInterval(interval); - interval = setInterval(waitForSearch,1000); - } - }) + $("#user_filter").keyup(function(e){ + if((e.which>96 && e.which<123) || (e.which>64 && e.which<92) || (e.which == 32) || (e.which == 8)){ + sval = $(this).val(); + $(".checkbox").popover("hide"); + $("div.checkblock").hide(); + clearInterval(interval); + interval = setInterval(waitForSearch,1000); + } + }) }) var waitForSearch = function(){ - if(sval){ - var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length - if(totalfoundbyname!=0){ - $("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show(); - }else if(totalfoundbyname==0){ - $("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show(); - } - }else{ - $(".checkbox").popover('hide'); - $("div.checkblock").show(); - } - clearInterval(interval); + if(sval){ + var re1 = new RegExp("^[\u4E00-\uFA29]*$"); //Chinese character range + var re2 = new RegExp("^[\uE7C7-\uE7F3]*$"); + if ((re1.test(sval) && (re2.test(sval)))){ + + var totalfoundbyname = $("div#users_checkbox_ary label.member-name:contains("+sval+")").length + if(totalfoundbyname!=0){ + $("div#users_checkbox_ary label.member-name:contains("+sval+")").parent().parent().show(); + }else if(totalfoundbyname==0){ + $("div#users_checkbox_ary div.for_unit:contains("+sval+")").parent().show(); + } + }else{ + var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length + if(totalfoundbyname!=0){ + $("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show(); + }else if(totalfoundbyname==0){ + $("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show(); + } + } + }else{ + $(".checkbox").popover('hide'); + $("div.checkblock").show(); + } + clearInterval(interval); } \ No newline at end of file diff --git a/app/assets/javascripts/lib/contenteditable.js.erb b/app/assets/javascripts/lib/contenteditable.js.erb index 40c19dd3..9d35acbe 100644 --- a/app/assets/javascripts/lib/contenteditable.js.erb +++ b/app/assets/javascripts/lib/contenteditable.js.erb @@ -40,11 +40,11 @@ $(".nav-tabs").find(".icons-pencil").click(function(){ data: { body: content_holder.html() }, success: function(json) { $(selector).attr("contenteditable",false) - alert("<%= I18n.t('admin.contenteditable.update_done') %>"); + alert("<%= I18n.t('update.success_') %>"); //content_holder.effect('highlight', {'color': '#0f0'}, 3000); }, error: function() { - alert("<%= I18n.t('admin.contenteditable.update_failed') %>"); + alert("<%= I18n.t('update.fail') %>"); //content_holder.effect('highlight', {'color': '#f00'}, 3000); content_holder.html(content); } diff --git a/app/assets/javascripts/news_bulletin_form.js.erb b/app/assets/javascripts/news_bulletin_form.js.erb index 092bbfff..2a96e6be 100644 --- a/app/assets/javascripts/news_bulletin_form.js.erb +++ b/app/assets/javascripts/news_bulletin_form.js.erb @@ -11,7 +11,7 @@ $('.news_bulletin_files_block a.delete').live('click', function(){ }); $(document).on('click', '.action a.remove_existing_record', function(){ - if(confirm("<%= I18n.t('news.sure?')%>")){ + if(confirm("<%= I18n.t(:sure?)%>")){ $(this).next('.should_destroy').attr('value', 1); $("tr#" + $(this).prev().attr('value')).hide(); } diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 17b14841..2b4eb629 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -332,9 +332,9 @@ var orbitDesktop = function(dom){ if(j==0)$group.attr("id",tile.group_id); if(tile.data_category == "app") - $li = $('
  • '+tile.title+'

  • '); + $li = $('
  • '+tile.title+'

  • '); else - $li = $('
  • '+tile.title+'

    Loading...
  • '); + $li = $('
  • '+tile.title+'

    Loading...
  • '); $group.find('.col'+colindex).append($li); } @@ -1557,10 +1557,10 @@ var orbitDesktop = function(dom){ var widget = $(this); if(widget.attr("data-category")=="widget"){ var widgename = widget.attr("data-content"); - $.getScript("/desktop_widgets/"+widgename+"/"+widgename+".js",function(){ - widget.find("div.appholder").load("/desktop_widgets/"+widgename+"/index.html.erb"); + $.getScript(widget.attr("js-link"),function(){ + widget.find("div.appholder").load(widget.attr("data-content")); }); - // $(this).find("div.appholder").append( $('').attr('href', "/desktop_widgets/"+widgename+"/css/"+widgename+".css")); + $(this).find("div.appholder").append( '') } }) @@ -1697,3 +1697,4 @@ orbitDesktop.prototype.currentUsername = "Harry"; var uselessfunction = function(){ $.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"}); } + diff --git a/app/assets/javascripts/tinymce_orbit.js.erb b/app/assets/javascripts/tinymce_orbit.js.erb index 50bcc232..975485a3 100644 --- a/app/assets/javascripts/tinymce_orbit.js.erb +++ b/app/assets/javascripts/tinymce_orbit.js.erb @@ -14,17 +14,20 @@ function load_tinymce() { theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, + relative_urls : false, // Skin options skin : "o2k7", skin_variant : "silver", - + font_size_style_values : "xx-small,x-small,small,medium,large,x-large,xx-large", // Drop lists for link/image/media/template dialogs template_external_list_url : "js/template_list.js", // external_link_list_url : "js/link_list.js", // external_image_list_url : "js/image_list.js", // media_external_list_url : "js/media_list.js" + content_css: "<%= asset_path('tinymce_orbit.css') %>", + // Style formats style_formats : [ {title : 'Bold text', inline : 'b'}, @@ -40,7 +43,15 @@ function load_tinymce() { template_replace_values : { username : "Some User", staffid : "991234" - } + }, + + // Valide HTML elements + valid_elements : '*[*]', + valid_children : '*[*]', + + // Height & width + height : '400', + width : '100%' }); } function myFileBrowser(field_name, url, type, win) { diff --git a/app/assets/stylesheets/bootstrap.css.erb.backup20120913 b/app/assets/stylesheets/bootstrap.css.erb.backup20120913 index 7cc53a52..e754a970 100644 --- a/app/assets/stylesheets/bootstrap.css.erb.backup20120913 +++ b/app/assets/stylesheets/bootstrap.css.erb.backup20120913 @@ -99,7 +99,7 @@ textarea { body { margin: 0; font-family: /*"Helvetica Neue", */Helvetica, Arial, sans-serif; - font-size: 13px; + font-size: 75%; line-height: 18px; color: #333333; background-color: #ffffff; diff --git a/app/assets/stylesheets/member.css b/app/assets/stylesheets/member.css index 7ef219be..add8774a 100644 --- a/app/assets/stylesheets/member.css +++ b/app/assets/stylesheets/member.css @@ -287,32 +287,65 @@ padding: 0 20px 0 150px !important; margin: 20px 0 0; } -.user-role .user-info { +.role-block .user-info { top: 23px; margin-left: -135px; width: 100px; border-right: none; box-shadow: none; } -.user-role .map-block h4 .gender { +.role-block .map-block h4 .gender { top: -1px; bottom: auto; left: -1px; right: auto; border-radius: 4px 0 0 0; } -.user-role .teacher h4 .gender { +.role-block .teacher h4 .gender { border-color: #186AB6 transparent transparent #186AB6; } -.user-role .student h4 .gender { +.role-block .student h4 .gender { border-color: #F38C08 transparent transparent #F38C08; } -.user-role .staff h4 .gender { +.role-block .staff h4 .gender { border-color: #139E2F transparent transparent #139E2F; } -.user-role .tab-content, .user-role .nav-pills { +.role-block .tab-content, .role-block .nav-pills { float: left; } -.user-role .nav-pills { - margin-left: 10px; +.role-block .nav-pills { + margin-bottom: 0;g +} +.role-block .nav-pills > li > a { + margin-top: 0; +} +/*.role-block .control-group .inline { + float: +}*/ +.plural .input-append input, .plural .input-append select, .plural .input-append .uneditable-input, .unRadius input { + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} +.plural .input-append .removeInput { + display: none; +} +.plural.editMore .input-append input, .plural.editMore .input-append select, .plural.editMore .input-append .uneditable-input { + -webkit-border-radius: 3px 0 0 3px; + -moz-border-radius: 3px 0 0 3px; + border-radius: 3px 0 0 3px; +} +.plural.editMore .input-append input, .plural.editMore .input-append select, .plural.editMore .input-append .uneditable-input { + -webkit-border-radius: 3px 0 0 3px; + -moz-border-radius: 3px 0 0 3px; + border-radius: 3px 0 0 3px; +} +.plural.editMore .input-append .add-on, .plural.editMore .input-append .btn { + -webkit-border-radius: 0 3px 3px 0; + -moz-border-radius: 0 3px 3px 0; + border-radius: 0 3px 3px 0; +} +.language-swich .tab-pane { + margin-bottom: 5px; + margin-right: 10px; } \ No newline at end of file diff --git a/app/assets/stylesheets/orbitTimeline.css b/app/assets/stylesheets/orbitTimeline111.css similarity index 100% rename from app/assets/stylesheets/orbitTimeline.css rename to app/assets/stylesheets/orbitTimeline111.css diff --git a/app/assets/stylesheets/site-map.css b/app/assets/stylesheets/site-map.css index 711b10e2..53e94c1f 100644 --- a/app/assets/stylesheets/site-map.css +++ b/app/assets/stylesheets/site-map.css @@ -69,8 +69,9 @@ } .site-map .disabled h4 { color: #CACACA; + border-radius: 4px; } -.site-map .disabled h4 .onoff { +.site-map .disabled h4 .onoff ,.onoff.disabled { box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(0,0,0,.2) inset; background-color: #9C9C9C; color: #CACACA; @@ -80,37 +81,60 @@ background-color: #5EB92B; font-size: 9px; padding: 0px 10px; - border-radius: 8px; - line-height: 16px; - height: 15px; + border-radius: 11px; + line-height: 20px; + height: 19px; color: #FFF; - width: 38px; + width: 40px; border: none; box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(13, 75, 23, 0.5) inset; - margin-top: 2px; + margin-top: 1px; } /* for mamber role */ - -.user-role .form-horizontal { +.role-block .form-horizontal { padding: 20px 10px 10px; background-color: #FFF; margin-bottom: 0; border-radius: 0 0 4px 4px; } -.user-role .form-horizontal .control-label { +.role-block [class*="type"] { + background-color: #F1F1F1; + padding: 20px 0 10px; + border-radius: 5px; + margin: -25px 0 40px; + /*box-shadow: 0px 1px 3px rgba(100,100,100,.4)*/ +} +.role-block .form-horizontal .control-label { width: 100px; } -.user-role .form-horizontal .controls { +.role-block .form-horizontal .controls { margin-left: 120px; } -.user-role .form-horizontal .controls>.input-append { +.role-block .form-horizontal .controls>.input-append { margin-bottom: 10px; } -.user-role .map-block { +.role-block .form-horizontal legend .onoff { + margin-top: 4px; +} +.role-block .form-horizontal legend .btn-danger { + margin-right: 20px; +} +.role-block .form-horizontal legend>.clear { + margin-right: 150px; + min-width: 350px; +} +.role-block .map-block { min-width: 440px; } -.user-role .map-block legend { +.role-block .map-block .form-actions { + margin: 0; + padding: 10px 20px; +} +.role-block .map-block legend { font-size: 18px; line-height: 25px; } +.role-block .map-block legend .nav { + font-size: 12px; +} diff --git a/app/assets/stylesheets/style.css.erb b/app/assets/stylesheets/style.css.erb index c1d6bdc9..6a496370 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -267,6 +267,12 @@ #post-body-content { padding: 8px 0 8px 6px; } +#post-body-content .middle { + width: 100%; + padding: 0; + border: none; + box-shadow: none; +} .filter .accordion-group { margin-bottom: 0; border: none; @@ -470,6 +476,9 @@ .view-mode .btn { margin-bottom: 0; } +.view-mode .btn { + margin-bottom: 0; +} .view-mode i { font-size: 1.2em; line-height: 17px !important; @@ -1458,4 +1467,4 @@ /*21*/ .icons- { background-position: -0px -640px; -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/tinymce_orbit.css b/app/assets/stylesheets/tinymce_orbit.css new file mode 100644 index 00000000..3fc87c96 --- /dev/null +++ b/app/assets/stylesheets/tinymce_orbit.css @@ -0,0 +1,4 @@ +body { + font-family: Arial, Helvetica, sans-serif !important; + font-size: 13px !important; +} \ No newline at end of file diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index e3cef303..e4749ade 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -41,7 +41,7 @@ class Admin::AdImagesController < OrbitBackendController @ad_banner = AdBanner.find params[:ad_banner_id] @ad_image = @ad_banner.ad_images.find params[:id] if @ad_image.destroy - flash[:notice] = t('admin.success_destroy_ad_image') + flash[:notice] = t('ad.success_destroy_ad_image') redirect_to admin_ad_banner_path @ad_banner end end diff --git a/app/controllers/admin/asset_categories_controller.rb b/app/controllers/admin/asset_categories_controller.rb index 9ce6bb48..d406543b 100644 --- a/app/controllers/admin/asset_categories_controller.rb +++ b/app/controllers/admin/asset_categories_controller.rb @@ -25,7 +25,7 @@ class Admin::AssetCategoriesController < OrbitBackendController respond_to do |format| if @asset_category.save - format.html { redirect_to(admin_asset_categories_url, :notice => t('announcement.create_asset_category_success')) } + format.html { redirect_to(admin_asset_categories_url, :notice => t('create.success.asset_category')) } format.js else format.html { render :action => "new" } @@ -41,8 +41,8 @@ class Admin::AssetCategoriesController < OrbitBackendController respond_to do |format| if @asset_category.update_attributes(params[:asset_category]) - # format.html { redirect_to(panel_announcement_back_end_asset_category_url(@asset_category), :notice => t('asset_category.update_asset_category_success')) } - # format.html { redirect_to(panel_announcement_back_end_asset_categories_url, :notice => t('asset_category.update_asset_category_success')) } + # format.html { redirect_to(panel_announcement_back_end_asset_category_url(@asset_category), :notice => t('create.success')) } + # format.html { redirect_to(panel_announcement_back_end_asset_categories_url, :notice => t('create.success')) } # format.xml { head :ok } format.js else diff --git a/app/controllers/admin/assets_controller.rb b/app/controllers/admin/assets_controller.rb index 6a847a12..77c52ffa 100644 --- a/app/controllers/admin/assets_controller.rb +++ b/app/controllers/admin/assets_controller.rb @@ -44,7 +44,7 @@ class Admin::AssetsController < OrbitBackendController # render :json=>{"url"=>@asset.data.url,"title"=>"xxx","desc"=>"sss"}.to_json render :layout=>false else - flash[:error] = t(:create_fail) + flash[:error] = t('create.fail') @asset_categories = AssetCategory.all @tags = AssetTag.all respond_to do |format| @@ -67,7 +67,7 @@ class Admin::AssetsController < OrbitBackendController format.js { render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} } end else - flash[:error] = t(:update_fail) + flash[:error] = t('update.fail') @asset_categories = AssetCategory.all @tags = AssetTag.all respond_to do |format| @@ -105,4 +105,8 @@ class Admin::AssetsController < OrbitBackendController render :layout => false end + def check_permission + true + end + end diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 9d434ff8..0b94317e 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -34,14 +34,37 @@ class Admin::DesignsController < OrbitBackendController def update @design = Design.find(params[:id]) - if @design.update_attributes(params[:design]) - flash[:notice] = "Successfully updated design and tasks." - redirect_to admin_designs_url(@design) - else - render :action => 'edit' + @design.update_attributes(params[:design]) + # if @design.update_attributes(params[:design]) + # flash[:notice] = "Successfully updated design and tasks." + # redirect_to admin_designs_url(@design) + # else + # render :action => 'edit' + # end + + respond_to do |format| + format.js {nil} end end + def update_file + @design = Design.find(params[:id]) + case params[:type] + when 'layout', 'css_default', 'css_reset' + @object = @design.send(params[:type]) + when 'image', 'javascript', 'theme' + @object = @design.send(params[:type]).find(params[:object_id]) + end + + Dir.mktmpdir('f_path') { |dir| + temp_file = File.new(dir + '/' + File.basename(@object.file.url), 'w+') + temp_file.write(params[:file][:content].force_encoding('UTF-8')) + @object.remove_file! + @object.file = temp_file + @object.save + } + end + def edit_file @design = Design.find(params[:id]) filename = params[:filename] @@ -91,6 +114,13 @@ class Admin::DesignsController < OrbitBackendController end redirect_to admin_designs_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) end + + def upload_image + @design = Design.find(params[:id]) + @image = @design.images.build(params[:image]) + @image.save + render :layout => false + end protected @@ -98,7 +128,6 @@ class Admin::DesignsController < OrbitBackendController Zip::ZipFile.open(file) { |zip_file| design = Design.new.from_json(zip_file.read("#{zip_name}/info.json")) Dir.mktmpdir('f_path') { |dir| - design.build_layout themes_entries = [] javascripts_entries = [] images_entries = [] @@ -106,25 +135,11 @@ class Admin::DesignsController < OrbitBackendController zip_file.entries.each do |entry| case (path = entry.to_s) when /\A(#{zip_name})\/(default\.css)\z/ #for default css - filename = File.basename(entry.to_s) - temp_file = File.new(dir + '/' + filename, 'w+') - temp_file.write (zip_file.read entry ).force_encoding('UTF-8') - default_css = design.build_default_css - default_css.file = temp_file - default_css.to_save = true + design.build_css_default(:file => get_temp_file(zip_file, dir, entry)) when /\A(#{zip_name})\/(reset\.css)\z/ #for reset css - filename = File.basename(entry.to_s) - temp_file = File.new(dir + '/' + filename, 'w+') - temp_file.write (zip_file.read entry ).force_encoding('UTF-8') - reset_css = design.build_reset_css - reset_css.file = temp_file - reset_css.to_save = true + design.build_css_reset(:file => get_temp_file(zip_file, dir, entry)) when /\A(#{zip_name})\/(layout\.html)\z/ #for layout html - filename = File.basename(entry.to_s) - temp_file = File.new(dir + '/' + filename, 'w+') - temp_file.write (zip_file.read entry ).force_encoding('UTF-8') - design.layout.file = temp_file - design.layout.to_save=true + design.build_layout(:file => get_temp_file(zip_file, dir, entry)) when /\A(#{zip_name})\/(themes)\/.*(\.css)\z/ #for themes css themes_entries << entry when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js @@ -136,12 +151,7 @@ class Admin::DesignsController < OrbitBackendController ['themes', 'javascripts', 'images'].each do |type| eval("#{type}_entries").each do |entry| - filename = File.basename entry.to_s - temp_file = File.new(dir + '/' + filename, 'w+') - temp_file.write (zip_file.read entry).force_encoding('UTF-8') - build_and_store = eval("design.#{type}").build - build_and_store.file = temp_file - build_and_store.to_save = true + eval("design.#{type}").build(:file => get_temp_file(zip_file, dir, entry)) end end } @@ -149,4 +159,11 @@ class Admin::DesignsController < OrbitBackendController } end + def get_temp_file(zip_file, dir, entry) + filename = File.basename(entry.to_s) + temp_file = File.new(dir + '/' + filename, 'w+') + temp_file.write (zip_file.read entry ).force_encoding('UTF-8') + temp_file + end + end diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb index 5ffa6a06..cec5c5f4 100644 --- a/app/controllers/admin/infos_controller.rb +++ b/app/controllers/admin/infos_controller.rb @@ -1,10 +1,11 @@ class Admin::InfosController < ApplicationController - layout "admin" + layout "new_admin" before_filter :authenticate_user! before_filter :is_admin? before_filter :set_attribute, :only => [:index, :show, :new, :edit] - + helper Admin::AttributeValuesViewHelper + def index @attributes = Info.all.entries render :template => 'admin/attributes/index' @@ -32,8 +33,8 @@ class Admin::InfosController < ApplicationController def update @attribute = Info.find(params[:id]) - # binding.pry @attribute.update_attributes(params[:info]) + @attribute.attribute_fields.each{|t| t.destroy if t["to_delete"] == true} respond_to do |format| format.html { redirect_to :action => :index } format.js { render 'admin/attributes/toggle_enable' } @@ -47,10 +48,10 @@ class Admin::InfosController < ApplicationController end def add_attribute_field - @attribute = Info.find(params[:id]) rescue nil - if !@attribute - @attribute = Info.new - end + attribute = Info.find(params[:info_id]) rescue nil + @attribute_field_counter = attribute.attribute_fields.count + @attribute_field = attribute.attribute_fields.build + @attribute_field.save end protected diff --git a/app/controllers/admin/items_controller.rb b/app/controllers/admin/items_controller.rb index 1ea40640..e028ab68 100644 --- a/app/controllers/admin/items_controller.rb +++ b/app/controllers/admin/items_controller.rb @@ -4,7 +4,6 @@ class Admin::ItemsController < ApplicationController before_filter :authenticate_user! before_filter :find_parent_item - before_filter :find_snippets, :only => :index before_filter :is_admin? before_filter :set_current_item @@ -22,10 +21,4 @@ class Admin::ItemsController < ApplicationController render :nothing => true end - protected - - def find_snippets - @snippets = Snippet.where( { :parent_id => @parent_item.id } ) rescue nil - end - end diff --git a/app/controllers/admin/links_controller.rb b/app/controllers/admin/links_controller.rb index c233c18f..7c7b4030 100644 --- a/app/controllers/admin/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -23,7 +23,7 @@ class Admin::LinksController < ApplicationController @item = Link.new(params[:link]) if @item.save - flash.now[:notice] = t('admin.create_success_link') + flash.now[:notice] = t('create.success.link') respond_to do |format| format.html { redirect_to admin_link_url(@item) @@ -31,7 +31,7 @@ class Admin::LinksController < ApplicationController format.js {} end else - flash.now[:error] = t('admin.create_error_link') + flash.now[:error] = t('create.error.link') render :action => "new" end end @@ -40,7 +40,7 @@ class Admin::LinksController < ApplicationController @item = Link.find(params[:id]) if @item.update_attributes(params[:link]) - flash.now[:notice] = t('admin.update_success_link') + flash.now[:notice] = t('update.success.link') respond_to do |format| format.html { redirect_to admin_link_url(@item) @@ -48,7 +48,7 @@ class Admin::LinksController < ApplicationController format.js {} end else - flash.now[:error] = t('admin.update_error_link') + flash.now[:error] = t('update.error.link') render :action => "edit" end end diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index f747d08b..af529086 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -66,14 +66,14 @@ class Admin::ModuleAppsController < ApplicationController def assign_sub_manager unless @assign_to_user.nil? || @assign_to_user.admin? if @module_app.assign_sub_manager(@assign_to_user,current_user) - flash[:notice] = t('admin.app_auth.assigning_manager.add_sub_manager_ok') + flash[:notice] = t('app_auth.assigning_manager.add_manager_ok') else - flash[:notice] = t('admin.app_auth.assigning_manager.add_sub_manager_fail') + flash[:notice] = t('app_auth.assigning_manager.add_manager_fail') end else - flash[:notice] = t('admin.app_auth.assigning_manager.failed_no_user') + flash[:notice] = t('app_auth.failed_no_user') end - flash[:notice] = t('admin.app_auth.can_not_add_this_user') + flash[:notice] = t('app_auth.can_not_add_this_user') redirect_to :action => "edit" end @@ -81,14 +81,14 @@ class Admin::ModuleAppsController < ApplicationController def assign_manager unless @assign_to_user.nil? || @assign_to_user.admin? if @module_app.assign_manager(@assign_to_user,current_user) - flash[:notice] = t('admin.app_auth.assigning_sub_manager.add_manager_ok') + flash[:notice] = t('app_auth.assigning_sub_manager.add_sub_manager_ok') else - flash[:notice] = t('admin.app_auth.assigning_sub_manager.add_manager_fail') + flash[:notice] = t('app_auth.assigning_sub_manager.add_sub_manager_fail') end else - flash[:notice] = t('admin.app_auth.assigning_sub_manager.failed_no_user') + flash[:notice] = t('app_auth.failed_no_user') end - flash[:notice] = t('admin.app_auth.can_not_add_this_user') + flash[:notice] = t('app_auth.can_not_add_this_user') redirect_to :action => "edit" end @@ -96,9 +96,9 @@ class Admin::ModuleAppsController < ApplicationController def remove_manager @app_manager = AppManager.find(params[:app_manager_id]) if @module_app.remove_manager(@app_manager.user) - flash[:notice] = t('admin.app_auth.delete_manager.success') + flash[:notice] = t('app_auth.delete_manager.success') else - flash[:notice] = t('admin.app_auth.delete_manager.fail') + flash[:notice] = t('app_auth.delete_manager.fail') end redirect_to :action => "edit" end @@ -107,9 +107,9 @@ class Admin::ModuleAppsController < ApplicationController def remove_sub_manager @app_sub_manager = AppManager.find(params[:app_sub_manager_id]) if @module_app.remove_sub_manager(@app_sub_manager.user) - flash[:notice] = t('admin.app_auth.delete_sub_manager.success') + flash[:notice] = t('app_auth.delete_sub_manager.success') else - flash[:notice] = t('admin.app_auth.delete_sub_manager.fail') + flash[:notice] = t('app_auth.delete_sub_manager.fail') end redirect_to :action => "edit" end @@ -123,7 +123,7 @@ class Admin::ModuleAppsController < ApplicationController return end #user is not permited to do that - flash[:notice] = t('admin.app_auth.operation_not_permitted') + flash[:notice] = t('app_auth.operation_not_permitted') render :nothing => true, :status => 403 end @@ -135,7 +135,7 @@ class Admin::ModuleAppsController < ApplicationController return end #user is not permited to do that - flash[:notice] = t('admin.app_auth.operation_not_permitted') + flash[:notice] = t('app_auth.operation_not_permitted') render :nothing => true, :status => 403 end diff --git a/app/controllers/admin/module_apps_new_interface_controller.rb b/app/controllers/admin/module_apps_new_interface_controller.rb index 863af560..2fd7685e 100644 --- a/app/controllers/admin/module_apps_new_interface_controller.rb +++ b/app/controllers/admin/module_apps_new_interface_controller.rb @@ -25,9 +25,9 @@ class Admin::ModuleAppsNewInterfaceController < OrbitBackendController def update_setting module_app = update_setting_by_params if module_app.save! - flash[:notice] = t("admin.object_auth.update_done") + flash[:notice] = t('update.success_') else - flash[:notice] = t("admin.object_auth.update_failed") + flash[:notice] = t('update.fail') end end diff --git a/app/controllers/admin/object_auths_controller.rb b/app/controllers/admin/object_auths_controller.rb index ab343360..dab659b4 100644 --- a/app/controllers/admin/object_auths_controller.rb +++ b/app/controllers/admin/object_auths_controller.rb @@ -30,7 +30,7 @@ class Admin::ObjectAuthsController < ApplicationController if @object_auth.save redirect_to edit_admin_object_auth_path(@object_auth) else - flash[:error] = t('admin.object.a_object_must_have_only_one_object_auth_profile_for_each_action') + flash[:error] = t('object.a_object_must_have_only_one_object_auth_profile_for_each_action') redirect_to (:back) end end @@ -91,7 +91,8 @@ private def check_if_user_can_do_object_auth unless check_permission(:manager) - render :nothing => true, :status => 403 + #render :nothing => true, :status => 403 + redirect_to '/' end end end \ No newline at end of file diff --git a/app/controllers/admin/object_auths_new_interface_controller.rb b/app/controllers/admin/object_auths_new_interface_controller.rb index 3b3f7c24..973f4215 100644 --- a/app/controllers/admin/object_auths_new_interface_controller.rb +++ b/app/controllers/admin/object_auths_new_interface_controller.rb @@ -7,7 +7,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController @sys_users = User.all(conditions: {admin: false}).includes(:avatar) @ob_auth = ObjectAuth.find params[:object_auth_id] - @options_from_collection_for_select_ob_auth = [@ob_auth].collect{|oa| [oa.auth_obj.pp_object,oa.id] } + @options_from_collection_for_select_ob_auth = @ob_auth.siblings.collect{|oa| [oa.auth_obj.pp_object,oa.id] } @users_array = @ob_auth.privilege_users rescue [] respond_to do |format| @@ -19,9 +19,9 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController def update_setting ob_auth = update_setting_by_params if ob_auth.save! - flash[:notice] = t("admin.object_auth.update_done") + flash[:notice] = t('update.success_') else - flash[:notice] = t("admin.object_auth.update_failed") + flash[:notice] = t('update.fail') end end @@ -38,10 +38,12 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController users_to_remove = oa.auth_users - user_sat users_to_new.each do |new_user| + oa.privilege_users << new_user oa.add_user_to_privilege_list(new_user) end users_to_remove.each do |remove_user| + oa.privilege_users.delete_if{|user| user == remove_user} oa.remove_user_from_privilege_list(remove_user) end oa @@ -63,8 +65,26 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController def check_if_user_can_do_object_auth unless check_permission(:manager) - render :nothing => true, :status => 403 + redirect_to '/' end end + def check_permission(var) + #app = ModuleApp.first({conditions:{key: params[:module_app_key]}}) + # setup_vars + @module_app.is_manager?(current_user) || current_user.admin? + end + + def setup_vars + if request.env['HTTP_REFERER'].split('/')[4] == "object_auths" + @app_key = params[:app_key] + else + @app_key = request.env['HTTP_REFERER'].split('/')[4] + end + + #@app_key = request.fullpath.split('/')[1] if(@app_key == "back_end") + @app_key.gsub!(/[?].*/,'') + @module_app = ModuleApp.first(conditions: {:key => @app_key} ) + end + end \ No newline at end of file diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index 4e4b665d..ed2748c2 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -61,7 +61,7 @@ class Admin::PagePartsController < ApplicationController if @part.update_attributes(params[:page_part]) set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu') - flash.now[:notice] = t('admin.update_success_content') + flash.now[:notice] = t('update.success.content') if @part.page.name == 'home' expire_page '/' diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 4a9c5408..cf935a09 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -72,7 +72,7 @@ class Admin::PagesController < ApplicationController end if @item.save - flash.now[:notice] = t('admin.create_success_page') + flash.now[:notice] = t('create.success.page') respond_to do |format| format.html { redirect_to admin_page_url(@item) @@ -80,7 +80,7 @@ class Admin::PagesController < ApplicationController format.js {} end else - flash.now[:error] = t('admin.create_error_page') + flash.now[:error] = t('create.error.page') @apps = ModuleApp.all @designs = Design.all.entries @design = Design.first @@ -99,7 +99,7 @@ class Admin::PagesController < ApplicationController params[:page][:frontend_field_type] = nil if @item.update_attributes(params[:page]) - flash[:notice] = t('admin.update_success_page') + flash[:notice] = t('update.success.page') respond_to do |format| format.html { redirect_to admin_page_url(@item) diff --git a/app/controllers/admin/purchases_controller.rb b/app/controllers/admin/purchases_controller.rb index ab5b047d..b259c12f 100644 --- a/app/controllers/admin/purchases_controller.rb +++ b/app/controllers/admin/purchases_controller.rb @@ -71,8 +71,8 @@ class Admin::PurchasesController < ApplicationController Dir.mktmpdir('f_path') { |dir| build_file(orig_zip, zip_name, dir, design.layout) if design.layout - build_file(orig_zip, zip_name, dir, design.default_css) if design.default_css - build_file(orig_zip, zip_name, dir, design.reset_css) if design.reset_css + build_file(orig_zip, zip_name, dir, design.css_default) if design.css_default + build_file(orig_zip, zip_name, dir, design.css_reset) if design.css_reset ['themes', 'javascripts', 'images'].each do |type| design.send(type).each do |object| diff --git a/app/controllers/admin/translations_controller.rb b/app/controllers/admin/translations_controller.rb deleted file mode 100644 index 54da8762..00000000 --- a/app/controllers/admin/translations_controller.rb +++ /dev/null @@ -1,81 +0,0 @@ -class Admin::TranslationsController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - before_filter :is_admin? - - def index - set_variables - end - - def edit - set_variables - end - - # Update either the i18n_variables or the languages - def update - begin - case params[:id] - # Update the i18n_variables - when 'all' - params[:i18n_variables].each do |id, var| - i18n_variable = I18nVariable.find(id) - i18n_variable.update_attributes(var) - end - # Add a language - when 'add' - site = Site.find(session[:site]) - if !site.valid_locales.include?(params[:language]) - site.valid_locales << params[:language] - site.save - I18nVariable.create({:key => params[:language], :document_class => 'language'}) - end - # Enable a language - when 'enable' - site = Site.find(session[:site]) - if !site.in_use_locales.include?(params[:enable_language]) - site.in_use_locales << params[:enable_language] - site.save - end - # Disable a language - when 'disable' - site = Site.find(session[:site]) - if site.in_use_locales.include?(params[:disable_language]) - site.in_use_locales.delete(params[:disable_language]) - site.save - end - # Delete a language and the corresponding i18n_variables - when 'delete' - site = Site.find(session[:site]) - site.in_use_locales.delete(params[:delete_language]) - site.valid_locales.delete(params[:delete_language]) - site.save - I18nVariable.destroy_all(:conditions => {:document_class => 'language', :key => params[:delete_language]}) - end - redirect_to admin_translations_url - rescue - set_variables - render :action => :edit - end - end - - protected - - # Get the i18n_variables and languages - def set_variables - @i18n_variables = I18nVariable.all.entries - @language_i18n_variables = @i18n_variables.inject([]) do |result, var| - result << var if var.document_class.eql?('language') - result - end - @role_i18n_variables = @i18n_variables.inject([]) do |result, var| - result << var if var.document_class.eql?('Role') - result - end - @info_i18n_variables = @i18n_variables.inject([]) do |result, var| - result << var if var.document_class.eql?('UserInfoModel') - result - end - end - -end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index ef44cfc1..e0c8a8f9 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -22,7 +22,7 @@ class Admin::UsersController < ApplicationController puts params.to_yaml @user = User.new(params[:user]) if @user.save - flash[:notice] = t('admin.create_success_user') + flash[:notice] = t('create.success.user') redirect_to :action => :index else render :action => :new @@ -42,10 +42,10 @@ class Admin::UsersController < ApplicationController @user.avatar = params[:file] if params[:file] if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b - flash.now[:error] = t('admin.cant_revoke_self_admin') + flash.now[:error] = t(:cant_revoke_self_admin) end if !flash[:error] && @user.update_attributes(params[:user]) - flash[:notice] = t('admin.update_success_user') + flash[:notice] = t('update.success.user') redirect_to :action => :index else get_info_and_roles @@ -55,7 +55,7 @@ class Admin::UsersController < ApplicationController def destroy if params[:id].eql?(session['warden.user.user.key'][1].to_s) - flash[:error] = t('admin.cant_delete_self') + flash[:error] = t(:cant_delete_self) else @user = User.find(params[:id]) @user.destroy diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 7a68cac9..95be536e 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -33,28 +33,12 @@ class Admin::UsersNewInterfaceController < ApplicationController @student_data = [] @staff_data = [] - - attribute_values = @user.attribute_values.reject{|att_val| - # binding.pry if(att_val.id.to_s == '507fa1295789b52a540000e0') - !att_val.attribute_field.locale and (att_val.attribute_field.neutral_for != I18n.locale.to_s) - } - + attribute_values = @user.attribute_values attribute_values.each{|att_val| - @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale)}) if att_val.attribute_field.attribute.key=="profile" rescue false + binding.pry if att_val.id.to_s == '5052dab52b5c49ae9d000006' + @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" rescue false } - attribute_values.each{|att_val| - @teacher_data.push({:name => att_val.attribute_field.title,:value => att_val.get_value_by_locale(I18n.locale) }) if att_val.attribute_field.role.key=="teacher"rescue false - } - - attribute_values.each{|att_val| - @student_data.push({:name => att_val.attribute_field.title,:value => att_val.get_value_by_locale(I18n.locale) }) if att_val.attribute_field.role.key=="student"rescue false - } - - attribute_values.each{|att_val| - @staff_data.push({:name => att_val.attribute_field.title,:value => att_val.get_value_by_locale(I18n.locale) }) if att_val.attribute_field.role.key=="staff_data"rescue false - } - if(!params[:show_plugin_profile].nil?) @right_partial = OrbitApp::Plugin::Registration.find_by_key(params[:show_plugin_profile]).profile_partial_path rescue 'plugin_summary' @@ -81,22 +65,23 @@ class Admin::UsersNewInterfaceController < ApplicationController def new @user = User.new - @disable_all_field = true + # @disable_all_field = true @form_index = 0 get_info_and_roles end def create puts params.to_yaml - attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values' - attribute_values = params[:user].delete(attribute_values_key) + # attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values' + # attribute_values = params[:user].delete(attribute_values_key) @user = User.new(params["user"]) - attribute_values.to_hash.each{|key,value| - @user.attribute_values.build(value) - } - @user.rebuild_sub_roles_from_attribute_values!(attribute_values) + # attribute_values.to_hash.each{|key,value| + # @user.attribute_values.build(value) + # } + # @user.rebuild_sub_roles_from_attribute_values!(attribute_values) + binding.pry if @user.save - flash[:notice] = t('admin.create_success_user') + flash[:notice] = t('create.success.user') redirect_to :action => :index else @form_index = 0 @@ -111,7 +96,7 @@ class Admin::UsersNewInterfaceController < ApplicationController end def edit - @disable_all_field = false + # @disable_all_field = false @user = User.find(params[:id]) @form_index = 0 get_info_and_roles @@ -122,7 +107,7 @@ class Admin::UsersNewInterfaceController < ApplicationController @user.update_attributes(params[:user]) attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values' attribute_values = params[:user].delete(attribute_values_key) - @user.rebuild_sub_roles_from_attribute_values!(attribute_values) + # @user.rebuild_sub_roles_from_attribute_values!(attribute_values) @user.save redirect_to :action => :show # # Update changes to the avatar @@ -130,10 +115,10 @@ class Admin::UsersNewInterfaceController < ApplicationController # @user.avatar = params[:file] if params[:file] # if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b - # flash.now[:error] = t('admin.cant_revoke_self_admin') + # flash.now[:error] = t(:cant_revoke_self_admin) # end # if !flash[:error] && @user.update_attributes(params[:user]) - # flash[:notice] = t('admin.update_success_user') + # flash[:notice] = t('update.success.user') # redirect_to :action => :index # else # get_info_and_roles @@ -143,7 +128,7 @@ class Admin::UsersNewInterfaceController < ApplicationController def destroy if params[:id].eql?(session['warden.user.user.key'][1].to_s) - flash[:error] = t('admin.cant_delete_self') + flash[:error] = t(:cant_delete_self) else @user = User.find(params[:id]) @user.destroy diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0588ae5a..e82365e5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -76,7 +76,7 @@ class ApplicationController < ActionController::Base if is_admin? true else - flash[:error] = t("admin.access.denied.not_admin") + flash[:error] = t("access.denied.not_admin") auth_failed_in_backend end end @@ -85,7 +85,7 @@ class ApplicationController < ActionController::Base if is_manager? true else - flash[:error] = t("admin.access.denied.app.not_manager") + flash[:error] = t("access.denied.app.not_manager") auth_failed_in_backend end end @@ -94,7 +94,7 @@ class ApplicationController < ActionController::Base if (@module_app.sub_managing_users.include?(current_or_guest_user) || is_manager?) true else - flash[:error] = t("admin.access.denied.app.not_sub_manager") + flash[:error] = t("access.denied.app.not_sub_manager") auth_failed_in_backend end end @@ -103,13 +103,13 @@ class ApplicationController < ActionController::Base if (@module_app.app_auth.auth_users.include?(current_or_guest_user) || for_app_sub_manager ) true else - flash[:error] = t("admin.access.denied.app.not_authed_user") + flash[:error] = t("access.denied.app.not_authed_user") auth_failed_in_backend end end def check_object_premission(obj,title) - flash[:error] = t("admin.access.denied.object") + flash[:error] = t("access.denied.object") auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_or_guest_user) || is_manager? || is_admin? ) end @@ -129,7 +129,9 @@ class ApplicationController < ActionController::Base object_class = params[:model].classify.constantize @object = object_class.find(params[:id]) module_app = ModuleApp.first(:conditions => {:key => params[:key]}) - @item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first + @item = @object.share_item + #@item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first + #binding.pry @orig_url = "http://#{request.host_with_port}/#{@item.path}?id=#{@object.id}" render 'shared/render_share', :layout => false end diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index 286ec1c4..ff657441 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -103,11 +103,41 @@ class DesktopController< ApplicationController def getgroups @section = Section.find(params["sectionid"]) @groups = @section.groups - a = Array.new + + gr = Array.new @groups.each do |group| - a << group.tiles + a = Array.new + t = group.tiles + t.each do |tile| + data_content = "" + jsfile = [] + cssfile = "" + shape = "w1 h1" + if tile.data_category == "widget" + widge = DesktopWidget.find(tile.desktop_widget_id.to_s) + # data_content = widge.widget_layout.file + data_content = "desktop/widget_layout?id="+tile.desktop_widget_id.to_s + jsfile = widge.javascripts.collect{|js| js.file} + cssfile = widge.css_default.file + shape = widge.shape + title = widge.name + else + data_content = tile.data_content + title = tile.title + end + a << {"id"=>tile.id,"data_category"=>tile.data_category,"data_content"=>data_content,"js"=>jsfile,"css"=>cssfile,"shape"=>shape,"position"=>tile.position,"title"=>title} + end + gr << a end - render :json =>a.to_json + render :json =>gr.to_json + end + + def widget_layout + widget = DesktopWidget.find(params[:id]) + link = '' + content = widget.widget_layout.body + dhtml = link + content + render :text => dhtml.html_safe end def getsectionlist diff --git a/app/controllers/desktop_publications_controller.rb b/app/controllers/desktop_publications_controller.rb index 14307022..fc3f36ab 100644 --- a/app/controllers/desktop_publications_controller.rb +++ b/app/controllers/desktop_publications_controller.rb @@ -8,6 +8,7 @@ class DesktopPublicationsController< ApplicationController end def journal_p_add + debugger render "desktop/journal_pages/add", :layout => false end diff --git a/app/controllers/desktop_widgets_controller.rb b/app/controllers/desktop_widgets_controller.rb new file mode 100644 index 00000000..2605f367 --- /dev/null +++ b/app/controllers/desktop_widgets_controller.rb @@ -0,0 +1,62 @@ +class DesktopWidgetsController < OrbitBackendController + require "net/http" + require "uri" + require 'zip/zip' + + def index + end + + def upload + if !params[:desktop_widget].nil? + temp_file = Tempfile.new("temp_file") + original_file = params[:desktop_widget][:package_file] + #if original_file.content_type == 'application/zip' + temp_file.write(original_file.read.force_encoding('UTF-8')) + temp_file.rewind + filename = File.basename(original_file.original_filename,".zip") + unzip_widget(temp_file, filename) + #else + # flash[:error] = "Upload file should be in zip format" + #end + temp_file.close + end + end + + def unzip_widget(file, zip_name) + Zip::ZipFile.open(file) { |zip_file| + dw = DesktopWidget.new.from_json(zip_file.read("#{zip_name}/settings.json")) + Dir.mktmpdir('f_path') { |dir| + javascripts_entries = [] + images_entries = [] + + zip_file.entries.each do |entry| + case (path = entry.to_s) + when /\A(#{zip_name})\/(default\.css)\z/ + #for default css + dw.build_css_default(:file => get_temp_file(zip_file, dir, entry)) + when /\A(#{zip_name})\/(widget\.html)\z/ #for layout html + dw.build_widget_layout(:file => get_temp_file(zip_file, dir, entry)) + when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js + javascripts_entries << entry + when /\A(#{zip_name})\/(images)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img + images_entries << entry + end + end + + ['javascripts', 'images'].each do |type| + eval("#{type}_entries").each do |entry| + eval("dw.#{type}").build(:file => get_temp_file(zip_file, dir, entry)) + end + end + } + dw.save + } + end + def get_temp_file(zip_file, dir, entry) + filename = File.basename(entry.to_s) + temp_file = File.new(dir + '/' + filename, 'w+') + temp_file.write (zip_file.read entry ).force_encoding('UTF-8') + temp_file + end + +end \ No newline at end of file diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 0ac853ed..8f78ea62 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -1,4 +1,4 @@ -class OrbitBackendController< ApplicationController +class OrbitBackendController < ApplicationController #before_filter :setup_vars #before_filter :set_current_user @@ -11,17 +11,15 @@ class OrbitBackendController< ApplicationController layout 'new_admin' def setup_vars - @app_title = request.fullpath.split('/')[2] - @app_title = request.fullpath.split('/')[1] if(@app_title == "back_end") - @app_title.gsub!(/[?].*/,'') - @module_app = ModuleApp.first(conditions: {:key => @app_title} ) + @app_title = controller_path.split('/')[1].singularize + @module_app ||= ModuleApp.first(conditions: {:key => @app_title} ) end private def force_order_for_visitor - setup_vars - set_current_user + setup_vars + set_current_user end diff --git a/app/controllers/otheraccounts_controller.rb b/app/controllers/otheraccounts_controller.rb index 454f108e..d946bd3c 100644 --- a/app/controllers/otheraccounts_controller.rb +++ b/app/controllers/otheraccounts_controller.rb @@ -1,4 +1,4 @@ -class OtheraccountsController< ApplicationController +class Desktop::OtheraccountsController< ApplicationController require 'open-uri' require 'rexml/document' require 'net/http' diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb deleted file mode 100644 index 32315aa5..00000000 --- a/app/controllers/sessions_controller.rb +++ /dev/null @@ -1,26 +0,0 @@ -class SessionsController < Devise::SessionsController - prepend_before_filter :require_no_authentication, :only => [ :new, :create ] - include Devise::Controllers::InternalHelpers - - # POST /resource/sign_in - def create - # login_password = params[:user][:password] - # login_uid = params[:user][:nccu_ldap_uid] - login_password = params[:user][:password] - login_email = params[:user][:login] - result = false - resource = User.first(conditions:{ email: login_email }) - set_flash_message(:notice, :signed_in) if is_navigational_format? - if resource.nil? - logger.error "Can't find user #{login_email}" - flash[:notice] = t('devise.failure.invalid') - render :action => "new" - else - logger.info "=== passed" - resource_name = resource.class.to_s.downcase - sign_in(resource_name, resource) - respond_with resource, :location => redirect_location(resource_name, resource) - end - end - -end diff --git a/app/helpers/admin/ad_banners_helper.rb b/app/helpers/admin/ad_banners_helper.rb index 9c068621..df0d3e73 100644 --- a/app/helpers/admin/ad_banners_helper.rb +++ b/app/helpers/admin/ad_banners_helper.rb @@ -22,8 +22,8 @@ module Admin::AdBannersHelper ad_banner.object_auths.new(title: type ).save oa = ad_banner.get_object_auth_by_title(type) end -# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) - link_to t('admin.ad.cate_auth'),admin_object_auth_ob_auth_path(oa),:class => "btn btn-warning" +# link_to t(:category_auth), edit_admin_object_auth_path(oa) + link_to t(:category_auth),admin_object_auth_ob_auth_path(oa),:class => "btn btn-warning" end diff --git a/app/helpers/admin/attribute_values_view_helper.rb b/app/helpers/admin/attribute_values_view_helper.rb new file mode 100644 index 00000000..9a724c96 --- /dev/null +++ b/app/helpers/admin/attribute_values_view_helper.rb @@ -0,0 +1,16 @@ +module Admin::AttributeValuesViewHelper + OPT = [ + ["YYYY / MM / DD hh : mm","format1"], + ["YYYY / MM / DD","format2"], + ["YYYY / MM","format3"], + ["YYYY","format4"] + ] + def show_type_panel(attribute_field,type) + markup = attribute_field.markup + LIST[:markups][markup]["panel"] == type ? type : [type,'hide'].join(" ") + end + + def name_to_id(str) + str.gsub(/\]/,'').gsub(/\[/,"_") + end +end \ No newline at end of file diff --git a/app/helpers/admin/items_helper.rb b/app/helpers/admin/items_helper.rb index 3ac6aed6..2f46b15f 100644 --- a/app/helpers/admin/items_helper.rb +++ b/app/helpers/admin/items_helper.rb @@ -15,9 +15,9 @@ module Admin::ItemsHelper ret << "
    " ret << (link_to node.title, dest, :class => 'js_history') ret << "
    " - ret << (link_to t('admin.edit'), eval("edit_admin_#{node.class.to_s.downcase}_path(node)"), :class => 'js_history') if node.class.to_s.eql?('Page') - ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node.class.to_s.eql?('Page') - ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node.class.to_s.eql?('Page') + ret << (link_to t(:edit), eval("edit_admin_#{node.class.to_s.downcase}_path(node)"), :class => 'js_history') if node.class.to_s.eql?('Page') + ret << (link_to t('new.page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node.class.to_s.eql?('Page') + ret << (link_to t('new.link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node.class.to_s.eql?('Page') ret << (link_to t(:delete), eval("delete_admin_#{node.class.to_s.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history') ret << "
    " ret << "
    " diff --git a/app/helpers/admin/module_apps_helper.rb b/app/helpers/admin/module_apps_helper.rb index 1bf78ab5..af235976 100644 --- a/app/helpers/admin/module_apps_helper.rb +++ b/app/helpers/admin/module_apps_helper.rb @@ -15,6 +15,6 @@ module Admin::ModuleAppsHelper def get_auth_by(manager_obj) showing_name = manager_obj.rule_creator==current_user ? t('me') : manager_obj.rule_creator.name - t("admin.user_role.auth.auth_by",:user_display_name => showing_name) + t("auth.auth_by",:user_display_name => showing_name) end end diff --git a/app/helpers/admin/web_component_helper.rb b/app/helpers/admin/web_component_helper.rb new file mode 100644 index 00000000..dda121d1 --- /dev/null +++ b/app/helpers/admin/web_component_helper.rb @@ -0,0 +1,23 @@ +module Admin::WebComponentHelper + include ActionView::Helpers::TagHelper + + def alert_block_tag(title="",context="",*args) + content_tag(:div,:class=>"alert alert-block alert-error fade in") do + a = ActiveSupport::SafeBuffer.new + a << button_tag( 'x',:class=>"close",:data=>{:dismiss=>"alert"}) if (args.first[:close] rescue false) + a << content_tag(:h4,:class=>"alert-heading") do + title + end + a << content_tag(:p) do + context + end + # TODO : 可以提供更多功能 + # a << content_tag(:p) do + # b = link_to("Take this action","",:class=>"btn btn-danger") + # b << link_to("Or do this","",:class=>"btn") + # b + # end + end + + end + end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b9522368..76f0f933 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -181,13 +181,13 @@ module ApplicationHelper stylesheets << "\n" stylesheets << "\n" end - stylesheets << "\n" if page.design.reset_css + stylesheets << "\n" if page.design.css_reset stylesheets << "\n" stylesheets << "\n" stylesheets << "\n" stylesheets << "\n" stylesheets << "\n" - stylesheets << "\n" if page.design.default_css + stylesheets << "\n" if page.design.css_default theme = page.design.themes.detect{ |d| d.id == page.theme_id } stylesheets << "\n" if theme stylesheets @@ -262,11 +262,15 @@ module ApplicationHelper js << "\n" rescue '' js << "\n" rescue '' content_tag :div, :class => 'fb' do - concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}?key=#{key}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") + concat social_share_button_tag(object.title, :fb_url => generate_fb_url(object,key), :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") # concat javascript_tag "$('head').append('#{j js}');" end end + def generate_fb_url(object,key) + "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}?key=#{key}" + end + def wrap_string_with(str,options={}) line_width = options[:line_width] || 12 wrap_mark = options[:wrap_mark] || "
    " diff --git a/app/helpers/attribute_fields_helper.rb b/app/helpers/attribute_fields_helper.rb index f750a1d8..9050b9e6 100644 --- a/app/helpers/attribute_fields_helper.rb +++ b/app/helpers/attribute_fields_helper.rb @@ -9,14 +9,18 @@ module AttributeFieldsHelper include ActionView::Helpers::RenderingHelper def block_helper(user,index,disable = false) - @index = index - @markup_options = markup_options.merge(:disabled=>disable) - @user = user - @attribute_value = @user.get_value_from_field_id(id) - @new_attribute = @attribute_value.nil? - @attribute_value = @attribute_value || @user.attribute_values.build(attribute_field_id: id) - @prefiled_value = @attribute_value.get_values - return instance_eval("render_#{markup}") #rescue "" + unless self.disabled + @index = index + @markup_options = markup_options.merge(:disabled=>disable,:func=>"input_unit") + @user = user + @attribute_value = @user.get_value_from_field_id(id) + @new_attribute = @attribute_value.nil? + @attribute_value = @attribute_value || @user.attribute_values.build( attribute_field_id: id ) + @prefiled_value = @attribute_value.value + @panel_setting = self.get_data + return instance_eval("render_#{markup}") #rescue "" + + end end def lang_tab(str,lang) @@ -24,6 +28,7 @@ module AttributeFieldsHelper end def render_address + #NP control_group_wrapper do |key,value| result = '
    '.html_safe @@ -44,34 +49,55 @@ module AttributeFieldsHelper end def render_checkbox - markup_value = eval(self.markup_value) rescue {} + + @prefiled_value ||=[] + # begin + # markup_value = eval(self.markup_value) + # rescue + # markup_value = self.markup_value + # ensure + # markup_value ||= {} + # end + control_group_wrapper do - markup_value.collect do |key,value| - label_tag(key,check_box_tag(get_field_name_base+"[value][#{key}]", value[I18n.locale.to_s], (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) + a = self[:option_list].collect do |key,value| + label_tag(key,check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) end.join rescue "" end end def render_date - control_group_wrapper{date_select(get_field_name_base+"[value]",nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")} + #NP + control_group_wrapper{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")} end def render_date_durnation #Need re-write low priority - + end def render_radio_button - markup_value = eval(self.markup_value) rescue {} - control_group_wrapper do - markup_value.collect do |key,value| - label_tag(key,radio_button_tag(get_field_name_base+"[value][#{key}]", value[I18n.locale.to_s], (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) - end.join rescue "" + @prefiled_value ||=[] + # begin + # markup_value = eval(self.markup_value) + # rescue + # markup_value = self.markup_value + # ensure + # markup_value ||= {} + # end + control_group_wrapper do + self[:option_list].collect do |key,value| + label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) + end.join end end def render_select - markup_value = eval(self.markup_value) rescue {} - control_group_wrapper{select_tag( get_field_name_base+"[value]",options_for_select(markup_value.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue "" + + prompt = @panel_setting[:prompt][I18n.locale] rescue nil + @markup_options.merge!(:prompt => prompt) unless prompt.nil? + # markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {} + # check self[:option_list].collect{|p| [p[1][I18n.locale.to_s],p[0]]} + control_group_wrapper{select_tag( get_field_name_base,options_for_select(self.option_list.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue "" end def render_text_area @@ -79,27 +105,35 @@ module AttributeFieldsHelper if(add_more and value.is_a?(Hash)) values = value values.each_with_index.collect do |value,index| - text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options) + place_holder= @panel_setting["placeholder"][key] + text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder)) end.join.html_safe else value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value - key = can_muti_lang_input ? "[#{key}]" : "[value]" - text_area_tag(get_field_name_base + key, value,@markup_options) + key = can_muti_lang_input ? "[#{key}]" : "" + place_holder= @panel_setting["placeholder"][I18n.locale.to_s] rescue '' + text_area_tag(get_field_name_base + key, value,@markup_options.merge(:placeholder=>place_holder)) end end end def render_text_field control_group_wrapper do |key,value| - if(add_more and value.is_a?(Hash)) + if(add_more) values = value - values.each_with_index.collect do |value,index| - text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options) - end.join.html_safe + result = "" + unless values.nil? + result = values.each_with_index.collect do |value,index| + place_holder= @panel_setting["placeholder"][key] + text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder)) + end.join.html_safe + end + result else - value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value - key = can_muti_lang_input ? "[#{key}]" : "[value]" - text_field_tag(get_field_name_base + key, value,@markup_options) + value = (can_muti_lang_input ? @prefiled_value[key] : @prefiled_value) rescue nil + key_field = can_muti_lang_input ? "[#{key}]" : "" + place_holder= @panel_setting["placeholder"][key] rescue '' + text_field_tag(get_field_name_base + key_field, value,@markup_options.merge(:placeholder=>place_holder)) end end end @@ -118,16 +152,18 @@ protected if can_muti_lang_input result << "
    " result << "
    " + VALID_LOCALES.collect do |key| value = @prefiled_value[key.to_s] rescue nil div_class = ["tab-pane" ,"fade"].join(" ") div_class << (key == I18n.locale.to_s ? " active in" : '') result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}") end + result << "
    " result << "" result << "
    " @@ -158,14 +194,13 @@ protected def end_block if @new_attribute - hidden_field_tag(get_field_name_base+"[attribute_field_id]",id,:for=>"field_#{@index}") + hidden_field_tag(get_basic_field_name_base+"[attribute_field_id]",id,:for=>"field_#{@index}") else - hidden_field_tag(get_field_name_base+"[id]",@attribute_value.id,:for=>"field_#{@index}") + hidden_field_tag(get_basic_field_name_base+"[id]",@attribute_value.id,:for=>"field_#{@index}") end end - def get_field_name_base - # "user[#{self.attribute._type.downcase.pluralize}][#{self.attribute._id.to_s}][attribute_values][#{attribute_value.id}]" + def get_basic_field_name_base if @new_attribute "user[new_attribute_values][#{@index}]" else @@ -173,12 +208,16 @@ protected end end + def get_field_name_base + get_basic_field_name_base + "[value]" + end + def label - label_tag(key,title,:class=>"control-label") + label_tag(key,title,:class=>"control-label",:func => "field_label") end def can_muti_lang_input - locale and LIST[:markups][markup]["muti_lang_input_supprt"] + LIST[:markups][markup]["muti_lang_input_supprt"] #and locale end def can_add_more diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb index f73ce2ae..c1894ac2 100644 --- a/app/helpers/orbit_backend_helper.rb +++ b/app/helpers/orbit_backend_helper.rb @@ -45,7 +45,7 @@ module OrbitBackendHelper end def show_toggle_archive_btn(object) - object.disable ? t("object_disable.change_to_false") : t("object_disable.change_to_true") + object.disable ? t(:disable) : t(:enable) end end \ No newline at end of file diff --git a/app/jobs/nccu_calendar.rb b/app/jobs/nccu_calendar.rb index 8756029d..df60bdd2 100644 --- a/app/jobs/nccu_calendar.rb +++ b/app/jobs/nccu_calendar.rb @@ -16,6 +16,6 @@ end # FileUtils.mv(temp_file, File.join(Rails.root, 'public/static', 'nccu_calendar.xml')) - puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]NccuCalendar Synced" + puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]NccuCalendar Synced #{File.join(Rails.root, 'public/static', 'nccu_calendar.xml')}" end end diff --git a/app/models/app_manager.rb b/app/models/app_manager.rb index 0d81a0ec..d2fdc24d 100644 --- a/app/models/app_manager.rb +++ b/app/models/app_manager.rb @@ -2,11 +2,11 @@ class AppManager include Mongoid::Document include Mongoid::Timestamps - belongs_to :user + belongs_to :user,index: true - belongs_to :managing_app, :polymorphic => true #,:class_name => 'ModuleApp',:inverse_of => :managers,:foreign_key => "user_id" + belongs_to :managing_app, :polymorphic => true,index: true #,:class_name => 'ModuleApp',:inverse_of => :managers,:foreign_key => "user_id" belongs_to :sub_managing_app, :polymorphic => true #,:class_name => 'ModuleApp',:inverse_of => :sub_manager,:foreign_key => "sub_user_id" belongs_to :rule_creator,:class_name => 'User' - + end \ No newline at end of file diff --git a/app/models/design/css_default.rb b/app/models/design/css_default.rb new file mode 100644 index 00000000..bd4baa8c --- /dev/null +++ b/app/models/design/css_default.rb @@ -0,0 +1,8 @@ +class CssDefault < Stylesheet + + # belongs_to :design + # belongs_to :desktop_widget + + belongs_to :css, polymorphic: true + +end diff --git a/app/models/design/css_reset.rb b/app/models/design/css_reset.rb new file mode 100644 index 00000000..b2a14b60 --- /dev/null +++ b/app/models/design/css_reset.rb @@ -0,0 +1,5 @@ +class CssReset < Stylesheet + + belongs_to :design + +end diff --git a/app/models/design/design.rb b/app/models/design/design.rb index 58f95bd4..54870a89 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -3,25 +3,27 @@ class Design include Mongoid::Timestamps include ParserLayout - field :title, :type => String field :author, :type => String field :intro, :type => String + field :title, :type => String field :version, :type => String + has_one :css_default, as: :css, :autosave => true, :dependent => :destroy + has_one :layout, :autosave => true, :dependent => :destroy + has_one :css_reset, :autosave => true, :dependent => :destroy + has_many :images,as: :imgs, :autosave => true, :dependent => :destroy + has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy has_many :pages - - embeds_one :layout, :cascade_callbacks => true - embeds_one :default_css, :class_name => "Stylesheet", :cascade_callbacks => true - embeds_one :reset_css, :class_name => "Stylesheet", :cascade_callbacks => true - embeds_many :themes, :cascade_callbacks => true - embeds_many :javascripts, :cascade_callbacks => true - embeds_many :images, :as => :design_image, :cascade_callbacks => true - # embeds_many :custom_images, :class_name => 'Image', :cascade_callbacks => true - - validates_presence_of :title - validates_presence_of :author + has_many :themes, :autosave => true, :dependent => :destroy + + accepts_nested_attributes_for :images, :allow_destroy => true + accepts_nested_attributes_for :javascripts, :allow_destroy => true + accepts_nested_attributes_for :themes, :allow_destroy => true + + validates_presence_of :author, :title after_save :parse_css_for_images + def new_files=(*attrs) attrs[0].map do |key,items_ary| #Loop by JSs,Themes,Imgs @@ -66,13 +68,9 @@ class Design protected def parse_css_for_images - if (self.default_css && self.default_css.changed) - self.default_css.parse_urls - end + self.css_default.parse_urls self.themes.each do |theme| - if theme.changed? - theme.parse_urls - end + theme.parse_urls end parse_body_for_images(self) end diff --git a/app/models/design/design_file.rb b/app/models/design/design_file.rb index 3aec9a0c..973313c4 100644 --- a/app/models/design/design_file.rb +++ b/app/models/design/design_file.rb @@ -4,7 +4,14 @@ class DesignFile mount_uploader :file, AssetUploader - field :to_save, :type => Boolean - field :to_destroy, :type => Boolean + field :name + + before_save :set_name + + protected + + def set_name + self.name = self.file_identifier + end end diff --git a/app/models/design/image.rb b/app/models/design/image.rb index 939095e8..d1a57d7f 100644 --- a/app/models/design/image.rb +++ b/app/models/design/image.rb @@ -1,11 +1,26 @@ -class Image < DesignFile +class Image + include Mongoid::Document + include Mongoid::Timestamps - field :in_css, :type => Boolean - field :name field :html_id field :html_class - - embedded_in :design_image, polymorphic: true + field :in_css, :type => Boolean, :default => false + field :in_html, :type => Boolean, :default => false + field :name mount_uploader :file, ImageUploader -end + + # belongs_to :design + # belongs_to :desktop_widget + + belongs_to :imgs, polymorphic: true + + before_save :set_name + + protected + + def set_name + self.name = self.file_identifier + end + +end \ No newline at end of file diff --git a/app/models/design/javascript.rb b/app/models/design/javascript.rb index 7bfd2c5a..808679d7 100644 --- a/app/models/design/javascript.rb +++ b/app/models/design/javascript.rb @@ -1,3 +1,6 @@ class Javascript < DesignFile - embedded_in :design + # belongs_to :design + # belongs_to :desktop_widget + + belongs_to :js, polymorphic: true end diff --git a/app/models/design/layout.rb b/app/models/design/layout.rb index bf48415c..a782894d 100644 --- a/app/models/design/layout.rb +++ b/app/models/design/layout.rb @@ -6,7 +6,7 @@ class Layout < DesignFile field :body embeds_one :menu - embedded_in :design + belongs_to :design embeds_many :layout_parts before_save :parse_layout diff --git a/app/models/design/stylesheet.rb b/app/models/design/stylesheet.rb index bb2ec85e..5e9a5775 100644 --- a/app/models/design/stylesheet.rb +++ b/app/models/design/stylesheet.rb @@ -1,34 +1,40 @@ -class Stylesheet < DesignFile - embedded_in :design - mount_uploader :file_orig, AssetUploader - - def parse_urls - orig_content = content = self.file.read.force_encoding("UTF-8") - # self.remove_file! - # self.remove_file_orig! - names = [] - images = self.design.images - content.scan(/(?<=url)(.*?)(?=\))/){ - css_name = $1.gsub(' ','').gsub('(','') - name = File.basename(css_name).gsub(/[\\\"]/, '') - file_name = images.detect{ |i| i.file_identifier.eql?(name) }.file_url rescue nil - names << [css_name, file_name] - } - names.each do |name| - content.gsub!(name[0], name[1]) if name[1] - end - Dir.mktmpdir('f_path') { |dir| - orig_file_name = self.file_identifier - - temp_file = File.new(dir + '/' + orig_file_name, 'w+') - temp_file.write orig_content.force_encoding("UTF-8") - self.file_orig = temp_file - - temp_file = File.new(dir + '/' + orig_file_name, 'w+') - temp_file.write content.force_encoding("UTF-8") - self.file = temp_file - self.save - } - end - -end +class Stylesheet < DesignFile + # belongs_to :design + mount_uploader :file_orig, AssetUploader + + def parse_urls + orig_content = content = self.file.read.force_encoding("UTF-8") + # self.remove_file! + # self.remove_file_orig! + names = {} + images = self.css.images + content.scan(/(?<=url)(.*?)(?=\))/){ + css_name = $1.gsub(' ','').gsub('(','') + unless names.has_key?(css_name) + name = File.basename(css_name).gsub(/[\\\"]/, '') + image = images.detect{ |i| i.file_identifier.eql?(name) } rescue nil + if image + image.update_attribute(:in_css, true) + file_name = image.file_url + names.merge!({css_name => file_name}) + end + end + } + names.each_pair do |key, value| + content.gsub!(key, value) + end + Dir.mktmpdir('f_path') { |dir| + orig_file_name = self.file_identifier + + temp_file = File.new(dir + '/' + orig_file_name, 'w+') + temp_file.write orig_content.force_encoding("UTF-8") + self.file_orig = temp_file + + temp_file = File.new(dir + '/' + orig_file_name, 'w+') + temp_file.write content.force_encoding("UTF-8") + self.file = temp_file + self.save + } + end + +end diff --git a/app/models/design/theme.rb b/app/models/design/theme.rb index 8aca324b..0935fe12 100644 --- a/app/models/design/theme.rb +++ b/app/models/design/theme.rb @@ -1,14 +1,11 @@ class Theme < Stylesheet - field :name - embedded_in :design - - before_save :set_name + belongs_to :design protected def set_name - self.name = File.basename(self.file_identifier,".css") + self.name = File.basename(self.file_identifier, ".css") end end diff --git a/app/models/desktop.rb b/app/models/desktop/desktop.rb similarity index 70% rename from app/models/desktop.rb rename to app/models/desktop/desktop.rb index e8c1e9c4..6633005f 100644 --- a/app/models/desktop.rb +++ b/app/models/desktop/desktop.rb @@ -2,14 +2,15 @@ class Desktop include Mongoid::Document include Mongoid::Timestamps - field :theme, default: "4f8d3f493b67fcd05f086359" + field :theme, default: "4f8d3f533b67fcd05f08635a" field :customtheme field :wallpaper belongs_to :user + has_and_belongs_to_many :desktop_widgets, :autosave => true has_many :sections, :autosave => true, :dependent => :destroy - has_many :desktop_widgets, :autosave => true, :dependent => :destroy + # has_many :desktop_widgets, :autosave => true, :dependent => :destroy before_create :initialize_section diff --git a/app/models/desktop_theme.rb b/app/models/desktop/desktop_theme.rb similarity index 100% rename from app/models/desktop_theme.rb rename to app/models/desktop/desktop_theme.rb diff --git a/app/models/desktop/desktop_widget.rb b/app/models/desktop/desktop_widget.rb new file mode 100644 index 00000000..feb40aa7 --- /dev/null +++ b/app/models/desktop/desktop_widget.rb @@ -0,0 +1,33 @@ +class DesktopWidget + include Mongoid::Document + include Mongoid::Timestamps + include ParserLayoutWidget + + field :name + field :author + field :shape + field :version, :type => String + + has_one :css_default, as: :css, :autosave => true, :dependent => :destroy + has_one :widget_layout, :autosave => true, :dependent => :destroy + has_many :images, as: :imgs, :autosave => true, :dependent => :destroy + has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy + has_and_belongs_to_many :desktops, :autosave => true + belongs_to :tiles, :autosave => true + + accepts_nested_attributes_for :images, :allow_destroy => true + accepts_nested_attributes_for :javascripts, :allow_destroy => true + + after_save :parse_css_for_images + + # belongs_to :desktop + + + protected + + def parse_css_for_images + self.css_default.parse_urls + parse_widget_for_images(self) + end + +end \ No newline at end of file diff --git a/app/models/desktop/group.rb b/app/models/desktop/group.rb new file mode 100644 index 00000000..2c1992f0 --- /dev/null +++ b/app/models/desktop/group.rb @@ -0,0 +1,18 @@ +class Group + include Mongoid::Document + include Mongoid::Timestamps + + belongs_to :section + has_many :tiles, :autosave => true, :dependent => :destroy + before_create :initialize_tile + + def initialize_tile + self.tiles.build(data_category: "app", data_content: "quotes", position: 5, shape: "w1 h1", title: "Quotes") + self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 6, shape: "w1 h1", title: "Daily English Word") + widgets = self.section.desktop.desktop_widgets.collect{|widget| widget.id} + for i in 0..3 + self.tiles.build(data_category: "widget", position: i+1,desktop_widget_id: widgets[i]) + end + end +end + \ No newline at end of file diff --git a/app/models/other_account.rb b/app/models/desktop/other_account.rb similarity index 100% rename from app/models/other_account.rb rename to app/models/desktop/other_account.rb diff --git a/app/models/section.rb b/app/models/desktop/section.rb similarity index 100% rename from app/models/section.rb rename to app/models/desktop/section.rb diff --git a/app/models/tile.rb b/app/models/desktop/tile.rb similarity index 86% rename from app/models/tile.rb rename to app/models/desktop/tile.rb index 70066d1b..91840d8a 100644 --- a/app/models/tile.rb +++ b/app/models/desktop/tile.rb @@ -9,6 +9,6 @@ class Tile field :title belongs_to :group - - + has_one :desktop_widget + end diff --git a/app/models/desktop/widget_layout.rb b/app/models/desktop/widget_layout.rb new file mode 100644 index 00000000..5bf24805 --- /dev/null +++ b/app/models/desktop/widget_layout.rb @@ -0,0 +1,18 @@ +class WidgetLayout < DesignFile + + attr_reader :content + + field :body + + belongs_to :desktop_widget + + + def content + self.file.read.force_encoding("UTF-8") rescue '' + end + + def self.exist_one? + WidgetLayout.count > 0 + end + +end diff --git a/app/models/desktop_widget.rb b/app/models/desktop_widget.rb deleted file mode 100644 index eb0446de..00000000 --- a/app/models/desktop_widget.rb +++ /dev/null @@ -1,13 +0,0 @@ -class DesktopWidget - include Mongoid::Document - include Mongoid::Timestamps - - field :name - field :author - field :shape - field :desktop_id - field :status - field :section - - belongs_to :desktop -end \ No newline at end of file diff --git a/app/models/group.rb b/app/models/group.rb deleted file mode 100644 index 7346ad1e..00000000 --- a/app/models/group.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Group - include Mongoid::Document - include Mongoid::Timestamps - - belongs_to :section - has_many :tiles, :autosave => true, :dependent => :destroy - before_create :initialize_tile - - def initialize_tile - self.tiles.build(data_category: "widget", data_content: "timetable", position: 1, shape: "w2 h2", title: "Tiime Table") - self.tiles.build(data_category: "app", data_content: "quotes", position: 2, shape: "w1 h1", title: "Quotes") - self.tiles.build(data_category: "widget", data_content: "weather", position: 3, shape: "w2 h2", title: "Weather") - self.tiles.build(data_category: "widget", data_content: "clock", position: 4, shape: "w2 h1", title: "Clock") - self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 5, shape: "w1 h1", title: "Daily English Word") - self.tiles.build(data_category: "widget", data_content: "school_events", position: 6, shape: "w2 h1", title: "School Events") - end - -end - \ No newline at end of file diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 88a5ce83..669d82aa 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -48,7 +48,7 @@ class ModuleApp def assign_manager(user,assigner) manager = AppManager.first(conditions: {managing_app_id: self.id,user_id: user.id}) rescue nil if manager.nil? - manager = self.managers.create(:user => user,:rule_creator => assigner) + manager = self.managers.create(:user_id => user.id,:rule_creator_id => (assigner.id rescue nil)) end manager end @@ -56,7 +56,7 @@ class ModuleApp def assign_sub_manager(user,assigner) submanager = AppManager.first(conditions: {sub_managing_app_id: self.id,user_id: user.id}) rescue nil if submanager.nil? && !self.managing_users.include?(user) - submanager = self.sub_managers.create(:user => user,:rule_creator => assigner) + submanager = self.sub_managers.create(:user_id => user.id,:rule_creator_id => (assigner.id rescue nil) ) end submanager end @@ -82,7 +82,7 @@ class ModuleApp protected def set_key - self.key = self.title.underscore if self.title + self.key = self.title.underscore.singularize if self.title end diff --git a/app/models/object_auth.rb b/app/models/object_auth.rb index d5cc48de..6c7405ca 100644 --- a/app/models/object_auth.rb +++ b/app/models/object_auth.rb @@ -2,23 +2,28 @@ class ObjectAuth < PrototypeAuth include OrbitCoreLib::ObjectTokenUnility validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| } belongs_to :obj_authable, polymorphic: true - after_save :check_user_has_app_auth + after_save :check_user_has_can_access_app # > - Something.find_with_auth(query) # > - or Something.find(query).auth + def siblings + ObjectAuth.where({obj_authable_type: obj_authable_type,title: title}) + end + def auth_obj class_obj = eval(self.obj_authable_type) class_obj.find self.obj_authable_id end - def check_user_has_app_auth - sub_managing_users = auth_obj.app_auth.sub_managing_users rescue [] - app_auth = auth_obj.app_auth + def check_user_has_can_access_app + sub_managing_users = auth_obj.module_app.sub_managing_users rescue [] + module_app = auth_obj.module_app self.auth_users.each do |auth_user| if !sub_managing_users.include? auth_user && !auth_user.admin? - app_auth.assign_sub_manager(auth_user,User.current) - app_auth.save! + module_app.assign_sub_manager(auth_user,User.current) + module_app.save end end + end end \ No newline at end of file diff --git a/app/models/preview.rb b/app/models/preview.rb new file mode 100644 index 00000000..9c55fc79 --- /dev/null +++ b/app/models/preview.rb @@ -0,0 +1,110 @@ +class Preview + include Mongoid::Document + include Mongoid::Timestamps + + # field :object_f, :type => Hash + field :object, :type=> Hash + field :preview_at_link + field :expired_at , :type => DateTime + field :link_args, :type => Array + field :object_class_type + + has_many :preview_files, :autosave => true, :dependent => :destroy + has_many :preview_associations, :autosave => true, :dependent => :destroy + # def object=(params) + # save_upload_temp_link(params,"news_bulletin_files_attributes") #unless params[] + # self.object_f = params + # end + + # def object + # return object_f + # end + + # def save_upload_temp_link(params,field_name = "bulletin_files_attributes") + # image = preview_files.build(:file=>params[:image]) + # params[:image] = image.id + + # params[field_name].each_with_index do |item,index| + # bfa = preview_files.build(:file=>params[field_name][index.to_s][:file]) + # params[field_name][index.to_s] = bfa.id + # end unless params[field_name].nil? + # end + + # def dig_in_hash(hash,paths_ary) + # hash.each_pair do |key,in_hash| + # if in_hash.kind_of? Array + # dig_in_array(hash,paths_ary) + # elsif in_hash.kind_of? Hash + # dig_in_hash(hash,paths_ary) + # else + # puts("\n End Node: \t #{paths_ary.join } #{in_hash.class} : #{key}##{in_hash}") + # end + # end + # end + + # def dig_in_array(array,paths_ary) + # array.each do |item| + # if item.kind_of? Array + # dig_in_array(hash,paths_ary) + # elsif item.kind_of? Hash + # dig_in_hash(hash,paths_ary) + # else + # puts("\n End Node: \t #{paths_ary.join } #{item.class} : {item}") + # end + # end + # end + + + # def dig_in_hash_old(hash,paths_ary) + # hash.each_pair do |k,in_hash| + # if (!in_hash.kind_of? Array and !in_hash.kind_of? Hash) + # #p "UploadedFile : #{in_hash.is_a? ActionDispatch::Http::UploadedFile}" + # #in_hash = "no file" if in_hash.is_a? ActionDispatch::Http::UploadedFile + # #in_hash.select{|key,hash| hash.is_a? ActionDispatch::Http::UploadedFile} + # puts("\n End Node:# \n") + # p "#{paths_ary.join } #{in_hash.class} : #{in_hash}" + # #p "UploadedFile(#{in_hash}) : #{in_hash.is_a? ActionDispatch::Http::UploadedFile}" + # else + # if (!in_hash.first.kind_of? Array and !in_hash.first.kind_of? Hash) + # paths_ary << "[#{in_hash.first}]" + # end + # puts("\n Go Down [#{in_hash.first}]\n") + # dig_in_hash(in_hash,paths_ary) + # puts("\n Go Out \n") + # end + # puts "This is last" + # paths_ary.pop + # end + # end + + def get_arg_hash + object.slice(*link_args).inject({}){|la,(k,v)| la[k.to_sym] = v; la} + end + + def get_preview_link + ap = Rails.application.routes.url_helpers + ap.send preview_at_link,({:id=>id,:preview=>true}.merge get_arg_hash) + #func = eval("Rails.application.routes.url_helpers.#{preview_at_link}").send + end + + def get_virtual_object + virtual_object = eval(self.object_class_type).new object + preview_files.each do |file| + if file.file_in_array + eval("virtual_object.#{file.field_name_for_rebuild}.build :file=>file.file") + else + eval("virtual_object.#{file.field_name_for_rebuild} = file.file") + end + end + + preview_associations.each do |local_object| + if local_object.object_in_array + eval("virtual_object.#{local_object.field_name_for_rebuild}.build local_object.object") + else + eval("virtual_object.#{local_object.field_name_for_rebuild} = local_object.object") + end + end + virtual_object + end + +end diff --git a/app/models/preview_association.rb b/app/models/preview_association.rb new file mode 100644 index 00000000..64785b9a --- /dev/null +++ b/app/models/preview_association.rb @@ -0,0 +1,16 @@ +class PreviewAssociation + + include Mongoid::Document + include Mongoid::Timestamps + + field :object, :type=> Hash + field :field_name_for_rebuild + field :object_in_array , :type => Boolean,default: false + + # field :to_save, :type => Boolean + field :should_destroy, :type => Boolean + + belongs_to :preview + # embedded_in :news_bulletin + +end diff --git a/app/models/preview_file.rb b/app/models/preview_file.rb new file mode 100644 index 00000000..d06ddc25 --- /dev/null +++ b/app/models/preview_file.rb @@ -0,0 +1,19 @@ +class PreviewFile + + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :file, AssetUploader + + field :title, localize: true + field :description, localize: true + field :field_name_for_rebuild + field :file_in_array , :type => Boolean,default: false + + # field :to_save, :type => Boolean + field :should_destroy, :type => Boolean + + belongs_to :preview + # embedded_in :news_bulletin + +end diff --git a/app/models/user/attribute.rb b/app/models/user/attribute.rb index faa5876a..c0970863 100644 --- a/app/models/user/attribute.rb +++ b/app/models/user/attribute.rb @@ -11,6 +11,7 @@ class Attribute has_many :attribute_fields, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :attribute_fields, :allow_destroy => true + def is_built_in? self.built_in end diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index 4407cb6d..a94a38a2 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -5,26 +5,68 @@ class AttributeField include ::AttributeFieldsHelper field :key - field :markup - field :markup_value ,:type => Hash + field :markup ,:default=>"text_field" + field :option_list ,:type => Hash,:default => {} field :markup_options,:type => Hash - field :locale, :type => Boolean, :default => true + # field :locale, :type => Boolean, :default => true # field :list_options, :type => Array field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - field :add_more,:type => Boolean, :default => false + field :to_delete,:type=> Boolean,:default => false + field :typeA,:type=> Hash,:default=>{} + field :typeB,:type=> Hash,:default=>{} + field :typeC,:type=> Hash,:default=>{:claendar=>"west_claendar"} + field :typeD,:type=> Hash,:default=>{} + field :typeE,:type=> Hash,:default=>{} + #field :title, localize: true - field :locale_title, localize: true - field :neutral_title - field :neutral_for + field :title, localize: true + belongs_to :attribute # belongs_to :role - has_many :attribute_values - + has_many :attribute_values,:autosave => true, :dependent => :destroy + before_save :check_option_list # validates_uniqueness_of :key + def add_more + (get_data["add_more"] == "true" ? true : false) rescue false + end + + def locale + default = true + if get_data["locale"].nil? + return default + else + (get_data["locale"] == "true" ? true : false) rescue default + end + end + + def self_defined_markup_options? + (self.attribute.role.method(self[:key].pluralize.to_sym) && self.attribute.role.method(self[:key].pluralize+"_for_"+markup)) rescue false + end + + def markup_value=(var) + if !self_defined_markup_options? + self[:markup_value] = (eval(var) rescue {}) + end + end + + def option_list + if self_defined_markup_options? + #Class need to have corresponding field and value agent + # Ex: For "status" the class must have field called "statuses" for the relation and "statuses_for_select" for the select function + method = self.attribute.role.method(self[:key].pluralize+"_for_"+markup) + return (method.call rescue {}) + elsif self[:option_list].nil? || (self[:option_list].empty?) + return {} + else + return self[:option_list] + end + end + + def markup_options=(var) self[:markup_options] = (eval(var) rescue {}) @@ -43,36 +85,49 @@ class AttributeField self.attribute.role end - def title_translations - if locale - return locale_title_translations - else - return Hash[VALID_LOCALES.map{|d| [d,neutral_title]}] - end + def panel + panel = LIST[:markups][self[:markup]]["panel"] end - def title_translations=(var) - if locale - self.locale_title_translations = var - end + def get_data + self[panel] end - def title - if locale - return self.locale_title - else - return self.neutral_title - end - end - def title=(var) - # binding.pry - if locale - self.locale_title = var - else - self.neutral_title = var - end - end + # def title_translations + # if locale + # return self.locale_title_translations + # else + # return self[:neutral_title] #Hash[VALID_LOCALES.map{|d| [d,neutral_title]}] + # end + # end + + # def title_translations=(var) + # if locale + # self.locale_title_translations = var + # end + # end + + # def title + # if locale + # return self.locale_title + # else + # return self.neutral_title + # end + # end + + # def check_title + # if locale + # self.locale_title_translations = self[:temp_title] + # else + # self.neutral_title = self[:temp_title] + # end + # self.unset("temp_title") + # end + + # def title=(var) + # self["temp_title"] = var + # end # # Convert the string list_options into an array # def select_list_options=(var) @@ -92,4 +147,9 @@ class AttributeField self.disabled end +protected + def check_option_list + self[:option_list] = self[panel]["option_list"] + end + end diff --git a/app/models/user/attribute_value.rb b/app/models/user/attribute_value.rb index 2835a0bd..d6500fbf 100644 --- a/app/models/user/attribute_value.rb +++ b/app/models/user/attribute_value.rb @@ -10,9 +10,55 @@ class AttributeValue belongs_to :user before_save :check_key - + before_save :data_proc # NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"] + + def data_proc + # binding.pry + # binding.pry if self.attribute_field.markup == 'radio_button' + # if self.attribute_field + case self.attribute_field.markup + when 'text_field','text_area' + # binding.pry + self[:temp_data].each{|key,val| + self[key] = val + } unless self[:temp_data].nil? + when 'select','date','radio_button' + self["val"] = self[:temp_data] + when 'checkbox' + self["val"] = self[:temp_data].keys rescue {} + end #end of case + else # if not locale + case self.attribute_field.markup + when 'text_field','text_area' + self["val"] = self[:temp_data] + when 'select','date','radio_button' + self["val"] = self[:temp_data] + when 'checkbox' + self["val"] = self[:temp_data].keys rescue {} + end #end of case + # end #of if self.attribute_field + self.unset('temp_data') + end + + def value + + result="" + if self.attribute_field.locale && (self.attribute_field.markup == "text_field" || self.attribute_field.markup == "text_area") + result= Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}] + else + result = self["val"] + end + result + end + + def value=(value) + #save everything to temp_data waiting for futher process + # binding + self[:temp_data] = value + end + def check_key self.key = attribute_field.key end @@ -26,45 +72,46 @@ class AttributeValue end def get_value_by_locale(locale) + case self.attribute_field.markup when "text_field" - self.attribute_field.locale ? self[locale] : self[:value] + self.attribute_field.locale ? self[locale.to_s] : self.value when "select" - markup_values = eval(self.attribute_field.markup_value) - markup_values[self[:value]][locale.to_s] rescue 'NoData' + markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : eval(self.attribute_field.markup_value) + markup_values[self.value][locale.to_s] rescue 'NoData' when "text_area" - self.attribute_field.locale ? self[locale] : self[:value] + self.attribute_field.locale ? self[locale.to_s] : self.value when "date" - Date.new(self[:value]["(1i)"].to_i,self[:value]["(2i)"].to_i,self[:value]["(3i)"].to_i) rescue nil + Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil when "addr" - self[:value] + self.value when "radio_button" markup_values = eval(self.attribute_field.markup_value) - markup_values[self[:value].first[0]][locale.to_s] - when "checkbox" - markup_values = eval(self.attribute_field.markup_value) - self[:value].keys.collect{|key| markup_values[key][locale.to_s] }.join(",") + markup_values[:value][locale.to_s] + when "checkbox" + markup_values = self.attribute_field.markup_value + self[:value].keys.collect{|key| markup_values[key][locale.to_s]}.join(",") when "date_durnation" - self[:value] + self.value else - self.attribute_field.locale ? self[locale] : self[:value] + self.attribute_field.locale ? self[locale.to_s] : self.value end end - def get_values - unless ['select','checkbox','radio_button'].include?(self.attribute_field.markup ) - if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"] - return Hash[VALID_LOCALES.collect{|lang| [lang,get_value_by_locale(lang.to_sym)]}] - else - return get_value_by_locale("") - end - else - if self.attribute_field.markup == "select" - self[:value] - else - self[:value].keys - end - end - end + # def get_values + # unless ['select','checkbox','radio_button'].include?(self.attribute_field.markup ) + # if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"] + # return Hash[VALID_LOCALES.collect{|lang| [lang,get_value_by_locale(lang.to_sym)]}] + # else + # return get_value_by_locale("") + # end + # else + # if self.attribute_field.markup == "select" + # self[:value] + # else + # self[:value].keys rescue self[:value] + # end + # end + # end end diff --git a/app/models/user/role.rb b/app/models/user/role.rb index 438e2dab..cd3d6775 100644 --- a/app/models/user/role.rb +++ b/app/models/user/role.rb @@ -27,4 +27,11 @@ class Role self.first(:conditions => {:key => key}) end + def statuses_for_select + data = self.statuses.map do |t| + [t.id.to_s,t.title_translations] + end + Hash[data] + end + end \ No newline at end of file diff --git a/app/models/user/status.rb b/app/models/user/status.rb index f9f19420..d9715d89 100644 --- a/app/models/user/status.rb +++ b/app/models/user/status.rb @@ -5,7 +5,7 @@ class Status has_and_belongs_to_many :users - + field :key belongs_to :role # has_and_belongs_to_many :sub_roles diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 14ebbc69..4f645f3b 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -9,10 +9,7 @@ class User field :admin, :type => Boolean, :default => true field :active_role - field :nccu_ldap_uid field :email - # field :cache_dept - # has_one :cache_dept, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy field :cache_dept,type: Hash field :status_record,type: Hash @@ -34,27 +31,61 @@ class User accepts_nested_attributes_for :attribute_values, :allow_destroy => true before_create :initialize_desktop - before_save :check_status_record + before_save :rebuild_status_record before_save :save_roles - scope :remote_account, where(:nccu_id.ne => nil) - validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique") - + # validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique") + # def new_attribute_values=(vars) # binding.pry # end # def new_attribute_values(vars) # binding.pry # end - def rebuild_sub_roles_from_attribute_values!(attribute_values) - # attribute_fields = AttributeField.find attribute_values.collect{|t| t[1][:attribute_field_id]} - # self.sub_roles = attribute_fields.collect{|t| t.attribute if t.attribute.is_a? SubRole}.compact.uniq + + ## # class << self + ## def initialize + ## self.define_method("asd"){ p "hi"} + ## sub_roles.each do |sr| + ## sr_ids = sr.attribute_fields.collect{|t| t.id.to_s} + ## self.define_method("attribute_values_for_"+sr.key.to_s) { + ## AttributeValue.where(user_id: id ).in(attribute_field_id: sr_ids) + ## } + ## end + ## yield self + ## end + + # end + + # def initialize + # binding.pry + # # yield self + # end + + def get_attribute_value(attribute_field) + attribute_values.where(attribute_field_id: attribute_field.id).first end + def get_sub_roles_by_role(role) + sub_roles.where(role_id: role.id) + end + + def disable_sub_role=(var) + var[:id].each do |id,val| + # binding.pry if id == '5052c5b22b5c49ab02000004' + if (val=="true") + self.sub_roles = self.sub_roles.reject{|t| t.id.to_s==id} + elsif(val=="false") + self.sub_roles << SubRole.find(id) + end + end + end + + + def set_sub_role(sub_role_id,status_id) - self.sub_roles << SubRole.find(sub_role_id) - self.status_record.store(sub_role_id,status_id) + self.status_record.merge!(Hash[sub_role_id,status_id]) end # def get_status(*params) @@ -80,11 +111,18 @@ class User def self.find_by_status_and_sub_role_key(sub_role_key,status_key) #Query for users by using specific sub_role and status key sr = ::SubRole.first({conditions: { key: sub_role_key }}) status = ::Status.first({conditions:{role_id: sr.role.id,key: status_key}}) - find_by_status(sr.id,status.id) + find_by_subrole_and_status(sr.id,status.id) end - def self.find_by_status(sub_role_id,status_id) #Query for users by using specific sub_role and status key buy within ID - User.where("status_record.#{sub_role_id}" => status_id) + def self.find_by_subrole_and_status(sub_role_id,status_id) #Query for users by using specific sub_role and status key by within ID + User.where("status_record.#{sub_role_id}" => status_id,:sub_role_ids.in => [ sub_role_id ]) + end + + def self.find_by_status(status_id) + status = ::Status.find status_id + ::SubRole.where({role_id: status.role.id.to_s,disabled: false}).collect{|sr| + find_by_subrole_and_status(sr.id.to_s,status_id) + }.uniq! end def create_dept_cache @@ -139,27 +177,21 @@ class User end def initialize_desktop - self.build_desktop + self.build_desktop(desktop_widget_ids: DesktopWidget.all.collect{|widget| widget.id}) end protected - def save_roles - self.roles = self.sub_roles.collect{|t| t.role}.uniq + def save_roles + self.roles = self.sub_roles.collect{|t| t.role}.uniq + end + + + def rebuild_status_record + self.status_record = {} + self.attribute_values.reject{|t| t.key!='status'}.each do |status| + # binding.pry + set_sub_role(status.attribute_field.attribute.id.to_s,status[:value]) rescue nil + end end - def check_status_record - roles = sub_roles.collect{|t| t.role}.uniq #get all role from sub_roles - sub_roles_ary = sub_roles.collect{|t| t.id.to_s} - self.status_record = status_record.keep_if{|sub_role_id, status_id| - includeing = sub_roles_ary.include?(sub_role_id) - valide = false - if includeing - sub_role = SubRole.find sub_role_id - valide = sub_role.role.statuses.include? (Status.find status_id) - end - - (includeing and valide) - } rescue {} - end - -end +end \ No newline at end of file diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb index 41480fd5..748bac16 100644 --- a/app/uploaders/image_uploader.rb +++ b/app/uploaders/image_uploader.rb @@ -24,7 +24,7 @@ class ImageUploader < CarrierWave::Uploader::Base # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir - "image/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + "#{model.id}" end # Provide a default URL as a default if there hasn't been a file uploaded: @@ -48,7 +48,7 @@ class ImageUploader < CarrierWave::Uploader::Base # end version :thumb do - process :resize_to_fit => [200, 200] + process :resize_to_limit => [200, 200] end # Add a white list of extensions which are allowed to be uploaded. diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index d65a17e0..56160931 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -2,26 +2,26 @@ <% if at_least_module_manager || sub_manager?(ad_banner_tab)%> <%= form_for ad_banner_tab,:url=> admin_ad_banner_path(ad_banner_tab),:method => :put,:class=>"input-medium" do |f| -%>
    - - <%= f.label :ad_fx, t('admin.ad.ab_fx') %> + + <%= f.label :ad_fx, t('ad.ab_fx') %> <%= f.select :ad_fx ,AdBanner::FX_TYPES %> - <%= f.label :transition_sec, t('admin.ad.transition_sec') %> - <%= f.text_field :transition_sec,:placeholder=>t('admin.ad.sec_place_holder'),:class=> "span3" %> <%= t("admin.ad.trans_unit_sec") %> + <%= f.label :transition_sec, t('ad.transition_sec') %> + <%= f.text_field :transition_sec,:placeholder=>t('ad.sec_place_holder'),:class=> "span3" %> <%= t("ad.trans_unit_sec") %> <%if at_least_module_manager%> - <%= f.label :best_size, t('admin.ad.best_size') %> + <%= f.label :best_size, t('ad.best_size') %> <%= f.text_field :best_size %> Ex: 500px x 300px <% end -%>
    - <%= f.submit t("admin.ad.update_banner"), :class => 'btn' %> + <%= f.submit t("ad.update_banner"), :class => 'btn' %> <%= f.submit t("cancel"),:type=>'reset', :class => 'btn' %>
    <% end -%> <% end -%> -

    <%= t("admin.ad.picture_list")%>

    +

    <%= t("ad.picture_list")%>

    <%if (at_least_module_manager || ad_banner_tab.cur_user_is_sub_manager_of(:edit) )%> <%= content_tag :div ,:class=>'adbanner-action' do%> - <%= link_to t("admin.ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%> + <%= link_to t("ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%> <%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(ad_banner_tab.id) , :class=>'preview_trigger btn btn-success'%> <% end -%> <% end -%> @@ -30,7 +30,7 @@ <% if at_least_module_manager %> <%= show_ad_banner_permission_link ad_banner_tab%> - <%= link_to t('admin.ad.delete_banner'),admin_ad_banner_path(ad_banner_tab),:class => 'btn',:method => :delete,:confirm => t('sure?') %> + <%= link_to t(:delete),admin_ad_banner_path(ad_banner_tab),:class => 'btn',:method => :delete,:confirm => t('sure?') %> <% end -%> <%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %> diff --git a/app/views/admin/ad_banners/_ad_image_update.html.erb b/app/views/admin/ad_banners/_ad_image_update.html.erb index 0b4277a0..15bb75d0 100644 --- a/app/views/admin/ad_banners/_ad_image_update.html.erb +++ b/app/views/admin/ad_banners/_ad_image_update.html.erb @@ -1,7 +1,7 @@
  • <%= image_tag ad_image.file rescue nil%>

    - <%= ad_image.display? ? "[#{t('admin.ad.showing')}]" : "[#{t('admin.ad.not_showing')}]" %> + <%= ad_image.display? ? "[#{t('ad.showing')}]" : "[#{t('ad.not_showing')}]" %> <%= "#{ad_image.post_date ||'NeedReset' }~#{ad_image.unpost_date || 'NeedReset'}" %>

    <%if at_least_module_manager || sub_manager?(ad_image.ad_banner) %> diff --git a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb index 68e0a9c6..dc77bc5f 100644 --- a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb +++ b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb @@ -4,33 +4,33 @@
  • - <%= f.text_field :nccu_ldap_uid, :class => 'span2', :placeholder => t('nccu_c.nccu_ldap_uid'), :size => 16 %> + <%= f.text_field :email, :class => 'span2', :placeholder => t(:email), :size => 16 %>
  • diff --git a/app/views/layouts/_side_bar_content.html.erb b/app/views/layouts/_side_bar_content.html.erb index 94c0b104..66e4542d 100644 --- a/app/views/layouts/_side_bar_content.html.erb +++ b/app/views/layouts/_side_bar_content.html.erb @@ -14,7 +14,7 @@ <%= content_tag :li, link_to((t('announcement.categories') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_announcement_back_end_bulletin_categorys_path), :class =>( active_for_action('bulletin_categorys', 'index') || active_for_ob_auths_object("BulletinCategory") )if (is_manager? rescue nil) %> <%= content_tag :li, link_to((t('announcement.tags') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_announcement_back_end_tags_path), :class => active_for_action('/panel/announcement/back_end/tags', 'index')if (is_manager? rescue nil) %> <%= content_tag :li, link_to((t('announcement.bulletin.approval_setting') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_announcement_back_end_approval_setting_path), :class => active_for_action('approvals', 'setting') if (is_manager? rescue nil) %> - <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: "Announcement"}))), :class => active_for_app_auth('Announcement') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "announcement"}))), :class => active_for_app_auth('Announcement') if (is_admin? rescue nil) %> <% end -%> @@ -46,14 +46,14 @@ <% end -%> -<%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') ||active_for_ob_auths_object("AdBanner") ||active_for_app_auth('ad_banners') do -%> +<%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') ||active_for_ob_auths_object("AdBanner") ||active_for_app_auth('ad_banner') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-link') + content_tag(:span, t('admin.ad_banner')), admin_ad_banners_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('ad_banners', 'ad_images') ) do -%> <%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> <%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> <%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> - <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "ad_banners"}))), :class => active_for_app_auth('ad_banners') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "ad_banner"}))), :class => active_for_app_auth('ad_banners') if (is_admin? rescue nil) %> <% end -%> <% end %> @@ -65,7 +65,7 @@ <%= content_tag :li, link_to((t('announcement.add_new') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_links', 'new') if (is_manager? rescue nil)%> <%= content_tag :li, link_to((t('announcement.categories') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_web_resource_back_end_web_link_categorys_path), :class => (active_for_action('web_link_categorys', 'index') || active_for_ob_auths_object("WebLinkCategory")) if (is_manager? rescue nil)%> <%= content_tag :li, link_to((t('announcement.tags') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_web_resource_back_end_tags_path), :class => active_for_action('/panel/web_resource/back_end/tags', 'index') if (is_manager? rescue nil)%> - <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: "web_resource"}))), :class => active_for_app_auth('web_resource') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "web_resource"}))), :class => active_for_app_auth('web_resource') if (is_admin? rescue nil) %> <% end -%> <% end -%> @@ -81,7 +81,7 @@ <% end -%> <% end %> -<%= content_tag :li, :class => active_for_controllers('archive_files', 'tags', 'archive_file_categorys') do -%> +<%= content_tag :li, :class => active_for_controllers('archive_files', 'panel/archive/back_end/tags', 'archive_file_categorys') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-asset') + content_tag(:span, t('admin.archive')), panel_archive_back_end_archive_files_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('archive_files', 'tags', 'archive_file_categorys')) do -%> <%= content_tag :li, link_to((t('admin.all_articles') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_archive_back_end_archive_files_path), :class => active_for_action('archive_file', 'index') %> @@ -91,14 +91,14 @@ <% end -%> <% end -%> -<%= content_tag :li, :class => active_for_controllers('cals') || active_for_app_auth("calendar") do -%> +<%= content_tag :li, :class => active_for_controllers('cals','panel/calendar/back_end/tags') || active_for_app_auth("calendar") do -%> <%= link_to content_tag(:i, nil, :class => 'icons-calendar') + content_tag(:span, t('admin.calendar')), panel_calendar_back_end_cals_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('cals','calendar_categories') ) do -%> <%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> <%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> <%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> - <%= content_tag :li, link_to((t('calendar.calendars') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_calendar_back_end_cal_path), :class => active_for_action('cals','new') %> - <%#= content_tag :li, link_to(t('gallery.tags'), panel_gallery_back_end_tags_path), :class => active_for_action('/panel/gallery/back_end/tags', 'index') %> + <%= content_tag :li, link_to((t('admin.calendars') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_calendar_back_end_cal_path), :class => active_for_action('cals','new') %> + <%= content_tag :li, link_to(t('admin.tags'), panel_calendar_back_end_tags_path), :class => active_for_action('/panel/calendar/back_end/tags', 'index') %> <%#= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "gallery"}))), :class => active_for_app_auth('gallery') if (is_admin? rescue nil) %> <% end -%> <% end %> diff --git a/app/views/layouts/panel.html.erb b/app/views/layouts/panel.html.erb deleted file mode 100644 index b21c66cb..00000000 --- a/app/views/layouts/panel.html.erb +++ /dev/null @@ -1,46 +0,0 @@ - - - - - R4 - - <%= yield :page_specific_link %> - <%= stylesheet_link_tag "application" %> - <%= javascript_include_tag "application" %> - <%= csrf_meta_tag %> - - -
    - - - - - -
    -
    <%= yield %>
    -
    <%= yield :secondary %>
    -
    <%= yield :tertiary %>
    -
    - - -
    -<%= yield :page_specific_javascript %> - - diff --git a/app/views/shared/_address_modal_dialog.html.erb b/app/views/shared/_address_modal_dialog.html.erb new file mode 100644 index 00000000..6e241074 --- /dev/null +++ b/app/views/shared/_address_modal_dialog.html.erb @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/app/views/shared/_privilege_user.html.erb b/app/views/shared/_privilege_user.html.erb index ba68996f..79cb4023 100644 --- a/app/views/shared/_privilege_user.html.erb +++ b/app/views/shared/_privilege_user.html.erb @@ -1,6 +1,6 @@
    - <%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.approval_setting_window_title'),:content => (user.cache_dept[I18n.locale.to_s] rescue '')},:class=>"checkbox clear" do %> + <%= content_tag :div,:data=>{'original-title' => t(:title),:content => (user.cache_dept[I18n.locale.to_s] rescue '')},:class=>"checkbox clear" do %>
    diff --git a/app/views/shared/preview/_modal_preview.html.erb b/app/views/shared/preview/_modal_preview.html.erb new file mode 100644 index 00000000..cad29773 --- /dev/null +++ b/app/views/shared/preview/_modal_preview.html.erb @@ -0,0 +1,47 @@ + \ No newline at end of file diff --git a/app/views/shared/preview/after_create.js.erb b/app/views/shared/preview/after_create.js.erb new file mode 100644 index 00000000..b700204f --- /dev/null +++ b/app/views/shared/preview/after_create.js.erb @@ -0,0 +1 @@ +window.location = "<%= @info[:redirect_url]%>"; \ No newline at end of file diff --git a/app/views/shared/preview/preview.html.erb b/app/views/shared/preview/preview.html.erb new file mode 100644 index 00000000..935824c8 --- /dev/null +++ b/app/views/shared/preview/preview.html.erb @@ -0,0 +1,12 @@ +<% if !request.xhr? %> + +<% end %> \ No newline at end of file diff --git a/app/views/shared/preview/preview.js.erb b/app/views/shared/preview/preview.js.erb new file mode 100644 index 00000000..717dc81e --- /dev/null +++ b/app/views/shared/preview/preview.js.erb @@ -0,0 +1,6 @@ +$('#show_preview').html('<%=escape_javascript(render :partial=>"/shared/preview/modal_preview") %>'); +var start_modal_with_id = "<%= @preview_obj.id %>"; +$("#"+start_modal_with_id).css("width","1050px"); +$("#"+start_modal_with_id).css("height","768px"); +$("#"+start_modal_with_id).css("margin","-270px 0 0 -550px"); +$("#"+start_modal_with_id).modal(); \ No newline at end of file diff --git a/config/application.rb b/config/application.rb index ccc4a65e..f0e40fcc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -33,6 +33,7 @@ module Orbit config.autoload_paths += %W(#{config.root}/app/models/meta) config.autoload_paths += %W(#{config.root}/app/models/purchase) config.autoload_paths += %W(#{config.root}/app/models/user) + config.autoload_paths += %W(#{config.root}/app/models/desktop) # Include all helpers # 'helper :all' must be removed in ApplicationController diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index ea19b137..817f12ea 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -21,7 +21,7 @@ Devise.setup do |config| # parameters are used only when authenticating and not when retrieving from # session. If you need permissions, you should implement that in a before filter. # config.authentication_keys = [ :email ] - config.authentication_keys = [ :nccu_ldap_uid ] + config.authentication_keys = [ :email ] # Tell if authentication through request.params is enabled. True by default. diff --git a/config/initializers/resque.rb b/config/initializers/resque.rb index 62de3fa4..bd7a91fe 100644 --- a/config/initializers/resque.rb +++ b/config/initializers/resque.rb @@ -1,9 +1,9 @@ require 'resque_scheduler' -# require 'resque_scheduler/server' +require 'resque_scheduler/server' # require 'yaml' Resque.redis = 'localhost:6379' -#Resque.redis.namespace = "resque:SchedulerExample" +Resque.redis.namespace = "resque" # If you want to be able to dynamically change the schedule, # uncomment this line. A dynamic schedule can be updated via the diff --git a/config/ldap.yml b/config/ldap.yml index 5c48fc1a..9d330c47 100644 --- a/config/ldap.yml +++ b/config/ldap.yml @@ -4,8 +4,8 @@ defaults: &defaults development: <<: *defaults - host: '127.0.0.1' - port: 8001 + host: '140.119.166.23' + port: 389 production: <<: *defaults host: '140.119.166.23' diff --git a/config/list.yml b/config/list.yml index b0cf253f..ebfff364 100644 --- a/config/list.yml +++ b/config/list.yml @@ -9,21 +9,27 @@ markups: text_field: muti_lang_input_supprt: true ext_support: true + panel: typeA select: muti_lang_input_supprt: false ext_support: false + panel: typeB date: muti_lang_input_supprt: false ext_support: false + panel: typeC text_area: muti_lang_input_supprt: true ext_support: false + panel: typeD radio_button: muti_lang_input_supprt: false ext_support: false + panel: typeE checkbox: muti_lang_input_supprt: false ext_support: false + panel: typeE # date_durnation: # muti_lang_input_supprt: false # ext_support: false diff --git a/config/locales/en.yml b/config/locales/en.yml index 05715db9..041e03d7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,46 +1,235 @@ -# Sample localization file for English. Add more files in this directory for other locales. -# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. - en: - + _locale: English - - me: Me + + access: + denied: + app: + not_sub_manager: Access Denied for you are not SubManager for this app + not_manager: Access Denied for you are not SubManager for this app + not_authed_user: Access Denied for you are not User for this app + object: Access Denied for you don't have permission for this object + not_admin: Access Denied for you are not Admin account_settings: Account settings + action: Action + ad: + ab_fx: FX + banner_best_size: Banner Best Size + best_size: Best size + new_image: New image + not_showing: Not showing + picture_list: Picture List + sec_place_holder: Enter 3 if 3 sec + showing: Showing + success_destroy_ad_image: Image successfully destroyed + trans_unit_sec: sec + transition_sec: Transition time + update_banner: Update Banner + widget_info_for_ad_image_size: "Best size with: %{best_size}" + ad_banner: AD Banner add: Add + add_item: Add item + addthis_tools: + add_to_bookmark: Add this to bookmark + admin: Admin + all_content: All Content + all_file: All File + all_member: All Member + always_display_title: Always displayed in the title bar + app_auth: + list_setting_result: Authorization List + assigning_manager: + add_manager_fail: Manager successfully added + add_manager_ok: Adding manager failed + assigning_sub_manager: + add_sub_manager_fail: Sub-manager successfully added + add_sub_manager_ok: Adding sub-manager failed + can_not_add_this_user: This user cannot be added + delete_manager: + fail: Removal of manager failed + success: Manager successfully removed + delete_sub_manager: + fail: Removal of sub-manager failed + success: Sub-manager successfully removed + failed_no_user: Failed, no user + approval: + not_pass: Not pass + not_pass_reason: Not pass reason + pass: Pass + setting: Approval setting + stat: Approval status + user_list: Unit + approval_: Approval + asset: Asset + auth: + add_manager: Add Manager + add_sub_manager: Add SubManager + add_to_block_list: Add to block List + add_to_privilege_list: Add to privilege List + all_member: All Member + auth_by: - Authorized by %{user_display_name} + by_role: By Role + by_sub_role: By SubRole + author: Author back: Back + basic: Basic browse: Browse cancel: Cancel + cant_delete_self: You can not delete yourself. cant_empty_star: Cannot be empty (*) - create_fail: Creation failed - create: Create + cant_revoke_self_admin: You can not revoke your admin role yourself. + categories: Categories + category: Category + category_auth: Category Authorization + clear: Clear + content: Content + create: + error: + link: Error when creating link. + page: Error when creating page. + fail: Creation failed + success: + asset_category: Asset category was successfully created. + link: Link was successfully created. + page: Page was successfully created. + user: User was successfully created. + create_: Create + data: Data + dashboard: + bulletin: Announcement + news_bulletin: News + page_context: Page + web_link: Link + dashboard_: Dashboard + deadline: Deadline + default_css: Default CSS delete: Delete + delete_file: Delete file + description: Description desktop: Desktop disable: Disable dots: ●●●●●● - downloaded: Downloaded download: Download + downloaded: Downloaded edit: Edit + editing: + asset: Editing asset + design: Editing design + link: Editing link + page: Editing page email: Email enable: Enable + enabled_for: Enabled for + end: End + end_date: End date + errors: + at_least_one: must at least have one value + file: + size: File size + type: File type + upload: File upload + file_: File + file_type: File Type forgot_password: Forgot your password? + frequency: Frequency help: Help + hidden: Hidden hide: Hide + hits: Hits homepage: Homepage - langs: - zh_tw: Traditional Chinese - en: English + horizontal: Horizontal + hot: Hot + image: Image + info: Information + intro: Introduction + is_published: Is published + item: Item + key: Key + last_modified: Last modified + layout: Layout + link: Link + list: + ad_banner: AdBanner list + asset: Asset list + info: User information list + link: Link list + purchase: Purchases list + role: User roles list + user: Users list + list_: List + list_lower: list + lists: + markups: + text_field: Text Field + select: Select + date: Date + text_area: Text Area + radio_button: Radio button + checkbox: Checkbox login: Login logout: Logout - no_: "No" - nothing: Nothing - nccu: NCCU + mail: + address: Address + authentication: Authentication + domain: Domain + enable_starttls_auto: Enable Start TLS Auto + password: Password + port: Port + setting: Mail settings + tls: TLS + user_name: User Name + manager: Manager + manager: Manager + me: Me + member: Member + menu_enabled_for: Menu enabled for + modal: + close: Close + preview: Preview + module: Module + module_authorization: Module Authorization + more_plus: more+ + most_visited_page: Most Visited Page + multilingual: Multilingual + name: Name nccu_c: nccu_ldap_uid: NCCU LDAP Account + new: + asset: New asset + banner: New banner + design: New design + link: New link + page: New page + user: New user + info: New user information + role: New user role + news: News + no_: "No" + no_deadline: No deadline + object_auth: + a_object_must_have_only_one_object_auth_profile_for_each_action: '' + list_title_of_users: authorization list + new_object_auth: New authorization off_upcase: "OFF" on_upcase: "ON" + options: Options or_lower: or + organization: Organization + page: Page + page_part_kinds: + module_widget: Plug-in Module Widget + public_r_tag: System Widget + text: Text Area + passed: Approved password: Password +# : <<<<<<< HEAD + pending: Pending + picture: Picture + postdate: Postdate + posted_by: Posted by + preview: Preview + purchase: Purchase +# : ======= register: Register remember_me: Remember me search_google: Search Google @@ -66,23 +255,116 @@ en: member: Member module: Module most_visited_page: Most Visited Page +# : >>>>>>> various_bugs quantity: Quantity + quick_edit: Quick edit recent_update: Recent Update referral_in_links: Referral in Links + register: Register + registered: Registered + rejected: Rejected + rejected_reason: 'Reason:' + rejected_reason_empty: "Approval rejected, no referencable information" + related_links: Related Links role: Role + Roles: Roles + ruling_site: Ruling Site + search: + domains: Google Search Domains + not_found: "NOT FOUND" + result_get: "Searched about ' %{search_word} ' Found %{item_num} items" + sitesearch: Google Site Search + too_many: "Search about ' %{search_word} 'resulted more than %{exceed_num} items maybe try to search with more specific terms?" + unit_get: "Listed items created by :%{unit_name} Found %{item_num} items" + search_nccu: Search NCCU + setup_member: Member setup + show: Show + site: + description: Site description + description_help: '' + footer: Site footer + footer_help: '' + info: Site information + keywords: Site keywords + keywords_help: '' + language: Site language + search: Site Search + search_help: Please Enter the search argument for Google search. + settings: Site setting + sub_menu: Site sub-menu + title: Site title + title_help: '' + site_: Site site_info: Site Info - site_name: Site Name sitemap: Sitemap + site_name: Site Name + start: Start + start_date: Start date statistics: Statistics + status: Status + structure: Structure + sub_manager: SubManager + subtitle: Subtitle + submit: Submit + submit_approval: Submit approval + submit_user_list: Submit user list + sure?: "Are you sure?" + sys: + can_not_display_due_to_no_context: "Can not display due to no context for English" + limit_of_upload_file_size: "Upload file must be less than: %{best_size}" + module_page_lang_not_support: "We are sorry, this page is not available for English" + not_previewable: "Preview not support" + preview_only_for_img: "Preview only supprt with file type: jpg, png, gif, bmp" + system_info: System information + tag_cloud: Tag cloud + tags: Tags + template: Template + template_name: Template name + text: Text + theme: Theme + themes: Themes title: Title + top: Top total_visitors: Total Visitors traffic: Traffic - - visitors_today: Today's visitors - visitors_this_week: This week's visitors + type: Type + unit_name: Unit name + up_to_date: Up-to-date + update: + error: + link: Error when updating link. + fail: Update failed + success: + content: Content was successfully updated. + link: Link was successfully updated. + page: Page was successfully updated. + user: User was successfully updated. + success_: Successfully updated + update_: Update + update_at: Update at + url: URL + use_status: '' + user: User + version: Version + vertical: Vertical + view: View + view_count: View count visitors_this_month: This month's visitors + visitors_this_week: This week's visitors visitors_this_year: This year's visitors + visitors_today: Today's visitors + yes_: "Yes" +# : <<<<<<< HEAD + nccu: + date: Date + file: File + file_description: Description + file_name: Name + link_name: Name + picture: Picture + selected_file: File +# : ======= errors: at_least_one: must at least have one value @@ -133,7 +415,7 @@ en: attributes: Attributes author: Author calendar: Calendar - gprs: GPRS + gprs: GPS cant_delete_self: You can not delete yourself. cant_revoke_self_admin: You can not revoke your admin role yourself. category: Category @@ -256,22 +538,11 @@ en: site_title: Site title super_pages: Super pages structure: Structure +# : >>>>>>> various_bugs tags: Tags - title: Title - translation: Translation - type: Type - up_to_date: Up-to-date - update_error_link: Error when updating link. - update_error_page: Error when updating page. - update_success_content: Content was successfully updated. - update_success_home: Homepage was successfully updated. - update_success_layout: Layout was successfully updated. - update_success_link: Link was successfully updated. - update_success_page: Page was successfully updated. - update_success_snippet: Snippet was successfully updated. - update_success_user: User was successfully updated. - upload_design: Upload design url: URL +# : <<<<<<< HEAD +# : ======= user: User user_new_interface: sys_basic_form: User system info @@ -322,3 +593,4 @@ en: result_get: "Searched about ' %{search_word} ' Found %{item_num} items" too_many: "Search about ' %{search_word} 'resulted more than %{exceed_num} items maybe try to search with more specific terms?" unit_get: "Listed items created by :%{unit_name} Found %{item_num} items" +# : >>>>>>> various_bugs diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 3fa4029f..efa69994 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -1,90 +1,379 @@ zh_tw: - - _locale: 中文 - - me: 我 - account_settings: 帳號設定 - add: 新增 - back: 回上一步 - browse: 選擇檔案 - cancel: 取消 - cant_empty_star: 不能為空 (*) - create: 新增 - create_fail: 創建失敗 - delete: 刪除 - desktop: 桌面 - disable: 禁用 - dots: … - downloaded: 已下載 - download: 下載 - edit: 編輯 - email: 電子郵件 - enable: 啟用 - forgot_password: 忘記密碼? - help: 協助 - hide: 隱藏 - homepage: 首頁 - langs: - zh_tw: 中文 - en: 英文 - login: 登入 - logout: 登出 - nccu: 政大 - nccu_c: - nccu_ldap_uid: iNCCU帳號 - no_: "No" - nothing: 無 - off_upcase: "OFF" - on_upcase: "ON" - or_lower: 或 - password: 密碼 - register: 註冊 - remember_me: 記住我 - search_google: 搜尋Google - show: 顯示 - submit: 送出 - sure?: 您肯定嗎? - update: 更新 - update_failed: 更新失敗 - view: 檢視 - view_count: 查看次數 - yes_: "Yes" + _locale: 中文 + + access: + denied: + app: + not_sub_manager: 拒絕存取,因你不是此應用程式次管理員 + not_manager: 拒絕存取,因你不是此應用程式管理員 + not_authed_user: 拒絕存取,因你不是此應用程式授權使用者 + object: 拒絕存取,因你沒有權限 + not_admin: 拒絕存取,因你不是此應用程式管理員 + account_settings: 帳號設定 + action: 操作 + ad: + ab_fx: 轉場效果 + banner_best_size: 輪播圖片尺寸 + best_size: 最佳尺寸 + new_image: 新增輪播圖片 + not_showing: 沒有顯示 + picture_list: 圖片列表 + sec_place_holder: 每張輪播圖片顯示秒數(3秒就請輸入3) + showing: 顯示中 + success_destroy_ad_image: 刪除圖片成功 + trans_unit_sec: 秒 + transition_sec: 轉場單位時間 + update_banner: 更新輪播 + widget_info_for_ad_image_size: "此區塊圖片尺寸使用: %{best_size}" + ad_banner: 廣告輪播 + add: 新增 + add_item: 新增項目 addthis_tools: add_to_bookmark: 加入書籤 - all_content: 全部內容有 - all_file: 全部檔案有 - all_member: 成員總數 + admin: 管理員 + all_content: 所有內容 + all_file: 所有檔案 + all_member: 所有會員 + always_display_title: 永遠顯示標題 + app_auth: + list_setting_result: 授權列表 + assigning_manager: + add_manager_fail: 新增管理員失敗 + add_manager_ok: 新增管理員成功 + assigning_sub_manager: + add_sub_manager_fail: 新增次管理員失敗 + add_sub_manager_ok: 新增次管理員成功 + can_not_add_this_user: 不能新增這個使用員 + delete_manager: + fail: 刪除管理員失敗 + success: 刪除管理員成功 + delete_sub_manager: + fail: 刪除次管理員失敗 + success: 刪除次管理員成功 + failed_no_user: 失敗,不是使用者 + approval: + not_pass: 拒絕 + not_pass_reason: 拒絕原因 + pass: 已認可 + setting: 審核設定 + stat: 審核狀態 + user_list: 使用者列表 + approval_: 審核 + asset: 資產 + auth: + add_manager: 新增管理員 + add_sub_manager: 新增次管理員 + add_to_block_list: 增加到封鎖名單 + add_to_privilege_list: 增加到特許名單 + all_member: 所有會員 + auth_by: -由%{user_display_name}授權 + by_role: 用戶狀態 + by_sub_role: 次用戶狀態 + author: 作者 + back: 回上一步 + basic: 基本 + browse: 瀏覽 + cancel: 取消 + cant_delete_self: 不可以刪除自己 + cant_empty_star: 不能為空白 (*) + cant_revoke_self_admin: 不可以撤銷自己的管理狀態 + categories: 類別 + category: 類別 + category_auth: 類別授權 + clear: 清除 content: 內容 - data: 數據 - file: 檔案 + create: + error: + link: 建立連結時出錯 + page: 建立頁面時出錯 + fail: 建立失敗 + success: + asset_category: 資產類別已成功建立 + link: 連結已成功建立 + page: 頁面已成功建立 + user: 使用者已成功建立 + create_: 建立 + data: 資料 + dashboard: + bulletin: 公告 + news_bulletin: 新聞 + page_context: 頁面內容 + web_link: 連結 + dashboard_: 儀表版 + deadline: 最後期限 + default_css: 預設樣式表 + delete: 刪除 + delete_file: 刪除檔案 + description: 描述 + desktop: 桌面 + disable: 關閉 + dots: ●●●●●● + download: 下載 + downloaded: 已下載 + edit: 編輯 + editing: + asset: 編輯資產 + design: 編輯設計 + link: 編輯連結 + page: 編輯頁面 + email: 電子郵件 + enable: 開啟 + enabled_for: 啟用 + end: 結束 + end_date: 結束日期 + errors: + at_least_one: 至少擁有一個值 + file: + size: 檔案大小 + type: 檔案類型 + upload: 上傳檔案 + file_: 檔案 file_type: 檔案類型 - hits: 點擊率 + forgot_password: 忘記密碼? + frequency: 頻率 + help: 幫助 + hidden: 隱藏的 + hide: 隱藏 + hits: 點擊次數 + homepage: 首頁 + horizontal: 水平的 + hot: 熱門 + image: 圖片 + info: 信息 + intro: 簡介 + is_published: 已發佈 item: 項目 + key: 索引 + last_modified: 最後修改者 + layout: 範本 + link: 連結 + list: + ad_banner: 廣告輪播列表 + asset: 資產列表 + info: 使用者資訊列表 + link: 連結列表 + purchase: 已購買項目列表 + role: 使用者角色列表 + user: 使用者列表 + list_: 列表 + list_lower: 列表 + lists: + markups: + text_field: 文字輸入框 + select: 下拉選單 + date: 日期 + text_area: 文字輸入方塊 + radio_button: 單選 + checkbox: 多選 + login: 登入 + logout: 登出 + mail: + address: 電子郵件地址 + authentication: 電子郵件認證 + domain: 電子郵件網域名稱 + enable_starttls_auto: 啟用安全通訊 + password: 密碼 + port: 電子郵件傳輸埠 + setting: 電子郵件設定 + tls: 電子郵件TLS + user_name: 電子郵件帳號 + manager: 管理者 + manager: 管理者 + me: 我 member: 會員 + menu_enabled_for: 選單啟用 + modal: + close: 關閉 + preview: 預覽 module: 模組 - most_visited_page: 熱門頁面 + module_authorization: 模組授權 + more_plus: 更多+ + most_visited_page: 最多瀏覽頁面 + multilingual: 多語系 + name: 名稱 + nccu_c: + nccu_ldap_uid: 政治大學LDAP帳號 + new: + asset: 新增資產 + banner: 新增橫幅 + design: 新增設計 + link: 新增連結 + page: 新增頁面 + user: 新增使用者 + info: 新增使用者資訊 + role: 新增使用者角色 + news: 新聞 + no_: "不是" + no_deadline: 沒有期限 + object_auth: + a_object_must_have_only_one_object_auth_profile_for_each_action: '' + list_title_of_users: 授權列表 + new_object_auth: 新增授權 + off_upcase: "開啟" + on_upcase: "關閉" + options: 選項 + or_lower: 或 + organization: 組織 + page: 頁面 + page_part_kinds: + module_widget: 外掛模塊 + public_r_tag: 系統模塊 + text: 文字區域 + passed: 通過審核 + password: 密碼 + pending: 待審核 + picture: 圖片 + postdate: 張貼日期 + posted_by: 張貼人 + preview: 預覽 + purchase: 購買 quantity: 數量 + quick_edit: 快速編輯 recent_update: 近期更新 - referral_in_links: 外部推薦連結 + referral_in_links: 參考連結 + register: 註冊 + registered: 已註冊 + rejected: 拒絕 + rejected_reason: '拒絕原因:' + rejected_reason_empty: "拒絕核准, 沒有參考資訊" + related_links: 相關連結 + remember_me: 記住我 role: 角色 + Roles: 角色 + ruling_site: 銳綸網站 + search: + domains: Google Search Domains + not_found: "沒有搜尋結果" + result_get: "搜尋標題有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料" + sitesearch: 全站搜尋 + too_many: "搜尋有關 ' %{search_word} '尋找到超過 %{exceed_num} 筆資料,請嘗試加入更多關鍵字縮小搜尋範圍,以作更精確的搜尋?" + unit_get: "列出由 :%{unit_name}發佈的資料,共有%{item_num}筆" + search_google: 搜尋Google + search_nccu: 搜尋政治大學 + setup_member: 會員設定 + show: 顯示 + site: + default_image: 預設圖像 + description: 網站描述 + description_help: '' + footer: 網站頁尾 + footer_help: '' + info: 網站資訊 + keywords: 搜尋關鍵字 + keywords_help: '' + language: 網站語言 + search: 網站搜尋 + search_help: 請輸入送交Google搜尋的參數 + settings: 基本設定 + sub_menu: 次選單 + title: 網站標題 + title_help: '' + site_: 網站 site_info: 網站資訊 - site_name: 網站名稱 sitemap: 網站地圖 - statistics: 統計 + site_name: 網站名稱 + start: 開始 + start_date: 開始日期 + statistics: 統計資訊 + status: 狀態 + structure: 結構 + sub_manager: 次管理員 + subtitle: 副標題 + submit: 送出 + submit_approval: 送出已核准 + submit_user_list: 送出使用者列表 + sure?: "您確定嗎?" + sys: + can_not_display_due_to_no_context: "因為沒有中文版本,所以無法顯示" + limit_of_upload_file_size: "上傳檔案大小限制: %{best_size}" + module_page_lang_not_support: "很抱歉,此頁面沒有開放中文版本" + not_previewable: "不支援預覽" + preview_only_for_img: "預覽僅支援:jpg,png,gif,bmp等圖片格式" + system_info: 系統資訊 + tag_cloud: 標籤雲 + tags: 標籤 + template: 樣版 + template_name: 樣版名稱 + text: 內文 + theme: 主題 + themes: 主題 title: 標題 - total_visitors: 造訪次數 + top: 置頂 + total_visitors: 總計造訪人次 traffic: 流量 + type: 類型 + unit_name: 單位名稱 + up_to_date: 最新版本 + update: + error: + link: 更新連接時出錯 + fail: 更新消息 + success: + content: 內容已更新成功 + link: 連結已更新成功 + page: 頁面已更新成功 + user: 使用者已更新成功 + success_: 更新成功 + update_: 更新 + update_at: 最後更新時間 + url: 網址 + use_status: '' + user: 使用者 + version: 版本 + vertical: 垂直的 + view: 檢視 + view_count: 查看次數 + visitors_this_month: 本月造訪人次 + visitors_this_week: 本星期造訪人次 + visitors_this_year: 今年造訪人次 + visitors_today: 今日造訪人次 + yes_: "是" - visitors_today: 今日造訪 - visitors_this_week: 本星期造訪 - visitors_this_month: 本月造訪 - visitors_this_year: 今年造訪 + nccu: + date: 起迄日期 + file: 附加檔案 + file_description: 檔案描述 + file_name: 檔案名稱 + link_name: 連結名稱 + picture: 刊頭圖片 + selected_file: 選擇檔案 + tags: 頁籤 + url: 連結位置 + + + + + +# : <<<<<<< HEAD +# : ======= errors: at_least_one: 必須至少有一個值 - admin: + infos: + add_attribute_field: 新增 + save: 儲存 + initial: 起始值 + markup: 輸入模式 + item_name: 資料表名稱 + name: 名稱 + options: 選項 + multilingual: 多語言輸入 + add_more: 使用者可自行延伸欄位 + add: 新增 + placeholder: 輸入協助 + type: 類型 + placeholder: 提示內容 + list: 自定選單 + is_range: 是 + not_range: 否 + date: + claendar: 紀年法 + range: 本欄為時間區段 + format: 格式 + tw_claendar: 民國 + west_claendar: 西元 access: denied: app: @@ -344,6 +633,7 @@ zh_tw: +# : >>>>>>> various_bugs # Chinese (Taiwan) translations for Ruby on Rails # by tsechingho (http://github.com/tsechingho) date: @@ -558,6 +848,24 @@ zh_tw: other: "有 %{count} 個錯誤發生使得「%{model}」無法被儲存。" body: "以下欄位發生問題:" +# : <<<<<<< HEAD + mongoid: + models: + news_bulletin: 新聞 + bulletin: 公告 + ad_banner: 廣告輪播 + web_link: 連結管理 + attributes: + news_bulletin: + title: 新聞標題 + bulletin: + title: 公告標題 + ad_banner: + title: 標題 + web_link: + title: 名稱 + url: 路徑 +# : ======= helpers: select: prompt: "請選擇" @@ -577,4 +885,5 @@ zh_tw: module_page_lang_not_support: "很抱歉,本頁沒有開放中文版本" object_disable: change_to_true: "設為停用" - change_to_false: "重新啓用" \ No newline at end of file + change_to_false: "重新啓用" +# : >>>>>>> various_bugs diff --git a/config/mongoid.yml b/config/mongoid.yml index b5ff2426..a809bc06 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -2,7 +2,7 @@ defaults: &defaults host: localhost # slaves: # - host: slave1.local - # port: 27018 + port: 27017 # - host: slave2.local # port: 27019 diff --git a/config/resque.god b/config/resque.god index 7622576c..afd706c0 100644 --- a/config/resque.god +++ b/config/resque.god @@ -1,5 +1,5 @@ #developer pls change here -rails_root = "/home/nccu/NCCU/" #keep this blank when development +rails_root = "/home/nccu/stage/NCCU" #keep this blank when development development_uid = 'kaito' #when dev development_gid = 'staff' #when dev @@ -16,7 +16,7 @@ num_workers.times do |num| w.dir = rails_root w.name = "resque-#{num}" - w.group = 'resque' + w.group = 'resque-stage' w.interval = 30.seconds w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env} @@ -25,7 +25,7 @@ num_workers.times do |num| w.uid = (rails_env == 'production' )? "root" : development_uid w.gid = (rails_env == 'production' )? "root" : development_gid - w.log = (rails_env == 'production' )? "/var/log/#{w.name}.log":"#{rails_root}/log/#{w.name}.log" + w.log = (rails_env == 'production' )? "/var/log/#{w.name}-stage.log":"#{rails_root}/log/#{w.name}.log" # restart if memory gets too high w.transition(:up, :restart) do |on| diff --git a/config/routes.rb b/config/routes.rb index 525d6808..27b87d90 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ Orbit::Application.routes.draw do - devise_for :users,:controllers => {:sessions => 'sessions'} + devise_for :users mount Resque::Server, :at => "/admin/resque" # routes for sinatra app @@ -58,6 +58,8 @@ Orbit::Application.routes.draw do end member do post 'edit_file' => 'designs#edit_file' + post 'update_file' => 'designs#update_file' + post 'upload_image' => 'designs#upload_image' end end resources :infos do @@ -124,9 +126,7 @@ Orbit::Application.routes.draw do get 'system_info' get 'ui_theme' end - resources :snippets resources :tags - resources :translations resources :users resources :users_new_interface do member do @@ -141,7 +141,17 @@ Orbit::Application.routes.draw do resources :users end - match '/desktop/'=>'desktop#index' + resources :desktop_widgets do + collection do + get 'upload' + get 'delete' + post 'upload' + end + end + +namespace :desktop do + + match "/"=>"desktop#index" # Sinatra Routes start @@ -176,46 +186,50 @@ Orbit::Application.routes.draw do # Sinatra Routes end - match '/desktop/desktop'=>'desktop#desktop' - match '/desktop/app_manager'=>'desktop#app_manager' - match '/desktop/sections'=>'desktop#sections' - match '/desktop/settings'=>'desktop#settings' - match '/desktop/get_desktop_settings/'=>'desktop#get_desktop_settings' - match '/desktop/save_desktop_settings/'=>'desktop#save_desktop_settings' - match '/desktop/getgroups/'=>'desktop#getgroups' - match '/desktop/getsectionlist/'=>'desktop#getsectionlist' - match '/desktop/settingthemes/'=>'desktop#settingthemes' - match '/desktop/settingsections/'=>'desktop#settingsections' - match '/desktop/getapplist/'=>'desktop#getapplist' - match '/desktop/newpositions/'=>'desktop#newpositions' - match '/desktop/settingconnection/'=>'desktop#settingconnection' + match '/desktop'=>'desktop#desktop' + match '/app_manager'=>'desktop#app_manager' + match '/sections'=>'desktop#sections' + match '/settings'=>'desktop#settings' + match '/get_desktop_settings/'=>'desktop#get_desktop_settings' + match '/save_desktop_settings/'=>'desktop#save_desktop_settings' + match '/getgroups/'=>'desktop#getgroups' + match '/getsectionlist/'=>'desktop#getsectionlist' + match '/settingthemes/'=>'desktop#settingthemes' + match '/settingsections/'=>'desktop#settingsections' + match '/getapplist/'=>'desktop#getapplist' + match '/newpositions/'=>'desktop#newpositions' + match '/settingconnection/'=>'desktop#settingconnection' + match '/widget_layout' => 'desktop#widget_layout' - match '/desktop/journal_p/'=>'desktop_publications#journal_p' - match '/desktop/journal_p_list/'=>'desktop_publications#journal_p_list' - match '/desktop/journal_p_add/'=>'desktop_publications#journal_p_add' - match '/desktop_publications/getjournals' => 'desktop_publications#getjournals' - match '/desktop/books' => 'desktop_publications#books' - match '/desktop/books_list/'=>'desktop_publications#books_list' - match '/desktop/books_add/'=>'desktop_publications#books_add' + match '/journal_p/'=>'desktop_publications#journal_p' + match '/journal_p_list/'=>'desktop_publications#journal_p_list' + match '/journal_p_add/'=>'desktop_publications#journal_p_add' + match '/books' => 'desktop_publications#books' + match '/books_list/'=>'desktop_publications#books_list' + match '/books_add/'=>'desktop_publications#books_add' - match '/desktop/seminar_p' => 'desktop_publications#seminar_p' - match '/desktop/seminar_p_list/'=>'desktop_publications#seminar_p_list' - match '/desktop/seminar_p_add/'=>'desktop_publications#seminar_p_add' + match '/seminar_p' => 'desktop_publications#seminar_p' + match '/seminar_p_list/'=>'desktop_publications#seminar_p_list' + match '/seminar_p_add/'=>'desktop_publications#seminar_p_add' - match '/desktop/research_d' => 'desktop_research#research_d' - match '/desktop/research_d_list/' => 'desktop_research#research_d_list' - match '/desktop/research_d_add' => 'desktop_research#research_d_add' + match '/research_d' => 'desktop_research#research_d' + match '/research_d_list/' => 'desktop_research#research_d_list' + match '/research_d_add' => 'desktop_research#research_d_add' - match '/desktop/research_p' => 'desktop_research#research_p' - match '/desktop/research_p_list/' => 'desktop_research#research_p_list' - match '/desktop/research_p_add' => 'desktop_research#research_p_add' + match '/research_p' => 'desktop_research#research_p' + match '/research_p_list/' => 'desktop_research#research_p_list' + match '/research_p_add' => 'desktop_research#research_p_add' - match '/desktop/twitter/'=>'otheraccounts#twitter' - match '/desktop/forgmail/'=>'otheraccounts#gmail' - match '/desktop/getaccounts'=>'otheraccounts#getaccounts' - match '/desktop/save_account_info/'=>'otheraccounts#saveaccountinfo' + + match '/temp_func/'=>'desktop#temp_func' +end + + match '/twitter/'=>'otheraccounts#twitter' + match '/forgmail/'=>'otheraccounts#gmail' + match '/getaccounts'=>'otheraccounts#getaccounts' + match '/save_account_info/'=>'otheraccounts#saveaccountinfo' match '/desktop_appstore/appstore'=>'desktop_appstore#appstore' match '/desktop_appstore/widgets'=>'desktop_appstore#widgets' @@ -226,13 +240,14 @@ Orbit::Application.routes.draw do match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload' match '/desktop_orbit/gettimelinespan' => 'desktop_orbit#gettimelinespan' + match '/desktop_publications/getjournals' => 'desktop_publications#getjournals' #match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal' #match '/desktop_orbit/eventajaxload' => 'desktop_publications#delete_journal' # match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal' - match '/desktop/temp_func/'=>'desktop#temp_func' + match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request| !request.query_string.include?("inner=true") diff --git a/config/sunspot.yml b/config/sunspot.yml index 7bbd32c0..e8323e42 100644 --- a/config/sunspot.yml +++ b/config/sunspot.yml @@ -1,7 +1,7 @@ production: solr: hostname: localhost - port: 8983 + port: 8982 log_level: WARNING development: @@ -14,4 +14,4 @@ test: solr: hostname: localhost port: 8981 - log_level: WARNING \ No newline at end of file + log_level: WARNING diff --git a/lib/orbit_core_lib.rb b/lib/orbit_core_lib.rb index d318b28c..3abeeddd 100644 --- a/lib/orbit_core_lib.rb +++ b/lib/orbit_core_lib.rb @@ -1,4 +1,17 @@ module OrbitCoreLib + module Preview + def self.included(base) + + # base.instance_eval("field :is_preview,type: Boolean,:default => false") + # base.instance_eval("scope :not_preview,where(:is_preview=>false)") + base.class_eval (" + def to_preview + raise 'Developer,please override to_preview method' + end + ") + end + end + module BelongsToCategoryMayDisable def self.included(base) base.instance_eval("belongs_to :#{base::BelongsToCategory.to_s}") @@ -79,7 +92,7 @@ module OrbitCoreLib authed_users(title).include?(User.current) end - def app_auth + def module_app ModuleApp.first(conditions: {:title => self.class::APP_NAME} ) end diff --git a/lib/parsers/parser_layout.rb b/lib/parsers/parser_layout.rb index 3379c487..817bf327 100644 --- a/lib/parsers/parser_layout.rb +++ b/lib/parsers/parser_layout.rb @@ -22,7 +22,7 @@ module ParserLayout body.css('.page_image').each do |page_image| image = design.images.where( file: File.basename(page_image['src']))[0] - image.update_attributes(:name => File.basename(page_image['src']), :html_id => page_image['id'], :html_class => page_image['class']) if image + image.update_attributes(:html_id => page_image['id'], :html_class => page_image['class'], :in_html => true) if image end end diff --git a/lib/parsers/parser_layout_widget.rb b/lib/parsers/parser_layout_widget.rb new file mode 100644 index 00000000..382657d8 --- /dev/null +++ b/lib/parsers/parser_layout_widget.rb @@ -0,0 +1,22 @@ +module ParserLayoutWidget + require 'nokogiri' + + def parse_widget_for_images(widget) + content = widget.widget_layout.file.read.force_encoding("UTF-8") + widge = Nokogiri::HTML(content) + a = [] + b = [] + widge.css('.widget_image').each do |page_image| + image = widget.images.where( file: File.basename(page_image['src']))[0] + a << page_image['src'] + b << image.file + image.update_attributes(:html_id => page_image['id'], :html_class => page_image['class'], :in_html => true) if image + end + a.each_with_index do |img,i| + content = content.gsub(img,b[i].to_s) + end + widget.widget_layout.update_attributes(:body => content) + end + + +end diff --git a/lib/tasks/build_new_member.rake b/lib/tasks/build_new_member.rake index 4e4a6bcc..5810f4fe 100644 --- a/lib/tasks/build_new_member.rake +++ b/lib/tasks/build_new_member.rake @@ -268,4 +268,66 @@ namespace :build_new_member do # p "==Finished building status for Students" # end + task :build_sub_role_for_staff_1023 => :environment do + role = Role.first(conditions: {key: 'staff'}) + staff_sub_roles ={ + :secretary => {"en"=>"Secretary", "zh_tw"=>"秘書"}, + :assistant => {"en"=>"Assistant", "zh_tw"=>"行政助理"}, + :research_assistant => {"en"=>"Research Assistant", "zh_tw"=>"研究助理"}, + :ta => {"en"=>"TA", "zh_tw"=>"助教"}, + :technical_specialist => {"en"=>"Technical Specialist", "zh_tw"=>"技士"} + } + staff_sub_roles.each do |key,item| + role.sub_roles.build(:key=>key,:title_translations=> item) + end + role.save + end + + task :build_staff_attribute_field_1023 => :environment do + sub_role_attribute_fields_template = [ + {key: 'status', markup: "select", locale: true, list_options: nil, built_in: true, disabled: false, locale_title_translations: {"zh_tw"=>"狀態", "en"=>"Status"}, neutral_title: nil }, + {key: 'responsibilities', markup: "text_field", locale: true, list_options: nil, built_in: true, disabled: false, locale_title_translations: {"zh_tw"=>"負責業務", "en"=>"Responsibilities"}, neutral_title: nil } + ] + role = Role.first({conditions:{key: 'staff'}}) + role.sub_roles.each{|sb| + sb.attribute_fields.destroy_all + sub_role_attribute_fields_template.each{|att_f| + sb.attribute_fields.build att_f + } + sb.save + } + role.save + end + + task :build_status_1023 => :environment do + student_status ={ + :studying => {"en"=>"Studying", "zh_tw"=>"在學"}, + :drop_out => {"en"=>"Drop-out", "zh_tw"=>"休學"}, + :alumi => {"en"=>"Alumi", "zh_tw"=>"校友"}, + :suspended => {"en"=>"Suspended", "zh_tw"=>"未完成"} + } + + role = Role.first(conditions: {key: 'student'}) + student_status.each do |key,item| + role.statuses.build(:key=>key.to_s,:title_translations=>item) + end + role.save + + teacher_status ={ + :fulltime => {"en"=>"Full Time", "zh_tw"=>"全職"}, + :adjunct => {"en"=>"Adjunct", "zh_tw"=>"兼職"}, + :co_hiring => {"en"=>"Co Hiring", "zh_tw"=>"合聘"}, + :distinguished => {"en"=>"Distinguished", "zh_tw"=>"特聘"} + } + role = Role.first(conditions: {key: 'teacher'}) + teacher_status.each do |key,item| + role.statuses.build(:key=>key.to_s,:title_translations=>item) + end + role.save + + end + + task :clean_up_attribute_value_for_deleted_fields => :environment do + AttributeValue.all.reject{|t| !AttributeField.find(t.attribute_field_id).nil? rescue false }.each{|t| t.delete} + end end diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 70776ed9..60a7ec93 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -71,7 +71,7 @@ namespace :dev do design = Design.new(:title => "Fraisier", :author => "Paul", :intro => "Strawberry cake") - design.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) + design.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) # image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif")) # @@ -89,7 +89,7 @@ namespace :dev do design_1 = Design.new(:title => "Bob", :author => "Me", :intro => "Moran") - design_1.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) + design_1.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) # image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif")) # diff --git a/lib/tasks/index.rake b/lib/tasks/index.rake new file mode 100644 index 00000000..c6058ae8 --- /dev/null +++ b/lib/tasks/index.rake @@ -0,0 +1,11 @@ +# encoding: utf-8 + +namespace :index do + task :rebuild => :environment do + Sunspot.remove_all! + Sunspot.commit + Sunspot.index NewsBulletin.all + Sunspot.index Bulletin.all + Sunspot.commit + end +end \ No newline at end of file diff --git a/lib/tasks/mid_site_sync.rake b/lib/tasks/mid_site_sync.rake index e009f861..e3ee411b 100644 --- a/lib/tasks/mid_site_sync.rake +++ b/lib/tasks/mid_site_sync.rake @@ -9,7 +9,7 @@ namespace :mid_site do admin_role = nil sub_role = nil test_account_ldap_id ='139716' - #MiddleSiteConnection.establish + MiddleSiteConnection.establish task :sync => :environment do info_profile = Info.first(conditions: {:key => 'profile'}) @@ -77,7 +77,6 @@ namespace :mid_site do local_user.save! end sys_users = User.all(conditions: {admin: false}).includes(:avatar).to_a - Rails.cache.write('user_setting', sys_users) end diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index 8b92ea9e..74f8df8c 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -355,5 +355,17 @@ namespace :migrate do p 'End Site' end + + + task :news_p => :environment do + news_bulletins = NewsBulletin.admin_manager_all rescue nil + i = 1 + news_bulletins.each do |news| + p "#{i}/#{news_bulletins.size} - #{news.id}" + news.subtitle_translations = {'en' => (news.subtitle_translations['en'].gsub(/^\/, '').gsub(/\<\/p\>$/, '') rescue ''), 'zh_tw' => (news.subtitle_translations['zh_tw'].gsub(/^\/, '').gsub(/\<\/p\>$/, '') rescue nil)} + p news.save(:validate => false) if news.changed? + i += 1 + end if news_bulletins + end end diff --git a/lib/tasks/nccu.rake b/lib/tasks/nccu.rake new file mode 100644 index 00000000..b3d5abf0 --- /dev/null +++ b/lib/tasks/nccu.rake @@ -0,0 +1,103 @@ +namespace :nccu do + task :copy_news_object_auth_to_all_of_news_cate => :environment do + # users = user_data.collect do |login_uid| + # nccu_id = get_nccu_id_from_mid_site(login_uid) + # resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_ldap_uid: nccu_id })) + # end + + + nbc = NewsBulletinCategory.first({conditions: "administration"}) + users_ary = Array.new(ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: nbc.id}}).privilege_user_ids) + to_nbcs = NewsBulletinCategory.where(:key.ne=> 'administration') + to_nbcs.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_user_ids = users_ary + oa.save + end + end + + task :apply_180_news_cate_auth_to_171 => :environment do + ldap_id_data = [3603,100212, 8151, 3471, 145232, 133380, 133222, 127983, 127977, 127692, 123617, 123566, 58483, 48234, 29237, 9253, 8948, 8703, 8251, 7336, 7242, 7220, 6912, 6603, 6459, 5475, 3643, 3641, 3559, 3310, 3248, 2672, 2531, 1633, 1521, 1516, 145571, 20610, 123604, 100211, 39571, 29479, 8013, 6968, 5868, 5724, 5401, 4369, 3573, 3377, 2918, 2822, 2309, 2134, 1731, 1527] + users_ary = Array.new(User.where(:nccu_ldap_uid.in => ldap_id_data )) + NewsBulletinCategory.all.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_users = users_ary + oa.save + end + end + + task :remove_3603 => :environment do + user_email = 'tu65@nccu.edu.tw' + user = User.first({conditions:{email: user_email}}) + NewsBulletinCategory.all.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_users.delete_if{|t| t == user} + oa.save + end + + key = 'Announcement' + bc = BulletinCategory.first({conditions:{key: key}}) + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "BulletinCategory",obj_authable_id: bc.id}}) + oa.privilege_users.delete_if{|t| t == user} + oa.save + end + + task :add_nccu_account_1008 => :environment do + a = ['yjlin3@nccu.edu.tw','liwen@nccu.edu.tw','yhc@nccu.edu.tw','kenliu@nccu.edu.tw','cfc@nccu.edu.tw','jasper@nccu.edu.tw','donghe@nccu.edu.tw','frees712@nccu.edu.tw','jeanch@nccu.edu.tw','posty@nccu.edu.tw','yiting@nccu.edu.tw','frank997@nccu.edu.tw'] + users_ary = User.any_in(email: a) + NewsBulletinCategory.all.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_users = oa.privilege_users + users_ary + oa.save + end + + key = 'Announcement' + bc = BulletinCategory.first({conditions:{key: key}}) + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "BulletinCategory",obj_authable_id: bc.id}}) + oa.privilege_users = oa.privilege_users + users_ary + oa.save + + end + + task :add_nccu_account_1009 => :environment do + a = ["blannytg@nccu.edu.tw","yucca@nccu.edu.tw","fish14@nccu.edu.tw","amanda13@nccu.edu.tw"] + users_ary = User.any_in(email: a) + NewsBulletinCategory.all.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_users = oa.privilege_users + users_ary + oa.save + end + + a=["annieayu@nccu.edu.tw","blannytg@nccu.edu.tw","yucca@nccu.edu.tw","amanda13@nccu.edu.tw"] + users_ary = User.any_in(email: a) + key = 'Announcement' + bc = BulletinCategory.first({conditions:{key: key}}) + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "BulletinCategory",obj_authable_id: bc.id}}) + oa.privilege_users = oa.privilege_users + users_ary + oa.save + + end + + task :add_nccu_account_1016 => :environment do + a = ["waynedd@nccu.edu.tw","sfchang@nccu.edu.tw","kyokolin@nccu.edu.tw","sfaylin@nccu.edu.tw","jinyulin@nccu.edu.tw"] + users_ary = User.any_in(email: a) + NewsBulletinCategory.all.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_users = oa.privilege_users + users_ary + oa.save + end + + users_ary = User.any_in(email: a) + key = 'Announcement' + bc = BulletinCategory.first({conditions:{key: key}}) + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "BulletinCategory",obj_authable_id: bc.id}}) + oa.privilege_users = oa.privilege_users + users_ary + oa.save + + end + + + task :consolidate_object_auth => :environment do + ObjectAuth.all.each{|t| t.save} + end +end \ No newline at end of file diff --git a/lib/tasks/pages.rake b/lib/tasks/pages.rake index 8a43f420..598d4b53 100644 --- a/lib/tasks/pages.rake +++ b/lib/tasks/pages.rake @@ -13,7 +13,7 @@ namespace :pages do design = Design.new(:title => "Fraisier", :author => "Paul", :intro => "Strawberry cake") - design.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) + design.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) # image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif")) # @@ -37,7 +37,7 @@ namespace :pages do design_1 = Design.new(:title => "Bob", :author => "Me", :intro => "Moran") - design_1.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) + design_1.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) # image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif")) # diff --git a/log/sunspot-solr-development.log.1 b/log/sunspot-solr-development.log.1 index 049dd80c..76fd38c6 100644 --- a/log/sunspot-solr-development.log.1 +++ b/log/sunspot-solr-development.log.1 @@ -1,222 +1,222 @@ -Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: JNDI not configured for solr (NoInitialContextEx) -Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader locateSolrHome -INFO: using system property solr.solr.home: /Users/kaito/Documents/MyWorkspeace/NCCU/solr -Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader -INFO: Solr home set to '/Users/kaito/Documents/MyWorkspeace/NCCU/solr/' -Jun 18, 2012 4:30:20 PM org.apache.solr.servlet.SolrDispatchFilter init +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: using system property solr.solr.home: /home/nccu/stage/NCCU/solr +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrResourceLoader +INFO: Solr home set to '/home/nccu/stage/NCCU/solr/' +Sep 24, 2012 10:20:33 AM org.apache.solr.servlet.SolrDispatchFilter init INFO: SolrDispatchFilter.init() -Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: JNDI not configured for solr (NoInitialContextEx) -Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader locateSolrHome -INFO: using system property solr.solr.home: /Users/kaito/Documents/MyWorkspeace/NCCU/solr -Jun 18, 2012 4:30:20 PM org.apache.solr.core.CoreContainer$Initializer initialize -INFO: looking for solr.xml: /Users/kaito/Documents/MyWorkspeace/NCCU/solr/solr.xml -Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader -INFO: Solr home set to '/Users/kaito/Documents/MyWorkspeace/NCCU/solr/' -Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrConfig initLibs +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: using system property solr.solr.home: /home/nccu/stage/NCCU/solr +Sep 24, 2012 10:20:33 AM org.apache.solr.core.CoreContainer$Initializer initialize +INFO: looking for solr.xml: /home/nccu/stage/NCCU/solr/solr.xml +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrResourceLoader +INFO: Solr home set to '/home/nccu/stage/NCCU/solr/' +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrConfig initLibs INFO: Adding specified lib dirs to ClassLoader -Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrConfig INFO: Loaded SolrConfig: solrconfig.xml -Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrCore -INFO: Opening new SolrCore at /Users/kaito/Documents/MyWorkspeace/NCCU/solr/, dataDir=/Users/kaito/Documents/MyWorkspeace/NCCU/solr/data/development/ -Jun 18, 2012 4:30:20 PM org.apache.solr.schema.IndexSchema readSchema +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrCore +INFO: Opening new SolrCore at /home/nccu/stage/NCCU/solr/, dataDir=/home/nccu/stage/NCCU/solr/data/development/ +Sep 24, 2012 10:20:33 AM org.apache.solr.schema.IndexSchema readSchema INFO: Reading Solr Schema -Jun 18, 2012 4:30:21 PM org.apache.solr.schema.IndexSchema readSchema +Sep 24, 2012 10:20:33 AM org.apache.solr.schema.IndexSchema readSchema INFO: Schema name=sunspot -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created string: org.apache.solr.schema.StrField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created tdouble: org.apache.solr.schema.TrieDoubleField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created rand: org.apache.solr.schema.RandomSortField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load -INFO: created null: org.apache.solr.analysis.StandardTokenizerFactory -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created null: org.apache.solr.analysis.CJKTokenizerFactory +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created null: org.apache.solr.analysis.StandardFilterFactory -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created null: org.apache.solr.analysis.LowerCaseFilterFactory -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created text: org.apache.solr.schema.TextField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created boolean: org.apache.solr.schema.BoolField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created date: org.apache.solr.schema.DateField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created sdouble: org.apache.solr.schema.SortableDoubleField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created sfloat: org.apache.solr.schema.SortableFloatField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created sint: org.apache.solr.schema.SortableIntField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created slong: org.apache.solr.schema.SortableLongField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created tint: org.apache.solr.schema.TrieIntField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created tfloat: org.apache.solr.schema.TrieFloatField -Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +Sep 24, 2012 10:20:33 AM org.apache.solr.util.plugin.AbstractPluginLoader load INFO: created tdate: org.apache.solr.schema.TrieDateField -Jun 18, 2012 4:30:21 PM org.apache.solr.schema.IndexSchema readSchema +Sep 24, 2012 10:20:33 AM org.apache.solr.schema.IndexSchema readSchema INFO: default search field is text -Jun 18, 2012 4:30:21 PM org.apache.solr.schema.IndexSchema readSchema +Sep 24, 2012 10:20:33 AM org.apache.solr.schema.IndexSchema readSchema INFO: query parser default operator is AND -Jun 18, 2012 4:30:21 PM org.apache.solr.schema.IndexSchema readSchema +Sep 24, 2012 10:20:33 AM org.apache.solr.schema.IndexSchema readSchema INFO: unique key field: id -Jun 18, 2012 4:30:21 PM org.apache.solr.core.JmxMonitoredMap +Sep 24, 2012 10:20:33 AM org.apache.solr.core.JmxMonitoredMap INFO: No JMX servers found, not exposing Solr information with JMX. -Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrCore initListeners +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrCore initListeners INFO: Added SolrEventListener: org.apache.solr.core.QuerySenderListener{queries=[]} -Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrCore initListeners +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrCore initListeners INFO: Added SolrEventListener: org.apache.solr.core.QuerySenderListener{queries=[{q=solr rocks,start=0,rows=10}, {q=static firstSearcher warming query from solrconfig.xml}]} -Jun 18, 2012 4:30:21 PM org.apache.solr.request.XSLTResponseWriter init +Sep 24, 2012 10:20:33 AM org.apache.solr.request.XSLTResponseWriter init INFO: xsltCacheLifetimeSeconds=5 -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created standard: solr.SearchHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created dismax: solr.SearchHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created partitioned: solr.SearchHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /spell: solr.SearchHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created tvrh: org.apache.solr.handler.component.SearchHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: adding lazy requestHandler: org.apache.solr.handler.extraction.ExtractingRequestHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /update/extract: org.apache.solr.handler.extraction.ExtractingRequestHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /terms: org.apache.solr.handler.component.SearchHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: adding lazy requestHandler: solr.SearchHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /elevate: solr.SearchHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /update: solr.XmlUpdateRequestHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /update/javabin: solr.BinaryUpdateRequestHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /analysis/document: solr.DocumentAnalysisRequestHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /analysis/field: solr.FieldAnalysisRequestHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: adding lazy requestHandler: solr.CSVRequestHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /update/csv: solr.CSVRequestHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /admin/: org.apache.solr.handler.admin.AdminHandlers -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /admin/ping: PingRequestHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /debug/dump: solr.DumpRequestHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +Sep 24, 2012 10:20:33 AM org.apache.solr.core.RequestHandlers initHandlersFromConfig INFO: created /mlt: solr.MoreLikeThisHandler -Jun 18, 2012 4:30:21 PM org.apache.solr.search.SolrIndexSearcher -INFO: Opening Searcher@3b5b123b main -Jun 18, 2012 4:30:21 PM org.apache.solr.update.DirectUpdateHandler2$CommitTracker +Sep 24, 2012 10:20:33 AM org.apache.solr.search.SolrIndexSearcher +INFO: Opening Searcher@6a510e39 main +Sep 24, 2012 10:20:33 AM org.apache.solr.update.DirectUpdateHandler2$CommitTracker INFO: AutoCommit: disabled -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SpellCheckComponent inform +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SpellCheckComponent inform INFO: Initializing spell checkers -Jun 18, 2012 4:30:21 PM org.apache.solr.spelling.AbstractLuceneSpellChecker init +Sep 24, 2012 10:20:33 AM org.apache.solr.spelling.AbstractLuceneSpellChecker init INFO: Using WhitespaceAnalzyer for dictionary: default -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SpellCheckComponent inform +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SpellCheckComponent inform WARNING: No queryConverter defined, using default converter -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.QueryElevationComponent inform -INFO: Loading QueryElevation from: /Users/kaito/Documents/MyWorkspeace/NCCU/solr/conf/elevate.xml -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.QueryComponent@7dc21ece -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.FacetComponent@5374a6e2 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@f786a3c -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@2a869113 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.StatsComponent@689e8c34 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@106df95 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.QueryComponent@7dc21ece -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.FacetComponent@5374a6e2 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@f786a3c -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@2a869113 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.StatsComponent@689e8c34 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@106df95 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.QueryComponent@7dc21ece -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.FacetComponent@5374a6e2 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@f786a3c -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@2a869113 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.StatsComponent@689e8c34 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@106df95 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.QueryComponent@7dc21ece -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.FacetComponent@5374a6e2 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@f786a3c -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@2a869113 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.StatsComponent@689e8c34 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.SpellCheckComponent@6a40afb9 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@106df95 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.QueryComponent@7dc21ece -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.FacetComponent@5374a6e2 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@f786a3c -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@2a869113 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.StatsComponent@689e8c34 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.TermVectorComponent@3cd0d12e -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@106df95 -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform -INFO: Adding component:org.apache.solr.handler.component.TermsComponent@31554233 -Jun 18, 2012 4:30:21 PM org.apache.solr.core.QuerySenderListener newSearcher -INFO: QuerySenderListener sending requests to Searcher@3b5b123b main -Jun 18, 2012 4:30:21 PM org.apache.solr.core.CoreContainer register +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.QueryElevationComponent inform +INFO: Loading QueryElevation from: /home/nccu/stage/NCCU/solr/conf/elevate.xml +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.QueryComponent@3cc70b0d +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.FacetComponent@2fa6a1a7 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@64bef361 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@345c98f3 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.StatsComponent@2b3d9460 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@57d840cd +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.QueryComponent@3cc70b0d +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.FacetComponent@2fa6a1a7 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@64bef361 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@345c98f3 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.StatsComponent@2b3d9460 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@57d840cd +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.QueryComponent@3cc70b0d +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.FacetComponent@2fa6a1a7 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@64bef361 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@345c98f3 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.StatsComponent@2b3d9460 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@57d840cd +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.QueryComponent@3cc70b0d +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.FacetComponent@2fa6a1a7 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@64bef361 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@345c98f3 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.StatsComponent@2b3d9460 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.SpellCheckComponent@36867fc9 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@57d840cd +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.QueryComponent@3cc70b0d +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.FacetComponent@2fa6a1a7 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@64bef361 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@345c98f3 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.StatsComponent@2b3d9460 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.TermVectorComponent@382f8116 +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@57d840cd +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.TermsComponent@36c3e82b +Sep 24, 2012 10:20:33 AM org.apache.solr.core.QuerySenderListener newSearcher +INFO: QuerySenderListener sending requests to Searcher@6a510e39 main +Sep 24, 2012 10:20:33 AM org.apache.solr.core.CoreContainer register INFO: registering core: -Jun 18, 2012 4:30:21 PM org.apache.solr.servlet.SolrDispatchFilter init -INFO: user.dir=/Users/kaito/.rvm/gems/ruby-1.9.2-p290@orbit/gems/sunspot_solr-1.3.3/solr -Jun 18, 2012 4:30:21 PM org.apache.solr.servlet.SolrDispatchFilter init +Sep 24, 2012 10:20:33 AM org.apache.solr.servlet.SolrDispatchFilter init +INFO: user.dir=/home/nccu/.rvm/gems/ruby-1.9.2-p318@stage/gems/sunspot_solr-1.3.3/solr +Sep 24, 2012 10:20:33 AM org.apache.solr.servlet.SolrDispatchFilter init INFO: SolrDispatchFilter.init() done -Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrCore execute -INFO: [] webapp=null path=null params={start=0&event=firstSearcher&q=solr+rocks&rows=10} hits=0 status=0 QTime=43 -Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrCore execute -INFO: [] webapp=null path=null params={event=firstSearcher&q=static+firstSearcher+warming+query+from+solrconfig.xml} hits=0 status=0 QTime=1 -Jun 18, 2012 4:30:21 PM org.apache.solr.core.QuerySenderListener newSearcher -INFO: QuerySenderListener done. -Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SpellCheckComponent$SpellCheckerListener newSearcher -INFO: Loading spell index for spellchecker: default -Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrCore registerSearcher -INFO: [] Registered new searcher Searcher@3b5b123b main -Jun 18, 2012 4:30:21 PM org.apache.solr.servlet.SolrServlet init +Sep 24, 2012 10:20:33 AM org.apache.solr.servlet.SolrServlet init INFO: SolrServlet.init() -Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: JNDI not configured for solr (NoInitialContextEx) -Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrResourceLoader locateSolrHome -INFO: using system property solr.solr.home: /Users/kaito/Documents/MyWorkspeace/NCCU/solr -Jun 18, 2012 4:30:21 PM org.apache.solr.servlet.SolrServlet init +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: using system property solr.solr.home: /home/nccu/stage/NCCU/solr +Sep 24, 2012 10:20:33 AM org.apache.solr.servlet.SolrServlet init INFO: SolrServlet.init() done -Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: JNDI not configured for solr (NoInitialContextEx) -Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrResourceLoader locateSolrHome -INFO: using system property solr.solr.home: /Users/kaito/Documents/MyWorkspeace/NCCU/solr -Jun 18, 2012 4:30:21 PM org.apache.solr.servlet.SolrUpdateServlet init +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: using system property solr.solr.home: /home/nccu/stage/NCCU/solr +Sep 24, 2012 10:20:33 AM org.apache.solr.servlet.SolrUpdateServlet init INFO: SolrUpdateServlet.init() done +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrCore execute +INFO: [] webapp=null path=null params={start=0&event=firstSearcher&q=solr+rocks&rows=10} hits=0 status=0 QTime=46 +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrCore execute +INFO: [] webapp=null path=null params={event=firstSearcher&q=static+firstSearcher+warming+query+from+solrconfig.xml} hits=0 status=0 QTime=4 +Sep 24, 2012 10:20:33 AM org.apache.solr.core.QuerySenderListener newSearcher +INFO: QuerySenderListener done. +Sep 24, 2012 10:20:33 AM org.apache.solr.handler.component.SpellCheckComponent$SpellCheckerListener newSearcher +INFO: Loading spell index for spellchecker: default +Sep 24, 2012 10:20:33 AM org.apache.solr.core.SolrCore registerSearcher +INFO: [] Registered new searcher Searcher@6a510e39 main diff --git a/public/assets/.gitignore b/public/assets/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_blue.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_blue.png deleted file mode 100755 index ea275d1b..00000000 Binary files a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_blue.png and /dev/null differ diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_green.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_green.png deleted file mode 100755 index 393618c2..00000000 Binary files a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_green.png and /dev/null differ diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_orange.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_orange.png deleted file mode 100755 index 84d32207..00000000 Binary files a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_orange.png and /dev/null differ diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/clock.css b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/clock.css deleted file mode 100755 index 8790b137..00000000 --- a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/clock.css +++ /dev/null @@ -1,69 +0,0 @@ -.clock{ - /* The .clock div. Created dynamically by jQuery */ - /*background-color:#252525;*/ - height:200px; - width:200px; - position:relative; - overflow:hidden; - float:left; -} - -.clock .rotate{ - /* There are two .rotate divs - one for each half of the background */ - position:absolute; - width:200px; - height:200px; - top:0; - left:0; -} - -.rotate.right{ - display:none; - z-index:11; -} - -.clock .bg, .clock .front{ - width:100px; - height:200px; - /*background-color:#252525;*/ - position:absolute; - top:0; -} - -.clock .display{ - /* Holds the number of seconds, minutes or hours respectfully */ - position:absolute; - width:200px; - font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; - z-index:20; - color:#F5F5F5; - font-size:60px; - text-align:center; - top:65px; - left:0; - - /* CSS3 text shadow: */ - text-shadow:4px 4px 5px #333333; -} - -/* The left part of the background: */ - -.clock .bg.left{ left:0; } - -/* Individual styles for each color: */ -.orange .bg.left{ background:url(bg_orange.png) no-repeat left top; } -.green .bg.left{ background:url(bg_green.png) no-repeat left top; } -.blue .bg.left{ background:url(bg_blue.png) no-repeat left top; } - -/* The right part of the background: */ -.clock .bg.right{ left:100px; } - -.orange .bg.right{ background:url(bg_orange.png) no-repeat right top; } -.green .bg.right{ background:url(bg_green.png) no-repeat right top; } -.blue .bg.right{ background:url(bg_blue.png) no-repeat right top; } - - -.clock .front.left{ - left:0; - z-index:10; -} diff --git a/public/desktop_widgets/4fa7817cc88514014d7c59c2/index.html.erb b/public/desktop_widgets/4fa7817cc88514014d7c59c2/index.html.erb deleted file mode 100644 index 9862a505..00000000 --- a/public/desktop_widgets/4fa7817cc88514014d7c59c2/index.html.erb +++ /dev/null @@ -1,45 +0,0 @@ - -
    -
    - sunny -
    - 29°C -
    -
    Sunny
    -
    -
    - weekly report -
    -
    Hsin-Chu
    - > Weekly Report -
    - \ No newline at end of file diff --git a/public/desktop_widgets/4fa7818cc88514014d7c59c3/index.html.erb b/public/desktop_widgets/4fa7818cc88514014d7c59c3/index.html similarity index 100% rename from public/desktop_widgets/4fa7818cc88514014d7c59c3/index.html.erb rename to public/desktop_widgets/4fa7818cc88514014d7c59c3/index.html diff --git a/public/desktop_widgets/4fa78153c88514014d7c59bf/4fa78153c88514014d7c59bf.js b/public/desktop_widgets/509091e6bd98eb0352000009/509091e6bd98eb0352000009.js similarity index 100% rename from public/desktop_widgets/4fa78153c88514014d7c59bf/4fa78153c88514014d7c59bf.js rename to public/desktop_widgets/509091e6bd98eb0352000009/509091e6bd98eb0352000009.js diff --git a/public/desktop_widgets/4fa78153c88514014d7c59bf/events.json b/public/desktop_widgets/509091e6bd98eb0352000009/events.json similarity index 100% rename from public/desktop_widgets/4fa78153c88514014d7c59bf/events.json rename to public/desktop_widgets/509091e6bd98eb0352000009/events.json diff --git a/public/desktop_widgets/4fa78153c88514014d7c59bf/index.html.erb b/public/desktop_widgets/509091e6bd98eb0352000009/index.html similarity index 100% rename from public/desktop_widgets/4fa78153c88514014d7c59bf/index.html.erb rename to public/desktop_widgets/509091e6bd98eb0352000009/index.html diff --git a/public/desktop_widgets/browser/default.css b/public/desktop_widgets/browser/default.css new file mode 100755 index 00000000..fe1e395e --- /dev/null +++ b/public/desktop_widgets/browser/default.css @@ -0,0 +1 @@ +/* No Css */ \ No newline at end of file diff --git a/public/desktop_widgets/4fba4bf36f4fea8095e389eb/4fba4bf36f4fea8095e389eb.js b/public/desktop_widgets/browser/javascripts/browser.js similarity index 100% rename from public/desktop_widgets/4fba4bf36f4fea8095e389eb/4fba4bf36f4fea8095e389eb.js rename to public/desktop_widgets/browser/javascripts/browser.js diff --git a/public/desktop_widgets/browser/settings.json b/public/desktop_widgets/browser/settings.json new file mode 100644 index 00000000..3ce3df02 --- /dev/null +++ b/public/desktop_widgets/browser/settings.json @@ -0,0 +1,6 @@ +{ + "author" : "Harry", + "name" : "Browser", + "shape" : "w2 h1", + "version" : "1.0" +} diff --git a/public/desktop_widgets/4fba4bf36f4fea8095e389eb/index.html.erb b/public/desktop_widgets/browser/widget.html similarity index 100% rename from public/desktop_widgets/4fba4bf36f4fea8095e389eb/index.html.erb rename to public/desktop_widgets/browser/widget.html diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/index.html.erb b/public/desktop_widgets/clock/default.css similarity index 86% rename from public/desktop_widgets/4fa7810ac88514014d7c59bc/index.html.erb rename to public/desktop_widgets/clock/default.css index 2a69e24c..24125313 100755 --- a/public/desktop_widgets/4fa7810ac88514014d7c59bc/index.html.erb +++ b/public/desktop_widgets/clock/default.css @@ -1,81 +1,74 @@ - - -
    - \ No newline at end of file +.clock{ + /* The .clock div. Created dynamically by jQuery */ + background-color:#111; + height:75px; + width:75px; + position:relative; + overflow:hidden; + float:left; +} + +.clock .rotate{ + /* There are two .rotate divs - one for each half of the background */ + position:absolute; + width:75px; + height:75px; + top:0; + left:0; +} + +.rotate.right{ + display:none; + z-index:9; +} + +.clock .bg, .clock .front{ + width:37.5px; + height:75px; + background-color:#111; + position:absolute; + top:0; +} + +.clock .display{ + /* Holds the number of seconds, minutes or hours respectfully */ + position:absolute; + width:75px; + font-family: Orbitron, sans-serif; + z-index:17; + color:#F5F5F5; + font-size:21px; + text-align:center; + top:27.5px; + left:0px; + +} + +/* The left part of the background: */ + +.clock .bg.left{ left:0px; } + +/* Individual styles for each color: */ +.orange .bg.left{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png) no-repeat left top; } +.green .bg.left{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png) no-repeat left top; } +.blue .bg.left{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png) no-repeat left top; } + +/* The right part of the background: */ +.clock .bg.right{ left:37.5px; } + +.orange .bg.right{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png) no-repeat right top; } +.green .bg.right{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png) no-repeat right top; } +.blue .bg.right{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png) no-repeat right top; } + + +.clock .front.left{ + left:0; + z-index:15; +} +#fancyClock { + position: absolute; + overflow: hidden; + top: 50%; + left: 50%; + margin: -36px 0 0 -114px; +} \ No newline at end of file diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png b/public/desktop_widgets/clock/images/bg_blue.png similarity index 100% rename from public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png rename to public/desktop_widgets/clock/images/bg_blue.png diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png b/public/desktop_widgets/clock/images/bg_green.png similarity index 100% rename from public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png rename to public/desktop_widgets/clock/images/bg_green.png diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png b/public/desktop_widgets/clock/images/bg_orange.png similarity index 100% rename from public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png rename to public/desktop_widgets/clock/images/bg_orange.png diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/4fa7810ac88514014d7c59bc.js b/public/desktop_widgets/clock/javascripts/clock.js similarity index 100% rename from public/desktop_widgets/4fa7810ac88514014d7c59bc/4fa7810ac88514014d7c59bc.js rename to public/desktop_widgets/clock/javascripts/clock.js diff --git a/public/desktop_widgets/clock/settings.json b/public/desktop_widgets/clock/settings.json new file mode 100644 index 00000000..8aa41d20 --- /dev/null +++ b/public/desktop_widgets/clock/settings.json @@ -0,0 +1,7 @@ +{ + "author" : "Harry", + "name" : "Clock", + "shape" : "w2 h1", + "version" : "1.0" + +} diff --git a/public/desktop_widgets/clock/widget.html b/public/desktop_widgets/clock/widget.html new file mode 100755 index 00000000..aeb6a444 --- /dev/null +++ b/public/desktop_widgets/clock/widget.html @@ -0,0 +1,5 @@ + +
    + \ No newline at end of file diff --git a/public/desktop_widgets/4fa78140c88514014d7c59be/index.html.erb b/public/desktop_widgets/googlesearch/default.css old mode 100644 new mode 100755 similarity index 59% rename from public/desktop_widgets/4fa78140c88514014d7c59be/index.html.erb rename to public/desktop_widgets/googlesearch/default.css index 341b8d81..1aede945 --- a/public/desktop_widgets/4fa78140c88514014d7c59be/index.html.erb +++ b/public/desktop_widgets/googlesearch/default.css @@ -1,4 +1,3 @@ - -
    - -
    - \ No newline at end of file +} \ No newline at end of file diff --git a/public/desktop_widgets/4fa78140c88514014d7c59be/img/google_64.png b/public/desktop_widgets/googlesearch/images/google_64.png similarity index 100% rename from public/desktop_widgets/4fa78140c88514014d7c59be/img/google_64.png rename to public/desktop_widgets/googlesearch/images/google_64.png diff --git a/public/desktop_widgets/4fa78140c88514014d7c59be/4fa78140c88514014d7c59be.js b/public/desktop_widgets/googlesearch/javascripts/google.js similarity index 100% rename from public/desktop_widgets/4fa78140c88514014d7c59be/4fa78140c88514014d7c59be.js rename to public/desktop_widgets/googlesearch/javascripts/google.js diff --git a/public/desktop_widgets/googlesearch/settings.json b/public/desktop_widgets/googlesearch/settings.json new file mode 100644 index 00000000..ddb52727 --- /dev/null +++ b/public/desktop_widgets/googlesearch/settings.json @@ -0,0 +1,7 @@ +{ + "author" : "Eric", + "name" : "Google Search", + "shape" : "w2 h1", + "version" : "1.0" + +} diff --git a/public/desktop_widgets/googlesearch/widget.html b/public/desktop_widgets/googlesearch/widget.html new file mode 100644 index 00000000..df5c715b --- /dev/null +++ b/public/desktop_widgets/googlesearch/widget.html @@ -0,0 +1,13 @@ + +
    + +
    + \ No newline at end of file diff --git a/public/desktop_widgets/4fa78161c88514014d7c59c0/4fa78161c88514014d7c59c0.js b/public/desktop_widgets/timetable/4fa78161c88514014d7c59c0.js similarity index 100% rename from public/desktop_widgets/4fa78161c88514014d7c59c0/4fa78161c88514014d7c59c0.js rename to public/desktop_widgets/timetable/4fa78161c88514014d7c59c0.js diff --git a/public/desktop_widgets/4fa78161c88514014d7c59c0/index.html.erb b/public/desktop_widgets/timetable/index.html.erb similarity index 100% rename from public/desktop_widgets/4fa78161c88514014d7c59c0/index.html.erb rename to public/desktop_widgets/timetable/index.html.erb diff --git a/public/desktop_widgets/weather/default.css b/public/desktop_widgets/weather/default.css new file mode 100644 index 00000000..ef65207d --- /dev/null +++ b/public/desktop_widgets/weather/default.css @@ -0,0 +1,26 @@ +.g_weather { position: relative; height: 198px; } + .g_weather img { float: left; display: block; margin: 0; padding: 12px; } + .g_weather .gw_recent { + overflow: hidden; + height: 96%; + padding-top: 4%; + } + .g_weather .gw_weekly { display: none; } + .g_weather .gw_location { + position: absolute; + left: 0; + bottom: 0; + font-size: 15px; + line-height: 20px; + } + .g_weather .gw_condition_des { font-size: 22px; } + .g_weather .gw_temp { margin-top: 26px; } + .g_weather .gw_temp_num { font-size: 56px; } + .g_weather .gw_temp_unit { font-size: 26px; } + .g_weather .gw_forecast { + position: absolute; + right: 0; + bottom: 0; + font-size: 13px; + line-height: 20px; +} \ No newline at end of file diff --git a/public/desktop_widgets/4fa7817cc88514014d7c59c2/img/sunny.png b/public/desktop_widgets/weather/images/sunny.png similarity index 100% rename from public/desktop_widgets/4fa7817cc88514014d7c59c2/img/sunny.png rename to public/desktop_widgets/weather/images/sunny.png diff --git a/public/desktop_widgets/4fa7817cc88514014d7c59c2/4fa7817cc88514014d7c59c2.js b/public/desktop_widgets/weather/javascripts/weather.js similarity index 100% rename from public/desktop_widgets/4fa7817cc88514014d7c59c2/4fa7817cc88514014d7c59c2.js rename to public/desktop_widgets/weather/javascripts/weather.js diff --git a/public/desktop_widgets/weather/settings.json b/public/desktop_widgets/weather/settings.json new file mode 100644 index 00000000..67e5a378 --- /dev/null +++ b/public/desktop_widgets/weather/settings.json @@ -0,0 +1,7 @@ +{ + "author" : "Devin", + "name" : "Weather", + "shape" : "w2 h2", + "version" : "0.0" + +} diff --git a/public/desktop_widgets/weather/widget.html b/public/desktop_widgets/weather/widget.html new file mode 100644 index 00000000..8cc412f2 --- /dev/null +++ b/public/desktop_widgets/weather/widget.html @@ -0,0 +1,17 @@ +
    +
    + sunny +
    + 29°C +
    +
    Sunny
    +
    +
    + weekly report +
    +
    Hsin-Chu
    + > Weekly Report +
    + \ No newline at end of file diff --git a/public/desktop_widgets/4fa78197c88514014d7c59c4/4fa78197c88514014d7c59c4.js b/public/desktop_widgets/youtube/4fa78197c88514014d7c59c4.js similarity index 100% rename from public/desktop_widgets/4fa78197c88514014d7c59c4/4fa78197c88514014d7c59c4.js rename to public/desktop_widgets/youtube/4fa78197c88514014d7c59c4.js diff --git a/public/desktop_widgets/4fa78197c88514014d7c59c4/index.html.erb b/public/desktop_widgets/youtube/index.html similarity index 100% rename from public/desktop_widgets/4fa78197c88514014d7c59c4/index.html.erb rename to public/desktop_widgets/youtube/index.html diff --git a/public/static/nccu_calendar.xml b/public/static/nccu_calendar.xml index e903ac45..ee4157b0 100644 --- a/public/static/nccu_calendar.xml +++ b/public/static/nccu_calendar.xml @@ -5,132 +5,28 @@ 本月最新活動 zh-tw - 政大講座論壇:東亞模式的民法典?(蘇永欽講座教授) - + 國立政治大學101學年度新住宿學生消防演練 + - 101/06/04 10:10-11:50 + 101/09/10 08:00-17:00 - 文化講座【父親與民國】-白先勇 - + 國立政治大學101學年度新住宿生教育訓練 + - 101/06/06 14:00-16:00 + 101/09/10 18:00-20:00 - 鄭丁旺講座教授榮退專題演講-我國會計發展的回顧與前瞻 - + 「中國大陸公民社會的發展與評估」研討會 + - 101/06/07 10:00-12:30 - - - 弦樂社 - - - - - 政大弦樂社期末成果發表音樂會 - - - 期末舞展 - - - - - 政大國標社期末舞展 歡迎大家來共襄盛舉 - - - 國際學院運動會 - - - - - 101/06/09 08:00-17:00 - - - IELTS雅思校園考 - - - - - 101/06/09 09:00-17:00 - - - 政橄隊慶 - - - - - 101/06/09 11:00-18:00 - - - 傳院頂大計畫「與未來對話:新的使用者體驗」交流會 - - - - - 101/06/09 13:00-17:30 - - - 2012年福祿貝爾恩物親子戲遊成長團體(下午) - - - - - 101/04/07-101/06/09 14:00-16:00 - - - 商院盃排球賽 - - - - - 101/06/10 08:00-17:00 - - - 教職員羽球賽 - - - - - 101/06/16 08:00-12:00 - - - 「樂活飲食•健康之鑰」系列活動--餐飲實務操作與食品安全 - - - - - 101/06/22 14:00-16:00 - - - 學生議會預備會議 - - - - - 第13屆學生議會第1會期預備會議,將選舉新任學生議會議長、副議長,歡迎政大同學列席旁聽!! - - - 山水講堂:政大教學日 - - - - - 101/06/26 08:20-16:40 - - - 「樂活飲食•健康之鑰」系列活動--廚房消毒與病媒防治 - - - - - 101/06/29 14:00-16:00 + 101/10/06 08:30-17:00 diff --git a/spec/factories/previews.rb b/spec/factories/previews.rb new file mode 100644 index 00000000..bd281c99 --- /dev/null +++ b/spec/factories/previews.rb @@ -0,0 +1,6 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :preview do + end +end diff --git a/spec/helpers/attribute_fields_helper_spec.rb b/spec/helpers/attribute_fields_helper_spec.rb new file mode 100644 index 00000000..84be036a --- /dev/null +++ b/spec/helpers/attribute_fields_helper_spec.rb @@ -0,0 +1,78 @@ +#encoding: UTF-8 +require 'spec_helper' + +describe AttributeFieldsHelper do + describe "#attribute_field" do + context "In the HTML,there should always be 'value' tag in it's name" + + before(:all) do + @user = User.where(email:'chris@rulingcom.com').first + end #end before + # binding.pry + LIST[:markups].each do |markup| + it "should have 'value' when it's #{markup[0]} (no locale)" do + title = "標題" + pre_set_markup_value = case markup[0] + when "select","checkbox","radio_button" + '{"1"=>{"en"=>"Male", "zh_tw"=>"男性"}, "2"=>{"en"=>"Female", "zh_tw"=>"女性"}, "3"=>{"en"=>"Not public", "zh_tw"=>"不公開"}}' + else + nil + end + + attribute_field=AttributeField.find_or_create_by(key:'Test',markup: markup[0],markup_value: pre_set_markup_value,:title=>title) + + html = attribute_field.block_helper(@user,1) + + nodes = Nokogiri::HTML.fragment(html).search('*[@func="input_unit"]') + + nodes.each do |input| + attri = input.attributes["name"] + attri = input.children().first.attributes["name"] if (markup[0] == 'checkbox' || markup[0] == 'radio_button' ) + attri.to_s.should match /user\[.*attribute_values\]\[\d*\]\[value\].*/ + # user[attribute_values][1][id] + # user[attribute_values][1][value][en] + end #end of input loop + end # end of it + end #end markups + + LIST[:markups].each do |markup| + if markup[1]["muti_lang_input_supprt"] + [true,false].each do |locale_sat| + title = locale_sat ? {"en"=>"Title", "zh_tw"=>"標題"} : "標題" + it "should have 'value' when it's #{markup[0]} for locale => #{locale_sat}" do + pre_set_markup_value = case markup[0] + when "select","checkbox","radio_button" + '{"1"=>{"en"=>"Male", "zh_tw"=>"男性"}, "2"=>{"en"=>"Female", "zh_tw"=>"女性"}, "3"=>{"en"=>"Not public", "zh_tw"=>"不公開"}}' + else + nil + end + if (markup[0] == "text_field" || markup[0] == "text_area") && (locale_sat == false) + # binding.pry + end + attribute_field=AttributeField.find_or_create_by(key:'Test',markup: markup[0],markup_value: pre_set_markup_value,:title=>title,:locale => locale_sat) + + html = attribute_field.block_helper(@user,1) + + # p html + nodes = Nokogiri::HTML.fragment(html).search('*[@func="input_unit"]') + nodes.each do |input| + input.attributes["name"].to_s.should match /user\[.*attribute_values\]\[\d*\]\[value\].*/ + # user[attribute_values][1][id] + # user[attribute_values][1][value][en] + end #end of input loop + nodes = Nokogiri::HTML.fragment(html).search('*[@func="field_label"]') + + nodes.each do |input| + # p input.to_s + # binding.pry if + + input.children.text.should match "標題" + end # end of field_label loop + end # end of it + end # end of T/F + end# end of if support + end #end markups + + + end +end \ No newline at end of file diff --git a/spec/models/app_auth_basic.rb b/spec/models/app_auth_basic.rb index 0f629119..0f8549b7 100644 --- a/spec/models/app_auth_basic.rb +++ b/spec/models/app_auth_basic.rb @@ -1,218 +1,218 @@ -require 'spec_helper' -require 'ruby-debug' +# require 'spec_helper' +# require 'ruby-debug' -describe AppAuth do +# describe AppAuth do - before do - User.all.destroy - Role.all.destroy - SubRole.all.destroy - AppAuth.all.destroy - ModuleApp.all.destroy +# before do +# User.all.destroy +# Role.all.destroy +# SubRole.all.destroy +# AppAuth.all.destroy +# ModuleApp.all.destroy - #Create some fixtures of Main Role - main_role_key = ["Stud","Teacher","Staff"] - @new_main_role_list = main_role_key.each do |role| - new_role = Role.new :key => role - new_role.save - end - #Create Some SubRoles - sub_role_key = ["graduated_school","undergraduated_school","TA","Senior"] - @new_main_role_list = sub_role_key.each do |role| - new_role = SubRole.new :key => role - new_role.save - end +# #Create some fixtures of Main Role +# main_role_key = ["Stud","Teacher","Staff"] +# @new_main_role_list = main_role_key.each do |role| +# new_role = Role.new :key => role +# new_role.save +# end +# #Create Some SubRoles +# sub_role_key = ["graduated_school","undergraduated_school","TA","Senior"] +# @new_main_role_list = sub_role_key.each do |role| +# new_role = SubRole.new :key => role +# new_role.save +# end - #Create some users of User - user_emails = ["a_good_ug_stud_1","a_good_ug_stud_2","a_bad_ug_stud","a_good_g_stud","a_bad_g_stud","a_teacher","a_staff"] - user_emails.each do |user_email| - email=user_email+"@rulingcom.com" - new_user = User.new :email=> email - new_user.save - end - #MRK = Member Role Key SRK=Sub Role Key - @stud_MRK = Role.first(conditions:{key:"Stud"}) - @teacher_MRK = Role.first(conditions:{key:"Teacher"}) - @staff_MRK = Role.first(conditions:{key:"Staff"}) +# #Create some users of User +# user_emails = ["a_good_ug_stud_1","a_good_ug_stud_2","a_bad_ug_stud","a_good_g_stud","a_bad_g_stud","a_teacher","a_staff"] +# user_emails.each do |user_email| +# email=user_email+"@rulingcom.com" +# new_user = User.new :email=> email +# new_user.save +# end +# #MRK = Member Role Key SRK=Sub Role Key +# @stud_MRK = Role.first(conditions:{key:"Stud"}) +# @teacher_MRK = Role.first(conditions:{key:"Teacher"}) +# @staff_MRK = Role.first(conditions:{key:"Staff"}) - @graduated_SRK = SubRole.first(conditions:{key:"graduated_school"}) - @under_graduated_SRK = SubRole.first(conditions:{key:"undergraduated_school"}) - @ta_SRK = SubRole.first(conditions:{key:"TA"}) - @senior_SRK = SubRole.first(conditions:{key:"Senior"}) +# @graduated_SRK = SubRole.first(conditions:{key:"graduated_school"}) +# @under_graduated_SRK = SubRole.first(conditions:{key:"undergraduated_school"}) +# @ta_SRK = SubRole.first(conditions:{key:"TA"}) +# @senior_SRK = SubRole.first(conditions:{key:"Senior"}) - @stud_MRK.sub_roles += [@graduated,@under_graduated,@ta] - @stud_MRK.save! +# @stud_MRK.sub_roles += [@graduated,@under_graduated,@ta] +# @stud_MRK.save! - @teacher_MRK.sub_roles = [@senior] - @teacher_MRK.save! +# @teacher_MRK.sub_roles = [@senior] +# @teacher_MRK.save! - @good_ug_stu_1 = User.first(conditions:{email:"a_good_ug_stud_1@rulingcom.com"}) - @good_ug_stu_2 = User.first(conditions:{email:"a_good_ug_stud_2@rulingcom.com"}) - @bad_ug_stu = User.first(conditions:{email:"a_bad_ug_stud@rulingcom.com"}) +# @good_ug_stu_1 = User.first(conditions:{email:"a_good_ug_stud_1@rulingcom.com"}) +# @good_ug_stu_2 = User.first(conditions:{email:"a_good_ug_stud_2@rulingcom.com"}) +# @bad_ug_stu = User.first(conditions:{email:"a_bad_ug_stud@rulingcom.com"}) - @good_g_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"}) - @bad_g_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"}) - @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"}) - @staff = User.first(conditions:{email:"a_staff@rulingcom.com"}) +# @good_g_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"}) +# @bad_g_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"}) +# @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"}) +# @staff = User.first(conditions:{email:"a_staff@rulingcom.com"}) - #setting Roles for users - @good_g_stu.role = @stud_MRK - @bad_g_stu.role = @stud_MRK - @good_ug_stu_1.role = @stud_MRK - @good_ug_stu_2.role = @stud_MRK - @bad_ug_stu.role = @stud_MRK +# #setting Roles for users +# @good_g_stu.role = @stud_MRK +# @bad_g_stu.role = @stud_MRK +# @good_ug_stu_1.role = @stud_MRK +# @good_ug_stu_2.role = @stud_MRK +# @bad_ug_stu.role = @stud_MRK - @good_g_stu.sub_roles = [@graduated_SRK,@ta_SRK] - @bad_g_stu.sub_roles << @graduated_SRK - @good_ug_stu_1.sub_roles << @under_graduated_SRK - @good_ug_stu_2.sub_roles << @under_graduated_SRK - @bad_ug_stu.sub_roles << @under_graduated_SRK +# @good_g_stu.sub_roles = [@graduated_SRK,@ta_SRK] +# @bad_g_stu.sub_roles << @graduated_SRK +# @good_ug_stu_1.sub_roles << @under_graduated_SRK +# @good_ug_stu_2.sub_roles << @under_graduated_SRK +# @bad_ug_stu.sub_roles << @under_graduated_SRK - @teacher.role = @teacher_MRK - @staff.role = @staff_MRK +# @teacher.role = @teacher_MRK +# @staff.role = @staff_MRK - @good_g_stu.save! - @bad_g_stu.save! - @good_ug_stu_1.save! - @good_ug_stu_2.save! - @bad_ug_stu.save! +# @good_g_stu.save! +# @bad_g_stu.save! +# @good_ug_stu_1.save! +# @good_ug_stu_2.save! +# @bad_ug_stu.save! - @teacher.save! - @staff.save! +# @teacher.save! +# @staff.save! - end - describe "Starting a ClassBulletin Auth for teacher , staff and ta" do - before do - @bulletin_app_auth = AppAuth.new() - #all teacher and staff has access right - @bulletin_app_auth.roles = [@teacher_MRK,@staff_MRK] - #all person with TA sub_role has access right - @bulletin_app_auth.sub_roles << @ta_SRK +# end +# describe "Starting a ClassBulletin Auth for teacher , staff and ta" do +# before do +# @bulletin_app_auth = AppAuth.new() +# #all teacher and staff has access right +# @bulletin_app_auth.roles = [@teacher_MRK,@staff_MRK] +# #all person with TA sub_role has access right +# @bulletin_app_auth.sub_roles << @ta_SRK - #a_bad_ug_stud add to block to bulletin_app_auth - #@bulletin_app_auth.blocked_users << @bad_ug_stu +# #a_bad_ug_stud add to block to bulletin_app_auth +# #@bulletin_app_auth.blocked_users << @bad_ug_stu - #all teacher has access right - # @bulletin_app_auth.roles << @teacher_MRK +# #all teacher has access right +# # @bulletin_app_auth.roles << @teacher_MRK - # @bulletin_app_auth.privilege_users << @staff - @bulletin_app_auth.save! - end - context "Should just initialize all obj that is needed" do +# # @bulletin_app_auth.privilege_users << @staff +# @bulletin_app_auth.save! +# end +# context "Should just initialize all obj that is needed" do - it "Testing @bulletin_app_auth init result" do - @bulletin_app_auth.roles.should have(2).item #teacher staff - @bulletin_app_auth.sub_roles.should have(1).item #ta - end +# it "Testing @bulletin_app_auth init result" do +# @bulletin_app_auth.roles.should have(2).item #teacher staff +# @bulletin_app_auth.sub_roles.should have(1).item #ta +# end - it "@bulletin_app_auth should have Roles: Staff , Teacher " do - key_ary = @bulletin_app_auth.roles.collect do |role| - role.key - end - key_ary.sort.should == ["Staff","Teacher"].sort - end +# it "@bulletin_app_auth should have Roles: Staff , Teacher " do +# key_ary = @bulletin_app_auth.roles.collect do |role| +# role.key +# end +# key_ary.sort.should == ["Staff","Teacher"].sort +# end - it "bulletin_app_auth should have 3 auth users" do - user_ary = [@teacher,@staff,@good_g_stu] - @bulletin_app_auth.auth_users.sort.should == user_ary.sort - check_user_has_app user_ary - end +# it "bulletin_app_auth should have 3 auth users" do +# user_ary = [@teacher,@staff,@good_g_stu] +# @bulletin_app_auth.auth_users.sort.should == user_ary.sort +# check_user_has_app user_ary +# end - it "Adding a undergraduate stud into app_auth by privilege list" do - user_ary = [@teacher,@staff,@good_g_stu,@good_ug_stu_1] - @bulletin_app_auth.add_user_to_privilege_list @good_ug_stu_1 - @bulletin_app_auth.auth_users.sort.should == user_ary.sort - check_user_has_app user_ary - end +# it "Adding a undergraduate stud into app_auth by privilege list" do +# user_ary = [@teacher,@staff,@good_g_stu,@good_ug_stu_1] +# @bulletin_app_auth.add_user_to_privilege_list @good_ug_stu_1 +# @bulletin_app_auth.auth_users.sort.should == user_ary.sort +# check_user_has_app user_ary +# end - it "Adding all graudated-stud into app_auth" do - user_ary = [@teacher,@staff,@good_g_stu,@bad_g_stu] - @bulletin_app_auth.add_sub_role @graduated_SRK - @bulletin_app_auth.auth_users.sort.should == user_ary.sort - check_user_has_app user_ary - end +# it "Adding all graudated-stud into app_auth" do +# user_ary = [@teacher,@staff,@good_g_stu,@bad_g_stu] +# @bulletin_app_auth.add_sub_role @graduated_SRK +# @bulletin_app_auth.auth_users.sort.should == user_ary.sort +# check_user_has_app user_ary +# end - it "Blocking bad-graduate student" do - user_ary =[@teacher,@staff,@good_g_stu] - @bulletin_app_auth.add_sub_role @graduated_SRK - @bulletin_app_auth.add_user_to_black_list @bad_g_stu - @bulletin_app_auth.auth_users_after_block_list.sort.should == user_ary.sort - check_user_has_app user_ary - end +# it "Blocking bad-graduate student" do +# user_ary =[@teacher,@staff,@good_g_stu] +# @bulletin_app_auth.add_sub_role @graduated_SRK +# @bulletin_app_auth.add_user_to_black_list @bad_g_stu +# @bulletin_app_auth.auth_users_after_block_list.sort.should == user_ary.sort +# check_user_has_app user_ary +# end - it "Removing all graudated-stud from app_auth" do - user_ary =[@teacher,@staff,@good_g_stu] - @bulletin_app_auth.add_sub_role @graduated_SRK - @bulletin_app_auth.remove_sub_role @graduated_SRK - @bulletin_app_auth.auth_users.sort.should == user_ary.sort - check_user_has_app user_ary - end +# it "Removing all graudated-stud from app_auth" do +# user_ary =[@teacher,@staff,@good_g_stu] +# @bulletin_app_auth.add_sub_role @graduated_SRK +# @bulletin_app_auth.remove_sub_role @graduated_SRK +# @bulletin_app_auth.auth_users.sort.should == user_ary.sort +# check_user_has_app user_ary +# end - # it "@bulletin_app_auth should have one Privialage user which is belongs to Staff" do - # p_user_ary = @bulletin_app_auth.privilege_users.collect do |p_user| - # p_user.roles.key - # end - # p_user_ary.should include("Staff") - # end +# # it "@bulletin_app_auth should have one Privialage user which is belongs to Staff" do +# # p_user_ary = @bulletin_app_auth.privilege_users.collect do |p_user| +# # p_user.roles.key +# # end +# # p_user_ary.should include("Staff") +# # end - # it "@bulletin_app_auth should have one student listed at blocklist" do - # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"}) - # @bulletin_app_auth.blocked_users.should have(1).item - # @bulletin_app_auth.blocked_users.should include(@bad_stu) - # end +# # it "@bulletin_app_auth should have one student listed at blocklist" do +# # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"}) +# # @bulletin_app_auth.blocked_users.should have(1).item +# # @bulletin_app_auth.blocked_users.should include(@bad_stu) +# # end - # it "[Development #1]-1.Authorizing roles: roles + blocklist" do - # @good_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"}) - # @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"}) - # @staff = User.first(conditions:{email:"a_staff@rulingcom.com"}) - # ary = [@good_stu,@teacher,@staff] - # @bulletin_app_auth.auth_users_after_block_list.should == ary - # end - # - # it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do - # user_emails = ["new_user1","new_user2","new_user3","new_user4"] - # user_emails.each do |user_email| - # email=user_email+"@rulingcom.com" - # new_user = User.new :email=> email - # new_user.save - # end - # user1= User.first(conditions:{email:"new_user1@rulingcom.com"}) - # user2= User.first(conditions:{email:"new_user2@rulingcom.com"}) - # user3= User.first(conditions:{email:"new_user3@rulingcom.com"}) - # user4= User.first(conditions:{email:"new_user4@rulingcom.com"}) - # - # @bulletin_app_auth.privilege_users << user1 - # @bulletin_app_auth.privilege_users << user2 - # - # @bulletin_app_auth.auth_users_after_block_list.should include(user1,user2) - # @bulletin_app_auth.auth_users_after_block_list.should_not include(user3,user4) - # - # end - # - # it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do - # @bulletin_app_auth.auth_users.should have(7).item - # end - # - # it "[Development #1]-4.Authorizing all: blocklist" do - # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"}) - # @new_bulletin_app_auth = (AppAuth.new :all => true) - # @new_bulletin_app_auth.blocked_users << @bad_stu - # - # @new_bulletin_app_auth.auth_users.should == User.all.entries - # @new_bulletin_app_auth.auth_users_after_block_list.should_not include(@bad_stu) - # @new_bulletin_app_auth.save! - # end - def check_user_has_app(user_ary) - user_ary.each do |user| - user.avb_apps.should include(@bulletin_app_auth) - end - end - end +# # it "[Development #1]-1.Authorizing roles: roles + blocklist" do +# # @good_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"}) +# # @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"}) +# # @staff = User.first(conditions:{email:"a_staff@rulingcom.com"}) +# # ary = [@good_stu,@teacher,@staff] +# # @bulletin_app_auth.auth_users_after_block_list.should == ary +# # end +# # +# # it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do +# # user_emails = ["new_user1","new_user2","new_user3","new_user4"] +# # user_emails.each do |user_email| +# # email=user_email+"@rulingcom.com" +# # new_user = User.new :email=> email +# # new_user.save +# # end +# # user1= User.first(conditions:{email:"new_user1@rulingcom.com"}) +# # user2= User.first(conditions:{email:"new_user2@rulingcom.com"}) +# # user3= User.first(conditions:{email:"new_user3@rulingcom.com"}) +# # user4= User.first(conditions:{email:"new_user4@rulingcom.com"}) +# # +# # @bulletin_app_auth.privilege_users << user1 +# # @bulletin_app_auth.privilege_users << user2 +# # +# # @bulletin_app_auth.auth_users_after_block_list.should include(user1,user2) +# # @bulletin_app_auth.auth_users_after_block_list.should_not include(user3,user4) +# # +# # end +# # +# # it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do +# # @bulletin_app_auth.auth_users.should have(7).item +# # end +# # +# # it "[Development #1]-4.Authorizing all: blocklist" do +# # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"}) +# # @new_bulletin_app_auth = (AppAuth.new :all => true) +# # @new_bulletin_app_auth.blocked_users << @bad_stu +# # +# # @new_bulletin_app_auth.auth_users.should == User.all.entries +# # @new_bulletin_app_auth.auth_users_after_block_list.should_not include(@bad_stu) +# # @new_bulletin_app_auth.save! +# # end +# def check_user_has_app(user_ary) +# user_ary.each do |user| +# user.avb_apps.should include(@bulletin_app_auth) +# end +# end +# end - end +# end -end \ No newline at end of file +# end \ No newline at end of file diff --git a/spec/models/app_auth_spec.rb b/spec/models/app_auth_spec.rb index 7353f29d..4080250a 100644 --- a/spec/models/app_auth_spec.rb +++ b/spec/models/app_auth_spec.rb @@ -1,81 +1,81 @@ -require 'spec_helper' -require 'ruby-debug' +# require 'spec_helper' +# require 'ruby-debug' -describe AppAuth do +# describe AppAuth do - before(:all) do - @app_ary = [ - {"name" => "G_app_1" , "all" => false,"blockusers" => ["a_bad_stud@rulingcom.com"]}, - {"name" => "G_app_2" , "all" => true,"blockusers" => ["a_bad_stud@rulingcom.com"]}, - {"name" => "G_app_3_for_bad" , "all" => true,"blockusers" => []} - ] +# before(:all) do +# @app_ary = [ +# {"name" => "G_app_1" , "all" => false,"blockusers" => ["a_bad_stud@rulingcom.com"]}, +# {"name" => "G_app_2" , "all" => true,"blockusers" => ["a_bad_stud@rulingcom.com"]}, +# {"name" => "G_app_3_for_bad" , "all" => true,"blockusers" => []} +# ] - @app_ary.each do |t| - a = ModuleApp.new :title => t["name"] - blocked_users = t["blockusers"].collect do |b_user| - User.first(conditions:{email:b_user}) - end - a.create_app_auth :all=> t["all"],:blocked_users => blocked_users - a.save! - end - @good_stud_become_bad = User.first(conditions:{email:"a_good_stud@rulingcom.com"}) - @bad_stud_become_good = User.first(conditions:{email:"a_bad_stud@rulingcom.com"}) - @g_app_1 = ModuleApp.first(conditions:{title:"G_app_1"}) - @g_app_2 = ModuleApp.first(conditions:{title:"G_app_2"}) - @g_app_3 = ModuleApp.first(conditions:{title:"G_app_3_for_bad"}) - end +# @app_ary.each do |t| +# a = ModuleApp.new :title => t["name"] +# blocked_users = t["blockusers"].collect do |b_user| +# User.first(conditions:{email:b_user}) +# end +# a.create_app_auth :all=> t["all"],:blocked_users => blocked_users +# a.save! +# end +# @good_stud_become_bad = User.first(conditions:{email:"a_good_stud@rulingcom.com"}) +# @bad_stud_become_good = User.first(conditions:{email:"a_bad_stud@rulingcom.com"}) +# @g_app_1 = ModuleApp.first(conditions:{title:"G_app_1"}) +# @g_app_2 = ModuleApp.first(conditions:{title:"G_app_2"}) +# @g_app_3 = ModuleApp.first(conditions:{title:"G_app_3_for_bad"}) +# end - describe "[Init status check]" do - it "bad_stud_become_good status " do - @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth - @bad_stud_become_good.avb_apps.should_not include @g_app_2.app_auth - @bad_stud_become_good.avb_apps.should include @g_app_3.app_auth - end +# describe "[Init status check]" do +# it "bad_stud_become_good status " do +# @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth +# @bad_stud_become_good.avb_apps.should_not include @g_app_2.app_auth +# @bad_stud_become_good.avb_apps.should include @g_app_3.app_auth +# end - it "good_stud_become_bad status " do - @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth - @good_stud_become_bad.avb_apps.should include @g_app_2.app_auth - @good_stud_become_bad.avb_apps.should include @g_app_3.app_auth - end - end +# it "good_stud_become_bad status " do +# @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth +# @good_stud_become_bad.avb_apps.should include @g_app_2.app_auth +# @good_stud_become_bad.avb_apps.should include @g_app_3.app_auth +# end +# end - describe ".add_user_to_black_list sutd" do - it "When good stud is blocked with app1 and app2" do - @g_app_1.app_auth.add_user_to_black_list @good_stud_become_bad - @g_app_2.app_auth.add_user_to_black_list @good_stud_become_bad - @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth - @good_stud_become_bad.avb_apps.should_not include @g_app_2.app_auth - end - end +# describe ".add_user_to_black_list sutd" do +# it "When good stud is blocked with app1 and app2" do +# @g_app_1.app_auth.add_user_to_black_list @good_stud_become_bad +# @g_app_2.app_auth.add_user_to_black_list @good_stud_become_bad +# @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth +# @good_stud_become_bad.avb_apps.should_not include @g_app_2.app_auth +# end +# end - describe ".remove_user_from_black_list sutd" do - it "When bad stud is authed with app1 and app2" do - @g_app_1.app_auth.remove_user_from_black_list @bad_stud_become_good - @g_app_2.app_auth.remove_user_from_black_list @bad_stud_become_good - #@bad_stud_become_good.avb_apps.should include @g_app_1.app_auth - @bad_stud_become_good.avb_apps.should include @g_app_2.app_auth - end - end +# describe ".remove_user_from_black_list sutd" do +# it "When bad stud is authed with app1 and app2" do +# @g_app_1.app_auth.remove_user_from_black_list @bad_stud_become_good +# @g_app_2.app_auth.remove_user_from_black_list @bad_stud_become_good +# #@bad_stud_become_good.avb_apps.should include @g_app_1.app_auth +# @bad_stud_become_good.avb_apps.should include @g_app_2.app_auth +# end +# end - describe ".add_user_to_privilege_list sutd" do - it "When bad stud is auth for one more app" do - @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth #shouldn't have at first time since app1 is not sat for all - @g_app_1.app_auth.add_user_to_privilege_list @bad_stud_become_good #change status - @bad_stud_become_good.avb_apps.should include @g_app_1.app_auth #check - end - end +# describe ".add_user_to_privilege_list sutd" do +# it "When bad stud is auth for one more app" do +# @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth #shouldn't have at first time since app1 is not sat for all +# @g_app_1.app_auth.add_user_to_privilege_list @bad_stud_become_good #change status +# @bad_stud_become_good.avb_apps.should include @g_app_1.app_auth #check +# end +# end - describe ".remove_user_from_privilege_list sutd" do - it "admin mistake. remove user from privilege list" do - @g_app_1.app_auth.remove_user_from_privilege_list @bad_stud_become_good - @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth - end - end +# describe ".remove_user_from_privilege_list sutd" do +# it "admin mistake. remove user from privilege list" do +# @g_app_1.app_auth.remove_user_from_privilege_list @bad_stud_become_good +# @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth +# end +# end - after(:all) do - @app_ary.each do |item| - ModuleApp.first(conditions: {title: item["name"]}).destroy - end - end +# after(:all) do +# @app_ary.each do |item| +# ModuleApp.first(conditions: {title: item["name"]}).destroy +# end +# end -end \ No newline at end of file +# end \ No newline at end of file diff --git a/spec/models/attribute_field_spec.rb b/spec/models/attribute_field_spec.rb new file mode 100644 index 00000000..6fb01ba8 --- /dev/null +++ b/spec/models/attribute_field_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' +describe AttributeField do + describe "#list field" do + context "when field is in type text_field(without add more)" do + before(:each) do + @attribute_field = AttributeField.new(:key=>'test',:markup=>"text_field") + + + end + end + end +end \ No newline at end of file diff --git a/spec/models/attribute_value_spec.rb b/spec/models/attribute_value_spec.rb new file mode 100644 index 00000000..a9a741db --- /dev/null +++ b/spec/models/attribute_value_spec.rb @@ -0,0 +1,63 @@ +#encoding: UTF-8 +require 'spec_helper' + +describe AttributeValue do + describe "#attribute_value" do + context "Data should be able to input and out put as aspect" + + before do + @af = AttributeField.find '5052cf9f2b5c49a742000005' + @user = User.where(email:'chris@rulingcom.com').first + @av = AttributeValue.last + end #end before + + [true,false].each do |locale_sat| + LIST[:markups].each do |markup| + @av = nil + it "[#{markup[0]}]Input: should save data at right way when local is set to #{locale_sat}" do + @af.markup = markup[0] + @av = nil + @input_value = assume_result = case markup[0] + when 'text_field','text_area' + (locale_sat ? {"en"=> "lalala","zh_tw"=>"拉拉拉"} : "hahaha") + when 'select','radio_button' + "1" + when 'date' + {"(1i)"=>Date.today.year.to_s,"(2i)"=>Date.today.month.to_s,"(3i)"=>Date.today.day.to_s} + when 'checkbox' + {"1"=>"true", "3"=>"true"} + end #end of case + assume_result = ["1","3"] if markup[0] == 'checkbox' + @af.locale = locale_sat + @af.save + @data_hash = {"attribute_field_id" => @af.id,"value" => @input_value} + @av = @user.attribute_values.build(@data_hash) + @av.save + + @av.value.should == assume_result + # @av.destroy + end + + it "[#{markup[0]}]Output(just for show): should output data at right way when local is set to #{locale_sat}" do + locale = I18n.locale + assume_result = case markup[0] + when 'text_area' + (locale_sat ? "拉拉拉" : "hahaha") + when 'text_field' + (locale_sat ? "拉拉拉" : "hahaha") + when 'select','radio_button' + (locale_sat ? "男性" : "男性") + when 'date' + Date.today + when 'checkbox' + (locale_sat ? "男性,不公開" : "男性,不公開") + end #end of case + + @av.get_value_by_locale(locale).should == assume_result + end + + end #end of LIST loop + end + + end +end \ No newline at end of file diff --git a/spec/models/preview_spec.rb b/spec/models/preview_spec.rb new file mode 100644 index 00000000..86318050 --- /dev/null +++ b/spec/models/preview_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Preview do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index a58799b4..0d8d2fe9 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -1,113 +1,113 @@ -require 'spec_helper' + # require 'spec_helper' -describe Role do - before do - @role = Role.create(:key => 'teacher', - :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'}, - :sub_roles => [{:key => 'undergrad', - :i18n_variable => {:key => 'yeah', :en => 'Yeah', :zh_tw => 'Yeah', :document_class => 'Role'}, - :attribute_fields => [{:key => 'department'}, - {:key => 'room'}]}, - {:key => 'master', - :attribute_fields => [{:key => 'department'}]}]) - end - describe 'New role' do - describe '#Role' do - it 'should have :built_in false' do - @role.built_in.should be false - end - it 'should have :disabled false' do - @role.disabled.should be false - end - it 'should have a i18n_variable' do - @role.i18n_variable.should be_an_instance_of I18nVariable - end - it 'should create sub_roles' do - @role.should have(2).sub_roles - end - it 'should create attribute_fields' do - @role.sub_roles[1].should have(1).attribute_fields - end - end - describe '#SubRole' do - it 'should have :built_in false' do - @role.sub_roles[0].built_in.should be false - end - it 'should have :disabled false' do - @role.sub_roles[0].disabled.should be false - end - it 'should have a i18n_variable' do - @role.sub_roles[0].i18n_variable.should be_an_instance_of I18nVariable - end - end - describe '#AttributeField' do - it 'should have :built_in false' do - @role.sub_roles[0].attribute_fields[0].built_in.should be false - end - it 'should have :disabled false' do - @role.sub_roles[0].attribute_fields[0].disabled.should be false - end - end - end - describe 'Edit role' do - describe '#Role' do - before do - @role.update_attributes({:key => 'student', :i18n_variable => {:en => 'Student'}, - :sub_roles => [{:key => 'new', - :attribute_fields => [{:key => 'bob'}, - {:key => 'great'}]}, - {:id => @role.sub_roles[0].id}, - {:id => @role.sub_roles[1].id}]}) - end - it 'should not be the old :key' do - @role.key.should_not == 'teacher' - end - it 'should be the new :key' do - @role.key.should == 'student' - end - it 'should not be the old :i18n_variable[:en]' do - @role.i18n_variable[:en].should_not == 'Teacher' - end - it 'should be the new :i18n_variable[:en]' do - @role.i18n_variable[:en].should == 'Student' - end - it 'should have one more SubRole' do - @role.should have(3).sub_roles - end - end - end - describe 'Destroy' do - describe '#AttributeField' do - before do - @role.update_attributes(:key => 'teacher', - :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'}, - :sub_roles_attributes => {'0' => {:id => @role.sub_roles[0].id, - :key => 'undergrad', - :attribute_fields_attributes => {'0' => {:id => @role.sub_roles[0].attribute_fields[0].id, - :key => 'department'}, - '1' => {:id => @role.sub_roles[0].attribute_fields[1].id, - :key => 'room', :_destroy => true}}}}) - end - it 'should have only one AttributeField for the first SubRole' do - @role.sub_roles[0].should have(1).attribute_fields - end - end - describe '#I18nVariable' do - before do - @role.update_attributes(:key => 'teacher', - :i18n_variable_attributes => {:id => @role.i18n_variable.id, :key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role', :_destroy => true}) - end - it 'should not have a I18nVariable' do - @role.i18n_variable.should_not be_an_instance_of I18nVariable - end - end - describe '#Role' do - it 'should destroy the I18nVariable' do - id = @role.i18n_variable.id - @role.destroy - lambda {I18nVariable.find(id)}.should raise_error - end - end - end +# describe Role do +# before do +# @role = Role.create(:key => 'teacher', +# :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'}, +# :sub_roles => [{:key => 'undergrad', +# :i18n_variable => {:key => 'yeah', :en => 'Yeah', :zh_tw => 'Yeah', :document_class => 'Role'}, +# :attribute_fields => [{:key => 'department'}, +# {:key => 'room'}]}, +# {:key => 'master', +# :attribute_fields => [{:key => 'department'}]}]) +# end +# describe 'New role' do +# describe '#Role' do +# it 'should have :built_in false' do +# @role.built_in.should be false +# end +# it 'should have :disabled false' do +# @role.disabled.should be false +# end +# it 'should have a i18n_variable' do +# @role.i18n_variable.should be_an_instance_of I18nVariable +# end +# it 'should create sub_roles' do +# @role.should have(2).sub_roles +# end +# it 'should create attribute_fields' do +# @role.sub_roles[1].should have(1).attribute_fields +# end +# end +# describe '#SubRole' do +# it 'should have :built_in false' do +# @role.sub_roles[0].built_in.should be false +# end +# it 'should have :disabled false' do +# @role.sub_roles[0].disabled.should be false +# end +# it 'should have a i18n_variable' do +# @role.sub_roles[0].i18n_variable.should be_an_instance_of I18nVariable +# end +# end +# describe '#AttributeField' do +# it 'should have :built_in false' do +# @role.sub_roles[0].attribute_fields[0].built_in.should be false +# end +# it 'should have :disabled false' do +# @role.sub_roles[0].attribute_fields[0].disabled.should be false +# end +# end +# end +# describe 'Edit role' do +# describe '#Role' do +# before do +# @role.update_attributes({:key => 'student', :i18n_variable => {:en => 'Student'}, +# :sub_roles => [{:key => 'new', +# :attribute_fields => [{:key => 'bob'}, +# {:key => 'great'}]}, +# {:id => @role.sub_roles[0].id}, +# {:id => @role.sub_roles[1].id}]}) +# end +# it 'should not be the old :key' do +# @role.key.should_not == 'teacher' +# end +# it 'should be the new :key' do +# @role.key.should == 'student' +# end +# it 'should not be the old :i18n_variable[:en]' do +# @role.i18n_variable[:en].should_not == 'Teacher' +# end +# it 'should be the new :i18n_variable[:en]' do +# @role.i18n_variable[:en].should == 'Student' +# end +# it 'should have one more SubRole' do +# @role.should have(3).sub_roles +# end +# end +# end +# describe 'Destroy' do +# describe '#AttributeField' do +# before do +# @role.update_attributes(:key => 'teacher', +# :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'}, +# :sub_roles_attributes => {'0' => {:id => @role.sub_roles[0].id, +# :key => 'undergrad', +# :attribute_fields_attributes => {'0' => {:id => @role.sub_roles[0].attribute_fields[0].id, +# :key => 'department'}, +# '1' => {:id => @role.sub_roles[0].attribute_fields[1].id, +# :key => 'room', :_destroy => true}}}}) +# end +# it 'should have only one AttributeField for the first SubRole' do +# @role.sub_roles[0].should have(1).attribute_fields +# end +# end +# describe '#I18nVariable' do +# before do +# @role.update_attributes(:key => 'teacher', +# :i18n_variable_attributes => {:id => @role.i18n_variable.id, :key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role', :_destroy => true}) +# end +# it 'should not have a I18nVariable' do +# @role.i18n_variable.should_not be_an_instance_of I18nVariable +# end +# end +# describe '#Role' do +# it 'should destroy the I18nVariable' do +# id = @role.i18n_variable.id +# @role.destroy +# lambda {I18nVariable.find(id)}.should raise_error +# end +# end +# end -end \ No newline at end of file +# end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2529da0f..cd0b93ad 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -38,6 +38,7 @@ Spork.prefork do # automatically. This will be the default behavior in future versions of # rspec-rails. config.infer_base_class_for_anonymous_controllers = false + end end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb index 5dfbb750..91f610b6 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -13,9 +13,9 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle @bulletin.proc_check(params[:bulletin][:is_checked],params[:bulletin][:not_checked_reason]) @bulletin.de_pending if @bulletin.save - notice = t('bulletin.approve_bulletin_success') + notice = t('announcement.approve_bulletin_success') else - notice = t('bulletin.approve_bulletin_fail') + notice = t('announcement.approve_bulletin_fail') end redirect_to(panel_announcement_back_end_bulletins_url,:notice => notice) end @@ -40,9 +40,9 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle def update_setting object_auth = update_setting_by_params if object_auth.save! - flash[:notice] = t("admin.object_auth.update_done") + flash[:notice] = t('update.success_') else - flash[:notice] = t("admin.object_auth.update_failed") + flash[:notice] = t('update.fail') end end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb index 56de2104..c0ae8244 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb @@ -92,8 +92,8 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo respond_to do |format| if @bulletin_category.update_attributes(params[:bulletin_category]) - # format.html { redirect_to(panel_announcement_back_end_bulletin_category_url(@bulletin_category), :notice => t('bulletin_category.update_bulletin_category_success')) } - # format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url, :notice => t('bulletin_category.update_bulletin_category_success')) } + # format.html { redirect_to(panel_announcement_back_end_bulletin_category_url(@bulletin_category), :notice => t('announcement.update_bulletin_category_success')) } + # format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url, :notice => t('announcement.update_bulletin_category_success')) } # format.xml { head :ok } format.js else @@ -112,14 +112,14 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo if @bulletin_category.save! respond_to do |format| - flash[:notice] = t("bulletin_category.update_success") - # flash[:error] += @bulletin_category.disable ? t("bulletin_category.disable_change_to_true") : t("bulletin_category.disable_change_to_false") + flash[:notice] = t("update.success_") + # flash[:error] += @bulletin_category.disable ? t(:enable) : t(disable) format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) } # format.xml { head :ok } format.js end else - flash[:error] = t("bulletin_category.update_failed") + flash[:error] = t("update.fail") format.html { render :action => "index" } end end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index fb3107cd..b6c0703d 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -2,15 +2,25 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController include AdminHelper include OrbitControllerLib::DivisionForDisable + before_filter :clean_values, :only => [:create, :update] + # before_filter :for_admin_only,:only => [:] # before_filter :for_app_manager,:only => [:index,:show,] before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_bulletins] before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins] before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins] + before_filter :only => [ :new,:create,:edit,:update,:create] do |controller| controller.get_categorys('BulletinCategory') end + def preview + #@preview_obj = Preview.create(:object=>params[:news_bulletin],:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin") + bulletin = Bulletin.new params + @preview_obj = bulletin.to_preview + @preview_obj.save + render '/shared/preview/preview.html.erb',:layout=>false + end def index # @bulletins = Bulletin.all @@ -68,8 +78,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # GET /bulletins/new # GET /bulletins/new.xml def new - @bulletin = Bulletin.new(:postdate => DateTime.now) - + if(session[:in_validate_object].blank?) + @bulletin = Bulletin.new(:postdate => DateTime.now) + else + @bulletin = session[:in_validate_object] + session[:in_validate_object] = {} + end + @link_url = panel_announcement_back_end_bulletins_path get_tags respond_to do |format| @@ -124,18 +139,30 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController @bulletin.create_user_id = current_user.id @bulletin.update_user_id = current_user.id if(is_manager? || is_admin?) - @bulletin.de_pending + @bulletin.is_checked = true + @bulletin.is_rejected = false + @bulletin.de_pending end respond_to do |format| if @bulletin.save - format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.create_bulletin_success')) } + format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) } format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin } - format.js + # format.js + format.js { + @info = {"success"=>"true","redirect_url"=>panel_announcement_back_end_bulletins_url} + flash[:notice] = t('bulletin.create_bulletin_success') + render "/shared/preview/after_create.js.erb" + } else format.html { render :action => "new" } format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } + format.js { + @info = {"success"=>"false","redirect_url"=>new_panel_announcement_back_end_bulletin_url(:bulletin => @bulletin)} + session[:in_validate_object] = @bulletin + render "/shared/preview/after_create.js.erb" + } end end @@ -337,7 +364,18 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def get_tags module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) - @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) + @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue [] + end + + def clean_values + if params[:bulletin] + params[:bulletin][:bulletin_links_attributes].each_with_index do |link, index| + params[:bulletin][:bulletin_links_attributes].delete(index.to_s) if link[1]['url'].blank? and link[1]['title'].blank? + end rescue nil + params[:bulletin][:bulletin_files_attributes].each_with_index do |link, index| + params[:bulletin][:bulletin_files_attributes].delete(index.to_s) if link[1]['file'].blank? and link[1]['title'].blank? + end rescue nil + end end end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index 4f54936b..8fa7af68 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -30,7 +30,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController @search = Bulletin.solr_search do fulltext params[:search_query] with(:frontend_search,true) - #order_by(:average_rating) + with(:available_lang).any_of([I18n.locale.to_s]) end search_result = @search.results.collect{|result| result.id} @@ -78,7 +78,8 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController end def preview_content - @bulletin = Bulletin.find params[:id] + @bulletin = Bulletin.find params[:id] rescue nil + @bulletin = Preview.find(params[:id]).get_virtual_object if @bulletin.nil? get_categorys end diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb index 92604985..16c69f40 100644 --- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb @@ -9,8 +9,8 @@ include ActionView::Helpers::UrlHelper bulletin_category.object_auths.new(title: type ).save oa = bulletin_category.get_object_auth_by_title(type) end -# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) - link_to t('announcement.bulletin.cate_auth'),admin_object_auth_ob_auth_path(oa) +# link_to t(:category_auth), edit_admin_object_auth_path(oa) + link_to t(:category_auth),admin_object_auth_ob_auth_path(oa) end end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb index 7e36a22d..31e08fb4 100644 --- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb @@ -49,4 +49,4 @@ module Panel::Announcement::BackEnd::BulletinsHelper end -end \ No newline at end of file +end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index adc50101..64b507c8 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -9,11 +9,7 @@ class Bulletin BelongsToCategory = :bulletin_category include OrbitCoreLib::BelongsToCategoryMayDisable - - # include NccuSearch - - #scope :searchable,where(:is_checked=>true,:is_hidden=>false,:is_pending=>false) - + include OrbitCoreLib::Preview is_impressionable :counter_cache => { :column_name => :view_count } field :title, localize: true @@ -36,7 +32,6 @@ class Bulletin field :is_checked, :type => Boolean, :default => false field :is_pending, :type => Boolean, :default => true field :is_rejected, :type => Boolean, :default => false - field :view_count, :type => Integer, :default => 0 field :not_checked_reason @@ -62,11 +57,10 @@ class Bulletin validates :title, :at_least_one => true - before_save :check_deadline, :update_avliable_language, :clean_tags + before_save :check_deadline, :update_avliable_language, :clean_values + before_create :update_avliable_language before_save :fetch_dept - after_save :save_bulletin_links - after_save :save_bulletin_files searchable do text :titles do @@ -75,6 +69,11 @@ class Bulletin text :texts do text_translations.to_a.collect{|t| Nokogiri::HTML(t[1]).text} end + + string :available_lang , :multiple => true do + VALID_LOCALES.collect{|t| enabled_for_lang(t.to_sym) ? t : nil}.delete_if{|t| t.nil?} + end + # text :text do # a = (title_translations["zh_tw"] + title_translations["en"]) # a @@ -86,6 +85,10 @@ class Bulletin integer :view_count string :bulletin_category_id end + + def share_item + Item.first(conditions:{name: 'announcement'}) + end def proc_check(check,not_pass_info = "") self.is_checked = true @@ -202,6 +205,24 @@ class Bulletin tags.order_by(I18n.locale, :asc) end + + def to_preview + preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_announcement_front_end_bulletin_path",:object_class_type=>"Bulletin") + + self.bulletin["bulletin_files_attributes"].each_with_index do |atr,idx| + preview_object.preview_files.build(:file=>self.bulletin["bulletin_files_attributes"][idx.to_s],:field_name_for_rebuild=>'bulletin_files',:file_in_array=>true) + end unless self.bulletin["bulletin_files_attributes"].nil? + + self.bulletin["bulletin_links_attributes"].each_with_index do |atr,idx| + preview_object.preview_associations.build(:object=>self.bulletin["bulletin_links_attributes"][idx.to_s],:field_name_for_rebuild=>'bulletin_links',:object_in_array=>true) + end unless self.bulletin["bulletin_links_attributes"].nil? + + + preview_object.object = self.bulletin.except("bulletin_files_attributes","bulletin_links_attributes") + preview_object + end + + protected def check_deadline @@ -224,8 +245,12 @@ class Bulletin self.cache_dept = (User.find(self.create_user_id).cache_dept rescue nil) if self.new_record? end - def clean_tags + def clean_values + self.bulletin_links.each do |link| + link.delete if link.url.blank? && link.title.blank? + end self.tag_ids.delete('') end + end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/_announcement_secondary.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/_announcement_secondary.html.erb deleted file mode 100644 index 40f5e871..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/_announcement_secondary.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -
    -
    -
    -
    -
    -
      -
    • <%= link_to t('bulletin.announcement_list'), panel_announcement_back_end_bulletins_path if is_manager?%>
    • -
    • <%= link_to t('bulletin.new_announcement_class'), panel_announcement_back_end_bulletin_categorys_path if is_manager?%>
    • -
    • <%= link_to t('bulletin.fact_check_for_manager'), panel_announcement_back_end_fact_checks_path if is_manager?%>
    • - -
    • <%= link_to t('bulletin.my_announcement'), panel_announcement_back_end_list_mine_path if is_sub_manager? %>
    • -
    • <%= link_to t('bulletin.new_announcement'), new_panel_announcement_back_end_bulletin_path if is_sub_manager? %>
    • - -
    \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/announcements/_list_table.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/announcements/_list_table.html.erb deleted file mode 100644 index a8c5a83b..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/announcements/_list_table.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -

    <%= bulletin_category.key %>

    - - - - - - - - - - -<% bulletin_category.bulletins.each do |post| %> - <%= render :partial => 'panel/announcement/back_end/bulletins/bulletins', :locals => {:post => post,:fact_check_allow=>false} %> -<% end %> -
    <%= t('bulletin.status') %><%= t('bulletin.category') %><%= t('bulletin.title') %><%= t('bulletin.postdate') %><%= t('bulletin.deadline') %><%= t('bulletin.action') %>
    \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/announcements/list_mine.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/announcements/list_mine.html.erb deleted file mode 100644 index 2bd98827..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/announcements/list_mine.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<% content_for :secondary do %> -<%= render :partial => '/panel/announcement/back_end/announcement_secondary' %> -<% end -%> - -<%= flash_messages %> - -
    -
    -
    -
    -
    -<%= render :partial => "list_table", :collection => @bulletin_categorys ,:as => :bulletin_category%> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb index 2a400a1f..ac04408b 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb @@ -19,19 +19,19 @@