typo 4.0.3 → 4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES-4.1 +83 -0
- data/MAINTAINERS +3 -7
- data/README +1 -1
- data/{components/sidebars/README → README.SIDEBARS} +3 -0
- data/Rakefile +1 -1
- data/TODO-4.1 +16 -0
- data/app/apis/blogger_service.rb +3 -3
- data/app/apis/meta_weblog_service.rb +4 -21
- data/app/apis/movable_type_service.rb +5 -5
- data/app/controllers/accounts_controller.rb +6 -3
- data/app/controllers/admin/blacklist_controller.rb +1 -1
- data/app/controllers/admin/cache_controller.rb +3 -7
- data/app/controllers/admin/content_controller.rb +46 -24
- data/app/controllers/admin/feedback_controller.rb +3 -3
- data/app/controllers/admin/general_controller.rb +3 -3
- data/app/controllers/admin/pages_controller.rb +7 -3
- data/app/controllers/admin/sidebar_controller.rb +19 -26
- data/app/controllers/admin/textfilters_controller.rb +3 -1
- data/app/controllers/admin/themes_controller.rb +1 -1
- data/app/controllers/admin/users_controller.rb +1 -1
- data/app/controllers/application.rb +25 -27
- data/app/controllers/articles_controller.rb +14 -18
- data/app/controllers/content_controller.rb +7 -7
- data/app/controllers/live_controller.rb +1 -1
- data/app/controllers/redirect_controller.rb +2 -0
- data/app/controllers/textfilter_controller.rb +0 -3
- data/app/controllers/theme_controller.rb +10 -5
- data/app/controllers/xml_controller.rb +7 -9
- data/app/helpers/admin/base_helper.rb +10 -5
- data/app/helpers/admin/content_helper.rb +6 -0
- data/app/helpers/admin/feedback_helper.rb +1 -1
- data/app/helpers/admin/pages_helper.rb +5 -0
- data/app/helpers/application_helper.rb +84 -51
- data/app/helpers/articles_helper.rb +29 -29
- data/app/helpers/mail_helper.rb +3 -2
- data/app/helpers/sidebar_helper.rb +25 -16
- data/app/helpers/xml_helper.rb +0 -16
- data/app/models/article.rb +90 -32
- data/app/models/blog.rb +82 -74
- data/app/models/blog_sweeper.rb +33 -8
- data/app/models/categorization.rb +4 -0
- data/app/models/category.rb +21 -4
- data/app/models/comment.rb +23 -21
- data/app/models/content.rb +106 -64
- data/app/models/content_state/base.rb +12 -3
- data/app/models/content_state/draft.rb +2 -3
- data/app/models/content_state/factory.rb +1 -1
- data/app/models/content_state/ham.rb +0 -1
- data/app/models/content_state/just_marked_as_ham.rb +8 -1
- data/app/models/content_state/just_marked_as_spam.rb +4 -1
- data/app/models/content_state/just_presumed_ham.rb +14 -14
- data/app/models/content_state/just_published.rb +11 -18
- data/app/models/content_state/just_withdrawn.rb +11 -0
- data/app/models/content_state/new.rb +0 -1
- data/app/models/content_state/presumed_ham.rb +9 -3
- data/app/models/content_state/presumed_spam.rb +4 -1
- data/app/models/content_state/publication_pending.rb +4 -4
- data/app/models/content_state/published.rb +7 -8
- data/app/models/content_state/spam.rb +0 -1
- data/app/models/content_state/unclassified.rb +12 -3
- data/app/models/content_state/withdrawn.rb +5 -6
- data/app/models/email_notifier.rb +1 -1
- data/app/models/feedback.rb +31 -11
- data/app/models/notification.rb +4 -0
- data/app/models/notification_mailer.rb +8 -8
- data/app/models/page.rb +19 -5
- data/app/models/ping.rb +27 -40
- data/app/models/sidebar.rb +241 -11
- data/app/models/tag.rb +12 -1
- data/app/models/text_filter.rb +33 -39
- data/app/models/theme.rb +9 -0
- data/app/models/trackback.rb +1 -5
- data/app/models/user.rb +7 -5
- data/app/views/accounts/login.rhtml +19 -15
- data/app/views/accounts/logout.rhtml +4 -4
- data/app/views/accounts/signup.rhtml +9 -9
- data/app/views/admin/base/_recent_comments.rhtml +2 -2
- data/app/views/admin/base/_recent_trackbacks.rhtml +2 -2
- data/app/views/admin/blacklist/_blacklist_patterns.rhtml +4 -4
- data/app/views/admin/blacklist/_form.rhtml +3 -3
- data/app/views/admin/blacklist/_quick_post.rhtml +7 -6
- data/app/views/admin/blacklist/destroy.rhtml +5 -5
- data/app/views/admin/blacklist/edit.rhtml +7 -7
- data/app/views/admin/blacklist/list.rhtml +2 -2
- data/app/views/admin/cache/list.rhtml +2 -2
- data/app/views/admin/categories/_categories.rhtml +3 -3
- data/app/views/admin/categories/_form.rhtml +1 -1
- data/app/views/admin/categories/_quick_post.rhtml +5 -5
- data/app/views/admin/categories/destroy.rhtml +7 -7
- data/app/views/admin/categories/edit.rhtml +6 -6
- data/app/views/admin/categories/list.rhtml +7 -4
- data/app/views/admin/categories/reorder.rhtml +1 -1
- data/app/views/admin/categories/show.rhtml +6 -6
- data/app/views/admin/comments/_form.rhtml +4 -4
- data/app/views/admin/comments/comments.rhtml +1 -1
- data/app/views/admin/comments/destroy.rhtml +6 -6
- data/app/views/admin/comments/edit.rhtml +8 -8
- data/app/views/admin/comments/list.rhtml +11 -11
- data/app/views/admin/comments/new.rhtml +7 -7
- data/app/views/admin/comments/show.rhtml +7 -7
- data/app/views/admin/content/_articles.rhtml +12 -10
- data/app/views/admin/content/_attachment.rhtml +15 -17
- data/app/views/admin/content/_form.rhtml +68 -45
- data/app/views/admin/content/_pages.rhtml +2 -2
- data/app/views/admin/content/_quick_post.rhtml +6 -6
- data/app/views/admin/content/_show_categories.rhtml +2 -2
- data/app/views/admin/content/_show_resources.rhtml +2 -2
- data/app/views/admin/content/destroy.rhtml +8 -8
- data/app/views/admin/content/edit.rhtml +8 -26
- data/app/views/admin/content/list.rhtml +4 -4
- data/app/views/admin/content/new.rhtml +5 -25
- data/app/views/admin/content/preview.rhtml +9 -2
- data/app/views/admin/content/show.rhtml +10 -9
- data/app/views/admin/feedback/_item.rhtml +2 -2
- data/app/views/admin/feedback/list.rhtml +21 -20
- data/app/views/admin/general/index.rhtml +261 -239
- data/app/views/admin/general/update_database.rhtml +15 -15
- data/app/views/admin/pages/_form.rhtml +32 -15
- data/app/views/admin/pages/_pages.rhtml +9 -8
- data/app/views/admin/pages/_quick_post.rhtml +2 -2
- data/app/views/admin/pages/destroy.rhtml +7 -7
- data/app/views/admin/pages/edit.rhtml +7 -26
- data/app/views/admin/pages/list.rhtml +4 -3
- data/app/views/admin/pages/new.rhtml +5 -22
- data/app/views/admin/pages/preview.rhtml +1 -1
- data/app/views/admin/pages/show.rhtml +5 -5
- data/app/views/admin/resources/_itunes_category_edit.rhtml +2 -2
- data/app/views/admin/resources/_metadata_add.rhtml +13 -13
- data/app/views/admin/resources/_metadata_edit.rhtml +14 -14
- data/app/views/admin/resources/_mime_edit.rhtml +5 -5
- data/app/views/admin/resources/_pages.rhtml +2 -2
- data/app/views/admin/resources/_resources.rhtml +8 -8
- data/app/views/admin/resources/destroy.rhtml +7 -7
- data/app/views/admin/resources/list.rhtml +6 -3
- data/app/views/admin/resources/new.rhtml +7 -3
- data/app/views/admin/shared/_edit.rhtml +17 -0
- data/app/views/admin/sidebar/_active.rhtml +5 -5
- data/app/views/admin/sidebar/_availables.rhtml +1 -1
- data/app/views/admin/sidebar/_publish.rhtml +1 -1
- data/app/views/admin/sidebar/_target.rhtml +1 -1
- data/app/views/admin/sidebar/index.rhtml +9 -5
- data/app/views/admin/textfilters/_form.rhtml +13 -5
- data/app/views/admin/textfilters/_macros.rhtml +4 -4
- data/app/views/admin/textfilters/_textfilters.rhtml +6 -6
- data/app/views/admin/textfilters/destroy.rhtml +5 -8
- data/app/views/admin/textfilters/edit.rhtml +2 -5
- data/app/views/admin/textfilters/list.rhtml +4 -2
- data/app/views/admin/textfilters/macro_help.rhtml +1 -1
- data/app/views/admin/textfilters/new.rhtml +9 -7
- data/app/views/admin/textfilters/show.rhtml +5 -5
- data/app/views/admin/textfilters/show_help.rhtml +3 -3
- data/app/views/admin/themes/index.rhtml +8 -2
- data/app/views/admin/trackbacks/_form.rhtml +4 -4
- data/app/views/admin/trackbacks/destroy.rhtml +4 -4
- data/app/views/admin/trackbacks/edit.rhtml +6 -6
- data/app/views/admin/trackbacks/list.rhtml +10 -10
- data/app/views/admin/trackbacks/new.rhtml +6 -6
- data/app/views/admin/trackbacks/show.rhtml +8 -8
- data/app/views/admin/users/_form.rhtml +10 -10
- data/app/views/admin/users/_user.rhtml +6 -6
- data/app/views/admin/users/destroy.rhtml +7 -7
- data/app/views/admin/users/edit.rhtml +9 -5
- data/app/views/admin/users/list.rhtml +2 -2
- data/app/views/admin/users/new.rhtml +9 -7
- data/app/views/admin/users/show.rhtml +10 -10
- data/app/views/articles/_article.rhtml +3 -3
- data/app/views/articles/_comment.rhtml +3 -3
- data/app/views/articles/_comment_box.rhtml +6 -6
- data/app/views/articles/_trackback.rhtml +1 -1
- data/app/views/articles/archives.rhtml +3 -3
- data/app/views/articles/comment_preview.rhtml +2 -2
- data/app/views/articles/groupings.rhtml +1 -1
- data/app/views/articles/index.rhtml +2 -2
- data/app/views/articles/read.rhtml +15 -15
- data/app/views/articles/view_page.rhtml +1 -1
- data/app/views/layouts/administration.rhtml +11 -17
- data/app/views/layouts/minimal.rhtml +13 -0
- data/app/views/live/search.rhtml +1 -1
- data/app/views/notification_mailer/_mail_footer.rhtml +2 -2
- data/app/views/notification_mailer/article.rhtml +1 -1
- data/app/views/notification_mailer/comment.rhtml +4 -4
- data/app/views/settings/done.rhtml +1 -1
- data/app/views/settings/install.rhtml +3 -3
- data/app/views/shared/_search.rhtml +4 -4
- data/app/views/xml/_atom10_item_article.rxml +9 -7
- data/app/views/xml/_atom10_item_comment.rxml +2 -3
- data/app/views/xml/_atom10_item_trackback.rxml +1 -1
- data/app/views/xml/_googlesitemap_item_article.rxml +2 -2
- data/app/views/xml/_googlesitemap_item_category.rxml +1 -1
- data/app/views/xml/_googlesitemap_item_page.rxml +2 -2
- data/app/views/xml/_googlesitemap_item_tag.rxml +2 -2
- data/app/views/xml/_itunes_item_resource.rxml +2 -4
- data/app/views/xml/_rss20_item_article.rxml +4 -10
- data/app/views/xml/_rss20_item_comment.rxml +2 -2
- data/app/views/xml/rsd.rxml +4 -4
- data/bin/typo +0 -1
- data/config/boot.rb +4 -3
- data/config/environment.rb +37 -28
- data/config/environments/test.rb +1 -1
- data/config/routes.rb +6 -5
- data/db/migrate/051_fix_canonical_server_url.rb +17 -0
- data/db/migrate/052_remove_cached_html.rb +11 -0
- data/db/migrate/053_promote_canonical_server_url.rb +22 -0
- data/db/migrate/054_upgrade_sidebar_objects.rb +26 -0
- data/db/migrate/055_link_sidebars_to_blog.rb +17 -0
- data/db/migrate/056_create_notifications.rb +32 -0
- data/db/migrate/057_add_categorization_model.rb +45 -0
- data/db/migrate/058_separate_entries_and_feedback.rb +68 -0
- data/db/migrate/059_cleanup_feedback_table.rb +25 -0
- data/db/migrate/060_cleanup_contents_table.rb +29 -0
- data/db/migrate/061_convert_title_prefix_setting.rb +25 -0
- data/db/schema.mysql.sql +139 -108
- data/db/schema.postgresql.sql +140 -108
- data/db/schema.rb +97 -75
- data/db/schema.sqlite.sql +140 -108
- data/db/schema.sqlserver.sql +144 -109
- data/db/schema_version +1 -1
- data/lang/fr_FR.rb +469 -0
- data/lib/email_notify.rb +4 -4
- data/lib/generators/sidebar/sidebar_generator.rb +15 -6
- data/lib/generators/sidebar/templates/Rakefile +22 -0
- data/lib/generators/sidebar/templates/content.rhtml +10 -0
- data/lib/generators/sidebar/templates/init.rb +4 -0
- data/lib/generators/sidebar/templates/sidebar.rb +16 -0
- data/lib/generators/sidebar/templates/unit_test.rb +8 -0
- data/lib/jabber_notify.rb +8 -7
- data/lib/memory_profiler.rb +60 -0
- data/lib/rails_patch/active_record.rb +0 -27
- data/lib/route_cache.rb +15 -0
- data/lib/sidebars/component_plugin.rb +3 -0
- data/lib/sidebars/consolidated_plugin.rb +26 -0
- data/lib/sidebars/plugin.rb +8 -13
- data/lib/spam_protection.rb +35 -23
- data/lib/tasks/release.rake +7 -7
- data/lib/text_filter_plugin.rb +55 -15
- data/lib/typo_deprecated.rb +19 -0
- data/lib/typo_version.rb +1 -1
- data/public/images/bracket.gif +0 -0
- data/public/images/cancel.png +0 -0
- data/public/images/checked.png +0 -0
- data/public/images/delete.png +0 -0
- data/public/images/edit.png +0 -0
- data/public/images/help.png +0 -0
- data/public/images/show.png +0 -0
- data/public/javascripts/codecollapse.js +8 -0
- data/public/javascripts/controls.js +41 -23
- data/public/javascripts/dragdrop.js +105 -76
- data/public/javascripts/effects.js +293 -163
- data/public/javascripts/prototype.js +900 -391
- data/public/stylesheets/administration.css +390 -318
- data/public/stylesheets/codecollapse.css +3 -0
- data/public/stylesheets/minimal.css +142 -0
- data/public/stylesheets/textmate/dawn.css +209 -0
- data/public/stylesheets/textmate/iplastic.css +142 -0
- data/public/stylesheets/textmate/space_cadet.css +99 -0
- data/public/stylesheets/textmate/textmate.css +48 -0
- data/public/stylesheets/textmate/twilight.css +227 -0
- data/script/process/inspector +3 -0
- data/spec/controllers/accounts_controller_spec.rb +184 -0
- data/spec/controllers/articles_controller_spec.rb +47 -0
- data/spec/fixtures/articles_tags.yml +19 -0
- data/spec/fixtures/blacklist_patterns.yml +10 -0
- data/spec/fixtures/blogs.yml +77 -0
- data/spec/fixtures/categories.yml +35 -0
- data/{test/fixtures/articles_categories.yml → spec/fixtures/categorizations.yml} +0 -0
- data/spec/fixtures/contents.yml +215 -0
- data/spec/fixtures/feedback.yml +159 -0
- data/spec/fixtures/notifications.yml +0 -0
- data/spec/fixtures/page_caches.yml +7 -0
- data/spec/fixtures/redirects.yml +13 -0
- data/spec/fixtures/resources.yml +24 -0
- data/spec/fixtures/sidebars.yml +12 -0
- data/spec/fixtures/tags.yml +13 -0
- data/spec/fixtures/text_filters.yml +42 -0
- data/spec/fixtures/triggers.yml +1 -0
- data/spec/fixtures/users.yml +56 -0
- data/spec/fixtures/whiteboards.yml +13 -0
- data/spec/helpers/admin_base_helper_spec.rb +13 -0
- data/spec/models/amazon_sidebar_spec.rb +40 -0
- data/spec/models/audioscrobbler_spec.rb +134 -0
- data/spec/models/blog_spec.rb +28 -0
- data/spec/models/cache_support_spec.rb +55 -0
- data/spec/models/category_spec.rb +48 -0
- data/spec/models/configuration_spec.rb +108 -0
- data/spec/models/content_state_spec.rb +1010 -0
- data/spec/models/delegate_to_content_state_spec.rb +126 -0
- data/spec/models/delicious_spec.rb +101 -0
- data/spec/models/flickr_spec.rb +128 -0
- data/spec/models/metafragment_spec.rb +65 -0
- data/spec/models/page_cache_spec.rb +35 -0
- data/spec/models/page_spec.rb +88 -0
- data/spec/models/ping_spec.rb +133 -0
- data/spec/models/redirect_spec.rb +17 -0
- data/spec/models/resource_spec.rb +43 -0
- data/spec/models/static_sidebar_spec.rb +17 -0
- data/spec/models/tag_spec.rb +54 -0
- data/spec/models/text_filter_spec.rb +38 -0
- data/spec/models/theme_spec.rb +45 -0
- data/spec/models/trackback_spec.rb +60 -0
- data/spec/models/trigger_spec.rb +41 -0
- data/spec/models/user_spec.rb +105 -0
- data/test/fixtures/blogs.yml +5 -4
- data/test/fixtures/categorizations.yml +31 -0
- data/test/fixtures/contents.yml +2 -160
- data/test/fixtures/feedback.yml +159 -0
- data/test/fixtures/sidebars.yml +11 -4
- data/test/functional/accounts_controller_test.rb +6 -10
- data/test/functional/admin/article_preview_test.rb +21 -6
- data/test/functional/admin/blacklist_controller_test.rb +11 -11
- data/test/functional/admin/categories_controller_test.rb +13 -13
- data/test/functional/admin/comments_controller_test.rb +21 -21
- data/test/functional/admin/content_controller_test.rb +30 -38
- data/test/functional/admin/feedback_controller_test.rb +12 -12
- data/test/functional/admin/general_controller_test.rb +2 -2
- data/test/functional/admin/pages_controller_test.rb +3 -18
- data/test/functional/admin/resources_controller_test.rb +7 -7
- data/test/functional/admin/textfilters_controller_test.rb +2 -2
- data/test/functional/admin/themes_controller_test.rb +1 -1
- data/test/functional/admin/trackbacks_controller_test.rb +21 -21
- data/test/functional/admin/users_controller_test.rb +21 -18
- data/test/functional/articles_controller_test.rb +62 -46
- data/test/functional/backend_controller_test.rb +6 -6
- data/test/functional/redirect_controller_test.rb +3 -3
- data/test/functional/textfilter_controller_test.rb +10 -12
- data/test/functional/theme_controller_test.rb +1 -1
- data/test/functional/xml_controller_test.rb +7 -5
- data/test/mocks/themes/azure/layouts/default.rhtml +2 -2
- data/test/test_helper.rb +75 -0
- data/test/unit/amazon_sidebar_test.rb +36 -0
- data/test/unit/article_test.rb +36 -4
- data/test/unit/blog_test.rb +5 -36
- data/test/unit/cache_support_test.rb +62 -0
- data/test/unit/category_test.rb +6 -1
- data/test/unit/comment_test.rb +34 -9
- data/test/unit/content_state/factory_test.rb +8 -0
- data/test/unit/content_state/feedback_states_test.rb +71 -0
- data/test/unit/magnolia_test.rb +1 -1
- data/test/unit/notification_test.rb +10 -0
- data/test/unit/page_test.rb +20 -0
- data/test/unit/ping_test.rb +1 -1
- data/test/unit/sidebar_test.rb +2 -7
- data/test/unit/static_sidebar_test.rb +19 -0
- data/test/unit/tag_test.rb +6 -1
- data/test/unit/text_filter_test.rb +21 -21
- data/test/unit/theme_test.rb +1 -1
- data/test/unit/trackback_test.rb +16 -1
- data/themes/azure/layouts/default.rhtml +2 -2
- data/themes/scribbish/layouts/default.rhtml +2 -2
- data/themes/scribbish/stylesheets/content.css +6 -8
- data/themes/scribbish/views/articles/_article.rhtml +10 -10
- data/themes/scribbish/views/articles/_comment.rhtml +16 -12
- data/themes/scribbish/views/articles/_comment_form.rhtml +25 -22
- data/themes/scribbish/views/articles/_search.rhtml +14 -13
- data/themes/scribbish/views/articles/comment_preview.rhtml +3 -3
- data/themes/scribbish/views/articles/index.rhtml +1 -1
- data/themes/scribbish/views/articles/read.rhtml +8 -8
- data/vendor/cached_model/History.txt +30 -0
- data/vendor/cached_model/LICENSE.txt +30 -0
- data/vendor/cached_model/Manifest.txt +7 -0
- data/vendor/cached_model/README.txt +96 -0
- data/vendor/cached_model/Rakefile +25 -0
- data/vendor/cached_model/lib/cached_model.rb +287 -0
- data/vendor/cached_model/test/test_cached_model.rb +593 -0
- data/vendor/flickr/flickr.rb +1 -1
- data/vendor/memcache-client/History.txt +25 -0
- data/vendor/memcache-client/LICENSE.txt +30 -0
- data/vendor/memcache-client/Manifest.txt +8 -0
- data/vendor/memcache-client/README.txt +46 -0
- data/vendor/memcache-client/Rakefile +23 -0
- data/vendor/memcache-client/lib/memcache.rb +491 -0
- data/vendor/memcache-client/lib/memcache_util.rb +71 -0
- data/vendor/memcache-client/test/test_mem_cache.rb +284 -0
- data/vendor/plugins/action_view_patch/Rakefile +22 -0
- data/vendor/plugins/action_view_patch/init.rb +1 -0
- data/vendor/plugins/action_view_patch/lib/action_view_patch.rb +18 -0
- data/vendor/plugins/action_view_patch/test/action_view_patch_test.rb +56 -0
- data/vendor/plugins/aimpresence_sidebar/Rakefile +22 -0
- data/vendor/plugins/aimpresence_sidebar/init.rb +4 -0
- data/vendor/plugins/aimpresence_sidebar/lib/aimpresence_sidebar.rb +21 -0
- data/vendor/plugins/aimpresence_sidebar/test/aimpresence_sidebar_test.rb +33 -0
- data/vendor/plugins/aimpresence_sidebar/views/content.rhtml +4 -0
- data/vendor/plugins/amazon_sidebar/init.rb +5 -0
- data/vendor/plugins/amazon_sidebar/lib/amazon_sidebar.rb +16 -0
- data/vendor/plugins/amazon_sidebar/views/content.rhtml +4 -0
- data/vendor/plugins/archives_sidebar/Rakefile +22 -0
- data/vendor/plugins/archives_sidebar/init.rb +5 -0
- data/{components/plugins/sidebars/archives_controller.rb → vendor/plugins/archives_sidebar/lib/archives_sidebar.rb} +7 -6
- data/vendor/plugins/archives_sidebar/test/archives_sidebar_test.rb +8 -0
- data/{components/plugins/sidebars/archives → vendor/plugins/archives_sidebar/views}/content.rhtml +2 -2
- data/vendor/plugins/audioscrobbler_sidebar/Rakefile +22 -0
- data/vendor/plugins/audioscrobbler_sidebar/init.rb +5 -0
- data/{app/models/aggregations → vendor/plugins/audioscrobbler_sidebar/lib}/audioscrobbler.rb +0 -0
- data/{components/plugins/sidebars/audioscrobbler_controller.rb → vendor/plugins/audioscrobbler_sidebar/lib/audioscrobbler_sidebar.rb} +7 -4
- data/vendor/plugins/audioscrobbler_sidebar/test/audioscrobbler_sidebar_test.rb +8 -0
- data/{components/plugins/sidebars/audioscrobbler → vendor/plugins/audioscrobbler_sidebar/views}/content.rhtml +4 -4
- data/vendor/plugins/backpack_sidebar/Rakefile +22 -0
- data/vendor/plugins/backpack_sidebar/init.rb +5 -0
- data/{app/models/aggregations → vendor/plugins/backpack_sidebar/lib}/backpack.rb +0 -0
- data/{components/plugins/sidebars/backpack_controller.rb → vendor/plugins/backpack_sidebar/lib/backpack_sidebar.rb} +6 -3
- data/vendor/plugins/backpack_sidebar/test/backpack_sidebar_test.rb +8 -0
- data/{components/plugins/sidebars/backpack → vendor/plugins/backpack_sidebar/views}/content.rhtml +4 -4
- data/vendor/plugins/category_sidebar/Rakefile +22 -0
- data/vendor/plugins/category_sidebar/init.rb +5 -0
- data/{components/plugins/sidebars/category_controller.rb → vendor/plugins/category_sidebar/lib/category_sidebar.rb} +3 -5
- data/vendor/plugins/category_sidebar/test/category_sidebar_test.rb +8 -0
- data/vendor/plugins/category_sidebar/views/content.rhtml +10 -0
- data/vendor/plugins/delicious_sidebar/Rakefile +22 -0
- data/vendor/plugins/delicious_sidebar/init.rb +5 -0
- data/{app/models/aggregations → vendor/plugins/delicious_sidebar/lib}/delicious.rb +0 -0
- data/{components/plugins/sidebars/delicious_controller.rb → vendor/plugins/delicious_sidebar/lib/delicious_sidebar.rb} +16 -10
- data/vendor/plugins/delicious_sidebar/test/delicious_sidebar_test.rb +8 -0
- data/vendor/plugins/delicious_sidebar/views/content.rhtml +20 -0
- data/vendor/plugins/flickr_sidebar/Rakefile +22 -0
- data/vendor/plugins/flickr_sidebar/init.rb +5 -0
- data/{app/models/aggregations → vendor/plugins/flickr_sidebar/lib}/flickr.rb +1 -1
- data/vendor/plugins/flickr_sidebar/lib/flickr_sidebar.rb +15 -0
- data/vendor/plugins/flickr_sidebar/test/flickr_sidebar_test.rb +8 -0
- data/{components/plugins/sidebars/flickr → vendor/plugins/flickr_sidebar/views}/content.rhtml +5 -5
- data/vendor/plugins/fortythree_sidebar/Rakefile +22 -0
- data/vendor/plugins/fortythree_sidebar/init.rb +5 -0
- data/{app/models/aggregations → vendor/plugins/fortythree_sidebar/lib}/fortythree.rb +0 -0
- data/{components/plugins/sidebars/fortythree_controller.rb → vendor/plugins/fortythree_sidebar/lib/fortythree_sidebar.rb} +5 -4
- data/vendor/plugins/fortythree_sidebar/test/fortythree_sidebar_test.rb +8 -0
- data/vendor/plugins/fortythree_sidebar/views/content.rhtml +8 -0
- data/vendor/plugins/fortythreeplaces_sidebar/Rakefile +22 -0
- data/vendor/plugins/fortythreeplaces_sidebar/init.rb +5 -0
- data/vendor/plugins/fortythreeplaces_sidebar/lib/fortythree.rb +62 -0
- data/{components/plugins/sidebars/fortythreeplaces_controller.rb → vendor/plugins/fortythreeplaces_sidebar/lib/fortythreeplaces_sidebar.rb} +5 -4
- data/vendor/plugins/fortythreeplaces_sidebar/test/fortythreeplaces_sidebar_test.rb +8 -0
- data/vendor/plugins/fortythreeplaces_sidebar/views/content.rhtml +8 -0
- data/vendor/plugins/haml/MIT-LICENSE +20 -0
- data/vendor/plugins/haml/REFERENCE +662 -0
- data/vendor/plugins/haml/Rakefile +171 -0
- data/vendor/plugins/haml/VERSION +1 -0
- data/vendor/plugins/haml/bin/haml +18 -0
- data/vendor/plugins/haml/init.rb +3 -0
- data/vendor/plugins/haml/lib/haml/buffer.rb +224 -0
- data/vendor/plugins/haml/lib/haml/engine.rb +557 -0
- data/vendor/plugins/haml/lib/haml/helpers.rb +220 -0
- data/vendor/plugins/haml/lib/haml/helpers/action_view_mods.rb +54 -0
- data/vendor/plugins/haml/lib/haml/template.rb +138 -0
- data/vendor/plugins/haml/test/benchmark.rb +62 -0
- data/vendor/plugins/haml/test/engine_test.rb +93 -0
- data/vendor/plugins/haml/test/helper_test.rb +105 -0
- data/vendor/plugins/haml/test/mocks/article.rb +6 -0
- data/vendor/plugins/haml/test/profile.rb +45 -0
- data/vendor/plugins/haml/test/results/content_for_layout.xhtml +16 -0
- data/vendor/plugins/haml/test/results/eval_suppressed.xhtml +2 -0
- data/vendor/plugins/haml/test/results/helpers.xhtml +50 -0
- data/vendor/plugins/haml/test/results/helpful.xhtml +5 -0
- data/vendor/plugins/haml/test/results/just_stuff.xhtml +38 -0
- data/vendor/plugins/haml/test/results/list.xhtml +12 -0
- data/vendor/plugins/haml/test/results/original_engine.xhtml +24 -0
- data/vendor/plugins/haml/test/results/partials.xhtml +20 -0
- data/vendor/plugins/haml/test/results/silent_script.xhtml +74 -0
- data/vendor/plugins/haml/test/results/standard.xhtml +42 -0
- data/vendor/plugins/haml/test/results/tag_parsing.xhtml +28 -0
- data/vendor/plugins/haml/test/results/very_basic.xhtml +7 -0
- data/vendor/plugins/haml/test/results/whitespace_handling.xhtml +51 -0
- data/vendor/plugins/haml/test/rhtml/standard.rhtml +51 -0
- data/vendor/plugins/haml/test/runner.rb +15 -0
- data/vendor/plugins/haml/test/template_test.rb +137 -0
- data/vendor/plugins/haml/test/templates/_partial.haml +7 -0
- data/vendor/plugins/haml/test/templates/_text_area.haml +3 -0
- data/vendor/plugins/haml/test/templates/content_for_layout.haml +10 -0
- data/vendor/plugins/haml/test/templates/eval_suppressed.haml +5 -0
- data/vendor/plugins/haml/test/templates/helpers.haml +39 -0
- data/vendor/plugins/haml/test/templates/helpful.haml +6 -0
- data/vendor/plugins/haml/test/templates/just_stuff.haml +34 -0
- data/vendor/plugins/haml/test/templates/list.haml +12 -0
- data/vendor/plugins/haml/test/templates/original_engine.haml +17 -0
- data/vendor/plugins/haml/test/templates/partialize.haml +1 -0
- data/vendor/plugins/haml/test/templates/partials.haml +12 -0
- data/vendor/plugins/haml/test/templates/silent_script.haml +40 -0
- data/vendor/plugins/haml/test/templates/standard.haml +40 -0
- data/vendor/plugins/haml/test/templates/tag_parsing.haml +24 -0
- data/vendor/plugins/haml/test/templates/very_basic.haml +4 -0
- data/vendor/plugins/haml/test/templates/whitespace_handling.haml +66 -0
- data/vendor/plugins/localization/CHANGELOG +1 -0
- data/vendor/plugins/localization/README +85 -0
- data/vendor/plugins/localization/init.rb +3 -0
- data/vendor/plugins/localization/lib/localization.rb +46 -0
- data/vendor/plugins/magnolia_sidebar/Rakefile +22 -0
- data/vendor/plugins/magnolia_sidebar/init.rb +5 -0
- data/{app/models/aggregations/magnolia.rb → vendor/plugins/magnolia_sidebar/lib/magnolia_aggregation.rb} +0 -0
- data/vendor/plugins/magnolia_sidebar/lib/magnolia_sidebar.rb +16 -0
- data/vendor/plugins/magnolia_sidebar/test/magnolia_sidebar_test.rb +8 -0
- data/vendor/plugins/magnolia_sidebar/views/content.rhtml +12 -0
- data/vendor/plugins/recent_comments_sidebar/Rakefile +22 -0
- data/vendor/plugins/recent_comments_sidebar/init.rb +5 -0
- data/vendor/plugins/recent_comments_sidebar/lib/recent_comments_sidebar.rb +16 -0
- data/vendor/plugins/recent_comments_sidebar/test/recent_comments_sidebar_test.rb +8 -0
- data/{components/plugins/sidebars/recent_comments → vendor/plugins/recent_comments_sidebar/views}/content.rhtml +2 -2
- data/vendor/plugins/static_sidebar/init.rb +4 -0
- data/{components/plugins/sidebars/static_controller.rb → vendor/plugins/static_sidebar/lib/static_sidebar.rb} +4 -7
- data/vendor/plugins/static_sidebar/views/content.rhtml +2 -0
- data/vendor/plugins/tada_sidebar/Rakefile +22 -0
- data/vendor/plugins/tada_sidebar/init.rb +5 -0
- data/{app/models/aggregations → vendor/plugins/tada_sidebar/lib}/tada.rb +0 -0
- data/{components/plugins/sidebars/tada_controller.rb → vendor/plugins/tada_sidebar/lib/tada_sidebar.rb} +8 -4
- data/vendor/plugins/tada_sidebar/test/tada_sidebar_test.rb +8 -0
- data/{components/plugins/sidebars/tada → vendor/plugins/tada_sidebar/views}/content.rhtml +4 -4
- data/vendor/plugins/tag_sidebar/Rakefile +22 -0
- data/vendor/plugins/tag_sidebar/init.rb +5 -0
- data/vendor/plugins/tag_sidebar/lib/tag_sidebar.rb +24 -0
- data/vendor/plugins/tag_sidebar/test/tag_sidebar_test.rb +8 -0
- data/vendor/plugins/tag_sidebar/views/content.rhtml +8 -0
- data/vendor/plugins/technorati_sidebar/Rakefile +22 -0
- data/vendor/plugins/technorati_sidebar/init.rb +5 -0
- data/{app/models/aggregations → vendor/plugins/technorati_sidebar/lib}/technorati.rb +0 -0
- data/{components/plugins/sidebars/technorati_controller.rb → vendor/plugins/technorati_sidebar/lib/technorati_sidebar.rb} +8 -4
- data/vendor/plugins/technorati_sidebar/test/technorati_sidebar_test.rb +8 -0
- data/vendor/plugins/technorati_sidebar/views/content.rhtml +8 -0
- data/vendor/plugins/typo_textfilter_amazon/README +5 -0
- data/vendor/plugins/typo_textfilter_amazon/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_amazon/init.rb +4 -0
- data/vendor/plugins/typo_textfilter_amazon/install.rb +1 -0
- data/vendor/plugins/typo_textfilter_amazon/lib/typo_textfilter_amazon.rb +45 -0
- data/vendor/plugins/typo_textfilter_amazon/tasks/typo_textfilter_amazon_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_amazon/test/typo_textfilter_amazon_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_code/README +4 -0
- data/vendor/plugins/typo_textfilter_code/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_code/init.rb +4 -0
- data/vendor/plugins/typo_textfilter_code/install.rb +1 -0
- data/vendor/plugins/typo_textfilter_code/lib/typo_textfilter_code.rb +62 -0
- data/vendor/plugins/typo_textfilter_code/tasks/typo_textfilter_code_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_code/test/typo_textfilter_code_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_flickr/README +4 -0
- data/vendor/plugins/typo_textfilter_flickr/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_flickr/init.rb +4 -0
- data/vendor/plugins/typo_textfilter_flickr/install.rb +1 -0
- data/vendor/plugins/typo_textfilter_flickr/lib/typo_textfilter_flickr.rb +79 -0
- data/vendor/plugins/typo_textfilter_flickr/tasks/typo_textfilter_flickr_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_flickr/test/typo_textfilter_flickr_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_htmlfilter/README +4 -0
- data/vendor/plugins/typo_textfilter_htmlfilter/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_htmlfilter/init.rb +2 -0
- data/vendor/plugins/typo_textfilter_htmlfilter/install.rb +1 -0
- data/vendor/plugins/typo_textfilter_htmlfilter/lib/typo_textfilter_htmlfilter.rb +12 -0
- data/vendor/plugins/typo_textfilter_htmlfilter/tasks/typo_textfilter_htmlfilter_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_htmlfilter/test/typo_textfilter_htmlfilter_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_lightbox/README +4 -0
- data/vendor/plugins/typo_textfilter_lightbox/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_lightbox/init.rb +2 -0
- data/vendor/plugins/typo_textfilter_lightbox/install.rb +1 -0
- data/{components/plugins/textfilters/lightbox_controller.rb → vendor/plugins/typo_textfilter_lightbox/lib/typo_textfilter_lightbox.rb} +64 -61
- data/vendor/plugins/typo_textfilter_lightbox/tasks/typo_textfilter_lightbox_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_lightbox/test/typo_textfilter_lightbox_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_markdown/README +4 -0
- data/vendor/plugins/typo_textfilter_markdown/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_markdown/init.rb +2 -0
- data/vendor/plugins/typo_textfilter_markdown/install.rb +1 -0
- data/{components/plugins/textfilters/markdown_controller.rb → vendor/plugins/typo_textfilter_markdown/lib/typo_textfilter_markdown.rb} +13 -9
- data/vendor/plugins/typo_textfilter_markdown/tasks/typo_textfilter_markdown_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_markdown/test/typo_textfilter_markdown_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_none/README +4 -0
- data/vendor/plugins/typo_textfilter_none/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_none/init.rb +2 -0
- data/vendor/plugins/typo_textfilter_none/install.rb +1 -0
- data/vendor/plugins/typo_textfilter_none/lib/typo_textfilter_none.rb +12 -0
- data/vendor/plugins/typo_textfilter_none/tasks/typo_textfilter_none_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_none/test/typo_textfilter_none_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_smartypants/README +4 -0
- data/vendor/plugins/typo_textfilter_smartypants/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_smartypants/init.rb +2 -0
- data/vendor/plugins/typo_textfilter_smartypants/install.rb +1 -0
- data/vendor/plugins/typo_textfilter_smartypants/lib/typo_textfilter_smartypants.rb +12 -0
- data/vendor/plugins/typo_textfilter_smartypants/tasks/typo_textfilter_smartypants_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_smartypants/test/typo_textfilter_smartypants_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_sparkline/README +4 -0
- data/vendor/plugins/typo_textfilter_sparkline/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_sparkline/init.rb +2 -0
- data/vendor/plugins/typo_textfilter_sparkline/install.rb +1 -0
- data/vendor/plugins/typo_textfilter_sparkline/lib/typo_textfilter_sparkline.rb +92 -0
- data/vendor/plugins/typo_textfilter_sparkline/tasks/typo_textfilter_sparkline_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_sparkline/test/typo_textfilter_sparkline_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_textile/README +4 -0
- data/vendor/plugins/typo_textfilter_textile/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_textile/init.rb +2 -0
- data/vendor/plugins/typo_textfilter_textile/install.rb +1 -0
- data/vendor/plugins/typo_textfilter_textile/lib/typo_textfilter_textile.rb +18 -0
- data/vendor/plugins/typo_textfilter_textile/tasks/typo_textfilter_textile_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_textile/test/typo_textfilter_textile_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_textile_and_markdown/README +4 -0
- data/vendor/plugins/typo_textfilter_textile_and_markdown/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_textile_and_markdown/init.rb +2 -0
- data/vendor/plugins/typo_textfilter_textile_and_markdown/install.rb +1 -0
- data/vendor/plugins/typo_textfilter_textile_and_markdown/lib/typo_textfilter_textile_and_markdown.rb +12 -0
- data/vendor/plugins/typo_textfilter_textile_and_markdown/tasks/typo_textfilter_textile_and_markdown_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_textile_and_markdown/test/typo_textfilter_textile_and_markdown_test.rb +8 -0
- data/vendor/plugins/typo_textfilter_tmcode/README +4 -0
- data/vendor/plugins/typo_textfilter_tmcode/Rakefile +22 -0
- data/vendor/plugins/typo_textfilter_tmcode/init.rb +3 -0
- data/vendor/plugins/typo_textfilter_tmcode/install.rb +1 -0
- data/vendor/plugins/typo_textfilter_tmcode/lib/typo_textfilter_tmcode.rb +86 -0
- data/vendor/plugins/typo_textfilter_tmcode/tasks/typo_textfilter_tmcode_tasks.rake +4 -0
- data/vendor/plugins/typo_textfilter_tmcode/test/typo_textfilter_tmcode_test.rb +8 -0
- data/vendor/plugins/upcoming_sidebar/Rakefile +22 -0
- data/vendor/plugins/upcoming_sidebar/init.rb +5 -0
- data/{app/models/aggregations → vendor/plugins/upcoming_sidebar/lib}/upcoming.rb +0 -0
- data/vendor/plugins/upcoming_sidebar/lib/upcoming_sidebar.rb +15 -0
- data/vendor/plugins/upcoming_sidebar/test/upcoming_sidebar_test.rb +8 -0
- data/{components/plugins/sidebars/upcoming → vendor/plugins/upcoming_sidebar/views}/content.rhtml +3 -3
- data/vendor/plugins/xbox_sidebar/Rakefile +22 -0
- data/vendor/plugins/xbox_sidebar/init.rb +5 -0
- data/{components/plugins/sidebars/xbox_controller.rb → vendor/plugins/xbox_sidebar/lib/xbox_sidebar.rb} +1 -1
- data/vendor/plugins/xbox_sidebar/test/xbox_sidebar_test.rb +8 -0
- data/vendor/plugins/xbox_sidebar/views/content.rhtml +2 -0
- data/vendor/plugins/xml_sidebar/Rakefile +22 -0
- data/vendor/plugins/xml_sidebar/init.rb +5 -0
- data/{components/plugins/sidebars/xml_controller.rb → vendor/plugins/xml_sidebar/lib/xml_sidebar.rb} +1 -1
- data/vendor/plugins/xml_sidebar/test/xml_sidebar_test.rb +8 -0
- data/vendor/plugins/xml_sidebar/views/content.rhtml +12 -0
- metadata +505 -101
- data/app/controllers/sidebar_controller.rb +0 -50
- data/app/models/content_observer.rb +0 -5
- data/components/plugins/sidebars/aimpresence/content.rhtml +0 -4
- data/components/plugins/sidebars/aimpresence_controller.rb +0 -10
- data/components/plugins/sidebars/amazon/content.rhtml +0 -4
- data/components/plugins/sidebars/amazon_controller.rb +0 -17
- data/components/plugins/sidebars/category/content.rhtml +0 -10
- data/components/plugins/sidebars/delicious/content.rhtml +0 -20
- data/components/plugins/sidebars/flickr_controller.rb +0 -16
- data/components/plugins/sidebars/fortythree/content.rhtml +0 -8
- data/components/plugins/sidebars/fortythreeplaces/content.rhtml +0 -8
- data/components/plugins/sidebars/magnolia/content.rhtml +0 -12
- data/components/plugins/sidebars/magnolia_controller.rb +0 -17
- data/components/plugins/sidebars/recent_comments_controller.rb +0 -23
- data/components/plugins/sidebars/static/content.rhtml +0 -2
- data/components/plugins/sidebars/tag/content.rhtml +0 -8
- data/components/plugins/sidebars/tag_controller.rb +0 -18
- data/components/plugins/sidebars/technorati/content.rhtml +0 -8
- data/components/plugins/sidebars/upcoming_controller.rb +0 -11
- data/components/plugins/sidebars/xbox/content.rhtml +0 -2
- data/components/plugins/sidebars/xml/content.rhtml +0 -12
- data/components/plugins/textfilters/amazon_controller.rb +0 -39
- data/components/plugins/textfilters/code_controller.rb +0 -59
- data/components/plugins/textfilters/flickr_controller.rb +0 -75
- data/components/plugins/textfilters/htmlfilter_controller.rb +0 -8
- data/components/plugins/textfilters/macropost_controller.rb +0 -14
- data/components/plugins/textfilters/macropre_controller.rb +0 -14
- data/components/plugins/textfilters/none_controller.rb +0 -8
- data/components/plugins/textfilters/smartypants_controller.rb +0 -8
- data/components/plugins/textfilters/sparkline_controller.rb +0 -88
- data/components/plugins/textfilters/textile_and_markdown_controller.rb +0 -8
- data/components/plugins/textfilters/textile_controller.rb +0 -14
- data/db/schema.mysql-v3.sql +0 -218
- data/lib/generators/sidebar/templates/components/plugins/sidebars/controller_template.rb +0 -20
- data/lib/generators/sidebar/templates/components/plugins/sidebars/views/content_template.rhtml +0 -4
- data/lib/rails_patch/components.rb +0 -14
- data/public/images/checked.gif +0 -0
- data/test/unit/observer_test.rb +0 -40
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
volatile_requires = ['rcov/rcovtask']
|
5
|
+
not_loaded = []
|
6
|
+
volatile_requires.each do |file|
|
7
|
+
begin
|
8
|
+
require file
|
9
|
+
rescue LoadError
|
10
|
+
not_loaded.push file
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# For some crazy reason,
|
15
|
+
# some Rake tasks interfere with others
|
16
|
+
# (specifically, benchmarking).
|
17
|
+
# Thus, it's advantageous to only show
|
18
|
+
# the task currently being used.
|
19
|
+
def is_task?(*tasks)
|
20
|
+
ARGV[0].nil? || tasks.include?(ARGV[0])
|
21
|
+
end
|
22
|
+
|
23
|
+
# ----- Default: Testing ------
|
24
|
+
|
25
|
+
desc 'Default: run unit tests.'
|
26
|
+
task :default => :test
|
27
|
+
|
28
|
+
if is_task?('test', 'default')
|
29
|
+
require 'rake/testtask'
|
30
|
+
|
31
|
+
desc 'Test the Haml plugin'
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
33
|
+
t.libs << 'lib'
|
34
|
+
t.pattern = 'test/**/*_test.rb'
|
35
|
+
t.verbose = true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# ----- Packaging -----
|
40
|
+
|
41
|
+
if is_task?('package', 'repackage', 'clobber_package')
|
42
|
+
require 'rake/gempackagetask'
|
43
|
+
|
44
|
+
spec = Gem::Specification.new do |spec|
|
45
|
+
spec.name = 'haml'
|
46
|
+
spec.summary = 'An elegant, structured XHTML/XML templating engine.'
|
47
|
+
spec.version = File.read('VERSION').strip
|
48
|
+
spec.author = 'Hampton Catlin'
|
49
|
+
spec.email = 'haml@googlegroups.com'
|
50
|
+
spec.description = <<-END
|
51
|
+
Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML
|
52
|
+
that's designed to express the structure of XHTML or XML documents
|
53
|
+
in a non-repetitive, elegant, easy way,
|
54
|
+
using indentation rather than closing tags
|
55
|
+
and allowing Ruby to be embedded with ease.
|
56
|
+
It was originally envisioned as a plugin for Ruby on Rails,
|
57
|
+
but it can function as a stand-alone templating engine.
|
58
|
+
END
|
59
|
+
|
60
|
+
readmes = FileList.new('*') { |list| list.exclude(/[a-z]/) }.to_a
|
61
|
+
spec.executables = ['haml']
|
62
|
+
spec.files = FileList['lib/**/*', 'bin/*', 'test/**/*', 'Rakefile'].to_a + readmes
|
63
|
+
spec.homepage = 'http://haml.hamptoncatlin.com/'
|
64
|
+
spec.has_rdoc = true
|
65
|
+
spec.extra_rdoc_files = readmes
|
66
|
+
spec.rdoc_options += [
|
67
|
+
'--title', 'Haml',
|
68
|
+
'--main', 'REFERENCE',
|
69
|
+
'--exclude', 'lib/haml/buffer.rb',
|
70
|
+
'--line-numbers',
|
71
|
+
'--inline-source'
|
72
|
+
]
|
73
|
+
spec.test_files = FileList['test/**/*_test.rb'].to_a
|
74
|
+
end
|
75
|
+
|
76
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
77
|
+
pkg.need_zip = true
|
78
|
+
pkg.need_tar_gz = true
|
79
|
+
pkg.need_tar_bz2 = true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# ----- Benchmarking -----
|
84
|
+
|
85
|
+
if is_task?('benchmark')
|
86
|
+
temp_desc = <<END
|
87
|
+
Benchmark HAML against ERb.
|
88
|
+
TIMES=n sets the number of runs. Defaults to 100.
|
89
|
+
END
|
90
|
+
|
91
|
+
desc temp_desc.chomp
|
92
|
+
task :benchmark do
|
93
|
+
require 'test/benchmark'
|
94
|
+
|
95
|
+
puts '-'*51, "Benchmark: Haml vs. ERb", '-'*51
|
96
|
+
puts "Running benchmark #{ENV['TIMES']} times..." if ENV['TIMES']
|
97
|
+
times = ENV['TIMES'].to_i if ENV['TIMES']
|
98
|
+
benchmarker = Haml::Benchmarker.new
|
99
|
+
puts benchmarker.benchmark(times || 100)
|
100
|
+
puts '-'*51
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# ----- Documentation -----
|
105
|
+
|
106
|
+
if is_task?('rdoc', 'rerdoc', 'clobber_rdoc', 'rdoc_devel', 'rerdoc_devel', 'clobber_rdoc_devel')
|
107
|
+
require 'rake/rdoctask'
|
108
|
+
|
109
|
+
rdoc_task = Proc.new do |rdoc|
|
110
|
+
rdoc.title = 'Haml'
|
111
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
112
|
+
rdoc.rdoc_files.include('REFERENCE')
|
113
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
114
|
+
rdoc.rdoc_files.exclude('lib/haml/buffer.rb')
|
115
|
+
end
|
116
|
+
|
117
|
+
Rake::RDocTask.new do |rdoc|
|
118
|
+
rdoc_task.call(rdoc)
|
119
|
+
rdoc.rdoc_dir = 'rdoc'
|
120
|
+
end
|
121
|
+
|
122
|
+
Rake::RDocTask.new(:rdoc_devel) do |rdoc|
|
123
|
+
rdoc_task.call(rdoc)
|
124
|
+
rdoc.rdoc_dir = 'rdoc_devel'
|
125
|
+
rdoc.options << '--all'
|
126
|
+
rdoc.rdoc_files.include('test/*.rb')
|
127
|
+
rdoc.rdoc_files = Rake::FileList.new(*rdoc.rdoc_files.to_a)
|
128
|
+
rdoc.rdoc_files.include('lib/haml/buffer.rb')
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# ----- Coverage -----
|
133
|
+
|
134
|
+
if is_task?('rcov', 'clobber_rcov')
|
135
|
+
unless not_loaded.include? 'rcov/rcovtask'
|
136
|
+
Rcov::RcovTask.new do |t|
|
137
|
+
t.libs << "test"
|
138
|
+
t.test_files = FileList['test/**/*_test.rb']
|
139
|
+
if ENV['NON_NATIVE']
|
140
|
+
t.rcov_opts << "--no-rcovrt"
|
141
|
+
end
|
142
|
+
t.verbose = true
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# ----- Profiling -----
|
148
|
+
|
149
|
+
if is_task?('profile')
|
150
|
+
temp_desc = <<END
|
151
|
+
Run a profile of HAML.
|
152
|
+
TIMES=n sets the number of runs. Defaults to 100.
|
153
|
+
FILE=n sets the file to profile. Defaults to 'standard'.
|
154
|
+
END
|
155
|
+
desc temp_desc.chomp
|
156
|
+
task :profile do
|
157
|
+
require 'test/profile'
|
158
|
+
|
159
|
+
puts '-'*51, "Profiling Haml::Template", '-'*51
|
160
|
+
|
161
|
+
args = []
|
162
|
+
args.push ENV['TIMES'].to_i if ENV['TIMES']
|
163
|
+
args.push ENV['FILE'] if ENV['FILE']
|
164
|
+
|
165
|
+
profiler = Haml::Profiler.new
|
166
|
+
res = profiler.profile(*args)
|
167
|
+
puts res
|
168
|
+
|
169
|
+
puts '-'*51
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
1.0.3
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# The command line Haml parser.
|
3
|
+
|
4
|
+
if ARGV[0] == "--help" or ARGV[0] == "-h" or ARGV[0] == "-?"
|
5
|
+
puts <<END
|
6
|
+
Usage: haml (template file) (output file)
|
7
|
+
|
8
|
+
Description:
|
9
|
+
Uses the Haml engine to parse the specified template
|
10
|
+
and outputs the result to the specified file.
|
11
|
+
END
|
12
|
+
else
|
13
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'haml', 'engine')
|
14
|
+
|
15
|
+
template = File.read(ARGV[0])
|
16
|
+
result = Haml::Engine.new(template).to_html
|
17
|
+
File.open(ARGV[1], "w") { |f| f.write(result) }
|
18
|
+
end
|
@@ -0,0 +1,224 @@
|
|
1
|
+
module Haml
|
2
|
+
# This class is used only internally. It holds the buffer of XHTML that
|
3
|
+
# is eventually output by Haml::Engine's to_html method. It's called
|
4
|
+
# from within the precompiled code, and helps reduce the amount of
|
5
|
+
# processing done within instance_eval'd code.
|
6
|
+
class Buffer
|
7
|
+
include Haml::Helpers
|
8
|
+
|
9
|
+
# Set the maximum length for a line to be considered a one-liner.
|
10
|
+
# Lines <= the maximum will be rendered on one line,
|
11
|
+
# i.e. <tt><p>Hello world</p></tt>
|
12
|
+
ONE_LINER_LENGTH = 50
|
13
|
+
|
14
|
+
# The string that holds the compiled XHTML. This is aliased as
|
15
|
+
# _erbout for compatibility with ERB-specific code.
|
16
|
+
attr_accessor :buffer
|
17
|
+
|
18
|
+
# The number of tabs that are added or subtracted from the
|
19
|
+
# tabulation proscribed by the precompiled template.
|
20
|
+
attr_accessor :tabulation
|
21
|
+
|
22
|
+
# Creates a new buffer.
|
23
|
+
def initialize(options = {})
|
24
|
+
@options = options
|
25
|
+
@quote_escape = options[:attr_wrapper] == '"' ? """ : "'"
|
26
|
+
@other_quote_char = options[:attr_wrapper] == '"' ? "'" : '"'
|
27
|
+
@buffer = ""
|
28
|
+
@one_liner_pending = false
|
29
|
+
@tabulation = 0
|
30
|
+
end
|
31
|
+
|
32
|
+
# Renders +text+ with the proper tabulation. This also deals with
|
33
|
+
# making a possible one-line tag one line or not.
|
34
|
+
def push_text(text, tabulation, flattened = false)
|
35
|
+
if flattened
|
36
|
+
# In this case, tabulation is the number of spaces, rather
|
37
|
+
# than the number of tabs.
|
38
|
+
@buffer << "#{' ' * tabulation}#{flatten(text + "\n")}"
|
39
|
+
@one_liner_pending = true
|
40
|
+
elsif @one_liner_pending && one_liner?(text)
|
41
|
+
@buffer << text
|
42
|
+
else
|
43
|
+
if @one_liner_pending
|
44
|
+
@buffer << "\n"
|
45
|
+
@one_liner_pending = false
|
46
|
+
end
|
47
|
+
@buffer << "#{tabs(tabulation)}#{text}\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Properly formats the output of a script that was run in the
|
52
|
+
# instance_eval.
|
53
|
+
def push_script(result, tabulation, flattened)
|
54
|
+
if flattened
|
55
|
+
result = find_and_flatten(result)
|
56
|
+
end
|
57
|
+
unless result.nil?
|
58
|
+
result = result.to_s
|
59
|
+
while result[-1] == 10 # \n
|
60
|
+
# String#chomp is slow
|
61
|
+
result = result[0...-1]
|
62
|
+
end
|
63
|
+
|
64
|
+
result = result.gsub("\n", "\n#{tabs(tabulation)}")
|
65
|
+
push_text result, tabulation
|
66
|
+
end
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
|
70
|
+
# Takes the various information about the opening tag for an
|
71
|
+
# element, formats it, and adds it to the buffer.
|
72
|
+
def open_tag(name, tabulation, atomic, try_one_line, class_id, attributes_hash, obj_ref, flattened)
|
73
|
+
attributes = {}
|
74
|
+
attributes.merge!(parse_object_ref(obj_ref)) if obj_ref
|
75
|
+
attributes.merge!(parse_class_and_id(class_id)) unless class_id.nil? || class_id.empty?
|
76
|
+
attributes.merge!(attributes_hash) if attributes_hash
|
77
|
+
|
78
|
+
@one_liner_pending = false
|
79
|
+
if atomic
|
80
|
+
str = " />\n"
|
81
|
+
elsif try_one_line
|
82
|
+
@one_liner_pending = true
|
83
|
+
str = ">"
|
84
|
+
elsif flattened
|
85
|
+
str = ">
"
|
86
|
+
else
|
87
|
+
str = ">\n"
|
88
|
+
end
|
89
|
+
@buffer << "#{tabs(tabulation)}<#{name}#{build_attributes(attributes)}#{str}"
|
90
|
+
end
|
91
|
+
|
92
|
+
# Creates a closing tag with the given name.
|
93
|
+
def close_tag(name, tabulation)
|
94
|
+
if @one_liner_pending
|
95
|
+
@buffer << "</#{name}>\n"
|
96
|
+
@one_liner_pending = false
|
97
|
+
else
|
98
|
+
push_text("</#{name}>", tabulation)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Opens an XHTML comment.
|
103
|
+
def open_comment(try_one_line, conditional, tabulation)
|
104
|
+
conditional << ">" if conditional
|
105
|
+
@buffer << "#{tabs(tabulation)}<!--#{conditional.to_s} "
|
106
|
+
if try_one_line
|
107
|
+
@one_liner_pending = true
|
108
|
+
else
|
109
|
+
@buffer << "\n"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Closes an XHTML comment.
|
114
|
+
def close_comment(has_conditional, tabulation)
|
115
|
+
close_tag = has_conditional ? "<![endif]-->" : "-->"
|
116
|
+
if @one_liner_pending
|
117
|
+
@buffer << " #{close_tag}\n"
|
118
|
+
@one_liner_pending = false
|
119
|
+
else
|
120
|
+
push_text(close_tag, tabulation)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Stops parsing a flat section.
|
125
|
+
def stop_flat
|
126
|
+
buffer.concat("\n")
|
127
|
+
@one_liner_pending = false
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
# Gets <tt>count</tt> tabs. Mostly for internal use.
|
133
|
+
def tabs(count)
|
134
|
+
' ' * (count + @tabulation)
|
135
|
+
end
|
136
|
+
|
137
|
+
# Iterates through the classes and ids supplied through <tt>.</tt>
|
138
|
+
# and <tt>#</tt> syntax, and returns a hash with them as attributes,
|
139
|
+
# that can then be merged with another attributes hash.
|
140
|
+
def parse_class_and_id(list)
|
141
|
+
attributes = {}
|
142
|
+
list.scan(/([#.])([-_a-zA-Z0-9]+)/) do |type, property|
|
143
|
+
case type
|
144
|
+
when '.'
|
145
|
+
if attributes[:class]
|
146
|
+
attributes[:class] += " "
|
147
|
+
else
|
148
|
+
attributes[:class] = ""
|
149
|
+
end
|
150
|
+
attributes[:class] += property
|
151
|
+
when '#'
|
152
|
+
attributes[:id] = property
|
153
|
+
end
|
154
|
+
end
|
155
|
+
attributes
|
156
|
+
end
|
157
|
+
|
158
|
+
# Takes an array of objects and uses the class and id of the first
|
159
|
+
# one to create an attributes hash.
|
160
|
+
def parse_object_ref(ref)
|
161
|
+
ref = ref[0]
|
162
|
+
# Let's make sure the value isn't nil. If it is, return the default Hash.
|
163
|
+
return {} if ref.nil?
|
164
|
+
class_name = ref.class.to_s.underscore
|
165
|
+
{:id => "#{class_name}_#{ref.id}", :class => class_name}
|
166
|
+
end
|
167
|
+
|
168
|
+
# Takes a hash and builds a list of XHTML attributes from it, returning
|
169
|
+
# the result.
|
170
|
+
def build_attributes(attributes = {})
|
171
|
+
result = attributes.collect do |a,v|
|
172
|
+
unless v.nil?
|
173
|
+
v = v.to_s
|
174
|
+
attr_wrapper = @options[:attr_wrapper]
|
175
|
+
if v.include? attr_wrapper
|
176
|
+
if v.include? @other_quote_char
|
177
|
+
v = v.gsub(attr_wrapper, @quote_escape)
|
178
|
+
else
|
179
|
+
attr_wrapper = @other_quote_char
|
180
|
+
end
|
181
|
+
end
|
182
|
+
" #{a}=#{attr_wrapper}#{v}#{attr_wrapper}"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
result.sort.join
|
186
|
+
end
|
187
|
+
|
188
|
+
# Returns whether or not the given value is short enough to be rendered
|
189
|
+
# on one line.
|
190
|
+
def one_liner?(value)
|
191
|
+
value.length <= ONE_LINER_LENGTH && value.scan(/\n/).empty?
|
192
|
+
end
|
193
|
+
|
194
|
+
# Isolates the whitespace-sensitive tags in the string and uses Haml::Helpers#flatten
|
195
|
+
# to convert any endlines inside them into html entities.
|
196
|
+
def find_and_flatten(input)
|
197
|
+
input = input.to_s
|
198
|
+
input.scan(/<(textarea|code|pre)[^>]*>(.*?)<\/\1>/im) do |tag, contents|
|
199
|
+
input = input.gsub(contents, Haml::Helpers.flatten(contents))
|
200
|
+
end
|
201
|
+
input
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
class String # :nodoc
|
207
|
+
alias_method :old_comp, :<=>
|
208
|
+
def <=>(other)
|
209
|
+
if other.is_a? NilClass
|
210
|
+
-1
|
211
|
+
else
|
212
|
+
old_comp(other)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
class NilClass # :nodoc:
|
218
|
+
include Comparable
|
219
|
+
|
220
|
+
def <=>(other)
|
221
|
+
other.nil? ? 0 : 1
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
@@ -0,0 +1,557 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helpers'
|
2
|
+
require File.dirname(__FILE__) + '/buffer'
|
3
|
+
|
4
|
+
module Haml
|
5
|
+
# This is the class where all the parsing and processing of the HAML
|
6
|
+
# template is done. It can be directly used by the user by creating a
|
7
|
+
# new instance and calling to_html to render the template. For example:
|
8
|
+
#
|
9
|
+
# template = File.load('templates/really_cool_template.haml')
|
10
|
+
# haml_engine = Haml::Engine.new(template)
|
11
|
+
# output = haml_engine.to_html
|
12
|
+
# puts output
|
13
|
+
class Engine
|
14
|
+
# Allow access to the precompiled template
|
15
|
+
attr_reader :precompiled
|
16
|
+
|
17
|
+
# Allow reading and writing of the options hash
|
18
|
+
attr :options, true
|
19
|
+
|
20
|
+
# Designates an XHTML/XML element.
|
21
|
+
ELEMENT = '%'[0]
|
22
|
+
|
23
|
+
# Designates a <tt><div></tt> element with the given class.
|
24
|
+
DIV_CLASS = '.'[0]
|
25
|
+
|
26
|
+
# Designates a <tt><div></tt> element with the given id.
|
27
|
+
DIV_ID = '#'[0]
|
28
|
+
|
29
|
+
# Designates an XHTML/XML comment.
|
30
|
+
COMMENT = '/'[0]
|
31
|
+
|
32
|
+
# Designates an XHTML doctype.
|
33
|
+
DOCTYPE = '!'[0]
|
34
|
+
|
35
|
+
# Designates script, the result of which is output.
|
36
|
+
SCRIPT = '='[0]
|
37
|
+
|
38
|
+
# Designates script, the result of which is flattened and output.
|
39
|
+
FLAT_SCRIPT = '~'[0]
|
40
|
+
|
41
|
+
# Designates script which is run but not output.
|
42
|
+
SILENT_SCRIPT = '-'[0]
|
43
|
+
|
44
|
+
# When following SILENT_SCRIPT, designates a comment that is not output.
|
45
|
+
SILENT_COMMENT = '#'[0]
|
46
|
+
|
47
|
+
# Designates a non-parsed line.
|
48
|
+
ESCAPE = '\\'[0]
|
49
|
+
|
50
|
+
# Designates a non-parsed line. Not actually a character.
|
51
|
+
PLAIN_TEXT = -1
|
52
|
+
|
53
|
+
# Keeps track of the ASCII values of the characters that begin a
|
54
|
+
# specially-interpreted line.
|
55
|
+
SPECIAL_CHARACTERS = [
|
56
|
+
ELEMENT,
|
57
|
+
DIV_CLASS,
|
58
|
+
DIV_ID,
|
59
|
+
COMMENT,
|
60
|
+
DOCTYPE,
|
61
|
+
SCRIPT,
|
62
|
+
FLAT_SCRIPT,
|
63
|
+
SILENT_SCRIPT,
|
64
|
+
ESCAPE
|
65
|
+
]
|
66
|
+
|
67
|
+
# The value of the character that designates that a line is part
|
68
|
+
# of a multiline string.
|
69
|
+
MULTILINE_CHAR_VALUE = '|'[0]
|
70
|
+
|
71
|
+
# Characters that designate that a multiline string may be about
|
72
|
+
# to begin.
|
73
|
+
MULTILINE_STARTERS = SPECIAL_CHARACTERS - ["/"[0]]
|
74
|
+
|
75
|
+
# Keywords that appear in the middle of a Ruby block with lowered
|
76
|
+
# indentation. If a block has been started using indentation,
|
77
|
+
# lowering the indentation with one of these won't end the block.
|
78
|
+
# For example:
|
79
|
+
#
|
80
|
+
# - if foo
|
81
|
+
# %p yes!
|
82
|
+
# - else
|
83
|
+
# %p no!
|
84
|
+
#
|
85
|
+
# The block is ended after <tt>%p no!</tt>, because <tt>else</tt>
|
86
|
+
# is a member of this array.
|
87
|
+
MID_BLOCK_KEYWORDS = ['else', 'elsif', 'rescue', 'ensure', 'when']
|
88
|
+
|
89
|
+
# Creates a new instace of Haml::Engine that will compile the given
|
90
|
+
# template string when <tt>to_html</tt> is called.
|
91
|
+
# See REFERENCE for available options.
|
92
|
+
#
|
93
|
+
#--
|
94
|
+
# When adding options, remember to add information about them
|
95
|
+
# to REFERENCE!
|
96
|
+
#++
|
97
|
+
#
|
98
|
+
def initialize(template, options = {})
|
99
|
+
@options = {
|
100
|
+
:suppress_eval => false,
|
101
|
+
:attr_wrapper => "'",
|
102
|
+
:locals => {}
|
103
|
+
}.merge options
|
104
|
+
@precompiled = @options[:precompiled]
|
105
|
+
|
106
|
+
@template = template.strip #String
|
107
|
+
@to_close_stack = []
|
108
|
+
@output_tabs = 0
|
109
|
+
@template_tabs = 0
|
110
|
+
|
111
|
+
# This is the base tabulation of the currently active
|
112
|
+
# flattened block. -1 signifies that there is no such block.
|
113
|
+
@flat_spaces = -1
|
114
|
+
|
115
|
+
# Only do the first round of pre-compiling if we really need to.
|
116
|
+
# They might be passing in the precompiled string.
|
117
|
+
do_precompile if @precompiled.nil? && (@precompiled = String.new)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Processes the template and returns the result as a string.
|
121
|
+
def to_html(scope = Object.new, &block)
|
122
|
+
@scope_object = scope
|
123
|
+
@buffer = Haml::Buffer.new(@options)
|
124
|
+
|
125
|
+
local_assigns = @options[:locals]
|
126
|
+
|
127
|
+
# Get inside the view object's world
|
128
|
+
@scope_object.instance_eval do
|
129
|
+
# Set all the local assigns
|
130
|
+
local_assigns.each do |key,val|
|
131
|
+
self.class.send(:define_method, key) { val }
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Compile the @precompiled buffer
|
136
|
+
compile &block
|
137
|
+
|
138
|
+
# Return the result string
|
139
|
+
@buffer.buffer
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
|
144
|
+
#Precompile each line
|
145
|
+
def do_precompile
|
146
|
+
push_silent <<-END
|
147
|
+
def _haml_render
|
148
|
+
_hamlout = @haml_stack[-1]
|
149
|
+
_erbout = _hamlout.buffer
|
150
|
+
END
|
151
|
+
|
152
|
+
old_line = nil
|
153
|
+
old_index = nil
|
154
|
+
old_spaces = nil
|
155
|
+
old_tabs = nil
|
156
|
+
(@template + "\n-#").each_with_index do |line, index|
|
157
|
+
spaces, tabs = count_soft_tabs(line)
|
158
|
+
line = line.strip
|
159
|
+
|
160
|
+
if !line.empty?
|
161
|
+
if old_line
|
162
|
+
block_opened = tabs > old_tabs && !line.empty?
|
163
|
+
|
164
|
+
suppress_render = handle_multiline(old_tabs, old_line, old_index)
|
165
|
+
|
166
|
+
if !suppress_render
|
167
|
+
line_empty = old_line.empty?
|
168
|
+
process_indent(old_tabs, old_line) unless line_empty
|
169
|
+
flat = @flat_spaces != -1
|
170
|
+
|
171
|
+
if flat
|
172
|
+
push_flat(old_line, old_spaces)
|
173
|
+
elsif !line_empty
|
174
|
+
process_line(old_line, old_index, block_opened)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
old_line = line
|
180
|
+
old_index = index
|
181
|
+
old_spaces = spaces
|
182
|
+
old_tabs = tabs
|
183
|
+
elsif @flat_spaces != -1
|
184
|
+
push_flat(old_line, old_spaces)
|
185
|
+
old_line = ''
|
186
|
+
old_spaces = 0
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
# Close all the open tags
|
191
|
+
@template_tabs.times { close }
|
192
|
+
|
193
|
+
push_silent "end"
|
194
|
+
end
|
195
|
+
|
196
|
+
# Processes and deals with lowering indentation.
|
197
|
+
def process_indent(count, line)
|
198
|
+
if count <= @template_tabs && @template_tabs > 0
|
199
|
+
to_close = @template_tabs - count
|
200
|
+
|
201
|
+
to_close.times do |i|
|
202
|
+
offset = to_close - 1 - i
|
203
|
+
unless offset == 0 && mid_block_keyword?(line)
|
204
|
+
close
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
# Processes a single line of HAML.
|
211
|
+
#
|
212
|
+
# This method doesn't return anything; it simply processes the line and
|
213
|
+
# adds the appropriate code to <tt>@precompiled</tt>.
|
214
|
+
def process_line(line, index, block_opened)
|
215
|
+
case line[0]
|
216
|
+
when DIV_CLASS, DIV_ID
|
217
|
+
render_div(line, index)
|
218
|
+
when ELEMENT
|
219
|
+
render_tag(line, index)
|
220
|
+
when COMMENT
|
221
|
+
render_comment(line)
|
222
|
+
when SCRIPT
|
223
|
+
push_script(line[1..-1], false, block_opened, index)
|
224
|
+
when FLAT_SCRIPT
|
225
|
+
push_flat_script(line[1..-1], block_opened, index)
|
226
|
+
when SILENT_SCRIPT
|
227
|
+
sub_line = line[1..-1]
|
228
|
+
unless sub_line[0] == SILENT_COMMENT
|
229
|
+
push_silent(sub_line, index)
|
230
|
+
if block_opened && !mid_block_keyword?(line)
|
231
|
+
push_and_tabulate([:script])
|
232
|
+
end
|
233
|
+
end
|
234
|
+
when DOCTYPE
|
235
|
+
if line[0...3] == '!!!'
|
236
|
+
render_doctype(line)
|
237
|
+
else
|
238
|
+
push_text line
|
239
|
+
end
|
240
|
+
when ESCAPE
|
241
|
+
push_text line[1..-1]
|
242
|
+
else
|
243
|
+
push_text line
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
# Returns whether or not the line is a silent script line with one
|
248
|
+
# of Ruby's mid-block keywords.
|
249
|
+
def mid_block_keyword?(line)
|
250
|
+
line.length > 2 && line[0] == SILENT_SCRIPT && MID_BLOCK_KEYWORDS.include?(line[1..-1].split[0])
|
251
|
+
end
|
252
|
+
|
253
|
+
# Deals with all the logic of figuring out whether a given line is
|
254
|
+
# the beginning, continuation, or end of a multiline sequence.
|
255
|
+
#
|
256
|
+
# This returns whether or not the line should be
|
257
|
+
# rendered normally.
|
258
|
+
def handle_multiline(count, line, index)
|
259
|
+
suppress_render = false
|
260
|
+
# Multilines are denoting by ending with a `|` (124)
|
261
|
+
if is_multiline?(line) && @multiline_buffer
|
262
|
+
# A multiline string is active, and is being continued
|
263
|
+
@multiline_buffer += line[0...-1]
|
264
|
+
suppress_render = true
|
265
|
+
elsif is_multiline?(line) && (MULTILINE_STARTERS.include? line[0])
|
266
|
+
# A multiline string has just been activated, start adding the lines
|
267
|
+
@multiline_buffer = line[0...-1]
|
268
|
+
@multiline_count = count
|
269
|
+
@multiline_index = index
|
270
|
+
process_indent(count, line)
|
271
|
+
suppress_render = true
|
272
|
+
elsif @multiline_buffer
|
273
|
+
# A multiline string has just ended, make line into the result
|
274
|
+
unless line.empty?
|
275
|
+
process_line(@multiline_buffer, @multiline_index, count > @multiline_count)
|
276
|
+
@multiline_buffer = nil
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
return suppress_render
|
281
|
+
end
|
282
|
+
|
283
|
+
# Checks whether or not +line+ is in a multiline sequence.
|
284
|
+
def is_multiline?(line) # ' '[0] == 32
|
285
|
+
line && line.length > 1 && line[-1] == MULTILINE_CHAR_VALUE && line[-2] == 32
|
286
|
+
end
|
287
|
+
|
288
|
+
# Takes <tt>@precompiled</tt>, a string buffer of Ruby code, and
|
289
|
+
# evaluates it in the context of <tt>@scope_object</tt>, after preparing
|
290
|
+
# <tt>@scope_object</tt>. The code in <tt>@precompiled</tt> populates
|
291
|
+
# <tt>@buffer</tt> with the compiled XHTML code.
|
292
|
+
def compile(&block)
|
293
|
+
# Set the local variables pointing to the buffer
|
294
|
+
buffer = @buffer
|
295
|
+
@scope_object.extend Haml::Helpers
|
296
|
+
@scope_object.instance_eval do
|
297
|
+
@haml_stack ||= Array.new
|
298
|
+
@haml_stack.push(buffer)
|
299
|
+
|
300
|
+
class << self
|
301
|
+
attr :haml_lineno # :nodoc:
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
begin
|
306
|
+
# Evaluate the buffer in the context of the scope object
|
307
|
+
@scope_object.instance_eval @precompiled
|
308
|
+
@scope_object._haml_render &block
|
309
|
+
rescue Exception => e
|
310
|
+
# Get information from the exception and format it so that
|
311
|
+
# Rails can understand it.
|
312
|
+
compile_error = e.message.scan(/\(eval\):([0-9]*):in `[-_a-zA-Z]*': compile error/)[0]
|
313
|
+
filename = "(haml)"
|
314
|
+
if @scope_object.methods.include? "haml_filename"
|
315
|
+
# For some reason that I can't figure out,
|
316
|
+
# @scope_object.methods.include? "haml_filename" && @scope_object.haml_filename
|
317
|
+
# is false when it shouldn't be. Nested if statements work, though.
|
318
|
+
|
319
|
+
if @scope_object.haml_filename
|
320
|
+
filename = "#{@scope_object.haml_filename}.haml"
|
321
|
+
end
|
322
|
+
end
|
323
|
+
lineno = @scope_object.haml_lineno
|
324
|
+
|
325
|
+
if compile_error
|
326
|
+
eval_line = compile_error[0].to_i
|
327
|
+
line_marker = @precompiled.split("\n")[0...eval_line].grep(/@haml_lineno = [0-9]*/)[-1]
|
328
|
+
lineno = line_marker.scan(/[0-9]+/)[0].to_i if line_marker
|
329
|
+
end
|
330
|
+
|
331
|
+
e.backtrace.unshift "#{filename}:#{lineno}"
|
332
|
+
raise e
|
333
|
+
end
|
334
|
+
|
335
|
+
# Get rid of the current buffer
|
336
|
+
@scope_object.instance_eval do
|
337
|
+
@haml_stack.pop
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
# Evaluates <tt>text</tt> in the context of <tt>@scope_object</tt>, but
|
342
|
+
# does not output the result.
|
343
|
+
def push_silent(text, index = nil)
|
344
|
+
if index
|
345
|
+
@precompiled << "@haml_lineno = #{index + 1}\n#{text}\n"
|
346
|
+
else
|
347
|
+
# Not really DRY, but probably faster
|
348
|
+
@precompiled << "#{text}\n"
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
# Adds <tt>text</tt> to <tt>@buffer</tt> with appropriate tabulation
|
353
|
+
# without parsing it.
|
354
|
+
def push_text(text)
|
355
|
+
@precompiled << "_hamlout.push_text(#{text.dump}, #{@output_tabs})\n"
|
356
|
+
end
|
357
|
+
|
358
|
+
# Adds +text+ to <tt>@buffer</tt> while flattening text.
|
359
|
+
def push_flat(text, spaces)
|
360
|
+
tabulation = spaces - @flat_spaces
|
361
|
+
@precompiled << "_hamlout.push_text(#{text.dump}, #{tabulation > -1 ? tabulation : 0}, true)\n"
|
362
|
+
end
|
363
|
+
|
364
|
+
# Causes <tt>text</tt> to be evaluated in the context of
|
365
|
+
# <tt>@scope_object</tt> and the result to be added to <tt>@buffer</tt>.
|
366
|
+
#
|
367
|
+
# If <tt>flattened</tt> is true, Haml::Helpers#find_and_flatten is run on
|
368
|
+
# the result before it is added to <tt>@buffer</tt>
|
369
|
+
def push_script(text, flattened, block_opened, index)
|
370
|
+
unless options[:suppress_eval]
|
371
|
+
push_silent("haml_temp = #{text}", index)
|
372
|
+
out = "haml_temp = _hamlout.push_script(haml_temp, #{@output_tabs}, #{flattened})\n"
|
373
|
+
if block_opened
|
374
|
+
push_and_tabulate([:loud, out])
|
375
|
+
else
|
376
|
+
@precompiled << out
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
# Causes <tt>text</tt> to be evaluated, and Haml::Helpers#find_and_flatten
|
382
|
+
# to be run on it afterwards.
|
383
|
+
def push_flat_script(text, block_opened, index)
|
384
|
+
unless text.empty?
|
385
|
+
push_script(text, true, block_opened, index)
|
386
|
+
else
|
387
|
+
start_flat(false)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
# Closes the most recent item in <tt>@to_close_stack</tt>.
|
392
|
+
def close
|
393
|
+
tag, value = @to_close_stack.pop
|
394
|
+
case tag
|
395
|
+
when :script
|
396
|
+
close_block
|
397
|
+
when :comment
|
398
|
+
close_comment value
|
399
|
+
when :element
|
400
|
+
close_tag value
|
401
|
+
when :flat
|
402
|
+
close_flat value
|
403
|
+
when :loud
|
404
|
+
close_loud value
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
# Puts a line in <tt>@precompiled</tt> that will add the closing tag of
|
409
|
+
# the most recently opened tag.
|
410
|
+
def close_tag(tag)
|
411
|
+
@output_tabs -= 1
|
412
|
+
@template_tabs -= 1
|
413
|
+
@precompiled << "_hamlout.close_tag(#{tag.dump}, #{@output_tabs})\n"
|
414
|
+
end
|
415
|
+
|
416
|
+
# Closes a Ruby block.
|
417
|
+
def close_block
|
418
|
+
push_silent "end"
|
419
|
+
@template_tabs -= 1
|
420
|
+
end
|
421
|
+
|
422
|
+
# Closes a comment.
|
423
|
+
def close_comment(has_conditional)
|
424
|
+
@output_tabs -= 1
|
425
|
+
@template_tabs -= 1
|
426
|
+
push_silent "_hamlout.close_comment(#{has_conditional}, #{@output_tabs})"
|
427
|
+
end
|
428
|
+
|
429
|
+
# Closes a flattened section.
|
430
|
+
def close_flat(in_tag)
|
431
|
+
@flat_spaces = -1
|
432
|
+
if in_tag
|
433
|
+
close
|
434
|
+
else
|
435
|
+
push_silent('_hamlout.stop_flat')
|
436
|
+
@template_tabs -= 1
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
# Closes a loud Ruby block.
|
441
|
+
def close_loud(command)
|
442
|
+
push_silent "end"
|
443
|
+
@precompiled << command
|
444
|
+
@template_tabs -= 1
|
445
|
+
end
|
446
|
+
|
447
|
+
# Parses a line that will render as an XHTML tag, and adds the code that will
|
448
|
+
# render that tag to <tt>@precompiled</tt>.
|
449
|
+
def render_tag(line, index)
|
450
|
+
line.scan(/[%]([-:_a-zA-Z0-9]+)([-_a-zA-Z0-9\.\#]*)(\{.*\})?(\[.*\])?([=\/\~]?)?(.*)?/) do |tag_name, attributes, attributes_hash, object_ref, action, value|
|
451
|
+
value = value.to_s
|
452
|
+
|
453
|
+
case action
|
454
|
+
when '/'
|
455
|
+
atomic = true
|
456
|
+
when '=', '~'
|
457
|
+
parse = true
|
458
|
+
else
|
459
|
+
value = value.strip
|
460
|
+
end
|
461
|
+
|
462
|
+
flattened = (action == '~')
|
463
|
+
value_exists = !value.empty?
|
464
|
+
attributes_hash = "nil" unless attributes_hash
|
465
|
+
object_ref = "nil" unless object_ref
|
466
|
+
|
467
|
+
push_silent "_hamlout.open_tag(#{tag_name.inspect}, #{@output_tabs}, #{atomic.inspect}, #{value_exists.inspect}, #{attributes.inspect}, #{attributes_hash}, #{object_ref}, #{flattened.inspect})"
|
468
|
+
|
469
|
+
unless atomic
|
470
|
+
push_and_tabulate([:element, tag_name])
|
471
|
+
@output_tabs += 1
|
472
|
+
|
473
|
+
if value_exists
|
474
|
+
if parse
|
475
|
+
push_script(value, flattened, false, index)
|
476
|
+
else
|
477
|
+
push_text(value)
|
478
|
+
end
|
479
|
+
close
|
480
|
+
elsif flattened
|
481
|
+
start_flat(true)
|
482
|
+
end
|
483
|
+
end
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
487
|
+
# Renders a line that creates an XHTML tag and has an implicit div because of
|
488
|
+
# <tt>.</tt> or <tt>#</tt>.
|
489
|
+
def render_div(line, index)
|
490
|
+
render_tag('%div' + line, index)
|
491
|
+
end
|
492
|
+
|
493
|
+
# Renders an XHTML comment.
|
494
|
+
def render_comment(line)
|
495
|
+
conditional, content = line.scan(/\/(\[[a-zA-Z0-9 \.]*\])?(.*)/)[0]
|
496
|
+
content = content.strip
|
497
|
+
try_one_line = !content.empty?
|
498
|
+
push_silent "_hamlout.open_comment(#{try_one_line}, #{conditional.inspect}, #{@output_tabs})"
|
499
|
+
@output_tabs += 1
|
500
|
+
push_and_tabulate([:comment, !conditional.nil?])
|
501
|
+
if try_one_line
|
502
|
+
push_text content
|
503
|
+
close
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
# Renders an XHTML doctype or XML shebang.
|
508
|
+
def render_doctype(line)
|
509
|
+
line = line[3..-1].lstrip.downcase
|
510
|
+
if line[0...3] == "xml"
|
511
|
+
encoding = line.split[1] || "utf-8"
|
512
|
+
wrapper = @options[:attr_wrapper]
|
513
|
+
doctype = "<?xml version=#{wrapper}1.0#{wrapper} encoding=#{wrapper}#{encoding}#{wrapper} ?>"
|
514
|
+
else
|
515
|
+
version, type = line.scan(/([0-9]\.[0-9])?[\s]*([a-zA-Z]*)/)[0]
|
516
|
+
if version == "1.1"
|
517
|
+
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
|
518
|
+
else
|
519
|
+
case type
|
520
|
+
when "strict"
|
521
|
+
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
|
522
|
+
when "frameset"
|
523
|
+
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'
|
524
|
+
else
|
525
|
+
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
526
|
+
end
|
527
|
+
end
|
528
|
+
end
|
529
|
+
push_text doctype
|
530
|
+
end
|
531
|
+
|
532
|
+
# Starts a flattened block.
|
533
|
+
def start_flat(in_tag)
|
534
|
+
# @flat_spaces is the number of indentations in the template
|
535
|
+
# that forms the base of the flattened area
|
536
|
+
if in_tag
|
537
|
+
@to_close_stack.push([:flat, true])
|
538
|
+
else
|
539
|
+
push_and_tabulate([:flat])
|
540
|
+
end
|
541
|
+
@flat_spaces = @template_tabs * 2
|
542
|
+
end
|
543
|
+
|
544
|
+
# Counts the tabulation of a line.
|
545
|
+
def count_soft_tabs(line)
|
546
|
+
spaces = line.index(/[^ ]/)
|
547
|
+
spaces ? [spaces, spaces/2] : []
|
548
|
+
end
|
549
|
+
|
550
|
+
# Pushes value onto <tt>@to_close_stack</tt> and increases
|
551
|
+
# <tt>@template_tabs</tt>.
|
552
|
+
def push_and_tabulate(value)
|
553
|
+
@to_close_stack.push(value)
|
554
|
+
@template_tabs += 1
|
555
|
+
end
|
556
|
+
end
|
557
|
+
end
|