nccu_com_vnccu_program

This commit is contained in:
spen 2015-02-02 11:08:13 +08:00
commit 6993ed3dac
83 changed files with 2177 additions and 0 deletions

14
Gemfile Normal file
View File

@ -0,0 +1,14 @@
source "https://rubygems.org"
# Declare your gem's dependencies in nccu_com_vnccu_program.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
# To use debugger
# gem 'debugger'

87
Gemfile.lock Normal file
View File

@ -0,0 +1,87 @@
PATH
remote: .
specs:
nccu_com_vnccu_program (0.0.1)
rails (~> 4.1.9)
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.1.9)
actionpack (= 4.1.9)
actionview (= 4.1.9)
mail (~> 2.5, >= 2.5.4)
actionpack (4.1.9)
actionview (= 4.1.9)
activesupport (= 4.1.9)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.9)
activesupport (= 4.1.9)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.9)
activesupport (= 4.1.9)
builder (~> 3.1)
activerecord (4.1.9)
activemodel (= 4.1.9)
activesupport (= 4.1.9)
arel (~> 5.0.0)
activesupport (4.1.9)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
arel (5.0.1.20140414130214)
builder (3.2.2)
erubis (2.7.0)
hike (1.2.3)
i18n (0.7.0)
json (1.8.2)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.4.3)
minitest (5.5.1)
multi_json (1.10.1)
rack (1.5.2)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.1.9)
actionmailer (= 4.1.9)
actionpack (= 4.1.9)
actionview (= 4.1.9)
activemodel (= 4.1.9)
activerecord (= 4.1.9)
activesupport (= 4.1.9)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.9)
sprockets-rails (~> 2.0)
railties (4.1.9)
actionpack (= 4.1.9)
activesupport (= 4.1.9)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.2.4)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
nccu_com_vnccu_program!
sqlite3

20
MIT-LICENSE Normal file
View File

@ -0,0 +1,20 @@
Copyright 2015 YOURNAME
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3
README.rdoc Normal file
View File

@ -0,0 +1,3 @@
= NccuComVnccuProgram
This project rocks and uses MIT-LICENSE.

32
Rakefile Normal file
View File

@ -0,0 +1,32 @@
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'NccuComVnccuProgram'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task default: :test

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the nccu_com_vnccu_program controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,44 @@
# encoding: utf-8
class Admin::NccuComVnccuProgramSongListsController < OrbitAdminController
include Admin::NccuComVnccuProgramsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
def initialize
super
@app_title = "nccu_com_vnccu_program"
end
def edit
params[:controller] = "admin/nccu_com_vnccu_programs"
@song_list = ComVnccuProgramSongList.find(params[:id])
@nccu_com_vnccu_program = ComVnccuProgram.find(@song_list.com_vnccu_program_id)
end
def update
@song_list = ComVnccuProgramSongList.find(params[:id])
@song_list.update_attributes(song_list_params)
redirect_to "/admin/nccu_com_vnccu_programs/#{@song_list.com_vnccu_program_id}/song_list"
end
def destroy
@song_list = ComVnccuProgramSongList.find(params[:id])
@program_id = @song_list.com_vnccu_program_id
@song_list.destroy
redirect_to "/admin/nccu_com_vnccu_programs/#{@program_id}/song_list"
end
private
def song_list_params
params.require(:com_vnccu_program_song_list).permit!
end
end

View File

@ -0,0 +1,118 @@
# encoding: utf-8
class Admin::NccuComVnccuProgramsController < OrbitAdminController
include Admin::NccuComVnccuProgramsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :set_nccu_com_vnccu_program, only: [:edit, :destroy, :song_list]
def initialize
super
@app_title = "nccu_com_vnccu_program"
end
def filter_fields(categories)
{
:category=>categories.map{|c| {:title=>(c.title.blank? ? " " : c.title), :id=>c.id}}
}
end
def index
@categories = @module_app.categories.enabled
@filter_fields = filter_fields(@categories)
@table_fields = [:category, 'nccu_com_vnccu_program.year', 'nccu_com_vnccu_program.semester', 'nccu_com_vnccu_program.program_name', 'nccu_com_vnccu_program.week', 'nccu_com_vnccu_program.hour', 'nccu_com_vnccu_program.host']
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"}
@nccu_com_vnccu_programs = ComVnccuProgram.order_by(sort).with_categories(filters("category"))
@nccu_com_vnccu_programs = search_data(@nccu_com_vnccu_programs,[:title]).page(params[:page]).per(10)
if request.xhr?
render :partial => "index"
end
end
def new
@nccu_com_vnccu_program = ComVnccuProgram.new
@hosts = @nccu_com_vnccu_program.get_hosts
end
def create
nccu_com_vnccu_program = ComVnccuProgram.new(com_vnccu_program)
nccu_com_vnccu_program.create_user_id = current_user.id
nccu_com_vnccu_program.update_user_id = current_user.id
nccu_com_vnccu_program.save
redirect_to params['referer_url']
end
def edit
if can_edit_or_delete?(@nccu_com_vnccu_program)
@categories = @module_app.categories.enabled
@hosts = @nccu_com_vnccu_program.get_hosts
else
render_401
end
end
def update
nccu_com_vnccu_program = ComVnccuProgram.find(params[:id])
nccu_com_vnccu_program.update_attributes(com_vnccu_program)
redirect_to params['referer_url']
end
def destroy
@nccu_com_vnccu_program.destroy
redirect_to "/admin/nccu_com_vnccu_programs"
end
def export
@nccu_com_vnccu_programs = ComVnccuProgram.where(:year=>params[:year], :semester=>params[:semester])
@year = params[:year]
@semester = params[:semester]
respond_to do |format|
format.xlsx {
response.headers['Content-Disposition'] = 'attachment; filename="export.xlsx"'
}
end
end
def export_data
end
def song_list
@song_lists = ComVnccuProgramSongList.where(:com_vnccu_program_id => @nccu_com_vnccu_program.id).page(params[:page]).per(10)
end
def edit_com_vnccu_program_song_list
@com_vnccu_program_song_list = ComVnccuProgramSongList.find(params[:id])
@com_vnccu_program = ComVnccuProgram.find(@com_vnccu_program_song_list.com_vnccu_program_id)
end
def delete_com_vnccu_program_song_list
@com_vnccu_program_song_list = ComVnccuProgramSongList.find(params[:id])
@com_vnccu_program_id = @com_vnccu_program_song_list.com_vnccu_program_id
@com_vnccu_program_song_list.destroy
redirect_to "/admin/nccu_com_vnccu_programs/@nccu_com_vnccu_program_id.to_s/com_vnccu_program_song_list"
end
private
def set_nccu_com_vnccu_program
@nccu_com_vnccu_program = ComVnccuProgram.find(params[:id])
end
def com_vnccu_program
params.require(:com_vnccu_program).permit!
end
end

View File

@ -0,0 +1,63 @@
class NccuComVnccuProgramsController < ApplicationController
include ApplicationHelper
helper MemberHelper
include SimpleCaptcha::ControllerHelpers
def index
programs = ComVnccuProgram.where(:is_hidden=>false)
moduleapp = ModuleApp.find_by(:key => "nccu_com_vnccu_program")
program_categorys = Category.where(:module_app_id=>moduleapp.id).asc(:created_at)
{
"programs" => programs,
"program_categorys" => program_categorys
}
end
def show_data
params = OrbitHelper.params
program = ComVnccuProgram.find(params[:no])
{
"program" => program
}
end
def vod
programs = ComVnccuProgram.where(:open_song=>true,:is_hidden=>false).asc(:week)
song_list = ComVnccuProgramSongList.new
{
"programs" => programs,
"song_list" => song_list
}
end
def create
@song_list = ComVnccuProgramSongList.new(song_list_params)
if simple_captcha_valid? && @song_list.save
redirect_to "#{ OrbitHelper.url_to_show("")}?method=send_ok"
else
redirect_to "#{ OrbitHelper.url_to_show("")}", :notice => t('recaptcha.errors.verification_failed')
end
end
def send_ok
end
def song_list_params
params.require(:com_vnccu_program_song_list).permit!
end
end

View File

@ -0,0 +1,31 @@
module Admin::NccuComVnccuProgramsHelper
def page_for_program(program=nil)
ann_page = nil
pages = Page.where(:module=>'nccu_com_vnccu_program')
pages.each do |page|
if page.categories.count ==1
if page.categories.include?(program.category.id.to_s)
ann_page = page
end
end
break if !ann_page.nil?
end
if ann_page.nil?
pages.each do |page|
if page.categories.include?(program.category.id.to_s)
ann_page = page
end
break if !ann_page.nil?
end
end
ann_page = pages.first if ann_page.nil?
if !program.blank?
request.protocol+(request.host_with_port+'/'+I18n.locale.to_s+ann_page.url).gsub('//','/') rescue "/"
else
request.protocol+(request.host_with_port+'/'+I18n.locale.to_s+ann_page.url).gsub('//','/') rescue "/"
end
end
end

View File

@ -0,0 +1,50 @@
# encoding: utf-8
class ComVnccuProgram
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitModel::Impression
include OrbitCategory::Categorizable
field :year
field :semester
field :program_name
field :open_song, :type => Boolean, :default => false
field :week
field :hour
field :description
field :host, :type => Array
field :create_user_id
field :update_user_id
has_many :com_vnccu_program_links, :autosave => true, :dependent => :destroy
has_many :com_vnccu_program_song_lists, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :com_vnccu_program_links, :allow_destroy => true
accepts_nested_attributes_for :com_vnccu_program_song_lists, :allow_destroy => true
# scope :can_display, ->{any_of({:sign_start_date.lt=>Time.now, :sign_end_date.gt=>Time.now},{:sign_start_date.lt=>Time.now, :sign_end_date=>nil}).order_by([:is_top, :desc])}
def get_hosts
@role = Role.where(:key=>"host").first
@nickname_field = AttributeField.where(:key => 'nickname', :role_id => @role).first
@values = AttributeValue.where(:attribute_field_id => @nickname_field ).collect{|t|t[:val]}.join('-').split('-')
return @values
end
def get_hosts_name(hosts=nil)
return hosts.join(",") if !hosts.blank?
end
end

View File

@ -0,0 +1,25 @@
# encoding: utf-8
require 'uri'
class ComVnccuProgramLink
include Mongoid::Document
include Mongoid::Timestamps
field :url
field :title
belongs_to :com_vnccu_program
before_validation :add_http
# validates :url, :presence => true, :format => /\A(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?\Z/i
protected
def add_http
unless self.url[/^http:\/\//] || self.url[/^https:\/\//]
self.url = 'http://' + self.url
end
end
end

View File

@ -0,0 +1,19 @@
# encoding: utf-8
class ComVnccuProgramSongList
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :song
field :singer
field :vod_partner
field :email
field :description
field :play_status , :type => Boolean , :default => false
field :play_time
belongs_to :com_vnccu_program
end

View File

@ -0,0 +1,66 @@
<%= form_for @song_list, url: admin_nccu_com_vnccu_program_song_list_path(@song_list), html: {class: "form-horizontal main-forms"} do |f| %>
<fieldset>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Language -->
<div class="tab-content">
<!-- Title -->
<div class="control-group">
<label class="control-label muted"><%= t('nccu_com_vnccu_program.program_name') %></label>
<div class="controls">
<%= @nccu_com_vnccu_program.program_name %>
</div>
</div>
<!-- paly status -->
<div class="control-group">
<label class="control-label muted"><%= t('vod.play_status') %></label>
<div class="controls">
<label class="radio inline">
<%= f.radio_button :play_status, "yes", checked: @song_list.play_status == true ? true : false %><%= t(:yes_) %>
</label>
<label class="radio inline">
<%= f.radio_button :play_status, "no", checked: @song_list.play_status == false ? true : false %><%= t("nccu_com_vnccu_program.no_") %>
</label>
</div>
</div>
<!-- paly time -->
<div class="control-group">
<label class="control-label muted"><%= t("vod.play_time") %></label>
<div class="controls">
<%= f.text_field :play_time %>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%#= get_referer_url[:action] rescue "" %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), "/admin/nccu_com_vnccu_programs/#{@nccu_com_vnccu_program.id}/song_list", :class=>"btn" %>
</div>
</fieldset>
<% end %>

View File

@ -0,0 +1,203 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @nccu_com_vnccu_program.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- year -->
<div class="control-group">
<label class="control-label muted"><%= t("nccu_com_vnccu_program.year") %></label>
<div class="controls">
<%= select_year((@nccu_com_vnccu_program.year ? @nccu_com_vnccu_program.year.to_i : DateTime.now.year), {:start_year => (DateTime.now.year - 1911), :end_year => (2014 - 1911)}, {:name => 'com_vnccu_program[year]', :class => "span1"} ) %>
</div>
</div>
<!-- semester -->
<div class="control-group">
<label class="control-label muted"><%= t('nccu_com_vnccu_program.semester') %></label>
<div class="controls">
<%= f.select :semester, (1..2).each{|a|[a,a]} %>
</div>
</div>
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= select_category(f, @module_app) %>
</div>
</div>
<!-- program name -->
<div class="control-group">
<label class="control-label muted"><%= t("nccu_com_vnccu_program.program_name") %></label>
<div class="controls">
<%= f.text_field :program_name %> (半形空白二格前台顯示為換行)
</div>
</div>
<!-- open song -->
<div class="control-group">
<label class="control-label muted"><%= t('nccu_com_vnccu_program.open_song') %></label>
<div class="controls">
<label class="radio inline">
<%= f.radio_button :open_song, "yes", checked: @nccu_com_vnccu_program.open_song == true ? true : false %><%= t(:yes_) %>
</label>
<label class="radio inline">
<%= f.radio_button :open_song, "no", checked: @nccu_com_vnccu_program.open_song == false ? true : false %><%= t("nccu_com_vnccu_program.no_") %>
</label>
</div>
</div>
<!-- week -->
<div class="control-group">
<label class="control-label muted"><%= t('nccu_com_vnccu_program.week') %></label>
<div class="controls">
<%= f.select :week, (1..7).collect{|a|[t("program_weeks.week#{a}"),a]} %>
</div>
</div>
<!-- hour -->
<div class="control-group">
<label class="control-label muted"><%= t("nccu_com_vnccu_program.hour") %></label>
<div class="controls">
<%= f.text_field :hour %> ( 請輸入四碼數字 )
</div>
</div>
<!-- description -->
<div class="control-group">
<label class="control-label muted"><%= t("nccu_com_vnccu_program.description") %></label>
<div class="controls">
<%= f.text_area :description %>
</div>
</div>
<!-- host -->
<div class="control-group">
<label class="control-label muted"><%= t("nccu_com_vnccu_program.host") %></label>
<div class="controls">
<% @hosts.each do |t| %>
<label class="checkbox inline">
<input type="checkbox" name="com_vnccu_program[host][]" value="<%=t%>" <%=(!@nccu_com_vnccu_program.host.blank? and @nccu_com_vnccu_program.host.include?(t)) ? "checked" : "" %> ><%= t %>
</label>
<% end %>
</div>
</div>
</div>
</div>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t("nccu_com_vnccu_program.link") %></label>
<div class="controls add-input">
<!-- Exist -->
<% if @nccu_com_vnccu_program && !@nccu_com_vnccu_program.com_vnccu_program_links.blank? %>
<div class="exist">
<% @nccu_com_vnccu_program.com_vnccu_program_links.each_with_index do |program_link, i| %>
<%= f.fields_for :com_vnccu_program_links, program_link do |f| %>
<%= render :partial => 'form_link', :object => program_link, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'com_vnccu_program_link_field_count', @nccu_com_vnccu_program.com_vnccu_program_links.count %>
<a id="add_link" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= get_referer_url[:action] rescue "" %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<input type="hidden" name="referer_url" value="<%= get_referer_url %>">
<%= link_to t('cancel'), admin_nccu_com_vnccu_programs_path, :class=>"btn" %>
</div>
<% content_for :page_specific_javascript do %>
<script>
$(function() {
$("#main-wrap").after("");
$(document).on('click', '#add_link', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_com_vnccu_program_links", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_link', f, :com_vnccu_program_links) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.tab-content').children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
formTip();
});
$(document).on('click', '.delete_link', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
$('#remind-check').prop('checked') ? '':$('.content-box').addClass('hide')
$('#remind-check').on('change', function() {
$(this).prop('checked') ? $('.content-box').removeClass('hide'):$('.content-box').addClass('hide')
})
});
</script>
<% end %>

View File

@ -0,0 +1,20 @@
<div class="input-prepend input-append start-line">
<span class="add-on icons-link" title="<%= t(:url) %>"></span>
<%= f.text_field :url, class: "input-large", placeholder: t(:url) %>
<span class="add-on icons-pencil" title="<%= t(:url_alt) %>"></span>
<span class="tab-content">
<%= f.text_field :title %>
</span>
<% if form_link.new_record? %>
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>

View File

@ -0,0 +1,47 @@
<script>
if(document.querySelectorAll("#orbit-bar").length==0) location.reload();
</script>
<table class="table main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |f| %>
<% if f == 'nccu_com_vnccu_program.program_name' %>
<th class='span5'><%= t(f)%></th>
<% else %>
<%= thead(f) %>
<% end %>
<% end %>
</tr>
</thead>
<tbody>
<% @nccu_com_vnccu_programs.each do |program| %>
<tr>
<td><%= program.category.title %></td>
<td><%= program.year %></td>
<td><%= program.semester %></td>
<td>
<a href="<%= page_for_program(program) %>?method=show_data&no=<%= program.id %>" target="_blank"><%= program.program_name %></a>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(program) %>
<li><a href="/admin/nccu_com_vnccu_programs/<%=program.id.to_s%>/edit"><%= t(:edit) %></a></li>
<li><a href="/admin/nccu_com_vnccu_programs/<%=program.id.to_s%>/song_list"><%= t("nccu_com_vnccu_program.song_list") %></a></li>
<li><a href="#" class="delete text-error" rel="/admin/nccu_com_vnccu_programs/<%=program.id.to_s%>"><%= t(:delete_) %></a></li>
<% end %>
</ul>
</div>
</td>
<td><%= program.week %></td>
<td><%= program.hour %></td>
<td><%= program.get_hosts_name(program.host) %></td>
</tr>
<% end %>
</tbody>
</table>
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, paginate(@nccu_com_vnccu_programs), class: "pagination pagination-centered"
end
%>

View File

@ -0,0 +1,5 @@
<%= form_for @nccu_com_vnccu_program, url: admin_nccu_com_vnccu_program_path(@nccu_com_vnccu_program), html: {class: "form-horizontal main-forms"} do |f| %>
<fieldset>
<%= render :partial => 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,45 @@
# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: "#{@year}年度 第#{@semester}學期 點歌單") do |sheet|
sheet.add_row ["#{@year}年度 第#{@semester}學期 點歌單"]
row = [t('nccu_com_vnccu_program.program_name')]
row << t('vod.time')
row << t('vod.name')
row << t('vod.singer')
row << t('vod.vod_partner')
row << t('vod.email')
row << t('vod.description')
row << t('vod.play_status')
row << t('vod.play_time')
sheet.add_row row
@nccu_com_vnccu_programs.each do |nccu_com_vnccu_program|
ComVnccuProgramSongList.where(:com_vnccu_program_id => nccu_com_vnccu_program.id).each do |song_list|
row2 = []
row2 << "#{nccu_com_vnccu_program[:program_name]} "
row2 << "#{format_value song_list.created_at} "
row2 << "#{song_list[:name]} "
row2 << "#{song_list[:singer]} "
row2 << "#{song_list[:vod_partner]} "
row2 << "#{song_list[:email]} "
row2 << "#{song_list[:description]} "
row2 << "#{song_list[:play_status]} "
row2 << "#{song_list[:play_time]} "
sheet.add_row row2
end
end
end

View File

@ -0,0 +1,36 @@
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "lib/main-forms.css" %>
<% end -%>
<%= form_tag export_admin_nccu_com_vnccu_programs_path(format: "xlsx"), :multipart => true , :class=>"form-horizontal main-forms", :id=>"vod-forms" do %>
<fieldset>
<div id="basic-area" class="input-area">
<div class="attributes">
<div class="attributes-header clearfix">
<h4><%= t("nccu_com_vnccu_program.export") %></h4>
</div>
<!-- year -->
<div class="control-group">
<label class="control-label muted"><%= t("nccu_com_vnccu_program.year") %></label>
<div class="controls">
<%= select_year(DateTime.now.year, {:start_year => (DateTime.now.year - 1911), :end_year => (2014 - 1911)}, {:name => 'year', :class => "span1"} ) %>
</div>
</div>
<!-- semester -->
<div class="control-group">
<label class="control-label muted"><%= t('nccu_com_vnccu_program.semester') %></label>
<div class="controls">
<%= select_tag "semester", options_for_select(['1','2']) %>
</div>
</div>
</div>
</div>
<div class="form-actions">
<%= submit_tag t('nccu_com_vnccu_program.export') , :class=>"btn btn-default" %>
</div>
</fieldset>
<% end -%>

View File

@ -0,0 +1,6 @@
<%= render_filter @filter_fields, "index_table" %>
<span id="index_table">
<%= render 'index'%>
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>

View File

@ -0,0 +1,5 @@
<%= form_for @nccu_com_vnccu_program, url: admin_nccu_com_vnccu_programs_path, html: {class: "form-horizontal main-forms"} do |f| %>
<fieldset>
<%= render :partial => 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,52 @@
<span id="index_table">
<script>
if(document.querySelectorAll("#orbit-bar").length==0) location.reload();
</script>
<h4><%= @nccu_com_vnccu_program.program_name %></h4>
<table class="table main-list">
<thead>
<tr class="sort-header">
<th class='span2'><%= t('vod.time')%></th>
<th class='span2'><%= t('vod.name')%></th>
<th class='span2'><%= t('vod.song')%></th>
<th class='span2'><%= t('vod.singer')%></th>
<th class='span2'><%= t('vod.vod_partner')%></th>
<th class='span2'><%= t('vod.email')%></th>
<th class='span2'><%= t('vod.play_status')%></th>
</tr>
</thead>
<tbody>
<% @song_lists.each do |song_list| %>
<tr>
<td><%= format_value song_list.created_at %></td>
<td>
<%= song_list.name %>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(song_list) %>
<li><a href="#" class="delete text-error" rel="/admin/nccu_com_vnccu_program_song_lists/<%=song_list.id.to_s%>"><%= t(:delete_) %></a></li>
<% end %>
</ul>
</div>
</td>
<td><%= song_list.song %></td>
<td><%= song_list.singer %></td>
<td><%= song_list.vod_partner %></td>
<td><%= song_list.email %></td>
<td><a href="/admin/nccu_com_vnccu_program_song_lists/<%=song_list.id.to_s%>/edit" class="btn"><%= t(:edit) %></a></td>
</tr>
<% end %>
</tbody>
</table>
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, paginate(@song_lists), class: "pagination pagination-centered"
end
%>
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>

View File

@ -0,0 +1,42 @@
<% # encoding: utf-8 %>
<%
data = action_data
@program_categorys = data["program_categorys"]
%>
<center>節目表</center>
<table class="table table-bordered program">
<tbody>
<tr>
<td> </td>
<% (1..7).each do |a| %>
<th><%= t("program_weeks.week#{a}") %><br /><%= t("program_weeks_en.week#{a}") %></td>
<% end %>
</tr>
<% @program_categorys.each do |program_category| %>
<tr>
<td class="program_category"><%= program_category.title.gsub(' ', '<br />').html_safe %></td>
<% (1..7).each do |a| %>
<td align="center">
<%
ComVnccuProgram.where(:is_hidden=>false, :week=>"#{a}", :category_id=>program_category.id).collect do |t|
%>
<a href="?method=show_data&no=<%= t.id %>" target="_blank"><%= t.program_name.gsub(' ', '<br />').html_safe %></a>
<% end %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<style>
.program.table td,
.program.table th {
text-align: center;
font-size: 12px;
padding: 12px 0;
}
</style>

View File

@ -0,0 +1,7 @@
<% # encoding: utf-8 %>
<%
data = action_data
%>
感謝您的點歌,我們將盡快為您安排,謝謝

View File

@ -0,0 +1,4 @@
<% # encoding: utf-8 %>
<%
data = action_data
%>

View File

@ -0,0 +1,49 @@
<% # encoding: utf-8 %>
<%
data = action_data
@program = data["program"]
%>
<table class="table table-striped nccu_com_vnccu_program-show-table">
<tbody >
<tr>
<th class="nccu_com_vnccu_program-title-field"><%= t(:category) %></th>
<td class="nccu_com_vnccu_program-title-value"><%= @program.category.title %></td>
</tr>
<tr>
<th class="nccu_com_vnccu_program-title-field"><%= t('nccu_com_vnccu_program.program_name') %></th>
<td class="nccu_com_vnccu_program-title-value"><%= @program.program_name %></td>
</tr>
<tr>
<th class="nccu_com_vnccu_program-title-field"><%= t('nccu_com_vnccu_program.week') %></th>
<td class="nccu_com_vnccu_program-title-value"><%= t("program_weeks.week#{@program.week}") %></td>
</tr>
<tr>
<th class="nccu_com_vnccu_program-title-field"><%= t('nccu_com_vnccu_program.hour') %></th>
<td class="nccu_com_vnccu_program-title-value"><%= @program.hour %></td>
</tr>
<tr>
<th class="nccu_com_vnccu_program-title-field"><%= t('nccu_com_vnccu_program.host') %></th>
<td class="nccu_com_vnccu_program-title-value"><%= @program.get_hosts_name(@program.host) %></td>
</tr>
<tr>
<th class="nccu_com_vnccu_program-title-field"><%= t('nccu_com_vnccu_program.description') %></th>
<td class="nccu_com_vnccu_program-title-value"><%= nl2br(@program.description) %></td>
</tr>
<% if !@program.com_vnccu_program_links.blank? %>
<tr>
<th class="active-title-field"><%= t('nccu_com_vnccu_program.link') %></th>
<td class="active-title-value">
<% @program.com_vnccu_program_links.map do |link| %>
<%= link_to (link.title.blank? ? link.url : link.title), link.url, :target => '_blank' %><br />
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<br />
<%= link_to t(:close), 'javascript:window.close();', :class => 'btn btn-primary' %>

View File

@ -0,0 +1,95 @@
<% # encoding: utf-8 %>
<%
data = action_data
@programs = data["programs"]
@song_list = data["song_list"]
%>
<% flash.collect do |key, msg| %>
<% msg.each do |m|%>
<%=
content_tag :p do
content_tag :span, m, :class => [key, "alert alert-error in fade"]
end
%>
<% end %>
<% end %>
<%= form_for @song_list, url: nccu_com_vnccu_programs_path, html: {class: "content form-horizontal" , :id=>"new-vod"} do |f| %>
<fieldset>
<!-- Name -->
<div class="form-group">
<label for="name" class="col-sm-2 control-label">*<%= t('vod.name') %></label>
<div class="col-xs-5">
<%= f.text_field :name, :id=>'nccu_com_vnccu_program_name', :class=>"form-control", :placeholder=> t('vod.name'), :required => true %>
</div>
</div>
<!-- song -->
<div class="form-group">
<label for="song" class="col-sm-2 control-label">*<%= t('vod.song') %></label>
<div class="col-xs-5">
<%= f.text_field :song, :id=>'nccu_com_vnccu_program_song', :class=>"form-control", :placeholder=> t('vod.song'), :required => true %>
</div>
</div>
<!-- singer -->
<div class="form-group">
<label for="singer" class="col-sm-2 control-label">*<%= t('vod.singer') %></label>
<div class="col-xs-5">
<%= f.text_field :singer, :id=>'nccu_com_vnccu_program_singer', :class=>"form-control", :placeholder=> t('vod.singer'), :required => true %>
</div>
</div>
<!-- vod_partner -->
<div class="form-group">
<label for="vod_partner" class="col-sm-2 control-label">*<%= t('vod.vod_partner') %></label>
<div class="col-xs-5">
<%= f.text_field :vod_partner, :id=>'nccu_com_vnccu_program_vod_partner', :class=>"form-control", :placeholder=> t('vod.vod_partner'), :required => true %>
</div>
</div>
<div class="form-group">
<label for="com_vnccu_program" class="col-sm-2 control-label"><%= t('vod.program') %></label>
<div class="col-sm-10">
<%= f.select :com_vnccu_program_id, @programs.collect{|t| [ (t.hour+'-'+t.program_name+'-'+t.get_hosts_name(t.host)), t.id ]} %>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label"><%= t('vod.email') %></label>
<div class="col-sm-10">
<%= f.text_field :email, :class=>"input-medium form-control", :id=>'email', :placeholder=> t('vod.email') %>
</div>
</div>
<!-- description -->
<div class="form-group">
<label for="description" class="col-sm-2 control-label"><%= t('vod.description') %></label>
<div class="col-sm-10">
<%= f.text_area :description, rows: 5, :class=>"input-medium form-control", :placeholder=> t('vod.description') %>
</div>
</div>
<div class="form-group">
<label for="note" class="col-sm-2 control-label"><%= t('vod.recaptcha') %></label>
<div class="col-sm-10">
<%= show_simple_captcha %>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="hidden" name="referer_url" value="<%= request.original_url.split(request.env["HTTP_HOST"]).last %>">
<%= f.submit t('submit'), class: 'btn btn-primary', :id => 'button-mail' %>
<%= f.button t('cancel'), type: 'reset', class: 'btn' %>
</div>
</div>
</fieldset>
<% end %>

View File

@ -0,0 +1,33 @@
<style type="text/css">
.simple_captcha{border: 1px solid #ccc; padding: 5px !important;}
.simple_captcha,
.simple_captcha div{display: table;}
.simple_captcha .simple_captcha_field,
.simple_captcha .simple_captcha_image{
border: 1px solid #ccc;
margin: 0px 0px 2px 0px !important;
padding: 0px !important;
}
.simple_captcha .simple_captcha_image img{
margin: 0px !important;
padding: 0px !important;
width: 110px !important;
}
.simple_captcha .simple_captcha_label{font-size: 12px;}
.simple_captcha .simple_captcha_field input{
width: 150px !important;
font-size: 16px;
border: none;
background-color: #efefef;
}
</style>
<div class='simple_captcha'>
<div class='simple_captcha_image'>
<%= simple_captcha_options[:image] %>
</div>
<div class='simple_captcha_field'>
<%= simple_captcha_options[:field] %>
</div>
</div>

18
bin/rails Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/active/engine', __FILE__)
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
# require 'rails/all'
# require 'rails/engine/commands'
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
require 'rails/engine/commands'
require "mongoid/railtie"

60
config/locales/en.yml Normal file
View File

@ -0,0 +1,60 @@
en:
simple_captcha:
placeholder: ""
label: ""
module_name:
nccu_com_vnccu_program: 節目表
recaptcha:
errors:
verification_failed: 驗證碼錯誤
nccu_com_vnccu_program:
nccu_com_vnccu_program: 節目表
export: 匯出
year: 年度
semester: 學期
program_name: 節目名稱
week: 星期
hour: 時段
open_song: 是否開放點歌
description: 節目描述說明
no_:
host: 主持人
link: 集數
song_list: 點歌列表
frontend:
program: 節目表
program_weeks:
week1: 星期一
week2: 星期二
week3: 星期三
week4: 星期四
week5: 星期五
week6: 星期六
week7: 星期日
program_weeks_en:
week1: MONDAY
week2: TUESDAY
week3: WEDNESDAY
week4: THURSDAY
week5: FRIDAY
week6: Saturday
week7: Sunday
vod:
name: 點歌者姓名
song: 歌名
singer: 歌手名稱
program: 播放節目
vod_partner: 送歌對象
email: 點歌者email
description: 文字敘述
play_status: 播放狀態
play_time: 播放時間
recaptcha: 驗證碼

61
config/locales/zh_tw.yml Normal file
View File

@ -0,0 +1,61 @@
zh_tw:
simple_captcha:
placeholder: ""
label: ""
module_name:
nccu_com_vnccu_program: 節目表
recaptcha:
errors:
verification_failed: 驗證碼錯誤
nccu_com_vnccu_program:
nccu_com_vnccu_program: 節目表
export: 匯出
year: 年度
semester: 學期
program_name: 節目名稱
week: 星期
hour: 時段
open_song: 是否開放點歌
description: 節目描述說明
no_:
host: 主持人
link: 集數
song_list: 點歌列表
frontend:
program: 節目表
program_weeks:
week1: 星期一
week2: 星期二
week3: 星期三
week4: 星期四
week5: 星期五
week6: 星期六
week7: 星期日
program_weeks_en:
week1: MONDAY
week2: TUESDAY
week3: WEDNESDAY
week4: THURSDAY
week5: FRIDAY
week6: Saturday
week7: Sunday
vod:
time: 時間
name: 點歌者姓名
song: 歌名
singer: 歌手名稱
program: 播放節目
vod_partner: 送歌對象
email: 點歌者email
description: 文字敘述
play_status: 播放狀態
play_time: 播放時間
recaptcha: 驗證碼

26
config/routes.rb Normal file
View File

@ -0,0 +1,26 @@
Rails.application.routes.draw do
locales = Site.first.in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
resources :nccu_com_vnccu_programs do
collection do
get 'export_data'
post 'export'
end
member do
get 'song_list'
end
end
resources :nccu_com_vnccu_program_song_lists
end
resources :nccu_com_vnccu_programs
end
end

View File

@ -0,0 +1,4 @@
require "nccu_com_vnccu_program/engine"
module NccuComVnccuProgram
end

View File

@ -0,0 +1,45 @@
module NccuComVnccuProgram
class Engine < ::Rails::Engine
initializer "nccu_com_vnccu_program" do
OrbitApp.registration "NccuComVnccuProgram", :type => "ModuleApp" do
module_label "nccu_com_vnccu_program.nccu_com_vnccu_program"
base_url File.expand_path File.dirname(__FILE__)
authorizable
categorizable
frontend_enabled
data_count 1..20
side_bar do
head_label_i18n 'nccu_com_vnccu_program.nccu_com_vnccu_program', icon_class: "icon-music"
available_for "users"
active_for_controllers (['admin/nccu_com_vnccu_programs'])
head_link_path "admin_nccu_com_vnccu_programs_path"
context_link 'list_',
:link_path=>"admin_nccu_com_vnccu_programs_path" ,
:priority=>1,
:active_for_action=>{'admin/nccu_com_vnccu_programs'=>'index'},
:available_for => 'users'
context_link 'new_',
:link_path=>"new_admin_nccu_com_vnccu_program_path" ,
:priority=>2,
:active_for_action=>{'admin/nccu_com_vnccu_programs'=>'new'},
:available_for => 'sub_managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'nccu_com_vnccu_program').id}",
:priority=>3,
:active_for_action=>{'admin/nccu_com_vnccu_programs'=>'categories'},
:active_for_category => 'NccuComVnccuProgram',
:available_for => 'managers'
context_link 'nccu_com_vnccu_program.export',
:link_path=>"export_data_admin_nccu_com_vnccu_programs_path" ,
:priority=>3,
:active_for_action=>{'admin/nccu_com_vnccu_programs'=>'nccu_com_vnccu_export'},
:available_for => 'managers'
end
end
end
end
end

View File

@ -0,0 +1,3 @@
module NccuComVnccuProgram
VERSION = "0.0.1"
end

View File

@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :nccu_com_vnccu_program do
# # Task goes here
# end

View File

@ -0,0 +1,23 @@
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "nccu_com_vnccu_program/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "nccu_com_vnccu_program"
s.version = NccuComVnccuProgram::VERSION
s.authors = ["TODO: Your name"]
s.email = ["TODO: Your email"]
s.homepage = "TODO"
s.summary = "TODO: Summary of NccuComVnccuProgram."
s.description = "TODO: Description of NccuComVnccuProgram."
s.license = "MIT"
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
s.add_dependency "rails", "~> 4.1.9"
s.add_development_dependency "sqlite3"
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class NccuComVnccuProgramControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

28
test/dummy/README.rdoc Normal file
View File

@ -0,0 +1,28 @@
== README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.

6
test/dummy/Rakefile Normal file
View File

@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks

View File

View File

@ -0,0 +1,13 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .

View File

@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/

View File

@ -0,0 +1,5 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end

View File

@ -0,0 +1,2 @@
module ApplicationHelper
end

View File

View File

View File

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>

3
test/dummy/bin/bundle Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

4
test/dummy/bin/rails Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

4
test/dummy/bin/rake Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run

4
test/dummy/config.ru Normal file
View File

@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application

View File

@ -0,0 +1,23 @@
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
require "nccu_com_vnccu_program"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
end
end

View File

@ -0,0 +1,5 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)

View File

@ -0,0 +1,25 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3

View File

@ -0,0 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!

View File

@ -0,0 +1,37 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end

View File

@ -0,0 +1,78 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end

View File

@ -0,0 +1,39 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.static_cache_control = 'public, max-age=3600'
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end

View File

@ -0,0 +1,8 @@
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )

View File

@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View File

@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

View File

@ -0,0 +1,16 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

View File

@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf

View File

@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_dummy_session'

View File

@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end

View File

@ -0,0 +1,23 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"

View File

@ -0,0 +1,56 @@
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end

View File

@ -0,0 +1,22 @@
# Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
development:
secret_key_base: fd9dfca01dfbe0afc1a1e88d557c8555c86f86a28fe050e76132f72d5d7ccf89b729bb833ad8575374efb027d8f0ffaf4bc50191b7f724b7befa81164d6404e7
test:
secret_key_base: 70b1ecfd504b4f4fda85a1c3371bd0b5e0cc8dc5ba35003a82ffd01b4f595bbc6d51b1015b8bff02bd9e0f394afb86c6c8aebdbfc750e79c732141e5ebe3ef28
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

View File

0
test/dummy/log/.keep Normal file
View File

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<div>
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<div>
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<title>We're sorry, but something went wrong (500)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<div>
<h1>We're sorry, but something went wrong.</h1>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

View File

@ -0,0 +1,4 @@
require 'test_helper'
class NccuComVnccuProgramHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class NccuComVnccuProgramTest < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, NccuComVnccuProgram
end
end

18
test/test_helper.rb Normal file
View File

@ -0,0 +1,18 @@
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
require "rails/test_help"
# Filter out Minitest backtrace while allowing backtrace from other libraries
# to be shown.
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
# Load fixtures from the engine
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
end