Permalink
Browse files

First commit

  • Loading branch information...
0 parents commit bcb9e6217417b8db55d231b6e30d9eac5010d5db @dolzenko committed Mar 23, 2010
Showing with 5,510 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +8 −0 Gemfile
  3. +10 −0 Rakefile
  4. +7 −0 app/controllers/application_controller.rb
  5. +83 −0 app/controllers/articles_controller.rb
  6. +2 −0 app/helpers/application_helper.rb
  7. +9 −0 app/helpers/articles_helper.rb
  8. +85 −0 app/models/article.rb
  9. +16 −0 app/stylesheets/ie.sass
  10. +11 −0 app/stylesheets/partials/_base.sass
  11. +8 −0 app/stylesheets/print.sass
  12. +86 −0 app/stylesheets/screen.sass
  13. +15 −0 app/views/articles/_form.html.haml
  14. +5 −0 app/views/articles/edit.html.haml
  15. +10 −0 app/views/articles/index.html.haml
  16. +5 −0 app/views/articles/new.html.haml
  17. +12 −0 app/views/articles/show.html.haml
  18. +12 −0 app/views/layouts/articles.html.haml
  19. +4 −0 config.ru
  20. +50 −0 config/application.rb
  21. +8 −0 config/boot.rb
  22. +11 −0 config/compass.rb
  23. +16 −0 config/database.yml
  24. +5 −0 config/environment.rb
  25. +21 −0 config/environments/development.rb
  26. +33 −0 config/environments/production.rb
  27. +29 −0 config/environments/test.rb
  28. +7 −0 config/initializers/backtrace_silencers.rb
  29. +5 −0 config/initializers/compass.rb
  30. +9 −0 config/initializers/cookie_verification_secret.rb
  31. +1 −0 config/initializers/core_extensions.rb
  32. +10 −0 config/initializers/inflections.rb
  33. +5 −0 config/initializers/mime_types.rb
  34. +24 −0 config/initializers/mysql_utf8_hack.rb
  35. +11 −0 config/initializers/session_store.rb
  36. +5 −0 config/locales/en.yml
  37. +60 −0 config/routes.rb
  38. +14 −0 db/migrate/20100322103740_create_articles.rb
  39. +227 −0 db/models/articles/14-vvedenie/content.html.erb
  40. +69 −0 db/models/articles/15-frensis-bekon-o-puteshestviyah/content.html.erb
  41. BIN db/models/articles/15-frensis-bekon-o-puteshestviyah/image001.jpg
  42. +16 −0 db/models/articles/16-rossiyskoe-obschestvo-turistov/content.html.erb
  43. BIN db/models/articles/16-rossiyskoe-obschestvo-turistov/image002.jpg
  44. 0 db/models/articles/17-razdel-pervyy-o-ponyatii-turizm/content.html.erb
  45. +255 −0 db/models/articles/18-modul-mnozhestvennost-ponyatiy-turizma/content.html.erb
  46. +41 −0 db/models/articles/19-suschnostnoe-opredelenie-turizma/content.html.erb
  47. BIN db/models/articles/19-suschnostnoe-opredelenie-turizma/image003.jpg
  48. BIN db/models/articles/19-suschnostnoe-opredelenie-turizma/image004.jpg
  49. BIN db/models/articles/20-modul-klassifitsirovanie-turizma/class.png
  50. +330 −0 db/models/articles/20-modul-klassifitsirovanie-turizma/content.html.erb
  51. +484 −0 db/models/articles/21-h-montaner-montehano-klassy-turisticheskoy-deyat/content.html.erb
  52. 0 db/models/articles/22-razdel-vtoroy-fiziologicheskie-osnovy-turizma-s-/content.html.erb
  53. +125 −0 db/models/articles/23-modul-issledovaniya-gosudarstvennogo-tsentralnog/content.html.erb
  54. +384 −0 db/models/articles/23-modul-issledovaniya-gosudarstvennogo-tsentralnog/table1.html
  55. +436 −0 db/models/articles/24-modul-rezultaty-issledovaniy-vnilte-v-1970-e-god/content.html.erb
  56. +227 −0 db/models/articles/25-vydayuschiesya-sobytiya-samodeyatelnogo-turizma-/content.html.erb
  57. BIN db/models/articles/25-vydayuschiesya-sobytiya-samodeyatelnogo-turizma-/image006.jpg
  58. BIN db/models/articles/25-vydayuschiesya-sobytiya-samodeyatelnogo-turizma-/image007.jpg
  59. BIN db/models/articles/25-vydayuschiesya-sobytiya-samodeyatelnogo-turizma-/image008.jpg
  60. +99 −0 db/models/articles/26-razdel-tretiy--modul-izuchenie-ekonomicheskih-as/content.html.erb
  61. +546 −0 db/models/articles/27-ekonomicheskie-osnovy-turistskoy-deyatelnosti/content.html.erb
  62. BIN db/models/articles/27-ekonomicheskie-osnovy-turistskoy-deyatelnosti/image009.jpg
  63. BIN db/models/articles/27-ekonomicheskie-osnovy-turistskoy-deyatelnosti/image010.jpg
  64. +144 −0 db/models/articles/28-razdel-chetvertyy--modul-istoriya-turizma-rossii/content.html.erb
  65. +44 −0 db/models/articles/29-razdel-pyatyy-rekreatsionnaya-geografiya--nauchn/content.html.erb
  66. +148 −0 db/models/articles/30-modul-territorialnaya-rekreatsionnaya-sistema/content.html.erb
  67. BIN db/models/articles/30-modul-territorialnaya-rekreatsionnaya-sistema/image016.jpg
  68. +32 −0 db/models/articles/31-vladimir-sergeevich-preobrazhenskiy/content.html.erb
  69. BIN db/models/articles/31-vladimir-sergeevich-preobrazhenskiy/image017.jpg
  70. +75 −0 db/models/articles/32-modul-rekreatsionnaya-digressiya-prirodnyh-kompl/content.html.erb
  71. +118 −0 db/models/articles/33-modul-bioklimaticheskie-issledovaniya-po-metodik/content.html.erb
  72. BIN db/models/articles/33-modul-bioklimaticheskie-issledovaniya-po-metodik/image018.jpg
  73. BIN db/models/articles/33-modul-bioklimaticheskie-issledovaniya-po-metodik/image019.jpg
  74. BIN db/models/articles/33-modul-bioklimaticheskie-issledovaniya-po-metodik/image020.jpg
  75. BIN db/models/articles/33-modul-bioklimaticheskie-issledovaniya-po-metodik/image021.jpg
  76. +178 −0 db/models/articles/34-klimat-i-teplovoy-balans-tela-cheloveka/content.html.erb
  77. BIN db/models/articles/34-klimat-i-teplovoy-balans-tela-cheloveka/table.png
  78. +21 −0 db/schema.rb
  79. +7 −0 db/seeds.rb
  80. +32 −0 lib/core_ext/kernel.rb
  81. 0 lib/tasks/.gitkeep
  82. +72 −0 lib/transliteration.rb
  83. +1 −0 public/.gitignore
  84. BIN public/images/grid.png
  85. 0 public/stylesheets/.gitkeep
  86. +89 −0 public/stylesheets/compiled/ie.css
  87. +74 −0 public/stylesheets/compiled/print.css
  88. +357 −0 public/stylesheets/compiled/screen.css
  89. +27 −0 script/cleaner.rb
  90. +9 −0 script/rails
  91. +17 −0 script/test.rb
  92. +9 −0 test/fixtures/articles.yml
  93. +49 −0 test/functional/articles_controller_test.rb
  94. +9 −0 test/performance/browsing_test.rb
  95. +13 −0 test/test_helper.rb
  96. +8 −0 test/unit/article_test.rb
  97. +4 −0 test/unit/helpers/articles_helper_test.rb
  98. 0 vendor/plugins/.gitkeep
  99. +16 −0 vendor/plugins/haml/init.rb
@@ -0,0 +1,6 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/**/*
+misc/
+.idea/
@@ -0,0 +1,8 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.0.0.beta1', :path => 'vendor/rails'
+gem 'mysql'
+# gem 'haml-edge'
+gem 'haml-edge'
+gem 'mongrel'
+gem "compass", "0.10.0.rc1"
@@ -0,0 +1,10 @@
+# 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__)
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+Rails::Application.load_tasks
@@ -0,0 +1,7 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+
+ def default_url_options
+ { :format => :html }
+ end
+end
@@ -0,0 +1,83 @@
+class ArticlesController < ApplicationController
+ # GET /articles
+ # GET /articles.xml
+ def index
+ @articles = Article.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @articles }
+ end
+ end
+
+ # GET /articles/1
+ # GET /articles/1.xml
+ def show
+ @article = Article.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @article }
+ end
+ end
+
+ # GET /articles/new
+ # GET /articles/new.xml
+ def new
+ @article = Article.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @article }
+ end
+ end
+
+ # GET /articles/1/edit
+ def edit
+ @article = Article.find(params[:id])
+ end
+
+ # POST /articles
+ # POST /articles.xml
+ def create
+ @article = Article.new(params[:article])
+
+ respond_to do |format|
+ if @article.save
+ format.html { redirect_to(@article, :notice => 'Article was successfully created.') }
+ format.xml { render :xml => @article, :status => :created, :location => @article }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @article.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /articles/1
+ # PUT /articles/1.xml
+ def update
+ @article = Article.find(params[:id])
+
+ respond_to do |format|
+ if @article.update_attributes(params[:article])
+ format.html { redirect_to(@article, :notice => 'Article was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @article.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /articles/1
+ # DELETE /articles/1.xml
+ def destroy
+ @article = Article.find(params[:id])
+ @article.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(articles_url) }
+ format.xml { head :ok }
+ end
+ end
+end
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
@@ -0,0 +1,9 @@
+module ArticlesHelper
+ def article_asset_path(path)
+ File.join("/models/articles/#{ @article.to_param }", path)
+ end
+
+ def article_image_tag(source, options = {})
+ image_tag(article_asset_path(source), options)
+ end
+end
@@ -0,0 +1,85 @@
+# encoding: utf-8
+require "fileutils"
+require "transliteration"
+
+class Article < ActiveRecord::Base
+ DATA_ROOT = Rails.root + "db/models"
+ before_save :sync_filesystem_attrs
+ after_create :init_filesystem_attrs
+ validate :title => :presence
+
+ def content
+ if file = filesystem_attr_file
+ IO.read(file)
+ else
+ self[:content]
+ end
+ end
+ alias :content_before_type_cast :content
+
+ def content=(val)
+ @content = val
+ end
+
+ def data_root
+ DATA_ROOT + self.class.table_name
+ end
+
+ def model_dir_glob(attribute)
+ data_root + "#{ id }{,-*}/#{ attribute }.html.erb"
+ end
+
+ def filesystem_attr_file
+ Dir[model_dir_glob(:content)][0]
+ end
+
+ def sync_filesystem_attrs
+ return unless defined?(@content)
+ return unless filesystem_attr_file
+ if title_changed?
+ old_path = File.dirname(filesystem_attr_file)
+ new_path = File.dirname(generate_path)
+ FileUtils.mv(old_path, new_path)
+ end
+ File.open(filesystem_attr_file, "w") do |file|
+ file.write(@content)
+ end
+ end
+
+ def expose_filesystem_attrs
+ File.open(filesystem_attr_file, "w") do |file|
+ file.write(self[:content])
+ end
+ end
+
+ def init_filesystem_attrs
+ file = generate_path
+
+ FileUtils.mkdir_p(File.dirname(file))
+ File.open(file, "w") do |file|
+ file.write(self[:content])
+ end
+ end
+
+ def generate_path
+ data_root + "#{ to_param }/content.html.erb"
+ end
+
+ def to_param
+ if title.present?
+ "#{ id }-#{ ::Transliteration.transliterate(title.force_encoding("utf-8")).downcase.gsub(/[\s\.:_]+/, '-').gsub(/[^-a-z0-9~;+=_]/, '') }"[0..50]
+ else
+ "#{ id }"
+ end
+ end
+
+ def fixup_paramed_dir
+ old_path = File.dirname(filesystem_attr_file)
+ new_path = File.dirname(generate_path)
+ FileUtils.mv(old_path, new_path) unless old_path == new_path
+ end
+
+ def self.fixup_paramed_dirs
+ find_each(&:fixup_paramed_dir)
+ end
+end
@@ -0,0 +1,16 @@
+@import blueprint.sass
+
+// To generate css equivalent to the blueprint css but with your configuration applied, uncomment:
+// +blueprint-ie
+
+//Recommended Blueprint configuration with scoping and semantic layout:
+body.bp
+ +blueprint-ie(true)
+ // Note: Blueprint centers text to fix IE6 container centering.
+ // This means all your texts will be centered under all version of IE by default.
+ // If your container does not have the .container class, don't forget to restore
+ // the correct behavior to your main container (but not the body tag!)
+ // Example:
+ // .my-container
+ // text-align: left
+
@@ -0,0 +1,11 @@
+// Here is where you can define your constants for your application and to configure the blueprint framework.
+// Feel free to delete these if you want keep the defaults:
+
+!blueprint_grid_columns = 24
+!blueprint_container_size = 950px
+!blueprint_grid_margin = 10px
+
+// Use this to calculate the width based on the total width.
+// Or you can set !blueprint_grid_width to a fixed value and unset !blueprint_container_size -- it will be calculated for you.
+!blueprint_grid_width = (!blueprint_container_size + !blueprint_grid_margin) / !blueprint_grid_columns - !blueprint_grid_margin
+
@@ -0,0 +1,8 @@
+@import blueprint.sass
+
+// To generate css equivalent to the blueprint css but with your configuration applied, uncomment:
+// +blueprint-print
+
+//Recommended Blueprint configuration with scoping and semantic layout:
+body.bp
+ +blueprint-print(true)
@@ -0,0 +1,86 @@
+// This import applies a global reset to any page that imports this stylesheet.
+@import blueprint/reset.sass
+// To configure blueprint, edit the partials/base.sass file.
+@import partials/base.sass
+// Import all the default blueprint modules so that we can access their mixins.
+@import blueprint
+// Import the non-default scaffolding module.
+@import blueprint/scaffolding.sass
+
+// To generate css equivalent to the blueprint css but with your configuration applied, uncomment:
+// +blueprint
+
+//Recommended Blueprint configuration with scoping and semantic layout:
++blueprint-scaffolding("body.bp")
+body.bp
+ // +blueprint-typography(true)
+ +blueprint-utilities
+ +blueprint-debug
+ +blueprint-interaction
+ // Remove the scaffolding when you're ready to start doing visual design.
+ // Or leave it in if you're happy with how blueprint looks out-of-the-box
+ background-color: rgb(212,208,200)
+ width: 620px
+ margin-left: 300px
+ text-align: justify
+form.bp
+ +blueprint-form
+
+// Page layout can be done using mixins applied to your semantic classes and IDs:
+body.three-col
+ #container
+ +container
+ #header, #footer
+ +column(!blueprint_grid_columns)
+ #sidebar
+ // One third of the grid columns, rounding down. With 24 cols, this is 8.
+ !sidebar_columns = floor(!blueprint_grid_columns / 3)
+ +column(!sidebar_columns)
+ #content
+ // Two thirds of the grid columns, rounding up.
+ // With 24 cols, this is 16.
+ !content_columns = ceil(2 * !blueprint_grid_columns / 3)
+ // true means it's the last column in the row
+ +column(!content_columns, true)
+
+
+@import compass/utilities.sass
+.article
+ font:
+ style: Times New Roman
+ size: 14pt
+ div
+ margin:
+ top: 10px
+ &:first-letter
+ margin-left: 2em
+ line-height: 150%
+
+ .quote
+ &:first-letter
+ margin-left: 0
+ font:
+ style: italic
+ weight: bold
+ margin-left: 4em
+
+ #tourism-in-different-languages
+ background-color: gray
+
+ .questions
+ font:
+ style: italic
+
+ #aleksandrova-class
+ > li
+ font-weight: bold
+ li
+ font-weight: normal
+
+ #opte-motto
+ background-color: gray
+
+ .table
+ table
+ +outer-table-borders(1px)
+ +inner-table-borders(1px)
@@ -0,0 +1,15 @@
+= form_for(@article) do |f|
+ = f.error_messages
+
+ .field
+ = f.label :title
+ %br
+ = f.text_field :title
+ /
+ .field
+ = f.label :content
+ %br
+ = f.text_area :content
+
+ .actions
+ = f.submit
@@ -0,0 +1,5 @@
+%h1 Editing article
+
+= render 'form'
+
+== #{ link_to 'Show', @article } | #{ link_to 'Back', articles_path }
@@ -0,0 +1,10 @@
+- 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
+
+- if Rails.env.development?
+ = link_to 'New article', new_article_path
@@ -0,0 +1,5 @@
+%h1 New article
+
+= render 'form'
+
+= link_to 'Back', articles_path
@@ -0,0 +1,12 @@
+= link_to 'Оглавление', articles_path
+
+%h1!= @article.title
+
+- if Rails.env.development?
+ = link_to 'New article', new_article_path
+ |
+ = link_to 'Edit', edit_article_path(@article)
+ |
+ = link_to 'Back', articles_path
+
+.article[]!= render(:inline => @article.content.html_safe)
Oops, something went wrong.

0 comments on commit bcb9e62

Please sign in to comment.