HornsAndHooves-publify_core 10.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +102 -0
- data/MIT-LICENSE +21 -0
- data/README.md +9 -0
- data/app/assets/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +288 -0
- data/app/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 +0 -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/bootstrap/affix.js +164 -0
- data/app/assets/javascripts/bootstrap/alert.js +95 -0
- data/app/assets/javascripts/bootstrap/button.js +125 -0
- data/app/assets/javascripts/bootstrap/collapse.js +212 -0
- data/app/assets/javascripts/bootstrap/dropdown.js +165 -0
- data/app/assets/javascripts/bootstrap/modal.js +358 -0
- data/app/assets/javascripts/bootstrap/tab.js +155 -0
- data/app/assets/javascripts/bootstrap/transition.js +59 -0
- data/app/assets/javascripts/bootstrap-sprockets.js +8 -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 +104 -0
- data/app/assets/javascripts/quicktags.js +448 -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/stylesheets/_bootstrap-compass.scss +9 -0
- data/app/assets/stylesheets/_bootstrap-mincer.scss +19 -0
- data/app/assets/stylesheets/_bootstrap-sprockets.scss +9 -0
- data/app/assets/stylesheets/_bootstrap.scss +43 -0
- data/app/assets/stylesheets/accounts.css.scss +7 -0
- data/app/assets/stylesheets/administration_structure.css.scss +255 -0
- data/app/assets/stylesheets/bootstrap/_alerts.scss +73 -0
- data/app/assets/stylesheets/bootstrap/_button-groups.scss +242 -0
- data/app/assets/stylesheets/bootstrap/_buttons.scss +168 -0
- data/app/assets/stylesheets/bootstrap/_close.scss +37 -0
- data/app/assets/stylesheets/bootstrap/_code.scss +69 -0
- data/app/assets/stylesheets/bootstrap/_component-animations.scss +38 -0
- data/app/assets/stylesheets/bootstrap/_dropdowns.scss +213 -0
- data/app/assets/stylesheets/bootstrap/_forms.scss +586 -0
- data/app/assets/stylesheets/bootstrap/_glyphicons.scss +307 -0
- data/app/assets/stylesheets/bootstrap/_grid.scss +94 -0
- data/app/assets/stylesheets/bootstrap/_labels.scss +66 -0
- data/app/assets/stylesheets/bootstrap/_media.scss +66 -0
- data/app/assets/stylesheets/bootstrap/_mixins.scss +37 -0
- data/app/assets/stylesheets/bootstrap/_modals.scss +150 -0
- data/app/assets/stylesheets/bootstrap/_navbar.scss +479 -0
- data/app/assets/stylesheets/bootstrap/_navs.scss +242 -0
- data/app/assets/stylesheets/bootstrap/_normalize.scss +427 -0
- data/app/assets/stylesheets/bootstrap/_pagination.scss +86 -0
- data/app/assets/stylesheets/bootstrap/_panels.scss +222 -0
- data/app/assets/stylesheets/bootstrap/_print.scss +99 -0
- data/app/assets/stylesheets/bootstrap/_scaffolding.scss +160 -0
- data/app/assets/stylesheets/bootstrap/_tables.scss +234 -0
- data/app/assets/stylesheets/bootstrap/_theme.scss +224 -0
- data/app/assets/stylesheets/bootstrap/_type.scss +296 -0
- data/app/assets/stylesheets/bootstrap/_utilities.scss +55 -0
- data/app/assets/stylesheets/bootstrap/_variables.scss +654 -0
- data/app/assets/stylesheets/bootstrap/_wells.scss +29 -0
- data/app/assets/stylesheets/bootstrap/mixins/_alerts.scss +15 -0
- data/app/assets/stylesheets/bootstrap/mixins/_background-variant.scss +12 -0
- data/app/assets/stylesheets/bootstrap/mixins/_border-radius.scss +18 -0
- data/app/assets/stylesheets/bootstrap/mixins/_buttons.scss +56 -0
- data/app/assets/stylesheets/bootstrap/mixins/_center-block.scss +7 -0
- data/app/assets/stylesheets/bootstrap/mixins/_clearfix.scss +22 -0
- data/app/assets/stylesheets/bootstrap/mixins/_forms.scss +82 -0
- data/app/assets/stylesheets/bootstrap/mixins/_gradients.scss +56 -0
- data/app/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +81 -0
- data/app/assets/stylesheets/bootstrap/mixins/_grid.scss +122 -0
- data/app/assets/stylesheets/bootstrap/mixins/_hide-text.scss +21 -0
- data/app/assets/stylesheets/bootstrap/mixins/_image.scss +28 -0
- data/app/assets/stylesheets/bootstrap/mixins/_labels.scss +12 -0
- data/app/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +10 -0
- data/app/assets/stylesheets/bootstrap/mixins/_nav-vertical-align.scss +9 -0
- data/app/assets/stylesheets/bootstrap/mixins/_opacity.scss +7 -0
- data/app/assets/stylesheets/bootstrap/mixins/_pagination.scss +24 -0
- data/app/assets/stylesheets/bootstrap/mixins/_panels.scss +20 -0
- data/app/assets/stylesheets/bootstrap/mixins/_reset-filter.scss +8 -0
- data/app/assets/stylesheets/bootstrap/mixins/_resize.scss +6 -0
- data/app/assets/stylesheets/bootstrap/mixins/_responsive-visibility.scss +17 -0
- data/app/assets/stylesheets/bootstrap/mixins/_size.scss +10 -0
- data/app/assets/stylesheets/bootstrap/mixins/_tab-focus.scss +9 -0
- data/app/assets/stylesheets/bootstrap/mixins/_table-row.scss +28 -0
- data/app/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +12 -0
- data/app/assets/stylesheets/bootstrap/mixins/_text-overflow.scss +8 -0
- data/app/assets/stylesheets/bootstrap/mixins/_vendor-prefixes.scss +222 -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 +10 -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/controllers/accounts_controller.rb +4 -0
- data/app/controllers/admin/base_controller.rb +27 -0
- data/app/controllers/admin/content_controller.rb +194 -0
- data/app/controllers/admin/dashboard_controller.rb +33 -0
- data/app/controllers/admin/feedback_controller.rb +160 -0
- data/app/controllers/admin/notes_controller.rb +73 -0
- data/app/controllers/admin/pages_controller.rb +73 -0
- data/app/controllers/admin/post_types_controller.rb +57 -0
- data/app/controllers/admin/profiles_controller.rb +57 -0
- data/app/controllers/admin/redirects_controller.rb +51 -0
- data/app/controllers/admin/resources_controller.rb +36 -0
- data/app/controllers/admin/seo_controller.rb +46 -0
- data/app/controllers/admin/settings_controller.rb +53 -0
- data/app/controllers/admin/sidebar_controller.rb +67 -0
- data/app/controllers/admin/tags_controller.rb +55 -0
- data/app/controllers/admin/themes_controller.rb +31 -0
- data/app/controllers/admin/users_controller.rb +67 -0
- data/app/controllers/articles_controller.rb +215 -0
- data/app/controllers/authors_controller.rb +30 -0
- data/app/controllers/base_controller.rb +43 -0
- data/app/controllers/comments_controller.rb +67 -0
- data/app/controllers/content_controller.rb +24 -0
- data/app/controllers/feedback_controller.rb +13 -0
- data/app/controllers/notes_controller.rb +35 -0
- data/app/controllers/setup_controller.rb +61 -0
- data/app/controllers/tags_controller.rb +50 -0
- data/app/controllers/text_controller.rb +7 -0
- data/app/controllers/textfilter_controller.rb +5 -0
- data/app/controllers/theme_controller.rb +63 -0
- data/app/controllers/xml_controller.rb +20 -0
- data/app/helpers/admin/base_helper.rb +87 -0
- data/app/helpers/admin/feedback_helper.rb +53 -0
- data/app/helpers/articles_helper.rb +10 -0
- data/app/helpers/authors_helper.rb +30 -0
- data/app/helpers/base_helper.rb +257 -0
- data/app/helpers/blog_helper.rb +14 -0
- data/app/helpers/xml_helper.rb +18 -0
- data/app/jobs/application_job.rb +5 -0
- data/app/mailers/notification_mailer.rb +40 -0
- data/app/models/ability.rb +53 -0
- data/app/models/archives_sidebar.rb +45 -0
- data/app/models/article/factory.rb +64 -0
- data/app/models/article.rb +308 -0
- data/app/models/blog.rb +280 -0
- data/app/models/comment.rb +57 -0
- data/app/models/config_manager.rb +83 -0
- data/app/models/content.rb +118 -0
- data/app/models/content_base.rb +88 -0
- data/app/models/feedback.rb +250 -0
- data/app/models/meta_sidebar.rb +10 -0
- data/app/models/note.rb +152 -0
- data/app/models/page.rb +42 -0
- data/app/models/page_sidebar.rb +14 -0
- data/app/models/ping.rb +5 -0
- data/app/models/post_type.rb +16 -0
- data/app/models/redirect.rb +51 -0
- data/app/models/redirection.rb +6 -0
- data/app/models/resource.rb +12 -0
- data/app/models/search_sidebar.rb +9 -0
- data/app/models/sidebar.rb +142 -0
- data/app/models/static_sidebar.rb +22 -0
- data/app/models/tag.rb +71 -0
- data/app/models/tag_sidebar.rb +30 -0
- data/app/models/text_filter.rb +141 -0
- data/app/models/trackback.rb +46 -0
- data/app/models/trigger.rb +34 -0
- data/app/models/user.rb +142 -0
- data/app/services/title_builder.rb +88 -0
- data/app/uploaders/resource_uploader.rb +63 -0
- data/app/views/accounts/confirm.html.erb +7 -0
- data/app/views/admin/content/_article_list.html.erb +26 -0
- data/app/views/admin/content/_form.html.erb +145 -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/_overview.html.erb +21 -0
- data/app/views/admin/dashboard/_welcome.html.erb +28 -0
- data/app/views/admin/dashboard/index.html.erb +16 -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 +72 -0
- data/app/views/admin/seo/_general.html.erb +104 -0
- data/app/views/admin/seo/_permalinks.html.erb +53 -0
- data/app/views/admin/seo/_titles.html.erb +209 -0
- data/app/views/admin/seo/show.html.erb +28 -0
- data/app/views/admin/settings/display.html.erb +101 -0
- data/app/views/admin/settings/feedback.html.erb +118 -0
- data/app/views/admin/settings/index.html.erb +73 -0
- data/app/views/admin/settings/write.html.erb +69 -0
- data/app/views/admin/shared/_edit.html.erb +4 -0
- data/app/views/admin/shared/_menu.html.erb +121 -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/_archives_article.html.erb +9 -0
- data/app/views/articles/_article.html.erb +9 -0
- data/app/views/articles/_article_author.html.erb +4 -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 +15 -0
- data/app/views/articles/_article_links.html.erb +12 -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 +4 -0
- data/app/views/articles/_password_form.html.erb +10 -0
- data/app/views/articles/_trackback.html.erb +6 -0
- data/app/views/articles/archives.html.erb +15 -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 +10 -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 +9 -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 +43 -0
- data/app/views/articles/search.html.erb +8 -0
- data/app/views/articles/trackback.xml.builder +7 -0
- data/app/views/articles/view_page.html.erb +3 -0
- data/app/views/authors/show.html.erb +30 -0
- data/app/views/authors/show_atom_feed.atom.builder +9 -0
- data/app/views/authors/show_rss_feed.rss.builder +20 -0
- data/app/views/comments/_comment.html.erb +17 -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 +11 -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 +11 -0
- data/app/views/errors/404.html.erb +2 -0
- data/app/views/feedback/index.atom.builder +9 -0
- data/app/views/feedback/index.rss.builder +20 -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 +33 -0
- data/app/views/layouts/editor.html.erb +17 -0
- data/app/views/meta_sidebar/_content.html.erb +8 -0
- data/app/views/notes/_note.html.erb +16 -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 +18 -0
- data/app/views/notification_mailer/_mail_footer.html.erb +5 -0
- data/app/views/notification_mailer/_mail_header.html.erb +3 -0
- data/app/views/notification_mailer/article.html.erb +7 -0
- data/app/views/notification_mailer/comment.html.erb +12 -0
- data/app/views/notification_mailer/notif_user.html.erb +9 -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 +17 -0
- data/app/views/shared/_atom_header.atom.builder +6 -0
- data/app/views/shared/_atom_item_article.atom.builder +36 -0
- data/app/views/shared/_atom_item_comment.atom.builder +10 -0
- data/app/views/shared/_atom_item_trackback.atom.builder +10 -0
- data/app/views/shared/_flash.erb +10 -0
- data/app/views/shared/_google_analytics.html.erb +8 -0
- data/app/views/shared/_page_header.html.erb +23 -0
- data/app/views/shared/_rss_item_article.rss.builder +32 -0
- data/app/views/shared/_rss_item_comment.rss.builder +9 -0
- data/app/views/shared/_rss_item_trackback.rss.builder +9 -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/xml/_googlesitemap_item_article.googlesitemap.builder +7 -0
- data/app/views/xml/_googlesitemap_item_category.googlesitemap.builder +6 -0
- data/app/views/xml/_googlesitemap_item_page.googlesitemap.builder +6 -0
- data/app/views/xml/_googlesitemap_item_tag.googlesitemap.builder +6 -0
- data/app/views/xml/sitemap.googlesitemap.builder +9 -0
- data/config/i18n-tasks.yml +49 -0
- data/config/initializers/devise.rb +271 -0
- data/config/initializers/mime_types.rb +7 -0
- data/config/locales/da.yml +769 -0
- data/config/locales/de.yml +769 -0
- data/config/locales/en.yml +770 -0
- data/config/locales/es-MX.yml +769 -0
- data/config/locales/fr.yml +769 -0
- data/config/locales/he.yml +769 -0
- data/config/locales/it.yml +769 -0
- data/config/locales/ja.yml +769 -0
- data/config/locales/lt.yml +783 -0
- data/config/locales/nb-NO.yml +769 -0
- data/config/locales/nl.yml +769 -0
- data/config/locales/pl.yml +797 -0
- data/config/locales/pt-BR.yml +769 -0
- data/config/locales/ro.yml +782 -0
- data/config/locales/ru.yml +797 -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 +768 -0
- data/config/locales/zh-TW.yml +769 -0
- data/config/routes.rb +174 -0
- data/db/migrate/113_initial_schema.rb +210 -0
- data/db/migrate/114_fixes_buggy_articles_and_notes.rb +56 -0
- data/db/migrate/115_drops_categories_for_tags.rb +37 -0
- data/db/migrate/20150207131657_add_missing_indexes.rb +23 -0
- data/db/migrate/20150807134129_simplify_redirect_relations.rb +45 -0
- data/db/migrate/20150808052637_add_blog_ids.rb +39 -0
- data/db/migrate/20150808191127_add_blog_id_to_redirects.rb +19 -0
- data/db/migrate/20150810094754_add_blog_id_to_tags.rb +19 -0
- data/db/migrate/20160108111120_add_devise_to_users.rb +57 -0
- data/db/migrate/20160108184201_move_last_connection_to_last_sign_in_at.rb +20 -0
- data/db/migrate/20160110094906_remove_profiles_rights.rb +18 -0
- data/db/migrate/20160605103918_replace_profile_id_with_string.rb +32 -0
- data/db/migrate/20160605154632_remove_profiles.rb +31 -0
- data/db/migrate/20160701061851_demand_blog_id_on_contents.rb +13 -0
- data/db/migrate/20160701062604_add_blog_id_to_resources.rb +32 -0
- data/db/migrate/20170528093024_move_resources_to_content.rb +9 -0
- data/db/migrate/20170528094923_move_tags_to_content.rb +10 -0
- data/db/migrate/20170528201606_remove_separate_published_flag.rb +9 -0
- data/db/migrate/20170605071626_remove_extra_state_columns_from_feedback.rb +10 -0
- data/db/migrate/20170702105201_remove_published_at_from_feedback.rb +9 -0
- data/db/migrate/20190208151235_add_text_filter_name_fields.rb +11 -0
- data/db/migrate/20190208152646_move_text_filter_to_name.rb +99 -0
- data/db/migrate/20190209155717_remove_text_filter_ids.rb +21 -0
- data/db/migrate/20190209160610_remove_text_filters.rb +19 -0
- data/db/seeds.rb +25 -0
- data/lib/email_notify.rb +28 -0
- data/lib/format.rb +9 -0
- data/lib/publify_core/engine.rb +31 -0
- data/lib/publify_core/lang.rb +9 -0
- data/lib/publify_core/testing_support/dns_mock.rb +15 -0
- data/lib/publify_core/testing_support/factories.rb +242 -0
- data/lib/publify_core/testing_support/feed_assertions.rb +48 -0
- data/lib/publify_core/testing_support/fixtures/exploit.svg +4 -0
- data/lib/publify_core/testing_support/fixtures/fakepng.png +1 -0
- data/lib/publify_core/testing_support/fixtures/otherfile.txt +1 -0
- data/lib/publify_core/testing_support/fixtures/testfile.png +0 -0
- data/lib/publify_core/testing_support/fixtures/testfile.txt +1 -0
- data/lib/publify_core/testing_support/upload_fixtures.rb +15 -0
- data/lib/publify_core/version.rb +5 -0
- data/lib/publify_core.rb +46 -0
- data/lib/publify_guid.rb +11 -0
- data/lib/publify_plugins.rb +77 -0
- data/lib/publify_textfilter_markdown.rb +57 -0
- data/lib/publify_textfilter_none.rb +16 -0
- data/lib/publify_textfilter_smartypants.rb +16 -0
- data/lib/publify_textfilter_textile.rb +23 -0
- data/lib/publify_textfilter_twitterfilter.rb +39 -0
- data/lib/publify_time.rb +34 -0
- data/lib/sidebar_field.rb +127 -0
- data/lib/sidebar_registry.rb +35 -0
- data/lib/spam_protection.rb +103 -0
- data/lib/tasks/i18n.rake +9 -0
- data/lib/tasks/manifest.rake +30 -0
- data/lib/tasks/publify_core_tasks.rake +6 -0
- data/lib/text_filter_plugin.rb +183 -0
- data/lib/theme.rb +72 -0
- data/lib/transforms.rb +47 -0
- data/themes/plain/about.markdown +4 -0
- data/themes/plain/javascripts/theme.js +0 -0
- data/themes/plain/preview.png +0 -0
- data/themes/plain/stylesheets/theme.css +57 -0
- metadata +1062 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConfigManager
|
4
|
+
def self.append_features(base)
|
5
|
+
super
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def fields
|
11
|
+
@fields ||= Hash.new { Item.new }
|
12
|
+
end
|
13
|
+
|
14
|
+
def setting(name, type = :object, default = nil)
|
15
|
+
item = Item.new
|
16
|
+
item.name = name.to_s
|
17
|
+
item.ruby_type = type
|
18
|
+
item.default = default
|
19
|
+
fields[name.to_s] = item
|
20
|
+
add_setting_accessor(item)
|
21
|
+
end
|
22
|
+
|
23
|
+
def default_for(key)
|
24
|
+
fields[key.to_s].default
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def add_setting_accessor(item)
|
30
|
+
add_setting_reader(item)
|
31
|
+
add_setting_writer(item)
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_setting_reader(item)
|
35
|
+
send(:define_method, item.name) do
|
36
|
+
raw_value = settings[item.name]
|
37
|
+
raw_value.nil? ? item.default : raw_value
|
38
|
+
end
|
39
|
+
if item.ruby_type == :boolean
|
40
|
+
send(:define_method, item.name + "?") do
|
41
|
+
raw_value = settings[item.name]
|
42
|
+
raw_value.nil? ? item.default : raw_value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_setting_writer(item)
|
48
|
+
send(:define_method, "#{item.name}=") do |newvalue|
|
49
|
+
self.settings ||= {}
|
50
|
+
retval = settings[item.name] = canonicalize(item.name, newvalue)
|
51
|
+
retval
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def canonicalize(key, value)
|
57
|
+
self.class.fields[key.to_s].canonicalize(value)
|
58
|
+
end
|
59
|
+
|
60
|
+
class Item
|
61
|
+
attr_accessor :name, :ruby_type, :default
|
62
|
+
|
63
|
+
def canonicalize(value)
|
64
|
+
case ruby_type
|
65
|
+
when :boolean
|
66
|
+
case value
|
67
|
+
when "0", 0, "", false, "false", "f", nil
|
68
|
+
false
|
69
|
+
else
|
70
|
+
true
|
71
|
+
end
|
72
|
+
when :integer
|
73
|
+
value.to_i
|
74
|
+
when :string
|
75
|
+
value.to_s
|
76
|
+
when :yaml
|
77
|
+
value.to_yaml
|
78
|
+
else
|
79
|
+
value
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "set"
|
4
|
+
require "uri"
|
5
|
+
|
6
|
+
class Content < ApplicationRecord
|
7
|
+
include ContentBase
|
8
|
+
|
9
|
+
belongs_to :user, optional: true, touch: true
|
10
|
+
belongs_to :blog
|
11
|
+
|
12
|
+
validates :blog, presence: true
|
13
|
+
|
14
|
+
has_one :redirect, dependent: :destroy, inverse_of: :content
|
15
|
+
|
16
|
+
has_many :triggers, as: :pending_item, dependent: :delete_all
|
17
|
+
has_many :resources, inverse_of: :content, dependent: :nullify
|
18
|
+
has_and_belongs_to_many :tags
|
19
|
+
|
20
|
+
scope :user_id, ->(user_id) { where("user_id = ?", user_id) }
|
21
|
+
scope :published, -> { where(state: "published"). order(default_order) }
|
22
|
+
scope :published_at, lambda { |time_params|
|
23
|
+
published.where(published_at: PublifyTime.delta(*time_params))
|
24
|
+
}
|
25
|
+
scope :not_published, -> { where.not(state: "published") }
|
26
|
+
scope :drafts, -> { where(state: "draft").order("created_at DESC") }
|
27
|
+
scope :no_draft, -> { where.not(state: "draft").order("published_at DESC") }
|
28
|
+
scope :searchstring, lambda { |search_string|
|
29
|
+
tokens = search_string.split(" ").map { |c| "%#{c.downcase}%" }
|
30
|
+
matcher = "(LOWER(body) LIKE ? OR LOWER(extended) LIKE ? OR LOWER(title) LIKE ?)"
|
31
|
+
template = "state = ? AND " + ([matcher] * tokens.size).join(" AND ")
|
32
|
+
where(template, "published", *tokens.map { |token| [token] * 3 }.flatten)
|
33
|
+
}
|
34
|
+
|
35
|
+
scope :published_at_like, lambda { |date_at|
|
36
|
+
where(published_at: PublifyTime.delta_like(date_at))
|
37
|
+
}
|
38
|
+
|
39
|
+
serialize :whiteboard
|
40
|
+
|
41
|
+
def author=(user)
|
42
|
+
if user.respond_to?(:login)
|
43
|
+
self[:author] = user.login
|
44
|
+
self.user = user
|
45
|
+
elsif user.is_a?(String)
|
46
|
+
self[:author] = user
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def author_name
|
51
|
+
if user.present? && user.name.present?
|
52
|
+
user.name
|
53
|
+
else
|
54
|
+
author
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def shorten_url
|
59
|
+
return unless published?
|
60
|
+
|
61
|
+
if redirect.present?
|
62
|
+
return if redirect.to_path == permalink_url
|
63
|
+
|
64
|
+
redirect.to_path = permalink_url
|
65
|
+
redirect.save
|
66
|
+
else
|
67
|
+
r = Redirect.new(blog: blog)
|
68
|
+
r.from_path = r.shorten
|
69
|
+
r.to_path = permalink_url
|
70
|
+
self.redirect = r
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# TODO: Inline this method
|
75
|
+
def self.find_already_published(limit)
|
76
|
+
published.limit(limit)
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.search_with(params)
|
80
|
+
params ||= {}
|
81
|
+
scoped = unscoped
|
82
|
+
scoped = scoped.searchstring(params[:searchstring]) if params[:searchstring].present?
|
83
|
+
|
84
|
+
if params[:published_at].present? && /(\d\d\d\d)-(\d\d)/ =~ params[:published_at]
|
85
|
+
scoped = scoped.published_at_like(params[:published_at])
|
86
|
+
end
|
87
|
+
|
88
|
+
if params[:user_id].present? && params[:user_id].to_i > 0
|
89
|
+
scoped = scoped.user_id(params[:user_id])
|
90
|
+
end
|
91
|
+
|
92
|
+
if params[:published].present?
|
93
|
+
scoped = scoped.published if params[:published].to_s == "1"
|
94
|
+
scoped = scoped.not_published if params[:published].to_s == "0"
|
95
|
+
end
|
96
|
+
|
97
|
+
scoped
|
98
|
+
end
|
99
|
+
|
100
|
+
def whiteboard
|
101
|
+
self[:whiteboard] ||= {}
|
102
|
+
end
|
103
|
+
|
104
|
+
def rss_description
|
105
|
+
return "" unless blog.rss_description
|
106
|
+
|
107
|
+
rss_desc = blog.rss_description_text
|
108
|
+
rss_desc.gsub!("%author%", author_name)
|
109
|
+
rss_desc.gsub!("%blog_url%", blog.base_url)
|
110
|
+
rss_desc.gsub!("%blog_name%", blog.blog_name)
|
111
|
+
rss_desc.gsub!("%permalink_url%", permalink_url)
|
112
|
+
rss_desc
|
113
|
+
end
|
114
|
+
|
115
|
+
def short_url
|
116
|
+
redirect.from_url if redirect.present?
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ContentBase
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_accessor :just_changed_published_status
|
9
|
+
alias just_changed_published_status? just_changed_published_status
|
10
|
+
|
11
|
+
def really_send_notifications
|
12
|
+
interested_users.each do |value|
|
13
|
+
send_notification_to_user(value)
|
14
|
+
end
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def send_notification_to_user(user)
|
19
|
+
notify_user_via_email(user)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Return HTML for some part of this object.
|
23
|
+
def html(field = :all)
|
24
|
+
if field == :all
|
25
|
+
generate_html(:all, content_fields.map { |f| self[f].to_s }.join("\n\n"))
|
26
|
+
elsif html_map(field)
|
27
|
+
generate_html(field)
|
28
|
+
else
|
29
|
+
raise "Unknown field: #{field.inspect} in content.html"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Generate HTML for a specific field using the text_filter in use for this
|
34
|
+
# object.
|
35
|
+
def generate_html(field, text = nil)
|
36
|
+
text ||= self[field].to_s
|
37
|
+
prehtml = html_preprocess(field, text).to_s
|
38
|
+
html = (text_filter || default_text_filter).filter_text(prehtml) || prehtml
|
39
|
+
html_postprocess(field, html).to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
# Post-process the HTML. This is a noop by default, but Comment overrides it
|
43
|
+
# to enforce HTML sanity.
|
44
|
+
def html_postprocess(_field, html)
|
45
|
+
html
|
46
|
+
end
|
47
|
+
|
48
|
+
def html_preprocess(_field, html)
|
49
|
+
html
|
50
|
+
end
|
51
|
+
|
52
|
+
def html_map(field)
|
53
|
+
content_fields.include? field
|
54
|
+
end
|
55
|
+
|
56
|
+
def excerpt_text(length = 160)
|
57
|
+
text = if respond_to?(:excerpt) && (excerpt || "") != ""
|
58
|
+
generate_html(:excerpt, excerpt)
|
59
|
+
else
|
60
|
+
html(:all)
|
61
|
+
end
|
62
|
+
|
63
|
+
text = text.strip_html
|
64
|
+
|
65
|
+
text.slice(0, length) +
|
66
|
+
(text.length > length ? "..." : "")
|
67
|
+
end
|
68
|
+
|
69
|
+
def text_filter
|
70
|
+
TextFilter.make_filter(text_filter_name)
|
71
|
+
end
|
72
|
+
|
73
|
+
# The default text filter. Generally, this is the filter specified by blog.text_filter,
|
74
|
+
# but comments may use a different default.
|
75
|
+
def default_text_filter
|
76
|
+
blog.text_filter_object
|
77
|
+
end
|
78
|
+
|
79
|
+
module ClassMethods
|
80
|
+
def content_fields(*attribs)
|
81
|
+
class_eval "def content_fields; #{attribs.inspect}; end"
|
82
|
+
end
|
83
|
+
|
84
|
+
def default_order
|
85
|
+
"published_at DESC"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,250 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "aasm"
|
4
|
+
require "akismet"
|
5
|
+
|
6
|
+
class Feedback < ApplicationRecord
|
7
|
+
self.table_name = "feedback"
|
8
|
+
|
9
|
+
belongs_to :article, touch: true
|
10
|
+
|
11
|
+
include PublifyGuid
|
12
|
+
include ContentBase
|
13
|
+
|
14
|
+
class ContentTextHelpers
|
15
|
+
include ActionView::Helpers::UrlHelper
|
16
|
+
include ActionView::Helpers::TextHelper
|
17
|
+
include ActionView::Helpers::SanitizeHelper
|
18
|
+
end
|
19
|
+
|
20
|
+
validate :feedback_not_closed, on: :create
|
21
|
+
validates :article, presence: true
|
22
|
+
|
23
|
+
before_create :create_guid, :article_allows_this_feedback
|
24
|
+
before_save :correct_url, :classify_content
|
25
|
+
|
26
|
+
# TODO: Rename so it doesn't sound like only approved ham
|
27
|
+
scope :ham, -> { where(state: %w(presumed_ham ham)) }
|
28
|
+
|
29
|
+
scope :spam, -> { where(state: "spam") }
|
30
|
+
scope :created_since, ->(time) { ham.where("created_at > ?", time) }
|
31
|
+
scope :presumed_ham, -> { where(state: "presumed_ham") }
|
32
|
+
scope :presumed_spam, -> { where(state: "presumed_spam") }
|
33
|
+
scope :unapproved, -> { where(state: ["presumed_spam", "presumed_ham"]) }
|
34
|
+
|
35
|
+
scope :published, -> { ham }
|
36
|
+
scope :oldest_first, -> { order(:created_at) }
|
37
|
+
scope :newest_first, -> { order(created_at: :desc) }
|
38
|
+
|
39
|
+
include AASM
|
40
|
+
|
41
|
+
aasm column: :state do
|
42
|
+
state :unclassified, initial: true
|
43
|
+
state :presumed_ham
|
44
|
+
state :presumed_spam
|
45
|
+
state :spam, after_enter: [:send_notifications, :report_as_spam]
|
46
|
+
state :ham, after_enter: [:send_notifications, :report_as_ham]
|
47
|
+
|
48
|
+
event :presume_ham do
|
49
|
+
transitions from: :unclassified, to: :ham, if: ->() { user_id.present? }
|
50
|
+
transitions from: :unclassified, to: :presumed_ham
|
51
|
+
end
|
52
|
+
|
53
|
+
event :presume_spam do
|
54
|
+
transitions from: :unclassified, to: :presumed_spam
|
55
|
+
end
|
56
|
+
|
57
|
+
event :mark_as_ham do
|
58
|
+
transitions to: :ham
|
59
|
+
end
|
60
|
+
|
61
|
+
event :mark_as_spam do
|
62
|
+
transitions to: :spam
|
63
|
+
end
|
64
|
+
|
65
|
+
event :withdraw do
|
66
|
+
transitions from: [:presumed_ham, :ham], to: :spam
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# FIXME: Inline this method
|
71
|
+
def self.paginated(page, per_page)
|
72
|
+
page(page).per(per_page)
|
73
|
+
end
|
74
|
+
|
75
|
+
def parent
|
76
|
+
article
|
77
|
+
end
|
78
|
+
|
79
|
+
def classify_content
|
80
|
+
return unless unclassified?
|
81
|
+
|
82
|
+
case classify
|
83
|
+
when :ham then presume_ham
|
84
|
+
else presume_spam
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def permalink_url(_anchor = :ignored, only_path = false)
|
89
|
+
article.permalink_url("#{self.class.to_s.downcase}-#{id}", only_path)
|
90
|
+
end
|
91
|
+
|
92
|
+
def html_postprocess(_field, html)
|
93
|
+
helper = ContentTextHelpers.new
|
94
|
+
helper.sanitize(helper.auto_link(html))
|
95
|
+
end
|
96
|
+
|
97
|
+
def correct_url
|
98
|
+
return if url.blank?
|
99
|
+
|
100
|
+
self.url = "http://" + url.to_s unless %r{^https?://}.match?(url)
|
101
|
+
end
|
102
|
+
|
103
|
+
def article_allows_this_feedback
|
104
|
+
article && blog_allows_feedback? && article_allows_feedback?
|
105
|
+
end
|
106
|
+
|
107
|
+
def blog_allows_feedback?
|
108
|
+
true
|
109
|
+
end
|
110
|
+
|
111
|
+
def akismet_options
|
112
|
+
{ type: self.class.to_s.downcase,
|
113
|
+
author: originator,
|
114
|
+
author_email: email,
|
115
|
+
author_url: url,
|
116
|
+
text: body }
|
117
|
+
end
|
118
|
+
|
119
|
+
def spam_fields
|
120
|
+
[:title, :body, :ip, :url]
|
121
|
+
end
|
122
|
+
|
123
|
+
def classify
|
124
|
+
return :ham if user_id
|
125
|
+
return :spam if blog.default_moderate_comments
|
126
|
+
return :ham unless blog.sp_global
|
127
|
+
|
128
|
+
# Yeah, three state logic is evil...
|
129
|
+
case sp_is_spam? || akismet_is_spam?
|
130
|
+
when nil then :spam
|
131
|
+
when true then :spam
|
132
|
+
when false then :ham
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def sp_is_spam?(_options = {})
|
137
|
+
sp = SpamProtection.new(blog)
|
138
|
+
Timeout.timeout(30) do
|
139
|
+
spam_fields.any? do |field|
|
140
|
+
sp.is_spam?(send(field))
|
141
|
+
end
|
142
|
+
end
|
143
|
+
rescue Timeout::Error
|
144
|
+
nil
|
145
|
+
end
|
146
|
+
|
147
|
+
def akismet_is_spam?(_options = {})
|
148
|
+
return false if akismet.nil?
|
149
|
+
|
150
|
+
begin
|
151
|
+
Timeout.timeout(60) do
|
152
|
+
akismet.comment_check(ip, user_agent, akismet_options)
|
153
|
+
end
|
154
|
+
rescue Timeout::Error
|
155
|
+
nil
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def change_state!
|
160
|
+
result = ""
|
161
|
+
if spam? || presumed_spam?
|
162
|
+
mark_as_ham!
|
163
|
+
result = "ham"
|
164
|
+
else
|
165
|
+
mark_as_spam!
|
166
|
+
result = "spam"
|
167
|
+
end
|
168
|
+
result
|
169
|
+
end
|
170
|
+
|
171
|
+
def confirm_classification!
|
172
|
+
confirm_classification
|
173
|
+
save!
|
174
|
+
end
|
175
|
+
|
176
|
+
def confirm_classification
|
177
|
+
if presumed_spam?
|
178
|
+
mark_as_spam
|
179
|
+
elsif presumed_ham?
|
180
|
+
mark_as_ham
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def report_as_spam
|
185
|
+
return if akismet.nil?
|
186
|
+
|
187
|
+
begin
|
188
|
+
Timeout.timeout(5) do
|
189
|
+
akismet.submit_spam(ip, user_agent, akismet_options)
|
190
|
+
end
|
191
|
+
rescue Timeout::Error
|
192
|
+
nil
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def report_as_ham
|
197
|
+
return if akismet.nil?
|
198
|
+
|
199
|
+
begin
|
200
|
+
Timeout.timeout(5) do
|
201
|
+
akismet.ham(ip, user_agent, akismet_options)
|
202
|
+
end
|
203
|
+
rescue Timeout::Error
|
204
|
+
nil
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def feedback_not_closed
|
209
|
+
errors.add(:article_id, "Comment are closed") if article.comments_closed?
|
210
|
+
end
|
211
|
+
|
212
|
+
def send_notifications
|
213
|
+
nil
|
214
|
+
end
|
215
|
+
|
216
|
+
def published?
|
217
|
+
ham? || presumed_ham?
|
218
|
+
end
|
219
|
+
|
220
|
+
def status_confirmed?
|
221
|
+
ham? || spam?
|
222
|
+
end
|
223
|
+
|
224
|
+
def spammy?
|
225
|
+
spam? || presumed_spam?
|
226
|
+
end
|
227
|
+
|
228
|
+
delegate :blog, to: :article
|
229
|
+
|
230
|
+
private
|
231
|
+
|
232
|
+
def akismet
|
233
|
+
@akismet ||= akismet_client
|
234
|
+
end
|
235
|
+
|
236
|
+
def akismet_client
|
237
|
+
return nil if blog.sp_akismet_key.blank?
|
238
|
+
|
239
|
+
client = Akismet::Client.new(blog.sp_akismet_key, blog.base_url)
|
240
|
+
begin
|
241
|
+
client.verify_key ? client : nil
|
242
|
+
rescue SocketError
|
243
|
+
nil
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def blog_id
|
248
|
+
article.blog_id if article.present?
|
249
|
+
end
|
250
|
+
end
|
data/app/models/note.rb
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Note < Content
|
4
|
+
require "twitter"
|
5
|
+
require "json"
|
6
|
+
require "uri"
|
7
|
+
include PublifyGuid
|
8
|
+
include ConfigManager
|
9
|
+
|
10
|
+
serialize :settings, Hash
|
11
|
+
|
12
|
+
setting :twitter_id, :string, ""
|
13
|
+
setting :in_reply_to_status_id, :string, ""
|
14
|
+
setting :in_reply_to_protected, :boolean, false
|
15
|
+
setting :in_reply_to_message, :string, ""
|
16
|
+
|
17
|
+
validates :body, presence: true
|
18
|
+
validates :permalink, :guid, uniqueness: true
|
19
|
+
|
20
|
+
after_create :set_permalink, :shorten_url
|
21
|
+
before_create :create_guid
|
22
|
+
|
23
|
+
scope :published, lambda {
|
24
|
+
where(state: "published").where("published_at <= ?", Time.zone.now).order(default_order)
|
25
|
+
}
|
26
|
+
default_scope { order("published_at DESC") }
|
27
|
+
|
28
|
+
TWITTER_FTP_URL_LENGTH = 19
|
29
|
+
TWITTER_HTTP_URL_LENGTH = 20
|
30
|
+
TWITTER_HTTPS_URL_LENGTH = 21
|
31
|
+
TWITTER_LINK_LENGTH = 22
|
32
|
+
|
33
|
+
def set_permalink
|
34
|
+
self.permalink = "#{id}-#{body.to_permalink[0..79]}" if permalink.blank?
|
35
|
+
save
|
36
|
+
end
|
37
|
+
|
38
|
+
def categories
|
39
|
+
[]
|
40
|
+
end
|
41
|
+
|
42
|
+
def tags
|
43
|
+
[]
|
44
|
+
end
|
45
|
+
|
46
|
+
def html_preprocess(_field, html)
|
47
|
+
PublifyApp::Textfilter::Twitterfilter.filtertext(html)
|
48
|
+
end
|
49
|
+
|
50
|
+
def truncate(message, length)
|
51
|
+
if message[length + 1] == " "
|
52
|
+
message[0..length]
|
53
|
+
else
|
54
|
+
message[0..(message[0..length].rindex(" ") - 1)]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def twitter_message
|
59
|
+
base_message = body.strip_html
|
60
|
+
if too_long?("#{base_message} (#{short_link})")
|
61
|
+
max_length = 140 - "... (#{redirect.from_url})".length - 1
|
62
|
+
"#{truncate(base_message, max_length)}... (#{redirect.from_url})"
|
63
|
+
else
|
64
|
+
"#{base_message} (#{short_link})"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# FIXME: This breaks if the user changes or deletes their handle.
|
69
|
+
def twitter_url
|
70
|
+
File.join("https://twitter.com", user.twitter, "status", twitter_id)
|
71
|
+
end
|
72
|
+
|
73
|
+
def send_to_twitter
|
74
|
+
return false unless blog.has_twitter_configured?
|
75
|
+
return false unless user.has_twitter_configured?
|
76
|
+
|
77
|
+
twitter = Twitter::REST::Client.new do |config|
|
78
|
+
config.consumer_key = blog.twitter_consumer_key
|
79
|
+
config.consumer_secret = blog.twitter_consumer_secret
|
80
|
+
config.access_token = user.twitter_oauth_token
|
81
|
+
config.access_token_secret = user.twitter_oauth_token_secret
|
82
|
+
end
|
83
|
+
|
84
|
+
begin
|
85
|
+
options = {}
|
86
|
+
if in_reply_to_status_id && in_reply_to_status_id != ""
|
87
|
+
options = { in_reply_to_status_id: in_reply_to_status_id }
|
88
|
+
self.in_reply_to_message = twitter.status(in_reply_to_status_id).to_json
|
89
|
+
end
|
90
|
+
tweet = twitter.update(twitter_message, options)
|
91
|
+
self.twitter_id = tweet.attrs[:id_str]
|
92
|
+
save
|
93
|
+
user.update_twitter_profile_image(tweet.attrs[:user][:profile_image_url])
|
94
|
+
true
|
95
|
+
rescue StandardError => e
|
96
|
+
Rails.logger.error("Error while sending to twitter: #{e}")
|
97
|
+
errors.add(:message, e)
|
98
|
+
false
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
content_fields :body
|
103
|
+
|
104
|
+
def password_protected?
|
105
|
+
false
|
106
|
+
end
|
107
|
+
|
108
|
+
def access_by?(user)
|
109
|
+
user.admin? || user_id == user.id
|
110
|
+
end
|
111
|
+
|
112
|
+
def permalink_url(anchor = nil, only_path = false)
|
113
|
+
blog.url_for(
|
114
|
+
controller: "/notes",
|
115
|
+
action: "show",
|
116
|
+
permalink: permalink,
|
117
|
+
anchor: anchor,
|
118
|
+
only_path: only_path)
|
119
|
+
end
|
120
|
+
|
121
|
+
def short_link
|
122
|
+
path = redirect.from_path
|
123
|
+
"#{prefix} #{path}"
|
124
|
+
end
|
125
|
+
|
126
|
+
def prefix
|
127
|
+
blog.shortener_url.sub(%r{^https?://}, "")
|
128
|
+
end
|
129
|
+
|
130
|
+
def published?
|
131
|
+
state == "published"
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def too_long?(message)
|
137
|
+
uris = URI.extract(message, %w(http https ftp))
|
138
|
+
uris << prefix
|
139
|
+
uris.each do |uri|
|
140
|
+
payload = case uri.split(":")[0]
|
141
|
+
when "https"
|
142
|
+
"-" * TWITTER_HTTPS_URL_LENGTH
|
143
|
+
when "ftp"
|
144
|
+
"-" * TWITTER_FTP_URL_LENGTH
|
145
|
+
else
|
146
|
+
"-" * TWITTER_HTTP_URL_LENGTH
|
147
|
+
end
|
148
|
+
message = message.gsub(uri, payload)
|
149
|
+
end
|
150
|
+
message.length > 140
|
151
|
+
end
|
152
|
+
end
|