├── log
└── .keep
├── app
├── mailers
│ └── .keep
├── models
│ ├── .keep
│ ├── concerns
│ │ └── .keep
│ └── course.rb
├── assets
│ ├── images
│ │ └── .keep
│ ├── javascripts
│ │ ├── application.js
│ │ ├── sessions
│ │ │ └── new.js
│ │ └── courses
│ │ │ └── front.js
│ └── stylesheets
│ │ └── application.scss
├── controllers
│ ├── concerns
│ │ └── .keep
│ ├── pages_controller.rb
│ ├── sessions_controller.rb
│ ├── application_controller.rb
│ ├── courses_controller.rb
│ └── update_courses_controller.rb
├── views
│ ├── courses
│ │ ├── remove_course.js.erb
│ │ ├── search.js.erb
│ │ ├── _course_table_body.html.haml
│ │ ├── front.html.haml
│ │ ├── _course_table.html.haml
│ │ ├── _list_of_courses.html.haml
│ │ ├── add_course.js.erb
│ │ ├── _search_result.html.haml
│ │ └── _form.html.haml
│ ├── shared
│ │ ├── _footer.html.haml
│ │ ├── _messages.html.haml
│ │ └── _header.html.haml
│ ├── pages
│ │ ├── landing_page.html.haml
│ │ ├── advice.html.haml
│ │ ├── useful_links.html.haml
│ │ └── about.html.haml
│ ├── update_courses
│ │ └── new.html.haml
│ ├── sessions
│ │ └── new.html.haml
│ └── layouts
│ │ └── application.html.erb
├── services
│ ├── course_search_service.rb
│ └── course_updates.rb
└── helpers
│ └── application_helper.rb
├── lib
├── assets
│ └── .keep
└── tasks
│ └── .keep
├── public
├── favicon.ico
├── robots.txt
├── 500.html
├── 422.html
└── 404.html
├── test
├── helpers
│ └── .keep
├── mailers
│ └── .keep
├── models
│ └── .keep
├── controllers
│ └── .keep
├── fixtures
│ └── .keep
├── integration
│ └── .keep
└── test_helper.rb
├── vendor
└── assets
│ ├── javascripts
│ ├── .keep
│ └── social.js
│ └── stylesheets
│ └── .keep
├── bin
├── bundle
├── rake
├── rails
├── spring
└── setup
├── config
├── boot.rb
├── initializers
│ ├── cookies_serializer.rb
│ ├── session_store.rb
│ ├── mime_types.rb
│ ├── filter_parameter_logging.rb
│ ├── backtrace_silencers.rb
│ ├── assets.rb
│ ├── wrap_parameters.rb
│ └── inflections.rb
├── environment.rb
├── database.yml
├── puma.rb
├── locales
│ └── en.yml
├── secrets.yml
├── application.rb
├── environments
│ ├── development.rb
│ ├── test.rb
│ └── production.rb
└── routes.rb
├── config.ru
├── db
├── migrate
│ ├── 20150526001645_add_index_to_institute_code_of_courses.rb
│ ├── 20150823032048_remove_several_tables.rb
│ ├── 20150507060955_create_basic_chineses.rb
│ ├── 20150507061712_create_general_educations.rb
│ ├── 20150507061640_create_citizenship_histories.rb
│ ├── 20150526000217_create_courses.rb
│ ├── 20150507061550_create_international_languages.rb
│ └── 20150621020208_add_columns_to_courses_tables.rb
├── seeds.rb
└── schema.rb
├── Rakefile
├── README.md
├── .gitignore
├── Gemfile
└── Gemfile.lock
/log/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/mailers/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/models/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/helpers/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/mailers/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/models/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/assets/images/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/controllers/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/integration/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/models/concerns/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/assets/javascripts/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/views/courses/remove_course.js.erb:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2 |
3 | require 'bundler/setup' # Set up gems listed in the Gemfile.
4 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Rails.application
5 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.action_dispatch.cookies_serializer = :json
4 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/app/views/shared/_footer.html.haml:
--------------------------------------------------------------------------------
1 | %footer.footer
2 | .container
3 | -#%p.text-muted Place sticky footer content here.
4 | -#= link_to "關於作者", "#"
5 | -#= link_to "關於本站", "#"
6 |
7 |
8 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.session_store :cookie_store, key: '_general_courses_helper_session'
4 |
--------------------------------------------------------------------------------
/app/views/courses/search.js.erb:
--------------------------------------------------------------------------------
1 | <% if @search_result %>
2 | $('#search-result').html("<%= escape_javascript (render partial: 'search_result', locals: {search_result: @search_result}) %>")
3 | <% end %>
4 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path("../spring", __FILE__)
4 | rescue LoadError
5 | end
6 | require_relative '../config/boot'
7 | require 'rake'
8 | Rake.application.run
9 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/db/migrate/20150526001645_add_index_to_institute_code_of_courses.rb:
--------------------------------------------------------------------------------
1 | class AddIndexToInstituteCodeOfCourses < ActiveRecord::Migration
2 | def change
3 | add_index :courses, :institute_code
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/views/shared/_messages.html.haml:
--------------------------------------------------------------------------------
1 | - flash.each do |name, msg|
2 | %div(class="alert alert-#{name}")
3 | %a.close(data-dismiss='alert') ×
4 | = content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String)
5 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path("../spring", __FILE__)
4 | rescue LoadError
5 | end
6 | APP_PATH = File.expand_path('../../config/application', __FILE__)
7 | require_relative '../config/boot'
8 | require 'rails/commands'
9 |
--------------------------------------------------------------------------------
/app/views/pages/landing_page.html.haml:
--------------------------------------------------------------------------------
1 | .intro-header
2 | .container
3 | .row
4 | .jumbotron
5 | %h1 成大選課小幫手
6 | %p 覺得學校課程系統找課不夠方便嗎?試試看選課小幫手吧!
7 | %p 讓你輕鬆找到空堂有什麼課
8 | = link_to "開始使用", setting_path, class: "btn btn-success btn-lg"
9 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 |
4 | require File.expand_path('../config/application', __FILE__)
5 |
6 | Rails.application.load_tasks
7 |
--------------------------------------------------------------------------------
/app/views/update_courses/new.html.haml:
--------------------------------------------------------------------------------
1 | .container
2 | .col-md-3
3 | = form_tag update_courses_path do
4 | .form-group
5 | = password_field_tag :password, nil, placeholder: 'password', class: 'form-control'
6 | = submit_tag '確認', class: 'btn btn-primary'
7 |
--------------------------------------------------------------------------------
/db/migrate/20150823032048_remove_several_tables.rb:
--------------------------------------------------------------------------------
1 | class RemoveSeveralTables < ActiveRecord::Migration
2 | def change
3 | drop_table :general_educations
4 | drop_table :basic_chineses
5 | drop_table :international_languages
6 | drop_table :citizenship_histories
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/app/controllers/pages_controller.rb:
--------------------------------------------------------------------------------
1 | class PagesController < ApplicationController
2 |
3 | def landing_page
4 | redirect_to front_path if user_has_finished_necessary_settings?
5 | end
6 |
7 | def about
8 | end
9 |
10 | def useful_links
11 | end
12 |
13 | def advice
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/app/views/courses/_course_table_body.html.haml:
--------------------------------------------------------------------------------
1 | - course_table_data(courses).each do |schedule_time, row|
2 | %tr
3 | %td
4 | - row.each do |day, data|
5 | - if data != {}
6 | %td.col-md-2.info{:class => "course-table-#{data[:id]}"}= data[:course_name].html_safe
7 | - else
8 | %td.col-md-2
9 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: postgresql
3 | encoding: unicode
4 | database: general_courses_helper_dev
5 | pool: 5
6 | username: Yulin
7 | password:
8 |
9 | test:
10 | adapter: postgresql
11 | encoding: unicode
12 | database: general_courses_helper_test
13 | pool: 5
14 | username: Yulin
15 | password:
16 |
17 |
--------------------------------------------------------------------------------
/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | ENV['RAILS_ENV'] ||= 'test'
2 | require File.expand_path('../../config/environment', __FILE__)
3 | require 'rails/test_help'
4 |
5 | class ActiveSupport::TestCase
6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
7 | fixtures :all
8 |
9 | # Add more helper methods to be used by all tests here...
10 | end
11 |
--------------------------------------------------------------------------------
/vendor/assets/javascripts/social.js:
--------------------------------------------------------------------------------
1 | (function(d, s, id) {
2 | var js, fjs = d.getElementsByTagName(s)[0];
3 | if (d.getElementById(id)) return;
4 | js = d.createElement(s); js.id = id;
5 | js.src = "//connect.facebook.net/zh_TW/sdk.js#xfbml=1&version=v2.3&appId=1666360613599510";
6 | fjs.parentNode.insertBefore(js, fjs);
7 | }(document, 'script', 'facebook-jssdk'));
8 |
--------------------------------------------------------------------------------
/app/views/pages/advice.html.haml:
--------------------------------------------------------------------------------
1 | .container
2 | .well
3 | %h2 建議或回報問題
4 | %p.lead
5 | 對「成大選課小幫手」有任何建議,或是發現 bug ,可以
6 | %a{:href => "https://www.facebook.com/yulin.sky.5"}直接聯繫我
7 | ,現在在當兵,我回來看到了會儘快回覆
8 | %p.lead
9 | 或者是您有能力解決 bug 或新增功能,也絕對歡迎發 pull request 給我!
10 | %h2 本站原始碼
11 | %div
12 | %p.lead
13 | %a{:href => "https://github.com/festime/NCKU-select-course-helper"} NCKU-select-course-helper
14 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast.
4 | # It gets overwritten when you run the `spring binstub` command.
5 |
6 | unless defined?(Spring)
7 | require "rubygems"
8 | require "bundler"
9 |
10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
11 | Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq }
12 | gem "spring", match[1]
13 | require "spring/binstub"
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | workers Integer(ENV['WEB_CONCURRENCY'] || 2)
2 | threads_count = Integer(ENV['MAX_THREADS'] || 5)
3 | threads threads_count, threads_count
4 |
5 | preload_app!
6 |
7 | rackup DefaultRackup
8 | port ENV['PORT'] || 3000
9 | environment ENV['RACK_ENV'] || 'development'
10 |
11 | on_worker_boot do
12 | # Worker specific setup for Rails 4.1+
13 | # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
14 | ActiveRecord::Base.establish_connection
15 | end
16 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | # Precompile additional assets.
10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11 | # Rails.application.config.assets.precompile += %w( search.js )
12 |
--------------------------------------------------------------------------------
/app/views/courses/front.html.haml:
--------------------------------------------------------------------------------
1 | .container
2 | .row
3 | .col-md-6
4 | = render partial: "course_table", locals: {courses: @courses}
5 | .col-md-6
6 | = render partial: "list_of_courses", locals: {courses: @courses}
7 | .row
8 | = render partial: "form", locals: {institute_code: @institute_code}
9 | .row
10 | #search-result
11 | %ul.nav.pull-left.scroll-top
12 | %li
13 | %a{:href => "#"}
14 | %i.glyphicon.glyphicon-chevron-up
15 | = javascript_tag do
16 | window.obligatory_courses = #{@courses.to_json.html_safe}
17 |
--------------------------------------------------------------------------------
/app/views/courses/_course_table.html.haml:
--------------------------------------------------------------------------------
1 | .table-responsive
2 | %table#course-table.table.table-bordered
3 | %thead
4 | %tr
5 | %th
6 | %th.monday.select-this-day-free-time 一
7 | %th.tuesday.select-this-day-free-time 二
8 | %th.wednesday.select-this-day-free-time 三
9 | %th.thursday.select-this-day-free-time 四
10 | %th.friday.select-this-day-free-time 五
11 | %tbody
12 | = render partial: "course_table_body", locals: {courses: courses}
13 | = link_to "恢復成預設課表", default_table_path, class: "btn btn-danger btn-lg"
14 |
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NCKU select course helper
2 |
3 | An open source website which grab courses data from NCKU official website. The site is created to help students in NCKU find courses easily.
4 |
5 | Visit [NCKU select course helper](https://ncku-select-course-helper.herokuapp.com)
6 |
7 | ## Main Features
8 | * Intuitive user interface
9 | * Better filter function to find courses
10 |
11 | ## Issues
12 | * The app can't automatically update space-available information of courses regularly.
13 | * The courses data need update manually.
14 |
15 | ## Version
16 | * Rails 4.2.0
17 | * Ruby 2.1.5
18 |
--------------------------------------------------------------------------------
/app/views/sessions/new.html.haml:
--------------------------------------------------------------------------------
1 | .container
2 | .col-md-3
3 | = form_tag setting_path do
4 | .form-group
5 | = label_tag :institute_code, "系"
6 | = select_tag(:institute_code, grouped_options_for_select(options_of_departments), class: "form-control")
7 | .form-group
8 | = label_tag :grade, "年級"
9 | = select_tag(:grade, options_for_select((1..4).map {|number| [number.to_s, number]}), class: "form-control")
10 | .form-group.two-classes-options
11 | .form-group.three-classes-options
12 | = submit_tag "確認", class: "btn btn-primary btn-lg"
13 |
--------------------------------------------------------------------------------
/db/migrate/20150507060955_create_basic_chineses.rb:
--------------------------------------------------------------------------------
1 | class CreateBasicChineses < ActiveRecord::Migration
2 | def change
3 | create_table :basic_chineses do |t|
4 | t.string :institute_code
5 | t.string :serial_number
6 | t.string :year
7 | t.string :category
8 | t.boolean :taught_in_english
9 | t.string :course_name
10 | t.integer :credits
11 | t.string :instructor
12 | t.string :selected
13 | t.string :space_available
14 | t.string :schedule
15 | t.string :classroom
16 | t.string :remark
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/db/migrate/20150507061712_create_general_educations.rb:
--------------------------------------------------------------------------------
1 | class CreateGeneralEducations < ActiveRecord::Migration
2 | def change
3 | create_table :general_educations do |t|
4 | t.string :institute_code
5 | t.string :serial_number
6 | t.string :year
7 | t.string :category
8 | t.boolean :taught_in_english
9 | t.string :course_name
10 | t.integer :credits
11 | t.string :instructor
12 | t.string :selected
13 | t.string :space_available
14 | t.string :schedule
15 | t.string :classroom
16 | t.string :remark
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/app/views/pages/useful_links.html.haml:
--------------------------------------------------------------------------------
1 | .container
2 | .well
3 | %div
4 | %p.lead
5 | 這裡列出一些對選課有用的連結,方便大家使用
6 | %ul
7 | %li
8 | %a{:href => 'http://course.ncku.edu.tw/course/'} 成大選課系統
9 | %li
10 | %a{:href => 'http://class-qry.acad.ncku.edu.tw/qry/'} 成大課程查詢系統
11 | %li
12 | %a{:href => 'http://cge.ncku.edu.tw/files/11-1024-13439.php'} 成大各系通識規定
13 | %li
14 | %a{:href => 'http://140.116.165.64/grachk/index.php'} 成大畢業預審系統
15 | %li
16 | %a{:href => 'https://www.facebook.com/groups/637099219647956/'} 成大選課懂ㄘ 懂ㄘ 社團
17 |
--------------------------------------------------------------------------------
/db/migrate/20150507061640_create_citizenship_histories.rb:
--------------------------------------------------------------------------------
1 | class CreateCitizenshipHistories < ActiveRecord::Migration
2 | def change
3 | create_table :citizenship_histories do |t|
4 | t.string :institute_code
5 | t.string :serial_number
6 | t.string :year
7 | t.string :category
8 | t.boolean :taught_in_english
9 | t.string :course_name
10 | t.integer :credits
11 | t.string :instructor
12 | t.string :selected
13 | t.string :space_available
14 | t.string :schedule
15 | t.string :classroom
16 | t.string :remark
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile '~/.gitignore_global'
6 |
7 | # Ignore bundler config.
8 | /.bundle
9 |
10 | # Ignore the default SQLite database.
11 | /db/*.sqlite3
12 | /db/*.sqlite3-journal
13 |
14 | # Ignore all logfiles and tempfiles.
15 | /log/*
16 | !/log/.keep
17 | /tmp
18 |
19 | # Ignore application configuration
20 | /config/application.yml
21 |
--------------------------------------------------------------------------------
/db/migrate/20150526000217_create_courses.rb:
--------------------------------------------------------------------------------
1 | class CreateCourses < ActiveRecord::Migration
2 | def change
3 | create_table :courses do |t|
4 | t.string :institute_code
5 | t.string :serial_number
6 | t.string :class_name
7 | t.string :year
8 | t.string :category
9 | t.boolean :taught_in_english
10 | t.string :course_name
11 | t.string :elective_or_required
12 | t.integer :credits
13 | t.string :instructor
14 | t.string :space_available
15 | t.string :schedule
16 | t.string :classroom
17 | t.string :remark
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/db/migrate/20150507061550_create_international_languages.rb:
--------------------------------------------------------------------------------
1 | class CreateInternationalLanguages < ActiveRecord::Migration
2 | def change
3 | create_table :international_languages do |t|
4 | t.string :institute_code
5 | t.string :serial_number
6 | t.string :year
7 | t.string :category
8 | t.boolean :taught_in_english
9 | t.string :course_name
10 | t.integer :credits
11 | t.string :instructor
12 | t.string :selected
13 | t.string :space_available
14 | t.string :schedule
15 | t.string :classroom
16 | t.string :remark
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/db/migrate/20150621020208_add_columns_to_courses_tables.rb:
--------------------------------------------------------------------------------
1 | class AddColumnsToCoursesTables < ActiveRecord::Migration
2 | def change
3 | add_column :basic_chineses, :class_name, :string
4 | add_column :basic_chineses, :elective_or_required, :string
5 | add_column :international_languages, :class_name, :string
6 | add_column :international_languages, :elective_or_required, :string
7 | add_column :general_educations, :class_name, :string
8 | add_column :general_educations, :elective_or_required, :string
9 | add_column :citizenship_histories, :class_name, :string
10 | add_column :citizenship_histories, :elective_or_required, :string
11 |
12 | add_column :courses, :selected, :string
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // compiled file.
9 | //
10 | // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11 | // about supported directives.
12 | //
13 | //= require jquery
14 | //= require bootstrap-sprockets
15 | //= require jquery_ujs
16 | //= require turbolinks
17 | //= require_tree .
18 | //= require social.js
19 |
--------------------------------------------------------------------------------
/app/views/courses/_list_of_courses.html.haml:
--------------------------------------------------------------------------------
1 | .form-group
2 | %h3= "目前修課"
3 | %table#course-list.table.table-striped
4 | %thead
5 | %tr
6 | %th
7 | %th 課名
8 | %th 學分
9 | %th 教師姓名
10 | %th 上課時間
11 | %th 上課地點
12 | %th 備註
13 | %tbody
14 | - courses.each do |course|
15 | %tr{:id => "list-#{course.id}"}
16 | %td
17 | = link_to '', remove_course_path(course_id: course.id), class: 'glyphicon glyphicon-remove', remote: true, method: :delete
18 | %td.col-md-2= course.course_name.html_safe
19 | %td.col-md-1= course.credits
20 | %td.col-md-2= course.instructor
21 | %td.col-md-2= better_schedule_text(course.schedule)
22 | %td.col-md-2= course.classroom
23 | %td.col-md-3= course.remark
24 |
25 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 |
4 | # path to your application root.
5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6 |
7 | Dir.chdir APP_ROOT do
8 | # This script is a starting point to setup your application.
9 | # Add necessary setup steps to this file:
10 |
11 | puts "== Installing dependencies =="
12 | system "gem install bundler --conservative"
13 | system "bundle check || bundle install"
14 |
15 | # puts "\n== Copying sample files =="
16 | # unless File.exist?("config/database.yml")
17 | # system "cp config/database.yml.sample config/database.yml"
18 | # end
19 |
20 | puts "\n== Preparing database =="
21 | system "bin/rake db:setup"
22 |
23 | puts "\n== Removing old logs and tempfiles =="
24 | system "rm -f log/*"
25 | system "rm -rf tmp/cache"
26 |
27 | puts "\n== Restarting application server =="
28 | system "touch tmp/restart.txt"
29 | end
30 |
--------------------------------------------------------------------------------
/app/views/courses/add_course.js.erb:
--------------------------------------------------------------------------------
1 | <% if @new_course %>
2 | var new_course = '
' +
3 | '| <%= link_to '', remove_course_path(course_id: @new_course.id), class: 'glyphicon glyphicon-remove', remote: true, method: :delete %> | ' +
4 | ' <%= @new_course.course_name.html_safe %> | ' +
5 | ' <%= @new_course.credits %> | ' +
6 | ' <%= @new_course.instructor %> | ' +
7 | ' <%= @new_course.schedule %> | ' +
8 | ' <%= @new_course.classroom %> | ' +
9 | ' <%= @new_course.remark %> | ' +
10 | '
'
11 |
12 | $('#course-table tbody').html("<%= escape_javascript (render partial: 'course_table_body', locals: {courses: @courses}) %>")
13 | $('#course-list tbody').append(new_course)
14 | <% else %>
15 | alert('這個時段已經有課囉');
16 | <% end %>
17 |
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rake secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | development:
14 | secret_key_base: 0473c500a9b97156a5213b9b865a79d4380214fc179823869ac459a63ea96f16d6b17edb39cd7268ff71f7de2079a6eb4bc309d201437610fca90010f646998e
15 |
16 | test:
17 | secret_key_base: 9bb92b88c3207a6fecd7319096c837f44cee890acadad20121ff80d8f40418dfcde73ec2647be591718476bd0a7c1bd0f61b29a816fd40750843b7654207c0ff
18 |
19 | # Do not keep production secrets in the repository,
20 | # instead read values from the environment.
21 | production:
22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
23 |
--------------------------------------------------------------------------------
/app/views/shared/_header.html.haml:
--------------------------------------------------------------------------------
1 | .navbar.navbar-default{:role => "navigation"}
2 | .container
3 | .navbar-header
4 | %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", :type => "button"}
5 | %span.sr-only Toggle navigation
6 | %span.icon-bar
7 | %span.icon-bar
8 | %span.icon-bar
9 | = link_to "成大選課小幫手", root_path, class: "navbar-brand"
10 | .navbar-collapse.collapse
11 | %ul.nav.navbar-nav.navbar-left
12 | %li
13 | = link_to "建議", advice_path
14 | %li
15 | = link_to "關於", about_path
16 | %li
17 | = link_to "有用連結", useful_links_path
18 | - if user_has_finished_necessary_settings?
19 | %li
20 | = link_to "清除系級設定", clear_setting_path, method: :delete
21 | %ul.nav.navbar-nav.navbar-right
22 | .fb-like{"data-action" => "like", "data-href" => "https://ncku-select-course-helper.herokuapp.com/", "data-layout" => "button_count", "data-share" => "true", "data-show-faces" => "true"}
23 | / /.nav-collapse
24 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 成大選課小幫手
5 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6 | <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7 | <%= csrf_meta_tags %>
8 |
9 |
10 |
11 |
12 |
13 |
15 |
20 |
21 |
22 | <%= render 'shared/header' %>
23 | <%= render 'shared/messages' %>
24 | <%= yield %>
25 | <%= render 'shared/footer' %>
26 |
27 |
28 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | require 'rails/all'
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module GeneralCoursesHelper
10 | class Application < Rails::Application
11 | # Settings in config/environments/* take precedence over those specified here.
12 | # Application configuration should go into files in config/initializers
13 | # -- all .rb files in that directory are automatically loaded.
14 |
15 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17 | # config.time_zone = 'Central Time (US & Canada)'
18 |
19 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21 | # config.i18n.default_locale = :de
22 |
23 | # Do not swallow errors in after_commit/after_rollback callbacks.
24 | config.active_record.raise_in_transactional_callbacks = true
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.scss:
--------------------------------------------------------------------------------
1 | // "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
2 | @import "bootstrap-sprockets";
3 | @import "bootstrap";
4 |
5 | .navbar {
6 | margin-bottom: 15px;
7 | }
8 |
9 | .footer {
10 | background-color: #f5f5f5;
11 | height: 45px;
12 | position: absolute;
13 | width: 100%;
14 | }
15 |
16 | .row {
17 | padding-top: 10px;
18 | padding-bottom: 10px;
19 | }
20 |
21 | .scroll-top {
22 | position: fixed;
23 | bottom: 50%;
24 | left: 0%;
25 | z-index: 100;
26 | font-size: 16px;
27 | border-top-left-radius: 3px;
28 | border-top-right-radius: 3px;
29 | /*background: #ffcc33;*/
30 | }
31 |
32 | .glyphicon-remove {
33 | color: red;
34 | }
35 |
36 | .glyphicon-plus {
37 | color: #337ab7;
38 | }
39 |
40 | .glyphicon-collapse-up {
41 | font-size: 20px;
42 | height: 25px;
43 | color: #337ab7;
44 | }
45 |
46 | .glyphicon-collapse-down {
47 | font-size: 20px;
48 | height: 25px;
49 | color: #337ab7;
50 | }
51 |
52 | .course-type {
53 | display: flex;
54 |
55 | h3 {
56 | margin-top: 0px;
57 | margin-bottom: 10px;
58 | }
59 | }
60 |
61 | .footer {
62 | margin-top: 20px;
63 | background-color: white;
64 | }
65 |
66 | .fb-like {
67 | margin-top: 14px;
68 | }
69 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7 | # Mayor.create(name: 'Emanuel', city: cities.first)
8 |
9 | departments = [
10 | '學士學程',
11 | '中文系',
12 | '外文系',
13 | '歷史系',
14 | '台文系',
15 | '數學系',
16 | '物理系',
17 | '化學系',
18 | '地科系',
19 | '光電系',
20 | '機械系',
21 | '化工系',
22 | '資源系',
23 | '材料系',
24 | '土木系',
25 | '水利系',
26 | '工科系',
27 | '能源學程',
28 | '系統系',
29 | '航太系',
30 | '環工系',
31 | '測量系',
32 | '醫工系',
33 | '會計系',
34 | '統計系',
35 | '工資系',
36 | '企管系',
37 | '交管系',
38 | '護理系',
39 | '醫技系',
40 | '醫學系',
41 | '物治系',
42 | '職治系',
43 | '藥學系',
44 | '法律系',
45 | '政治系',
46 | '經濟系',
47 | '心理系',
48 | '電機系',
49 | 'CSIE',
50 | '建築系',
51 | '都計系',
52 | '工設系',
53 | '生科系'
54 | ]
55 |
56 | general_education = [
57 | '外國語言',
58 | '基礎國文',
59 | '通識中心',
60 | '公民歷史'
61 | ]
62 |
63 | CourseUpdates.new.execute(departments[0..13])
64 | CourseUpdates.new.execute(departments[14..27])
65 | CourseUpdates.new.execute(departments[28..-1])
66 | CourseUpdates.new.execute(general_education)
67 |
--------------------------------------------------------------------------------
/app/views/pages/about.html.haml:
--------------------------------------------------------------------------------
1 | .container
2 | .well
3 | %h2 關於本站
4 | %div
5 | %p.lead
6 | 「成大選課小幫手」嘗試解決的是,每次新學期要選課時,
7 | 用學校的課程查詢系統找課、排課,對某些人(或者至少對我)
8 | 來說是個有點麻煩的過程,只不過想找自己想修的課而已,
9 | 卻得在好幾個分頁之間跳來跳去、用肉眼過濾資訊,
10 | 實在是有點費事...
11 | %p.lead
12 | 我大一大二的時候只有想法,沒有技術,只能紙上談兵,
13 | 最近一年多到資訊系修課、自學 Rails ,終於可以實際動手解決這個我耿耿於懷已久的問題
14 | %p.lead
15 | 但是,懂技術之後發現,因為我並不是學校負責選課和課程網站的人員,
16 | 我沒有取得同學修課歷史資料的權限,所以無法達成我心目中最理想的解決方案
17 | %p.lead
18 | 理想上,如果我知道一個同學過去修了哪些課、還有他的系的畢業規定,
19 | 那我就能在網站上直接列出他還要修哪些通識課、多少選修課,以達成畢業要求
20 | %p.lead
21 | 理想方案雖然無法實現,但找課的過程依然可以改善,學校課程查詢系統的篩選功能,
22 | 有改進的空間,所以這個網站就誕生了
23 | %h2 本站原始碼
24 | %div
25 | %p.lead
26 | %a{:href => "https://github.com/festime/NCKU-select-course-helper"} NCKU-select-course-helper
27 | %h2 作者
28 | %p.lead
29 | 我是 Yulin Chen ,統計 104 級,因為對本科系沒興趣,後來就開始到資訊系修課、學程式設計,
30 | 起初什麼都不懂,過了一陣子認知到程式和電腦科學非常廣,思考自己想走什麼路,
31 | 想到之前選課時對學校的課程查詢網站一直覺得 OOXX ,心想何不嘗試改善它呢?
32 | 這問題沒想像中容易,至少不是一個外行人摸個幾天就能做出來的,
33 | 所以最近半年多我主要聚焦在學習 web programming 和 Rails ,
34 | 成大選課小幫手算是到目前為止的一個學習成果吧
35 | %h3 我的 github 和部落格
36 | %p.lead
37 | %a{:href => 'https://github.com/festime'} 我的 github
38 | ,
39 | %a{:href => 'http://yulin-learn-web-dev.logdown.com'} 我的技術部落格
40 | ,歡迎互相交流
41 |
--------------------------------------------------------------------------------
/app/assets/javascripts/sessions/new.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function() {
2 | $('select#institute_code').on("change", function() {
3 | var department = $(this).find(":selected").text();
4 |
5 | if (department === "機械系" || department === "化工系" ||
6 | department === "電機系") {
7 | $('.two-classes-options').children('label').remove();
8 | $('.three-classes-options').children('label').remove();
9 | $('#class_name').remove();
10 | $('.three-classes-options').append('