Permalink
Browse files

Add features, fix bugs

  • Loading branch information...
dolzenko committed Mar 24, 2010
1 parent a219e12 commit 74df7c332be29ac59e9b85d88b12506fa3255022
Showing with 6,836 additions and 15 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 Gemfile
  3. +25 −1 app/controllers/application_controller.rb
  4. +1 −1 app/controllers/articles_controller.rb
  5. +6 −0 app/helpers/articles_helper.rb
  6. +2 −0 app/models/article.rb
  7. +10 −1 app/stylesheets/screen.sass
  8. +7 −0 app/views/articles/_article.html.haml
  9. +1 −7 app/views/articles/index.html.haml
  10. +5 −2 app/views/layouts/articles.html.haml
  11. +15 −0 config/initializers/relative_assets_paths.rb
  12. +2 −1 config/routes.rb
  13. +11 −0 db/migrate/20100323142951_add_parent_id_and_order_to_article.rb
  14. +7 −0 db/migrate/20100323145036_test_migration.rb
  15. +7 −0 db/migrate/20100323150701_test3.rb
  16. +17 −0 db/models/articles/48-annotatsiya/content.html.erb
  17. 0 db/models/articles/49-dopolnitelnye-materialy/content.html.erb
  18. 0 db/models/articles/50-dopolnitelnye-materialy/content.html.erb
  19. 0 db/models/articles/51-dopolnitelnye-materialy/content.html.erb
  20. 0 db/models/articles/52-dopolnitelnye-materialy/content.html.erb
  21. +3 −1 db/schema.rb
  22. +54 −0 lib/static_builder.rb
  23. +5 −0 public/javascripts/application.js
  24. +6,286 −0 public/javascripts/jquery.js
  25. +26 −0 vendor/plugins/acts_as_tree/README
  26. +22 −0 vendor/plugins/acts_as_tree/Rakefile
  27. +1 −0 vendor/plugins/acts_as_tree/init.rb
  28. +96 −0 vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb
  29. 0 vendor/plugins/acts_as_tree/test/abstract_unit.rb
  30. +219 −0 vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb
  31. 0 vendor/plugins/acts_as_tree/test/database.yml
  32. 0 vendor/plugins/acts_as_tree/test/fixtures/mixin.rb
  33. 0 vendor/plugins/acts_as_tree/test/fixtures/mixins.yml
  34. 0 vendor/plugins/acts_as_tree/test/schema.rb
  35. +3 −1 vendor/plugins/haml/init.rb
View
@@ -3,4 +3,5 @@ db/*.sqlite3
log/*.log
tmp/**/*
misc/
+build/
.idea/
View
@@ -6,3 +6,7 @@ gem 'mysql'
gem 'haml-edge'
gem 'mongrel'
gem "compass", "0.10.0.rc1"
+
+group :development do
+ gem "ruby-debug19"
+end
@@ -1,7 +1,31 @@
class ApplicationController < ActionController::Base
- protect_from_forgery
+ if Rails.env.production?
+ def self.caches_all_pages(*actions)
+ return unless perform_caching
+ options = actions.extract_options!
+ after_filter(options) do |c|
+ c.expire_page
+ c.cache_page
+ end
+ end
+ caches_all_pages
+ end
+
def default_url_options
{ :format => :html }
end
+
+ def url_for(options)
+ url = super(options)
+ if url =~ /^http/
+ url
+ else
+ relative_to_request(url)
+ end
+ end
+
+ def relative_to_request(absolute_path)
+ Pathname.new(absolute_path).relative_path_from(Pathname.new(File.dirname(request.path))).to_s
+ end
end
@@ -2,7 +2,7 @@ class ArticlesController < ApplicationController
# GET /articles
# GET /articles.xml
def index
- @articles = Article.all
+ @articles = Article.roots
respond_to do |format|
format.html # index.html.erb
@@ -6,4 +6,10 @@ def article_asset_path(path)
def article_image_tag(source, options = {})
image_tag(article_asset_path(source), options)
end
+
+ def parent_select_choices
+ choices = []
+
+ Article.root
+ end
end
View
@@ -7,6 +7,8 @@ class Article < ActiveRecord::Base
before_save :sync_filesystem_attrs
after_create :init_filesystem_attrs
validate :title => :presence
+
+ acts_as_tree :order => :position
def content
if file = filesystem_attr_file
@@ -45,6 +45,10 @@ body.three-col
@import compass/utilities.sass
+.module
+ margin:
+ left: 2em
+
.article
font:
family: Times New Roman
@@ -88,4 +92,9 @@ body.three-col
.attention
font:
weight: bold
- style: italic
+ style: italic
+
+
+.articles.index
+ .controls
+ display: none
@@ -0,0 +1,7 @@
+.item.section
+ = link_to article.title, article
+ - if Rails.env.development?
+ .controls
+ = link_to 'Edit', edit_article_path(article)
+ = link_to 'Destroy', article, :confirm => 'Are you sure?', :method => :delete
+ .item.module= render article.children
@@ -1,10 +1,4 @@
-- for article in @articles
- %div= link_to article.title, article
- - if Rails.env.development?
- = link_to 'Edit', edit_article_path(article)
- = link_to 'Destroy', article, :confirm => 'Are you sure?', :method => :delete
- %br
- %br
+!= render @articles
- if Rails.env.development?
= link_to 'New article', new_article_path
@@ -1,12 +1,15 @@
!!!
-%html
+%html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "ru", :lang => "ru"}
%head
+ %meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=UTF-8'}
%title== Articles: #{ controller.action_name }
= stylesheet_link_tag 'compiled/screen.css', :media => 'screen, projection'
+ = javascript_include_tag %w(jquery application)
= csrf_meta_tag
%body.bp
-if notice.present?
%p.notice= notice
- = yield
+ %div{:class => page_class}
+ = yield
@@ -0,0 +1,15 @@
+module RelativeAssetsPaths
+ private
+
+ def rewrite_asset_path(source)
+ relative_to_request(source)
+ end
+
+ def relative_to_request(absolute_path)
+ Pathname.new(absolute_path).relative_path_from(Pathname.new(File.dirname(request.path))).to_s
+ end
+end
+
+ActionView::Base.class_eval do
+ include RelativeAssetsPaths
+end
View
@@ -50,7 +50,8 @@
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
- # root :to => "welcome#index"
+ # root :to => "articles#index"
+ match "index.:format" => "articles#index"
# See how all your routes lay out with "rake routes"
@@ -0,0 +1,11 @@
+class AddParentIdAndOrderToArticle < ActiveRecord::Migration
+ def self.up
+ change_table :articles do |t|
+ t.belongs_to :parent
+ t.integer :position, :default => 0
+ end
+ end
+
+ def self.down
+ end
+end
@@ -0,0 +1,7 @@
+class TestMigration < ActiveRecord::Migration
+ def self.up
+ end
+
+ def self.down
+ end
+end
@@ -0,0 +1,7 @@
+class Test3 < ActiveRecord::Migration
+ def self.up
+ end
+
+ def self.down
+ end
+end
@@ -0,0 +1,17 @@
+<div>Электронное учебное пособие «Развитие научных исследований туристской деятельности в России: 1930 - 2010 гг.»
+ представляет собой обязательный литературный источник новой учебной дисциплины «История и методология туризмоведения»,
+ включенной в 2010 г. в учебный план специальности 100 201 «Туризм» на геолого-географическом факультете Южного
+ федерального университета.
+</div>
+<div>Впервые в отечественной литературе, как научного, так и учебного характера, в пособии представлено развитие научных
+ исследований в области туризма в СССР и Российской Федерации за 80 лет, начиная с первых работ Центрального
+ государственного института курортологии по изучению физиологии туристских путешествий с активными средствами
+ передвижения.
+</div>
+<div>Авторы рассматривают как происходило развитие в изучении экономических и исторических аспектов туризма, становление
+ и эволюцию рекреационной географии, современные прикладные научно-исследовательские направления работ в целях
+ дальнейшего совершенствования российской индустрии туризма.
+</div>
+<div>Учебное пособие может быть использовано как студентами, обучающимися по специальности «Туризм», так и по
+ специальности «Социально-культурный сервис и туризм» при изучении дисциплин «Основы туризма» и «История туризма».
+</div>
View
@@ -9,13 +9,15 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20100322103740) do
+ActiveRecord::Schema.define(:version => 20100323150701) do
create_table "articles", :force => true do |t|
t.string "title"
t.text "content"
t.datetime "created_at"
t.datetime "updated_at"
+ t.integer "parent_id"
+ t.integer "position", :default => 0
end
end
View
@@ -0,0 +1,54 @@
+require "fileutils"
+require "rails/console/app"
+
+class StaticBuilder
+ include Rails.application.routes.url_helpers
+
+ def self.build
+ ActionController::Base.page_cache_directory = "build" # ???
+ new.build
+ end
+
+ def build
+ purge_build_dir
+
+ cache_paths
+
+ copy_public
+
+ cleanup_unused
+ end
+
+ def build_dir
+ Rails.root + "build"
+ end
+
+ def cache_paths
+ paths = []
+ paths << "/index"
+ paths << "/articles"
+ paths += Article.all.map { |a| article_path(a) }
+ paths.each(&method(:get))
+ end
+
+ def purge_build_dir
+ puts "Purging #{ build_dir }"
+ FileUtils.rm_rf(Dir[build_dir])
+ end
+
+ def get(path)
+ p = "#{ path }.html"
+ puts "Caching #{ p }"
+ app.get p
+ end
+
+ def copy_public
+ puts "Copying public/ dir to build/"
+ FileUtils.cp_r(Rails.root + "public/.", build_dir)
+ end
+
+ def cleanup_unused
+ FileUtils.rm build_dir + ".gitignore"
+ FileUtils.rm Dir[build_dir + "**/*.erb"]
+ end
+end
@@ -0,0 +1,5 @@
+$(function() {
+ $(".articles.index .item").hover(function() {
+ $(this).find(".controls:first").toggle();
+ });
+});
Oops, something went wrong.

0 comments on commit 74df7c3

Please sign in to comment.