publify_core 9.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of publify_core might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/MIT-LICENSE +21 -0
- data/README.rdoc +3 -0
- data/Rakefile +35 -0
- data/app/assets/fonts/open-sans-bold.woff +0 -0
- data/app/assets/fonts/open-sans.woff +0 -0
- data/app/assets/images/admin/loading.gif +0 -0
- data/app/assets/images/admin/typologo.gif +0 -0
- data/app/assets/images/calendar_date_select/calendar.gif +0 -0
- data/app/assets/images/close.gif +0 -0
- data/app/assets/images/closelabel.gif +0 -0
- data/app/assets/images/go.png +0 -0
- data/app/assets/images/loading.gif +0 -0
- data/app/assets/images/nextlabel.gif +0 -0
- data/app/assets/images/overlay.png +0 -0
- data/app/assets/images/powered.gif +0 -0
- data/app/assets/images/prevlabel.gif +0 -0
- data/app/assets/images/spinner-blue.gif +0 -0
- data/app/assets/images/spinner.gif +0 -0
- data/app/assets/images/thumb_blank.jpg +0 -0
- data/app/assets/javascripts/application.js +2 -0
- data/app/assets/javascripts/cookies.js +60 -0
- data/app/assets/javascripts/datetimepicker.js +1470 -0
- data/app/assets/javascripts/lang/da_DK.js +17 -0
- data/app/assets/javascripts/lang/default.js +21 -0
- data/app/assets/javascripts/lang/en_US.js +21 -0
- data/app/assets/javascripts/lang/fr_FR.js +21 -0
- data/app/assets/javascripts/lang/nl_NL.js +21 -0
- data/app/assets/javascripts/lang/zh_TW.js +17 -0
- data/app/assets/javascripts/lightbox.js +350 -0
- data/app/assets/javascripts/observe.js +28 -0
- data/app/assets/javascripts/publify.js +11 -0
- data/app/assets/javascripts/publify_admin.js +138 -0
- data/app/assets/javascripts/quicktags.js +440 -0
- data/app/assets/javascripts/set-timeago-lang.js +3 -0
- data/app/assets/javascripts/sidebar.js +28 -0
- data/app/assets/javascripts/spinnable.js +5 -0
- data/app/assets/javascripts/tagmanager.js +481 -0
- data/app/assets/javascripts/typeahead.js +1139 -0
- data/app/assets/javascripts/widearea.js +486 -0
- data/app/assets/stylesheets/accounts.css.scss +7 -0
- data/app/assets/stylesheets/administration_structure.css.scss +239 -0
- data/app/assets/stylesheets/coderay.css +135 -0
- data/app/assets/stylesheets/datetimepicker.css +306 -0
- data/app/assets/stylesheets/lightbox.css +63 -0
- data/app/assets/stylesheets/publify.css.scss +9 -0
- data/app/assets/stylesheets/publify_admin.css.scss +11 -0
- data/app/assets/stylesheets/rss.css +53 -0
- data/app/assets/stylesheets/sidebar_admin.css.scss +36 -0
- data/app/assets/stylesheets/tagmanager.css +102 -0
- data/app/assets/stylesheets/user-styles.css +29 -0
- data/app/assets/stylesheets/widearea.css +133 -0
- data/app/controllers/accounts_controller.rb +2 -0
- data/app/controllers/admin/base_controller.rb +41 -0
- data/app/controllers/admin/cache_controller.rb +33 -0
- data/app/controllers/admin/content_controller.rb +174 -0
- data/app/controllers/admin/dashboard_controller.rb +87 -0
- data/app/controllers/admin/feedback_controller.rb +159 -0
- data/app/controllers/admin/migrations_controller.rb +20 -0
- data/app/controllers/admin/notes_controller.rb +69 -0
- data/app/controllers/admin/pages_controller.rb +88 -0
- data/app/controllers/admin/post_types_controller.rb +56 -0
- data/app/controllers/admin/profiles_controller.rb +48 -0
- data/app/controllers/admin/redirects_controller.rb +47 -0
- data/app/controllers/admin/resources_controller.rb +30 -0
- data/app/controllers/admin/seo_controller.rb +45 -0
- data/app/controllers/admin/settings_controller.rb +53 -0
- data/app/controllers/admin/sidebar_controller.rb +66 -0
- data/app/controllers/admin/tags_controller.rb +53 -0
- data/app/controllers/admin/textfilters_controller.rb +6 -0
- data/app/controllers/admin/themes_controller.rb +37 -0
- data/app/controllers/admin/users_controller.rb +65 -0
- data/app/controllers/articles_controller.rb +205 -0
- data/app/controllers/authors_controller.rb +27 -0
- data/app/controllers/base_controller.rb +45 -0
- data/app/controllers/comments_controller.rb +69 -0
- data/app/controllers/content_controller.rb +31 -0
- data/app/controllers/feedback_controller.rb +47 -0
- data/app/controllers/notes_controller.rb +37 -0
- data/app/controllers/setup_controller.rb +62 -0
- data/app/controllers/tags_controller.rb +55 -0
- data/app/controllers/text_controller.rb +9 -0
- data/app/controllers/textfilter_controller.rb +3 -0
- data/app/controllers/theme_controller.rb +59 -0
- data/app/controllers/trackbacks_controller.rb +36 -0
- data/app/controllers/xml_controller.rb +70 -0
- data/app/helpers/admin/base_helper.rb +87 -0
- data/app/helpers/admin/feedback_helper.rb +42 -0
- data/app/helpers/articles_helper.rb +8 -0
- data/app/helpers/authors_helper.rb +39 -0
- data/app/helpers/base_helper.rb +246 -0
- data/app/helpers/blog_helper.rb +12 -0
- data/app/helpers/xml_helper.rb +16 -0
- data/app/mailers/notification_mailer.rb +38 -0
- data/app/models/ability.rb +52 -0
- data/app/models/archives_sidebar.rb +45 -0
- data/app/models/article/factory.rb +56 -0
- data/app/models/article/states.rb +178 -0
- data/app/models/article.rb +321 -0
- data/app/models/blog.rb +290 -0
- data/app/models/blog_sweeper.rb +86 -0
- data/app/models/comment.rb +53 -0
- data/app/models/config_manager.rb +81 -0
- data/app/models/content.rb +138 -0
- data/app/models/content_base.rb +95 -0
- data/app/models/feedback/states.rb +256 -0
- data/app/models/feedback.rb +225 -0
- data/app/models/meta_sidebar.rb +8 -0
- data/app/models/note.rb +144 -0
- data/app/models/page.rb +36 -0
- data/app/models/page_cache.rb +33 -0
- data/app/models/page_sidebar.rb +12 -0
- data/app/models/ping.rb +116 -0
- data/app/models/post_type.rb +15 -0
- data/app/models/redirect.rb +45 -0
- data/app/models/redirection.rb +4 -0
- data/app/models/resource.rb +28 -0
- data/app/models/search_sidebar.rb +7 -0
- data/app/models/sidebar.rb +138 -0
- data/app/models/static_sidebar.rb +20 -0
- data/app/models/tag.rb +63 -0
- data/app/models/tag_sidebar.rb +27 -0
- data/app/models/text_filter.rb +61 -0
- data/app/models/trackback.rb +58 -0
- data/app/models/trigger.rb +45 -0
- data/app/models/user.rb +148 -0
- data/app/services/migrator.rb +25 -0
- data/app/services/title_builder.rb +80 -0
- data/app/uploaders/resource_uploader.rb +30 -0
- data/app/views/accounts/confirm.html.erb +8 -0
- data/app/views/admin/cache/show.html.erb +18 -0
- data/app/views/admin/content/_article_list.html.erb +26 -0
- data/app/views/admin/content/_form.html.erb +165 -0
- data/app/views/admin/content/autosave.js.erb +5 -0
- data/app/views/admin/content/edit.html.erb +3 -0
- data/app/views/admin/content/index.html.erb +48 -0
- data/app/views/admin/content/index.js.erb +1 -0
- data/app/views/admin/content/new.html.erb +3 -0
- data/app/views/admin/dashboard/_comment.html.erb +18 -0
- data/app/views/admin/dashboard/_comments.html.erb +10 -0
- data/app/views/admin/dashboard/_drafts.html.erb +25 -0
- data/app/views/admin/dashboard/_inbound.html.erb +31 -0
- data/app/views/admin/dashboard/_overview.html.erb +23 -0
- data/app/views/admin/dashboard/_welcome.html.erb +28 -0
- data/app/views/admin/dashboard/index.html.erb +17 -0
- data/app/views/admin/feedback/_button.html.erb +19 -0
- data/app/views/admin/feedback/_feedback.html.erb +7 -0
- data/app/views/admin/feedback/_ham.html.erb +17 -0
- data/app/views/admin/feedback/_spam.html.erb +23 -0
- data/app/views/admin/feedback/article.html.erb +69 -0
- data/app/views/admin/feedback/edit.html.erb +48 -0
- data/app/views/admin/feedback/ham.js +1 -0
- data/app/views/admin/feedback/index.html.erb +53 -0
- data/app/views/admin/feedback/spam.js +1 -0
- data/app/views/admin/migrations/show.html.erb +39 -0
- data/app/views/admin/notes/_form.html.erb +37 -0
- data/app/views/admin/notes/_header.html.erb +6 -0
- data/app/views/admin/notes/_list.html.erb +13 -0
- data/app/views/admin/notes/_note.html.erb +14 -0
- data/app/views/admin/notes/edit.html.erb +11 -0
- data/app/views/admin/notes/index.html.erb +11 -0
- data/app/views/admin/notes/show.html.erb +14 -0
- data/app/views/admin/pages/_form.html.erb +101 -0
- data/app/views/admin/pages/_pages.html.erb +21 -0
- data/app/views/admin/pages/edit.html.erb +1 -0
- data/app/views/admin/pages/index.html.erb +17 -0
- data/app/views/admin/pages/new.html.erb +1 -0
- data/app/views/admin/post_types/_index_and_form.html.erb +65 -0
- data/app/views/admin/post_types/edit.html.erb +1 -0
- data/app/views/admin/post_types/index.html.erb +1 -0
- data/app/views/admin/profiles/index.html.erb +10 -0
- data/app/views/admin/redirects/_index_and_form.html.erb +68 -0
- data/app/views/admin/redirects/edit.html.erb +1 -0
- data/app/views/admin/redirects/index.html.erb +1 -0
- data/app/views/admin/resources/index.html.erb +68 -0
- data/app/views/admin/seo/_general.html.erb +123 -0
- data/app/views/admin/seo/_permalinks.html.erb +53 -0
- data/app/views/admin/seo/_titles.html.erb +210 -0
- data/app/views/admin/seo/show.html.erb +32 -0
- data/app/views/admin/settings/display.html.erb +110 -0
- data/app/views/admin/settings/feedback.html.erb +125 -0
- data/app/views/admin/settings/index.html.erb +73 -0
- data/app/views/admin/settings/write.html.erb +87 -0
- data/app/views/admin/shared/_edit.html.erb +4 -0
- data/app/views/admin/shared/_menu.html.erb +122 -0
- data/app/views/admin/shared/_twitter_alert.html.erb +3 -0
- data/app/views/admin/sidebar/_available.html.erb +6 -0
- data/app/views/admin/sidebar/_available.json.erb +6 -0
- data/app/views/admin/sidebar/_config.html.erb +27 -0
- data/app/views/admin/sidebar/_target.html.erb +9 -0
- data/app/views/admin/sidebar/_target_sidebar.html.erb +20 -0
- data/app/views/admin/sidebar/destroy.js.erb +1 -0
- data/app/views/admin/sidebar/index.html.erb +31 -0
- data/app/views/admin/sidebar/sortable.js.erb +3 -0
- data/app/views/admin/sidebar/update.js.erb +2 -0
- data/app/views/admin/tags/_index_and_form.html.erb +59 -0
- data/app/views/admin/tags/edit.html.erb +1 -0
- data/app/views/admin/tags/index.html.erb +1 -0
- data/app/views/admin/themes/index.html.erb +27 -0
- data/app/views/admin/users/_form.html.erb +215 -0
- data/app/views/admin/users/edit.html.erb +8 -0
- data/app/views/admin/users/index.html.erb +39 -0
- data/app/views/admin/users/new.html.erb +8 -0
- data/app/views/archives_sidebar/_content.html.erb +13 -0
- data/app/views/articles/_article.html.erb +9 -0
- data/app/views/articles/_article_collection.html.erb +8 -0
- data/app/views/articles/_article_content.html.erb +5 -0
- data/app/views/articles/_article_excerpt.html.erb +13 -0
- data/app/views/articles/_article_links.html.erb +10 -0
- data/app/views/articles/_comment.html.erb +1 -0
- data/app/views/articles/_comment_errors.html.erb +2 -0
- data/app/views/articles/_comment_form.html.erb +48 -0
- data/app/views/articles/_comment_list.html.erb +5 -0
- data/app/views/articles/_comment_preview.html.erb +4 -0
- data/app/views/articles/_full_article_content.html.erb +2 -0
- data/app/views/articles/_password_form.html.erb +10 -0
- data/app/views/articles/_protected_article_content.html.erb +6 -0
- data/app/views/articles/_trackback.html.erb +6 -0
- data/app/views/articles/archives.html.erb +25 -0
- data/app/views/articles/comment.js.erb +5 -0
- data/app/views/articles/comment_failed.js.erb +3 -0
- data/app/views/articles/error.html.erb +3 -0
- data/app/views/articles/feedback_atom_feed.atom.builder +8 -0
- data/app/views/articles/feedback_rss_feed.rss.builder +21 -0
- data/app/views/articles/index.html.erb +1 -0
- data/app/views/articles/index_atom_feed.atom.builder +8 -0
- data/app/views/articles/index_rss_feed.rss.builder +20 -0
- data/app/views/articles/live_search.html.erb +10 -0
- data/app/views/articles/read.html.erb +61 -0
- data/app/views/articles/search.html.erb +8 -0
- data/app/views/articles/trackback.xml.builder +5 -0
- data/app/views/articles/view_page.html.erb +3 -0
- data/app/views/authors/show.html.erb +40 -0
- data/app/views/authors/show_atom_feed.atom.builder +8 -0
- data/app/views/authors/show_rss_feed.rss.builder +20 -0
- data/app/views/comments/_comment.html.erb +16 -0
- data/app/views/comments/index.html.erb +1 -0
- data/app/views/comments/index_atom_feed.atom.builder +8 -0
- data/app/views/comments/index_rss_feed.rss.builder +20 -0
- data/app/views/comments/preview.html.erb +1 -0
- data/app/views/comments/preview.js.erb +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +13 -0
- data/app/views/devise/passwords/edit.html.erb +28 -0
- data/app/views/devise/passwords/new.html.erb +20 -0
- data/app/views/devise/registrations/new.html.erb +36 -0
- data/app/views/devise/sessions/new.html.erb +32 -0
- data/app/views/devise/shared/_links.html.erb +15 -0
- data/app/views/errors/404.html.erb +2 -0
- data/app/views/layouts/accounts.html.erb +33 -0
- data/app/views/layouts/administration.html.erb +37 -0
- data/app/views/layouts/default.html.erb +32 -0
- data/app/views/layouts/editor.html.erb +31 -0
- data/app/views/meta_sidebar/_content.html.erb +8 -0
- data/app/views/notes/_note.html.erb +15 -0
- data/app/views/notes/error.html.erb +3 -0
- data/app/views/notes/index.html.erb +15 -0
- data/app/views/notes/show.html.erb +5 -0
- data/app/views/notes/show_in_reply.html.erb +16 -0
- data/app/views/notification_mailer/_mail_footer.html.erb +7 -0
- data/app/views/notification_mailer/_mail_header.html.erb +1 -0
- data/app/views/notification_mailer/article.html.erb +6 -0
- data/app/views/notification_mailer/comment.html.erb +11 -0
- data/app/views/notification_mailer/notif_user.html.erb +14 -0
- data/app/views/page_sidebar/_content.html.erb +12 -0
- data/app/views/search_sidebar/_content.html.erb +10 -0
- data/app/views/settings/done.html.erb +2 -0
- data/app/views/settings/install.html.erb +12 -0
- data/app/views/setup/index.html.erb +13 -0
- data/app/views/shared/_atom_header.atom.builder +6 -0
- data/app/views/shared/_atom_item_article.atom.builder +39 -0
- data/app/views/shared/_atom_item_comment.atom.builder +10 -0
- data/app/views/shared/_atom_item_trackback.atom.builder +9 -0
- data/app/views/shared/_flash.erb +10 -0
- data/app/views/shared/_page_header.html.erb +26 -0
- data/app/views/shared/_rss_item_article.rss.builder +35 -0
- data/app/views/shared/_rss_item_comment.rss.builder +8 -0
- data/app/views/shared/_rss_item_trackback.rss.builder +7 -0
- data/app/views/sidebar/_row.html.erb +1 -0
- data/app/views/sidebar/_sidebar.html.erb +5 -0
- data/app/views/sidebar/display_plugins.html.erb +5 -0
- data/app/views/sidebar/show.html.erb +1 -0
- data/app/views/static_sidebar/_content.html.erb +2 -0
- data/app/views/tag_sidebar/_content.html.erb +10 -0
- data/app/views/tags/index.html.erb +15 -0
- data/app/views/tags/show.html.erb +1 -0
- data/app/views/theme/static_view_test.html.erb +1 -0
- data/app/views/trackbacks/index_atom_feed.atom.builder +7 -0
- data/app/views/trackbacks/index_rss_feed.rss.builder +20 -0
- data/app/views/trackbacks/trackback.xml.builder +4 -0
- data/app/views/xml/_googlesitemap_item_article.googlesitemap.builder +5 -0
- data/app/views/xml/_googlesitemap_item_category.googlesitemap.builder +4 -0
- data/app/views/xml/_googlesitemap_item_page.googlesitemap.builder +4 -0
- data/app/views/xml/_googlesitemap_item_tag.googlesitemap.builder +4 -0
- data/app/views/xml/feed.googlesitemap.builder +7 -0
- data/app/views/xml/rsd.rsd.builder +8 -0
- data/config/i18n-tasks.yml +49 -0
- data/config/initializers/devise.rb +265 -0
- data/config/initializers/mime_types.rb +6 -0
- data/config/locales/da.yml +827 -0
- data/config/locales/de.yml +827 -0
- data/config/locales/en.yml +827 -0
- data/config/locales/es-MX.yml +827 -0
- data/config/locales/fr.yml +827 -0
- data/config/locales/he.yml +827 -0
- data/config/locales/it.yml +827 -0
- data/config/locales/ja.yml +827 -0
- data/config/locales/lt.yml +827 -0
- data/config/locales/nb-NO.yml +827 -0
- data/config/locales/nl.yml +827 -0
- data/config/locales/pl.yml +827 -0
- data/config/locales/pt-BR.yml +827 -0
- data/config/locales/ro.yml +827 -0
- data/config/locales/ru.yml +827 -0
- data/config/locales/sidebars.da.yml +20 -0
- data/config/locales/sidebars.de.yml +20 -0
- data/config/locales/sidebars.en.yml +20 -0
- data/config/locales/sidebars.es-MX.yml +20 -0
- data/config/locales/sidebars.fr.yml +20 -0
- data/config/locales/sidebars.he.yml +20 -0
- data/config/locales/sidebars.it.yml +20 -0
- data/config/locales/sidebars.ja.yml +20 -0
- data/config/locales/sidebars.lt.yml +20 -0
- data/config/locales/sidebars.nb-NO.yml +20 -0
- data/config/locales/sidebars.nl.yml +20 -0
- data/config/locales/sidebars.pl.yml +20 -0
- data/config/locales/sidebars.pt-BR.yml +20 -0
- data/config/locales/sidebars.ro.yml +20 -0
- data/config/locales/sidebars.ru.yml +20 -0
- data/config/locales/sidebars.zh-CN.yml +20 -0
- data/config/locales/sidebars.zh-TW.yml +20 -0
- data/config/locales/zh-CN.yml +827 -0
- data/config/locales/zh-TW.yml +827 -0
- data/config/routes.rb +177 -0
- data/db/migrate/113_initial_schema.rb +205 -0
- data/db/migrate/114_fixes_buggy_articles_and_notes.rb +52 -0
- data/db/migrate/115_drops_categories_for_tags.rb +34 -0
- data/db/migrate/20150207131657_add_missing_indexes.rb +19 -0
- data/db/migrate/20150807134129_simplify_redirect_relations.rb +38 -0
- data/db/migrate/20150808052637_add_blog_ids.rb +33 -0
- data/db/migrate/20150808191127_add_blog_id_to_redirects.rb +15 -0
- data/db/migrate/20150810094754_add_blog_id_to_tags.rb +15 -0
- data/db/migrate/20160108111120_add_devise_to_users.rb +53 -0
- data/db/migrate/20160108184201_move_last_connection_to_last_sign_in_at.rb +16 -0
- data/db/migrate/20160110094906_remove_profiles_rights.rb +14 -0
- data/db/migrate/20160605103918_replace_profile_id_with_string.rb +30 -0
- data/db/migrate/20160605154632_remove_profiles.rb +24 -0
- data/db/migrate/20160701061851_demand_blog_id_on_contents.rb +9 -0
- data/db/migrate/20160701062604_add_blog_id_to_resources.rb +28 -0
- data/db/seeds.rb +37 -0
- data/lib/email_notify.rb +26 -0
- data/lib/format.rb +17 -0
- data/lib/publify_core/engine.rb +23 -0
- data/lib/publify_core/lang.rb +5 -0
- data/lib/publify_core/version.rb +3 -0
- data/lib/publify_core.rb +56 -0
- data/lib/publify_guid.rb +9 -0
- data/lib/publify_plugins.rb +72 -0
- data/lib/publify_textfilter_markdown.rb +44 -0
- data/lib/publify_textfilter_none.rb +14 -0
- data/lib/publify_textfilter_smartypants.rb +14 -0
- data/lib/publify_textfilter_textile.rb +21 -0
- data/lib/publify_textfilter_twitterfilter.rb +33 -0
- data/lib/publify_time.rb +30 -0
- data/lib/sidebar_field.rb +115 -0
- data/lib/sidebar_registry.rb +33 -0
- data/lib/spam_protection.rb +101 -0
- data/lib/stateful.rb +106 -0
- data/lib/tasks/publify_core_tasks.rake +4 -0
- data/lib/text_filter_plugin.rb +182 -0
- data/lib/theme.rb +72 -0
- data/lib/transforms.rb +45 -0
- metadata +865 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
class ReplaceProfileIdWithString < ActiveRecord::Migration
|
2
|
+
class Profile < ActiveRecord::Base
|
3
|
+
|
4
|
+
end
|
5
|
+
class User < ActiveRecord::Base
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
def up
|
10
|
+
add_column :users, :profile, :string
|
11
|
+
|
12
|
+
User.reset_column_information
|
13
|
+
User.find_each do |user|
|
14
|
+
user.update_attribute(:profile, Profile.find(user.profile_id).label)
|
15
|
+
end
|
16
|
+
|
17
|
+
remove_column :users, :profile_id
|
18
|
+
end
|
19
|
+
|
20
|
+
def down
|
21
|
+
add_column :users, :profile_id, :integer
|
22
|
+
|
23
|
+
User.reset_column_information
|
24
|
+
User.find_each do |user|
|
25
|
+
user.update_attribute(:profile_id, Profile.find_by(label: user.profile).id)
|
26
|
+
end
|
27
|
+
|
28
|
+
remove_column :users, :profile
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class RemoveProfiles < ActiveRecord::Migration
|
2
|
+
class Profile < ActiveRecord::Base
|
3
|
+
serialize :modules
|
4
|
+
end
|
5
|
+
|
6
|
+
def up
|
7
|
+
drop_table :profiles
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
create_table :profiles do |t|
|
12
|
+
t.string :label
|
13
|
+
t.string :nicename
|
14
|
+
t.text :modules
|
15
|
+
end
|
16
|
+
|
17
|
+
Profile.create!(label: 'admin', nicename: 'Publify administrator',
|
18
|
+
modules: [:dashboard, :articles, :notes, :pages, :feedback, :media, :themes, :sidebar, :profile, :users, :settings, :seo])
|
19
|
+
Profile.create!(label: 'publisher', nicename: 'Blog publisher',
|
20
|
+
modules: [:dashboard, :articles, :notes, :pages, :feedback, :media, :profile])
|
21
|
+
Profile.create!(label: 'contributor', nicename: 'Contributor',
|
22
|
+
modules: [:dashboard, :profile ])
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class AddBlogIdToResources < ActiveRecord::Migration
|
2
|
+
class Blog < ActiveRecord::Base; end
|
3
|
+
class Content < ActiveRecord::Base; end
|
4
|
+
class Resource < ActiveRecord::Base; end
|
5
|
+
|
6
|
+
def up
|
7
|
+
add_column :resources, :blog_id, :integer
|
8
|
+
|
9
|
+
if Resource.any?
|
10
|
+
default_blog_id = Blog.order(:id).first.id
|
11
|
+
Resource.find_each do |resource|
|
12
|
+
content_id = resource.article_id
|
13
|
+
blog_id = if content_id
|
14
|
+
Content.find(content_id).blog_id
|
15
|
+
else
|
16
|
+
default_blog_id
|
17
|
+
end
|
18
|
+
resource.update_column(:blog_id, blog_id)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
change_column :resources, :blog_id, :integer, null: false
|
23
|
+
end
|
24
|
+
|
25
|
+
def down
|
26
|
+
remove_column :resources, :blog_id
|
27
|
+
end
|
28
|
+
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Daley', city: cities.first)
|
8
|
+
|
9
|
+
blog = Blog.first || Blog.create!
|
10
|
+
|
11
|
+
unless blog.sidebars.any?
|
12
|
+
PageSidebar.create!(active_position: 0, staged_position: 0, blog_id: blog.id)
|
13
|
+
TagSidebar.create!(active_position: 1, blog_id: blog.id)
|
14
|
+
ArchivesSidebar.create!(active_position: 2, blog_id: blog.id)
|
15
|
+
StaticSidebar.create!(active_position: 3, blog_id: blog.id)
|
16
|
+
MetaSidebar.create!(active_position: 4, blog_id: blog.id)
|
17
|
+
end
|
18
|
+
|
19
|
+
TextFilter.
|
20
|
+
create_with(description: 'None', markup: 'none', filters: [], params: {}).
|
21
|
+
find_or_create_by!(name: 'none')
|
22
|
+
TextFilter.
|
23
|
+
create_with(description: 'Markdown', markup: "markdown", filters: [], params: {}).
|
24
|
+
find_or_create_by!(name: 'markdown')
|
25
|
+
TextFilter.
|
26
|
+
create_with(description: 'SmartyPants', markup: 'none', filters: [:smartypants], params: {}).
|
27
|
+
find_or_create_by!(name: 'smartypants')
|
28
|
+
TextFilter.
|
29
|
+
create_with(description: 'Markdown with SmartyPants', markup: 'markdown', filters: [:smartypants], params: {}).
|
30
|
+
find_or_create_by!(name: 'markdown smartypants')
|
31
|
+
TextFilter.
|
32
|
+
create_with(description: 'Textile', markup: 'textile', filters: [], params: {}).
|
33
|
+
find_or_create_by!(name: 'textile')
|
34
|
+
|
35
|
+
unless File.directory?("#{::Rails.root.to_s}/public/files")
|
36
|
+
Dir.mkdir("#{::Rails.root.to_s}/public/files")
|
37
|
+
end
|
data/lib/email_notify.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# TODO: Use deliver_later to avoid slowness and errors
|
2
|
+
class EmailNotify
|
3
|
+
def self.logger
|
4
|
+
@@logger ||= ::Rails.logger || Logger.new(STDOUT)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.send_comment(comment, user)
|
8
|
+
return if user.email.blank?
|
9
|
+
|
10
|
+
email = NotificationMailer.comment(comment, user)
|
11
|
+
email.deliver_now
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.send_article(article, user)
|
15
|
+
return if user.email.blank?
|
16
|
+
|
17
|
+
email = NotificationMailer.article(article, user)
|
18
|
+
email.deliver_now
|
19
|
+
end
|
20
|
+
|
21
|
+
# Send a welcome mail to the user created
|
22
|
+
def self.send_user_create_notification(user)
|
23
|
+
email = NotificationMailer.notif_user(user)
|
24
|
+
email.deliver_now
|
25
|
+
end
|
26
|
+
end
|
data/lib/format.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Format
|
2
|
+
EMAIL = /^[_a-z0-9\+\.\-]+\@[_a-z0-9\-]+\.[_a-z0-9\.\-]+$/i
|
3
|
+
PASSWORD = /^[\_a-zA-Z0-9\.\-]+$/
|
4
|
+
|
5
|
+
# matches everything to the last \ or / in a string.
|
6
|
+
# can chop of path of a filename like this : '/tobi/home/tobi.jpg'.sub(/^.*[\\\/]/,'') => tobi.jpg
|
7
|
+
FILENAME = /^.*[\\\/]/
|
8
|
+
|
9
|
+
# good for replacing all special chars with something else, like an underscore
|
10
|
+
FILENORMAL = /[^a-zA-Z0-9.]/
|
11
|
+
|
12
|
+
# Laxly matches an IP Address , would also pass numbers > 255 though
|
13
|
+
IP_ADDRESS = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
|
14
|
+
|
15
|
+
# Laxly matches an HTTP(S) URI
|
16
|
+
HTTP_URI = /^https?:\/\/\S+$/
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module PublifyCore
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
config.generators do |generators|
|
4
|
+
generators.test_framework :rspec, fixture: false
|
5
|
+
generators.fixture_replacement :factory_girl, dir: 'spec/factories'
|
6
|
+
end
|
7
|
+
|
8
|
+
initializer 'publify_core.assets.precompile' do |app|
|
9
|
+
app.config.assets.precompile += %w(
|
10
|
+
publify.js
|
11
|
+
publify.css
|
12
|
+
publify_admin.js
|
13
|
+
publify_admin.css
|
14
|
+
accounts.css
|
15
|
+
bootstrap.css
|
16
|
+
user-styles.css
|
17
|
+
coderay.css
|
18
|
+
spinner-blue.gif
|
19
|
+
spinner.gif
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/publify_core.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'devise'
|
2
|
+
require 'devise-i18n'
|
3
|
+
|
4
|
+
require 'publify_core/engine'
|
5
|
+
require 'publify_core/lang'
|
6
|
+
|
7
|
+
require 'actionpack/page_caching'
|
8
|
+
require 'activerecord/session_store'
|
9
|
+
require 'bootstrap-sass'
|
10
|
+
require 'carrierwave'
|
11
|
+
require 'dynamic_form'
|
12
|
+
require 'jquery-rails'
|
13
|
+
require 'jquery-ui-rails'
|
14
|
+
require 'kaminari'
|
15
|
+
# Ensure Rails Observers defines ActiveRecord::Observer before loading
|
16
|
+
# sweeping.rb. Otherwise, Sweeper won't be defined.
|
17
|
+
# TODO: Replace or update rails-observers
|
18
|
+
require 'rails/observers/activerecord/active_record'
|
19
|
+
require 'rails-observers'
|
20
|
+
require 'rails_autolink'
|
21
|
+
require 'rails-timeago'
|
22
|
+
require 'recaptcha/rails'
|
23
|
+
require 'sass-rails'
|
24
|
+
|
25
|
+
require 'email_notify'
|
26
|
+
require 'publify_guid'
|
27
|
+
require 'publify_textfilter_none'
|
28
|
+
require 'publify_textfilter_markdown'
|
29
|
+
require 'publify_textfilter_smartypants'
|
30
|
+
require 'publify_textfilter_textile'
|
31
|
+
require 'publify_textfilter_twitterfilter'
|
32
|
+
require 'publify_time'
|
33
|
+
require 'sidebar_registry'
|
34
|
+
require 'spam_protection'
|
35
|
+
require 'stateful'
|
36
|
+
require 'text_filter_plugin'
|
37
|
+
require 'theme'
|
38
|
+
require 'transforms'
|
39
|
+
|
40
|
+
# TODO: Handle this differently than with a global variable
|
41
|
+
# define default secret token to avoid information duplication
|
42
|
+
$default_token = '08aac1f2d29e54c90efa24a4aefef843ab62da7a2610d193bc0558a50254c7debac56b48ffd0b5990d6ed0cbecc7dc08dce1503b6b864d580758c3c46056729a'
|
43
|
+
|
44
|
+
module PublifyCore
|
45
|
+
Theme.register_themes File.join(Engine.root, 'themes')
|
46
|
+
|
47
|
+
SidebarRegistry.register_sidebar 'ArchivesSidebar'
|
48
|
+
SidebarRegistry.register_sidebar 'MetaSidebar'
|
49
|
+
SidebarRegistry.register_sidebar 'PageSidebar'
|
50
|
+
SidebarRegistry.register_sidebar 'SearchSidebar'
|
51
|
+
SidebarRegistry.register_sidebar 'StaticSidebar'
|
52
|
+
SidebarRegistry.register_sidebar 'TagSidebar'
|
53
|
+
|
54
|
+
# Mime type is fully determined by url
|
55
|
+
Engine.config.action_dispatch.ignore_accept_header = true
|
56
|
+
end
|
data/lib/publify_guid.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module PublifyPlugins
|
2
|
+
# Deprecated?
|
3
|
+
def plugin_public_action(action)
|
4
|
+
@@plugin_public_actions ||= []
|
5
|
+
@@plugin_public_actions.push action
|
6
|
+
end
|
7
|
+
|
8
|
+
# Deprecated?
|
9
|
+
def plugin_public_actions
|
10
|
+
@@plugin_public_actions
|
11
|
+
end
|
12
|
+
|
13
|
+
# Deprecated?
|
14
|
+
def plugin_description(description)
|
15
|
+
eval "def self.description; '#{description}'; end"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Deprecated?
|
19
|
+
def plugin_display_name(name)
|
20
|
+
eval "def self.display_name; '#{name}'; end"
|
21
|
+
end
|
22
|
+
|
23
|
+
unless defined?(Keeper) # Something in rails double require this module. Prevent that to keep @@registered integrity
|
24
|
+
class Keeper
|
25
|
+
KINDS = [:avatar, :textfilter].freeze
|
26
|
+
@@registered = {}
|
27
|
+
|
28
|
+
class << self
|
29
|
+
def available_plugins(kind = nil)
|
30
|
+
return @@registered.inspect unless kind
|
31
|
+
check_kind(kind)
|
32
|
+
@@registered[kind] || []
|
33
|
+
end
|
34
|
+
|
35
|
+
def register(klass)
|
36
|
+
kind = klass.kind
|
37
|
+
check_kind(kind)
|
38
|
+
@@registered[kind] ||= []
|
39
|
+
@@registered[kind] << klass
|
40
|
+
@@registered[kind]
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def check_kind(kind)
|
46
|
+
unless KINDS.include?(kind)
|
47
|
+
raise ArgumentError,
|
48
|
+
"#{kind} is not part of available plugin targets (#{KINDS.join(',')})"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def initialize
|
56
|
+
raise 'No instance allowed.'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end # Defined
|
60
|
+
|
61
|
+
class Base
|
62
|
+
class << self
|
63
|
+
attr_accessor :name
|
64
|
+
attr_accessor :description
|
65
|
+
attr_reader :registered
|
66
|
+
|
67
|
+
def kind
|
68
|
+
:void
|
69
|
+
end
|
70
|
+
end # << self
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'text_filter_plugin'
|
2
|
+
require 'bluecloth'
|
3
|
+
|
4
|
+
# TODO: Move to a different namespace
|
5
|
+
class PublifyApp
|
6
|
+
class Textfilter
|
7
|
+
class Markdown < TextFilterPlugin::Markup
|
8
|
+
plugin_display_name 'Markdown'
|
9
|
+
plugin_description 'Markdown markup language from <a href="http://daringfireball.com/">Daring Fireball</a>'
|
10
|
+
|
11
|
+
def self.help_text
|
12
|
+
%{
|
13
|
+
[Markdown](http://daringfireball.net/projects/markdown/) is a simple text-to-HTML converter that
|
14
|
+
turns common text idioms into HTML. The [full syntax](http://daringfireball.net/projects/markdown/syntax)
|
15
|
+
is available from the author's site, but here's a short summary:
|
16
|
+
|
17
|
+
* **Paragraphs**: Start a new paragraph by skipping a line.
|
18
|
+
* **Italics**: Put text in *italics* by enclosing it in either \* or \_: `*italics*` turns into *italics*.
|
19
|
+
* **Bold**: Put text in **bold** by enclosing it in two \*s: `**bold**` turns into **bold**.
|
20
|
+
* **Pre-formatted text**: Enclosing a short block of text in backquotes (`) displays it in a monospaced font
|
21
|
+
and converts HTML metacharacters so they display correctly. Example: ``<img src="foo"/>`` displays as `<img src="foo"/>`.
|
22
|
+
Also, any paragraph indented 4 or more spaces is treated as pre-formatted text.
|
23
|
+
* **Block quotes**: Any paragraph (or line) that starts with a `>` is treated as a blockquote.
|
24
|
+
* **Hyperlinks**: You can create links like this: `[amazon's web site](http://www.amazon.com)`. That produces
|
25
|
+
"[amazon's web site](http://www.amazon.com)".
|
26
|
+
* **Lists**: You can create numbered or bulleted lists by ending a paragraph with a colon (:), skipping a line, and then using
|
27
|
+
asterisks (*, for bullets) or numbers (for numbered lists). See the
|
28
|
+
[Markdown syntax page](http://daringfireball.net/projects/markdown/syntax) for examples.
|
29
|
+
* **Raw HTML**: Markdown will pass raw HTML through unchanged, so you can use HTML's syntax whenever Markdown doesn't provide
|
30
|
+
a reasonable alternative.
|
31
|
+
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.filtertext(text)
|
36
|
+
# FIXME: Workaround for BlueCloth not interpreting <publify:foo> as an
|
37
|
+
# HTML tag. See <http://deveiate.org/projects/BlueCloth/ticket/70>.
|
38
|
+
escaped_macros = text.gsub(%r{(</?publify):}, '\1X')
|
39
|
+
html = BlueCloth.new(escaped_macros).to_html.gsub(%r{</?notextile>}, '')
|
40
|
+
html.gsub(%r{(</?publify)X}, '\1:')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubypants'
|
2
|
+
|
3
|
+
class PublifyApp
|
4
|
+
class Textfilter
|
5
|
+
class Smartypants < TextFilterPlugin::PostProcess
|
6
|
+
plugin_display_name 'Smartypants'
|
7
|
+
plugin_description 'Converts HTML to use typographically correct quotes and dashes'
|
8
|
+
|
9
|
+
def self.filtertext(text)
|
10
|
+
RubyPants.new(text).to_html
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'text_filter_plugin'
|
2
|
+
require 'RedCloth'
|
3
|
+
|
4
|
+
class PublifyApp
|
5
|
+
class Textfilter
|
6
|
+
class Textile < TextFilterPlugin::Markup
|
7
|
+
plugin_display_name 'Textile'
|
8
|
+
plugin_description 'Textile markup language'
|
9
|
+
|
10
|
+
def self.help_text
|
11
|
+
%{
|
12
|
+
See [_why's Textile reference](http://hobix.com/textile/).
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.filtertext(text)
|
17
|
+
RedCloth.new(text).to_html(:textile)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'text_filter_plugin'
|
2
|
+
|
3
|
+
class PublifyApp
|
4
|
+
class Textfilter
|
5
|
+
class Twitterfilter < TextFilterPlugin::PostProcess
|
6
|
+
plugin_display_name 'HTML Filter'
|
7
|
+
plugin_description 'Strip HTML tags'
|
8
|
+
|
9
|
+
def self.filtertext(text)
|
10
|
+
# First, autolink
|
11
|
+
text = text.to_s
|
12
|
+
URI.extract(text, %w(http https mailto gopher)) do |item|
|
13
|
+
text = text.gsub(item, "<a href='#{item}'>#{item}</a>")
|
14
|
+
end
|
15
|
+
|
16
|
+
# hashtags
|
17
|
+
text.split.grep(/^#\w+/) do |item|
|
18
|
+
# strip_html because Ruby considers "#prouddad</p>" as a word
|
19
|
+
uri = URI.escape("https://twitter.com/search?q=#{item.strip_html}&src=tren&mode=realtime")
|
20
|
+
text = text.gsub(item, "<a href='#{uri}'>#{item.strip_html}</a>")
|
21
|
+
end
|
22
|
+
|
23
|
+
# @mention
|
24
|
+
text.to_s.split.grep(/@\w+/) do |item|
|
25
|
+
uri = URI.escape("https://twitter.com/#{item.strip_html.delete('@')}")
|
26
|
+
text = text.gsub(item, "<a href='#{uri}'>#{item.strip_html}</a>")
|
27
|
+
end
|
28
|
+
|
29
|
+
text
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/publify_time.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
class PublifyTime
|
2
|
+
def self.delta(year = nil, month = nil, day = nil)
|
3
|
+
return nil if year.nil? && month.nil? && day.nil?
|
4
|
+
year = year.to_i unless year.nil?
|
5
|
+
month = month.to_i unless month.nil?
|
6
|
+
day = day.to_i unless day.nil?
|
7
|
+
return nil if year.zero?
|
8
|
+
from = Time.zone.local(year, month, day)
|
9
|
+
to = from.end_of_year
|
10
|
+
to = from.end_of_month unless month.blank?
|
11
|
+
to = from.end_of_day unless day.blank?
|
12
|
+
from..to
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.delta_like(str)
|
16
|
+
case str
|
17
|
+
when /(\d{4})-(\d{2})-(\d{2})/
|
18
|
+
delta(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3))
|
19
|
+
|
20
|
+
when /(\d{4})-(\d{2})/
|
21
|
+
delta(Regexp.last_match(1), Regexp.last_match(2))
|
22
|
+
|
23
|
+
when /(\d{4})/
|
24
|
+
delta(Regexp.last_match(1))
|
25
|
+
|
26
|
+
else
|
27
|
+
str
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
class SidebarField
|
2
|
+
attr_accessor :key
|
3
|
+
attr_accessor :options
|
4
|
+
attr_accessor :default
|
5
|
+
include ActionView::Helpers::TagHelper
|
6
|
+
include ActionView::Helpers::FormTagHelper
|
7
|
+
include ActionView::Helpers::FormOptionsHelper
|
8
|
+
|
9
|
+
def initialize(key, default, options = {})
|
10
|
+
@key = key.to_s
|
11
|
+
@default = default
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def label
|
16
|
+
options[:label] || key.humanize.gsub(/url/i, 'URL')
|
17
|
+
end
|
18
|
+
|
19
|
+
def label_html(_sidebar)
|
20
|
+
content_tag('label', label)
|
21
|
+
end
|
22
|
+
|
23
|
+
def input_html(sidebar)
|
24
|
+
text_field_tag(input_name(sidebar), sidebar.config[key], class: 'form-control')
|
25
|
+
end
|
26
|
+
|
27
|
+
def line_html(sidebar)
|
28
|
+
html = label_html(sidebar)
|
29
|
+
html << content_tag(:div, input_html(sidebar), class: 'form-group')
|
30
|
+
end
|
31
|
+
|
32
|
+
def input_name(sidebar)
|
33
|
+
"configure[#{sidebar.id}][#{key}]"
|
34
|
+
end
|
35
|
+
|
36
|
+
def canonicalize(value)
|
37
|
+
value
|
38
|
+
end
|
39
|
+
|
40
|
+
class SelectField < self
|
41
|
+
def input_html(sidebar)
|
42
|
+
select_tag(input_name(sidebar),
|
43
|
+
options_for_select(options[:choices], sidebar.config[key]),
|
44
|
+
options)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class TextAreaField < self
|
49
|
+
def input_html(sidebar)
|
50
|
+
html_options = { 'rows' => '10', 'class' => 'form-control' }.update(options.stringify_keys)
|
51
|
+
text_area_tag(input_name(sidebar), sidebar.config[key], html_options)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class RadioField < self
|
56
|
+
def input_html(sidebar)
|
57
|
+
options[:choices].map do |choice|
|
58
|
+
value = value_for(choice)
|
59
|
+
radio_button_tag(input_name(sidebar), value,
|
60
|
+
value == sidebar.config[key], options) +
|
61
|
+
content_tag('label', label_for(choice))
|
62
|
+
end.join('<br />')
|
63
|
+
end
|
64
|
+
|
65
|
+
def label_for(choice)
|
66
|
+
choice.is_a?(Array) ? choice.last : choice.to_s.humanize
|
67
|
+
end
|
68
|
+
|
69
|
+
def value_for(choice)
|
70
|
+
choice.is_a?(Array) ? choice.first : choice
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class CheckBoxField < self
|
75
|
+
def line_html(sidebar)
|
76
|
+
hidden_field_tag(input_name(sidebar), 0) +
|
77
|
+
content_tag('label',
|
78
|
+
safe_join([check_box_tag(input_name(sidebar), 1, sidebar.config[key], options), label], ' '))
|
79
|
+
end
|
80
|
+
|
81
|
+
def canonicalize(value)
|
82
|
+
case value
|
83
|
+
when '0'
|
84
|
+
false
|
85
|
+
else
|
86
|
+
true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.build(key, default, options)
|
92
|
+
class_for(options).new(key, default, options)
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.class_for(options)
|
96
|
+
case options[:input_type]
|
97
|
+
when :text_area
|
98
|
+
TextAreaField
|
99
|
+
when :textarea
|
100
|
+
TextAreaField
|
101
|
+
when :radio
|
102
|
+
RadioField
|
103
|
+
when :checkbox
|
104
|
+
CheckBoxField
|
105
|
+
when :select
|
106
|
+
SelectField
|
107
|
+
else
|
108
|
+
if options[:choices]
|
109
|
+
SelectField
|
110
|
+
else
|
111
|
+
self
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class SidebarRegistry
|
2
|
+
class << self
|
3
|
+
def register_sidebar(klass_name)
|
4
|
+
registered_sidebars << klass_name.to_s
|
5
|
+
end
|
6
|
+
|
7
|
+
def available_sidebars
|
8
|
+
registered_sidebars.sort.map(&:constantize)
|
9
|
+
end
|
10
|
+
|
11
|
+
def available_sidebar_types
|
12
|
+
registered_sidebars.sort
|
13
|
+
end
|
14
|
+
|
15
|
+
def register_sidebar_directory(plugins_root, paths)
|
16
|
+
separator = plugins_root.include?('/') ? '/' : '\\'
|
17
|
+
|
18
|
+
Dir.glob(File.join(plugins_root, '*_sidebar')).select do |file|
|
19
|
+
plugin_name = file.split(separator).last
|
20
|
+
register_sidebar plugin_name.classify
|
21
|
+
# TODO: Move Sidebars to app/models, and views to app/views so this can
|
22
|
+
# be simplified.
|
23
|
+
paths << File.join(plugins_root, plugin_name, 'lib')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def registered_sidebars
|
30
|
+
@registered_sidebars ||= Set.new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|