community_engine 2.3.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.travis.yml +5 -4
- data/CHANGELOG +43 -5
- data/Gemfile +1 -16
- data/README.markdown +22 -19
- data/UPGRADING.markdown +10 -0
- data/about.yml +1 -1
- data/app/assets/javascripts/community_engine.js +187 -18
- data/app/assets/javascripts/cropper.js +86 -565
- data/app/assets/javascripts/forum.js +26 -71
- data/app/assets/javascripts/jquery.migrate.js +521 -0
- data/app/assets/stylesheets/_colors.css.scss +100 -0
- data/app/assets/stylesheets/_font.css.scss +17 -0
- data/app/assets/stylesheets/_forms.css.scss +20 -0
- data/app/assets/stylesheets/_forum.css.scss +0 -0
- data/app/assets/stylesheets/_grid.css.scss +7 -0
- data/app/assets/stylesheets/_layers.css.scss +7 -0
- data/app/assets/stylesheets/_layout.css.scss +28 -0
- data/app/assets/stylesheets/community_engine.css.scss +18 -0
- data/app/assets/stylesheets/cropper.css +6 -182
- data/app/controllers/activities_controller.rb +10 -10
- data/app/controllers/admin_controller.rb +23 -23
- data/app/controllers/ads_controller.rb +16 -5
- data/app/controllers/albums_controller.rb +11 -5
- data/app/controllers/base_controller.rb +5 -8
- data/app/controllers/categories_controller.rb +31 -31
- data/app/controllers/clippings_controller.rb +18 -12
- data/app/controllers/comments_controller.rb +17 -8
- data/app/controllers/events_controller.rb +25 -21
- data/app/controllers/favorites_controller.rb +12 -12
- data/app/controllers/forums_controller.rb +20 -9
- data/app/controllers/friendships_controller.rb +41 -48
- data/app/controllers/homepage_features_controller.rb +11 -5
- data/app/controllers/invitations_controller.rb +15 -9
- data/app/controllers/messages_controller.rb +25 -19
- data/app/controllers/metro_areas_controller.rb +9 -3
- data/app/controllers/moderators_controller.rb +1 -1
- data/app/controllers/monitorships_controller.rb +2 -2
- data/app/controllers/pages_controller.rb +16 -4
- data/app/controllers/password_resets_controller.rb +0 -1
- data/app/controllers/photos_controller.rb +32 -30
- data/app/controllers/posts_controller.rb +33 -17
- data/app/controllers/rsvps_controller.rb +8 -4
- data/app/controllers/sb_posts_controller.rb +22 -18
- data/app/controllers/sessions_controller.rb +2 -1
- data/app/controllers/sitemap_controller.rb +8 -8
- data/app/controllers/statistics_controller.rb +9 -8
- data/app/controllers/tags_controller.rb +26 -24
- data/app/controllers/topics_controller.rb +10 -6
- data/app/controllers/users_controller.rb +63 -34
- data/app/helpers/base_helper.rb +119 -29
- data/app/helpers/friendships_helper.rb +3 -3
- data/app/helpers/posts_helper.rb +5 -7
- data/app/models/acts_as_taggable_on/tag.rb +12 -13
- data/app/models/ad.rb +2 -5
- data/app/models/album.rb +0 -2
- data/app/models/category.rb +6 -7
- data/app/models/clipping.rb +2 -5
- data/app/models/clipping_image.rb +5 -5
- data/app/models/comment.rb +4 -5
- data/app/models/country.rb +2 -4
- data/app/models/event.rb +1 -2
- data/app/models/favorite.rb +5 -10
- data/app/models/forum.rb +0 -2
- data/app/models/friendship.rb +3 -5
- data/app/models/friendship_status.rb +0 -2
- data/app/models/homepage_feature.rb +4 -6
- data/app/models/invitation.rb +6 -8
- data/app/models/message.rb +25 -26
- data/app/models/message_thread.rb +1 -1
- data/app/models/metro_area.rb +0 -2
- data/app/models/page.rb +0 -2
- data/app/models/photo.rb +8 -8
- data/app/models/poll.rb +7 -9
- data/app/models/post.rb +11 -15
- data/app/models/role.rb +1 -2
- data/app/models/rsvp.rb +0 -3
- data/app/models/sb_post.rb +14 -9
- data/app/models/state.rb +0 -2
- data/app/models/topic.rb +5 -6
- data/app/models/user.rb +50 -63
- data/app/models/vote.rb +1 -1
- data/app/views/activities/_activity.html.haml +9 -9
- data/app/views/activities/destroy.js.erb +1 -0
- data/app/views/activities/index.html.haml +13 -13
- data/app/views/activities/network.html.haml +10 -13
- data/app/views/admin/comments.html.haml +48 -70
- data/app/views/admin/events.html.haml +20 -27
- data/app/views/admin/messages.html.haml +2 -3
- data/app/views/admin/update.js.erb +1 -0
- data/app/views/admin/users.html.haml +51 -66
- data/app/views/ads/_form.html.haml +21 -0
- data/app/views/ads/edit.html.haml +6 -46
- data/app/views/ads/index.html.haml +25 -39
- data/app/views/ads/new.html.haml +4 -43
- data/app/views/ads/show.html.haml +18 -35
- data/app/views/albums/_form.html.haml +17 -12
- data/app/views/albums/edit.html.haml +12 -14
- data/app/views/albums/new.html.haml +8 -13
- data/app/views/albums/show.html.haml +25 -32
- data/app/views/base/_homepage_banner_message.html.haml +5 -19
- data/app/views/base/advertise.html.haml +5 -8
- data/app/views/base/site_index.html.haml +25 -27
- data/app/views/categories/_form.html.haml +8 -0
- data/app/views/categories/_menu_item.html.haml +13 -0
- data/app/views/categories/_tips.html.haml +2 -2
- data/app/views/categories/edit.html.haml +3 -33
- data/app/views/categories/index.html.haml +18 -28
- data/app/views/categories/new.html.haml +3 -8
- data/app/views/categories/show.html.haml +33 -36
- data/app/views/clippings/_clipping.html.haml +10 -17
- data/app/views/clippings/_favorite.html.haml +14 -0
- data/app/views/clippings/_form.html.haml +15 -0
- data/app/views/clippings/_images.html.haml +1 -1
- data/app/views/clippings/_menu_item.html.haml +6 -0
- data/app/views/clippings/edit.html.haml +12 -23
- data/app/views/clippings/index.html.haml +29 -30
- data/app/views/clippings/load_images_from_uri.js.erb +1 -0
- data/app/views/clippings/new.html.haml +9 -26
- data/app/views/clippings/new_clipping.html.haml +30 -77
- data/app/views/clippings/show.html.haml +48 -53
- data/app/views/clippings/site_index.html.haml +19 -32
- data/app/views/comments/_comment.html.haml +40 -40
- data/app/views/comments/_comment_form.html.haml +22 -46
- data/app/views/comments/_edit_form.html.haml +13 -28
- data/app/views/comments/create.js.erb +25 -0
- data/app/views/comments/destroy.js.erb +3 -0
- data/app/views/comments/edit.js.erb +11 -0
- data/app/views/comments/index.html.haml +12 -22
- data/app/views/comments/update.js.erb +14 -0
- data/app/views/events/_event.html.haml +26 -24
- data/app/views/events/_form.html.haml +18 -0
- data/app/views/events/_menu_item.html.haml +6 -0
- data/app/views/events/_subscribe.html.haml +1 -1
- data/app/views/events/edit.html.haml +7 -32
- data/app/views/events/index.html.haml +11 -19
- data/app/views/events/new.html.haml +2 -31
- data/app/views/events/show.html.haml +54 -24
- data/app/views/favorites/create.js.erb +10 -0
- data/app/views/favorites/destroy.js.erb +6 -0
- data/app/views/favorites/index.html.haml +6 -8
- data/app/views/forums/_form.html.haml +10 -20
- data/app/views/forums/_menu_item.html.haml +6 -0
- data/app/views/forums/edit.html.haml +8 -10
- data/app/views/forums/index.html.haml +56 -64
- data/app/views/forums/new.html.haml +5 -8
- data/app/views/forums/show.html.haml +65 -72
- data/app/views/friendships/_friendship.html.haml +14 -16
- data/app/views/friendships/accepted.html.haml +7 -11
- data/app/views/friendships/create.js.haml +1 -0
- data/app/views/friendships/denied.html.haml +4 -8
- data/app/views/friendships/pending.html.haml +4 -6
- data/app/views/friendships/show.html.haml +10 -11
- data/app/views/homepage_features/_form.html.haml +6 -0
- data/app/views/homepage_features/edit.html.haml +5 -30
- data/app/views/homepage_features/index.html.haml +22 -28
- data/app/views/homepage_features/new.html.haml +2 -30
- data/app/views/homepage_features/show.html.haml +27 -29
- data/app/views/invitations/index.html.haml +8 -0
- data/app/views/invitations/new.html.haml +21 -30
- data/app/views/kaminari/bootstrap/_first_page.html.erb +13 -0
- data/app/views/kaminari/bootstrap/_gap.html.erb +8 -0
- data/app/views/kaminari/bootstrap/_last_page.html.erb +13 -0
- data/app/views/kaminari/bootstrap/_next_page.html.erb +13 -0
- data/app/views/kaminari/bootstrap/_page.html.erb +12 -0
- data/app/views/kaminari/bootstrap/_paginator.html.erb +25 -0
- data/app/views/kaminari/bootstrap/_prev_page.html.erb +13 -0
- data/app/views/layouts/application.html.haml +26 -37
- data/app/views/messages/_form.html.haml +6 -12
- data/app/views/messages/_inbox.html.haml +34 -39
- data/app/views/messages/_menu_item.html.haml +11 -0
- data/app/views/messages/_sent.html.haml +22 -33
- data/app/views/messages/_sidebar_nav.html.haml +12 -9
- data/app/views/messages/index.html.haml +2 -2
- data/app/views/messages/new.html.haml +2 -9
- data/app/views/messages/show.html.haml +28 -36
- data/app/views/metro_areas/_form.html.haml +6 -0
- data/app/views/metro_areas/edit.html.haml +6 -14
- data/app/views/metro_areas/index.html.haml +19 -26
- data/app/views/metro_areas/new.html.haml +4 -14
- data/app/views/metro_areas/show.html.haml +13 -21
- data/app/views/moderators/_toggle.html.haml +6 -0
- data/app/views/moderators/create.js.erb +5 -0
- data/app/views/moderators/destroy.js.erb +1 -0
- data/app/views/monitorships/create.js.erb +1 -0
- data/app/views/monitorships/destroy.js.erb +1 -0
- data/app/views/pages/_form.html.haml +16 -23
- data/app/views/pages/edit.html.haml +2 -14
- data/app/views/pages/index.html.haml +32 -32
- data/app/views/pages/new.html.haml +5 -12
- data/app/views/pages/show.html.haml +4 -8
- data/app/views/password_resets/edit.html.haml +6 -14
- data/app/views/password_resets/new.html.haml +7 -11
- data/app/views/photo_manager/index.html.haml +45 -43
- data/app/views/photos/_form.html.haml +24 -0
- data/app/views/photos/_manage_photos.html.haml +14 -6
- data/app/views/photos/_show_image_list.html.haml +2 -2
- data/app/views/photos/create.js.erb +1 -0
- data/app/views/photos/edit.html.haml +10 -38
- data/app/views/photos/index.html.haml +20 -20
- data/app/views/photos/manage_photos.js.erb +5 -0
- data/app/views/photos/new.html.haml +11 -49
- data/app/views/photos/recent.html.haml +6 -6
- data/app/views/photos/show.html.haml +48 -52
- data/app/views/polls/_edit.html.haml +6 -10
- data/app/views/polls/_excerpt.html.haml +3 -4
- data/app/views/polls/_new.html.haml +10 -9
- data/app/views/polls/_poll_ui.html.haml +30 -34
- data/app/views/posts/_author_profile.html.haml +12 -11
- data/app/views/posts/_favorited_post.html.haml +8 -10
- data/app/views/posts/_form.html.haml +40 -0
- data/app/views/posts/_menu_item.html.haml +6 -0
- data/app/views/posts/_post.html.haml +27 -24
- data/app/views/posts/_send_to_friend.html.haml +26 -0
- data/app/views/posts/edit.html.haml +11 -48
- data/app/views/posts/featured.html.haml +7 -12
- data/app/views/posts/index.html.haml +14 -18
- data/app/views/posts/manage.html.haml +44 -59
- data/app/views/posts/new.html.haml +9 -64
- data/app/views/posts/popular.html.haml +25 -30
- data/app/views/posts/preview.html.haml +27 -26
- data/app/views/posts/recent.html.haml +20 -27
- data/app/views/posts/send_to_friend.js.erb +3 -0
- data/app/views/posts/show.html.haml +67 -76
- data/app/views/rsvps/_form.html.haml +3 -0
- data/app/views/rsvps/edit.html.haml +3 -9
- data/app/views/rsvps/new.html.haml +3 -9
- data/app/views/sb_posts/_dummy_forum_post.html.haml +13 -0
- data/app/views/sb_posts/_edit.html.haml +6 -0
- data/app/views/sb_posts/_edit_script.js.erb +14 -0
- data/app/views/sb_posts/_reply_form.html.haml +14 -35
- data/app/views/sb_posts/_reply_script.js.erb +13 -0
- data/app/views/sb_posts/_sb_post.html.haml +31 -33
- data/app/views/sb_posts/create.js.erb +30 -0
- data/app/views/sb_posts/destroy.js.erb +2 -0
- data/app/views/sb_posts/edit.html.erb +4 -4
- data/app/views/sb_posts/edit.js.erb +14 -0
- data/app/views/sb_posts/index.html.haml +3 -16
- data/app/views/sb_posts/monitored.html.erb +3 -9
- data/app/views/sb_posts/update.js.erb +11 -0
- data/app/views/sessions/_menu_item.html.haml +28 -0
- data/app/views/sessions/new.html.haml +19 -24
- data/app/views/shared/_add_friend_link.html.haml +9 -0
- data/app/views/shared/_admin_nav.html.haml +6 -8
- data/app/views/shared/_contact.html.haml +1 -1
- data/app/views/shared/_end_javascript.html.haml +4 -4
- data/app/views/shared/_explore.html.haml +7 -6
- data/app/views/shared/_footer_content.html.haml +12 -10
- data/app/views/shared/_footer_links.html.haml +18 -0
- data/app/views/shared/_friend_link.html.haml +25 -0
- data/app/views/shared/_header.html.haml +22 -42
- data/app/views/shared/_jumbotron.html.haml +3 -0
- data/app/views/shared/_load_tinymce.js.erb +15 -0
- data/app/views/shared/_location_chooser.html.haml +26 -17
- data/app/views/shared/_login_sidebar.html.haml +6 -5
- data/app/views/shared/_messages.html.haml +6 -8
- data/app/views/shared/_scripts_and_styles.html.haml +1 -2
- data/app/views/shared/_sidebar.html.haml +1 -0
- data/app/views/shared/_tag_auto_complete.html.haml +19 -0
- data/app/views/shared/_widget.html.haml +3 -0
- data/app/views/sitemap/index.html.haml +15 -20
- data/app/views/statistics/index.html.haml +32 -40
- data/app/views/tags/edit.html.haml +12 -19
- data/app/views/tags/index.html.haml +16 -25
- data/app/views/tags/manage.html.haml +24 -33
- data/app/views/tags/show.html.haml +52 -58
- data/app/views/topics/_form.html.haml +23 -25
- data/app/views/topics/_recent_topics_sidebar.haml +1 -1
- data/app/views/topics/edit.html.haml +7 -9
- data/app/views/topics/new.html.haml +6 -21
- data/app/views/topics/show.html.haml +48 -106
- data/app/views/user_notifier/follow_up_comment_notice.text.erb +1 -1
- data/app/views/user_notifier/message_notification.text.erb +1 -1
- data/app/views/user_notifier/new_forum_post_notice.text.erb +1 -1
- data/app/views/users/_dashboard_nav.html.haml +36 -39
- data/app/views/users/_menu_item.html.haml +6 -0
- data/app/views/users/_omniauth_connect.html.haml +4 -4
- data/app/views/users/_profile_completeness.html.haml +3 -3
- data/app/views/users/_profile_user_info_sidebar.html.haml +40 -43
- data/app/views/users/_search_options.html.haml +9 -7
- data/app/views/users/_sidebar_user.html.haml +1 -1
- data/app/views/users/_user.html.haml +27 -28
- data/app/views/users/crop_profile_photo.html.haml +30 -37
- data/app/views/users/dashboard.html.haml +37 -41
- data/app/views/users/edit.html.haml +53 -71
- data/app/views/users/edit_account.html.haml +44 -64
- data/app/views/users/forgot_username.html.haml +6 -12
- data/app/views/users/index.html.haml +4 -14
- data/app/views/users/invite.html.haml +14 -25
- data/app/views/users/new.html.haml +27 -48
- data/app/views/users/resend_activation.html.haml +7 -12
- data/app/views/users/show.html.haml +88 -90
- data/app/views/users/signup_completed.html.haml +7 -7
- data/app/views/users/statistics.html.haml +17 -18
- data/app/views/users/update.js.erb +1 -0
- data/app/views/users/upload_profile_photo.html.haml +10 -15
- data/app/views/users/welcome_about.html.haml +54 -61
- data/app/views/users/welcome_invite.html.haml +16 -25
- data/app/views/users/welcome_photo.html.haml +18 -27
- data/app/views/votes/create.js.erb +5 -0
- data/community_engine.gemspec +49 -41
- data/config/application_config.rb +13 -16
- data/config/initializers/mce_options.rb +9 -32
- data/config/initializers/recaptcha_constants.rb +2 -2
- data/config/locales/de-DE.yml +1 -17
- data/config/locales/en.yml +18 -32
- data/config/locales/es-AR.yml +2 -14
- data/config/locales/es-ES.yml +0 -6
- data/config/locales/es-MX.yml +1 -9
- data/config/locales/fr-FR.yml +3 -17
- data/config/locales/ja-JP.yml +2 -18
- data/config/locales/ru-RU.yml +3 -21
- data/config/locales/sr-CP.yml +0 -4
- data/config/locales/sv-SE.yml +3 -20
- data/config/routes.rb +37 -42
- data/db/migrate/016_add_metro_areas.rb +2 -2
- data/db/migrate/039_create_activities_table.rb +2 -2
- data/db/migrate/056_create_roles.rb +8 -6
- data/db/migrate/069_create_pages.rb +3 -3
- data/db/migrate/081_upgrade_to_friendly_id_5x.rb +25 -0
- data/db/migrate/082_upgrade_to_acts_as_commentable_4x.rb +29 -0
- data/lib/activity_tracker.rb +3 -0
- data/{vendor/plugins/activity_tracker/lib → lib/activity_tracker}/activity.rb +6 -6
- data/{vendor/plugins/activity_tracker/lib → lib/activity_tracker}/activity_tracker.rb +0 -0
- data/{vendor/plugins/acts_as_publishable/init.rb → lib/acts_as_publishable.rb} +1 -1
- data/{vendor/plugins/acts_as_publishable/lib → lib/acts_as_publishable}/acts_as_publishable.rb +3 -3
- data/lib/community_engine.rb +31 -9
- data/lib/community_engine/engine.rb +17 -1
- data/lib/community_engine/engines_extensions.rb +1 -3
- data/lib/community_engine/version.rb +3 -3
- data/{config/initializers → lib/paperclip_processors}/cropper.rb +3 -3
- data/lib/resource_feeder.rb +3 -0
- data/{vendor/plugins/resource_feeder/lib → lib}/resource_feeder/atom.rb +0 -0
- data/{vendor/plugins/resource_feeder/lib → lib}/resource_feeder/rss.rb +0 -0
- data/{vendor/plugins/white_list/init.rb → lib/white_list.rb} +1 -1
- data/{vendor/plugins/white_list/lib → lib/white_list}/white_list_helper.rb +0 -0
- data/test/fixtures/messages.yml +2 -2
- data/test/functional/admin_controller_test.rb +11 -11
- data/test/functional/ads_controller_test.rb +11 -11
- data/test/functional/albums_controller_test.rb +4 -4
- data/test/functional/categories_controller_test.rb +4 -4
- data/test/functional/clippings_controller_test.rb +4 -4
- data/test/functional/comments_controller_test.rb +20 -16
- data/test/functional/events_controller_test.rb +6 -6
- data/test/functional/forums_controller_test.rb +8 -8
- data/test/functional/friendships_controller_test.rb +13 -18
- data/test/functional/homepage_features_controller_test.rb +5 -5
- data/test/functional/messages_controller_test.rb +6 -2
- data/test/functional/metro_areas_controller_test.rb +7 -7
- data/test/functional/moderators_controller_test.rb +1 -1
- data/test/functional/pages_controller_test.rb +2 -2
- data/test/functional/password_reset_controller_test.rb +2 -2
- data/test/functional/photos_controller_test.rb +16 -15
- data/test/functional/posts_controller_test.rb +4 -4
- data/test/functional/rsvps_controller_test.rb +6 -6
- data/test/functional/sb_posts_controller_test.rb +53 -50
- data/test/functional/sessions_controller_test.rb +4 -1
- data/test/functional/tags_controller_test.rb +1 -1
- data/test/functional/topics_controller_test.rb +10 -10
- data/test/functional/users_controller_test.rb +32 -19
- data/test/functional/votes_controller_test.rb +1 -1
- data/test/test_helper.rb +3 -1
- data/test/testapp/config/application.rb +1 -9
- data/test/testapp/config/environments/development.rb +1 -2
- data/test/testapp/config/environments/production.rb +2 -0
- data/test/testapp/config/environments/test.rb +1 -2
- data/test/testapp/config/initializers/omniauth.rb +3 -3
- data/test/testapp/config/initializers/secret_token.rb +1 -0
- data/test/testapp/db/schema.rb +143 -152
- data/test/unit/category_test.rb +2 -2
- data/test/unit/comment_test.rb +64 -53
- data/test/unit/event_test.rb +4 -4
- data/test/unit/forum_test.rb +1 -1
- data/test/unit/message_test.rb +7 -1
- data/test/unit/page_test.rb +2 -2
- data/test/unit/post_test.rb +47 -47
- data/test/unit/sb_post_test.rb +24 -20
- data/test/unit/topic_test.rb +7 -6
- data/test/unit/user_test.rb +75 -52
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/javascripts/jcrop/jquery.Jcrop.js +1699 -0
- data/vendor/assets/javascripts/jcrop/jquery.color.js +661 -0
- data/vendor/assets/javascripts/tag-it/tag-it.js +597 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/jcrop/Jcrop.gif +0 -0
- data/vendor/assets/stylesheets/jcrop/jquery.Jcrop.min.css +28 -0
- data/vendor/assets/stylesheets/tag-it/tag-it.css +69 -0
- data/vendor/assets/stylesheets/tag-it/tagit.ui-zendesk.css +107 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/README +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/Rakefile +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/generators/publishing/publishing_generator.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/generators/publishing/templates/migration.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/install.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/acts_as_publishable/test/acts_as_publishable_test.rb +0 -0
- data/vendor/{plugins/activity_tracker → converted2.3plugins_to_lib_leftovers/acts_as_publishable}/uninstall.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/resource_feeder/README +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/resource_feeder/Rakefile +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/resource_feeder/test/atom_feed_test.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/resource_feeder/test/rss_feed_test.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/resource_feeder/test/test_helper.rb +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/white_list/README +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/white_list/Rakefile +0 -0
- data/vendor/{plugins → converted2.3plugins_to_lib_leftovers}/white_list/test/white_list_test.rb +0 -0
- metadata +348 -302
- data/app/assets/images/bg_h6btn.gif +0 -0
- data/app/assets/images/bg_navbar.gif +0 -0
- data/app/assets/images/clearbits/bg_rounded.gif +0 -0
- data/app/assets/images/clearbits/comment.gif +0 -0
- data/app/assets/images/clearbits/lock.gif +0 -0
- data/app/assets/images/clearbits/smile.gif +0 -0
- data/app/assets/images/close.gif +0 -0
- data/app/assets/images/cropper/marqueeHoriz.gif +0 -0
- data/app/assets/images/cropper/marqueeVert.gif +0 -0
- data/app/assets/images/feed.png +0 -0
- data/app/assets/images/icons/31.png +0 -0
- data/app/assets/images/icons/52.png +0 -0
- data/app/assets/images/icons/accept.png +0 -0
- data/app/assets/images/icons/activity_default.png +0 -0
- data/app/assets/images/icons/add.png +0 -0
- data/app/assets/images/icons/book.png +0 -0
- data/app/assets/images/icons/bullet_arrow_down.png +0 -0
- data/app/assets/images/icons/bullet_arrow_down_50.png +0 -0
- data/app/assets/images/icons/clipping.png +0 -0
- data/app/assets/images/icons/comment.png +0 -0
- data/app/assets/images/icons/comments.png +0 -0
- data/app/assets/images/icons/date.png +0 -0
- data/app/assets/images/icons/delete.png +0 -0
- data/app/assets/images/icons/email.png +0 -0
- data/app/assets/images/icons/email_edit.png +0 -0
- data/app/assets/images/icons/email_go.png +0 -0
- data/app/assets/images/icons/email_open.png +0 -0
- data/app/assets/images/icons/group_go.png +0 -0
- data/app/assets/images/icons/heart.png +0 -0
- data/app/assets/images/icons/heart_add.png +0 -0
- data/app/assets/images/icons/heart_off.png +0 -0
- data/app/assets/images/icons/page_white.png +0 -0
- data/app/assets/images/icons/page_white_magnify.png +0 -0
- data/app/assets/images/icons/picture.png +0 -0
- data/app/assets/images/icons/poll.png +0 -0
- data/app/assets/images/icons/post.png +0 -0
- data/app/assets/images/icons/printer.png +0 -0
- data/app/assets/images/icons/rss.png +0 -0
- data/app/assets/images/icons/slides.png +0 -0
- data/app/assets/images/icons/tag_blue.png +0 -0
- data/app/assets/images/icons/user.png +0 -0
- data/app/assets/images/icons/user_add.png +0 -0
- data/app/assets/images/icons/user_edit.png +0 -0
- data/app/assets/images/icons/user_go.png +0 -0
- data/app/assets/images/icons/vote.png +0 -0
- data/app/assets/images/icons/world.png +0 -0
- data/app/assets/images/icons/wrench.png +0 -0
- data/app/assets/images/logo.gif +0 -0
- data/app/assets/images/reply_background.png +0 -0
- data/app/assets/images/search.gif +0 -0
- data/app/assets/images/thumb.gif +0 -0
- data/app/assets/javascripts/builder.js +0 -136
- data/app/assets/javascripts/calendarview.js +0 -839
- data/app/assets/javascripts/lightbox.js +0 -151
- data/app/assets/javascripts/prototip-min.js +0 -27
- data/app/assets/javascripts/rails.js +0 -202
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/css/advimage.css +0 -84
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/editor_plugin.js +0 -52
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/editor_plugin_src.js +0 -45
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/image.htm +0 -180
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/img/sample.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/js/functions.js +0 -508
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/langs/en.js +0 -3
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/langs/en_dlg.js +0 -43
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/editor_plugin.js +0 -8
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/editor_plugin_src.js +0 -1001
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress10.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress11.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress12.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress2.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress3.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress4.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress5.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress6.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress7.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress8.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/progress9.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/restore.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/images/restore.png +0 -0
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/langs/da.js +0 -5
- data/app/assets/javascripts/tinymce/plugins/tinyautosave/langs/en.js +0 -5
- data/app/assets/stylesheets/community_engine.css +0 -6
- data/app/assets/stylesheets/forum.css +0 -605
- data/app/assets/stylesheets/prototip.css +0 -73
- data/app/assets/stylesheets/reset-fonts-grids.css +0 -8
- data/app/assets/stylesheets/screen.css +0 -977
- data/app/helpers/monitorships_helper.rb +0 -2
- data/app/views/activities/_icon.html.haml +0 -14
- data/app/views/activities/destroy.js.rjs +0 -1
- data/app/views/clippings/_meta.html.haml +0 -26
- data/app/views/clippings/load_images_from_uri.js.rjs +0 -1
- data/app/views/comments/create.js.rjs +0 -20
- data/app/views/comments/edit.js.rjs +0 -7
- data/app/views/comments/update.js.rjs +0 -9
- data/app/views/favorites/create.js.rjs +0 -17
- data/app/views/favorites/destroy.js.rjs +0 -14
- data/app/views/favorites/show.html.haml +0 -13
- data/app/views/friendships/_friendships.html.erb +0 -14
- data/app/views/friendships/index.html.erb +0 -3
- data/app/views/friendships/index.xml.builder +0 -29
- data/app/views/invitations/index.html.erb +0 -16
- data/app/views/moderators/_toggle.html.erb +0 -14
- data/app/views/moderators/create.js.rjs +0 -5
- data/app/views/moderators/destroy.js.rjs +0 -1
- data/app/views/monitorships/create.js.rjs +0 -4
- data/app/views/monitorships/destroy.js.rjs +0 -4
- data/app/views/photos/manage_photos.js.rjs +0 -5
- data/app/views/polls/_polls_sidebar.html.haml +0 -8
- data/app/views/posts/_send_to_friend.html.erb +0 -29
- data/app/views/sb_posts/_dummy_forum_post.html.erb +0 -13
- data/app/views/sb_posts/_edit.html.erb +0 -31
- data/app/views/sb_posts/create.js.rjs +0 -16
- data/app/views/sb_posts/edit.js.rjs +0 -6
- data/app/views/sb_posts/update.js.rjs +0 -5
- data/app/views/shared/_user_menu.html.haml +0 -21
- data/app/views/votes/create.js.rjs +0 -6
- data/db/migrate/090_add_comment_role.rb +0 -15
- data/vendor/plugins/activity_tracker/README +0 -4
- data/vendor/plugins/activity_tracker/Rakefile +0 -22
- data/vendor/plugins/activity_tracker/generators/activity_migration/USAGE +0 -13
- data/vendor/plugins/activity_tracker/generators/activity_migration/activity_migration_generator.rb +0 -11
- data/vendor/plugins/activity_tracker/generators/activity_migration/templates/migration.rb +0 -17
- data/vendor/plugins/activity_tracker/init.rb +0 -1
- data/vendor/plugins/activity_tracker/install.rb +0 -1
- data/vendor/plugins/activity_tracker/tasks/activity_tracker_tasks.rake +0 -4
- data/vendor/plugins/activity_tracker/test/abstract_unit.rb +0 -47
- data/vendor/plugins/activity_tracker/test/activity_tracker_test.rb +0 -48
- data/vendor/plugins/activity_tracker/test/database.yml +0 -18
- data/vendor/plugins/activity_tracker/test/debug.log +0 -3329
- data/vendor/plugins/activity_tracker/test/fixtures/test_post.rb +0 -5
- data/vendor/plugins/activity_tracker/test/fixtures/test_posts.yml +0 -3
- data/vendor/plugins/activity_tracker/test/fixtures/test_user.rb +0 -4
- data/vendor/plugins/activity_tracker/test/fixtures/test_users.yml +0 -6
- data/vendor/plugins/activity_tracker/test/schema.rb +0 -21
- data/vendor/plugins/acts_as_list/README +0 -23
- data/vendor/plugins/acts_as_list/init.rb +0 -3
- data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +0 -256
- data/vendor/plugins/acts_as_list/test/list_test.rb +0 -332
- data/vendor/plugins/acts_as_publishable/uninstall.rb +0 -1
- data/vendor/plugins/auto_complete/README +0 -23
- data/vendor/plugins/auto_complete/Rakefile +0 -22
- data/vendor/plugins/auto_complete/init.rb +0 -2
- data/vendor/plugins/auto_complete/lib/auto_complete.rb +0 -47
- data/vendor/plugins/auto_complete/lib/auto_complete_macros_helper.rb +0 -143
- data/vendor/plugins/auto_complete/test/auto_complete_test.rb +0 -67
- data/vendor/plugins/enumerations_mixin/.gitignore +0 -1
- data/vendor/plugins/enumerations_mixin/Gemfile +0 -1
- data/vendor/plugins/enumerations_mixin/LICENSE +0 -20
- data/vendor/plugins/enumerations_mixin/README.md +0 -120
- data/vendor/plugins/enumerations_mixin/README_ENUMERATIONS +0 -163
- data/vendor/plugins/enumerations_mixin/Rakefile +0 -14
- data/vendor/plugins/enumerations_mixin/VERSION +0 -1
- data/vendor/plugins/enumerations_mixin/enumerations_mixin.gemspec +0 -44
- data/vendor/plugins/enumerations_mixin/examples/virtual_enumerations_sample.rb +0 -76
- data/vendor/plugins/enumerations_mixin/init.rb +0 -21
- data/vendor/plugins/enumerations_mixin/lib/active_record/acts/enumerated.rb +0 -180
- data/vendor/plugins/enumerations_mixin/lib/active_record/aggregations/has_enumerated.rb +0 -60
- data/vendor/plugins/enumerations_mixin/lib/active_record/virtual_enumerations.rb +0 -68
- data/vendor/plugins/enumerations_mixin/lib/enumerations_mixin.rb +0 -12
- data/vendor/plugins/enumerations_mixin/virtual_enumerations_sample.rb +0 -76
- data/vendor/plugins/prototype_legacy_helper/README.markdown +0 -13
- data/vendor/plugins/prototype_legacy_helper/init.rb +0 -1
- data/vendor/plugins/prototype_legacy_helper/lib/prototype_legacy_helper.rb +0 -432
- data/vendor/plugins/prototype_legacy_helper/test/test_prototype_helper.rb +0 -297
- data/vendor/plugins/resource_feeder/init.rb +0 -2
- data/vendor/plugins/resource_feeder/lib/resource_feeder.rb +0 -2
- data/vendor/plugins/respond_to_parent/MIT-LICENSE +0 -20
- data/vendor/plugins/respond_to_parent/README +0 -47
- data/vendor/plugins/respond_to_parent/Rakefile +0 -22
- data/vendor/plugins/respond_to_parent/init.rb +0 -1
- data/vendor/plugins/respond_to_parent/install.rb +0 -1
- data/vendor/plugins/respond_to_parent/lib/responds_to_parent.rb +0 -70
- data/vendor/plugins/respond_to_parent/test/responds_to_parent_test.rb +0 -10
- data/vendor/plugins/respond_to_parent/test/test_helper.rb +0 -6
- data/vendor/plugins/respond_to_parent/uninstall.rb +0 -1
@@ -1,21 +0,0 @@
|
|
1
|
-
ActiveRecord::Schema.define(:version => 0) do
|
2
|
-
|
3
|
-
create_table :activities, :force => true do |t|
|
4
|
-
t.column :user_id, :integer, :limit => 10
|
5
|
-
t.column :action, :string, :limit => 50
|
6
|
-
t.column :item_id, :integer, :limit => 10
|
7
|
-
t.column :item_type, :string
|
8
|
-
t.column :created_at, :datetime
|
9
|
-
end
|
10
|
-
|
11
|
-
create_table :test_users, :force => true do |t|
|
12
|
-
t.column :login, :string
|
13
|
-
end
|
14
|
-
|
15
|
-
create_table :test_posts, :force => true do |t|
|
16
|
-
t.column :title, :string
|
17
|
-
t.column :test_user_id, :integer
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
ActsAsList
|
2
|
-
==========
|
3
|
-
|
4
|
-
This acts_as extension provides the capabilities for sorting and reordering a number of objects in a list. The class that has this specified needs to have a +position+ column defined as an integer on the mapped database table.
|
5
|
-
|
6
|
-
|
7
|
-
Example
|
8
|
-
=======
|
9
|
-
|
10
|
-
class TodoList < ActiveRecord::Base
|
11
|
-
has_many :todo_items, :order => "position"
|
12
|
-
end
|
13
|
-
|
14
|
-
class TodoItem < ActiveRecord::Base
|
15
|
-
belongs_to :todo_list
|
16
|
-
acts_as_list :scope => :todo_list
|
17
|
-
end
|
18
|
-
|
19
|
-
todo_list.first.move_to_bottom
|
20
|
-
todo_list.last.move_higher
|
21
|
-
|
22
|
-
|
23
|
-
Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license
|
@@ -1,256 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module Acts #:nodoc:
|
3
|
-
module List #:nodoc:
|
4
|
-
def self.included(base)
|
5
|
-
base.extend(ClassMethods)
|
6
|
-
end
|
7
|
-
|
8
|
-
# This +acts_as+ extension provides the capabilities for sorting and reordering a number of objects in a list.
|
9
|
-
# The class that has this specified needs to have a +position+ column defined as an integer on
|
10
|
-
# the mapped database table.
|
11
|
-
#
|
12
|
-
# Todo list example:
|
13
|
-
#
|
14
|
-
# class TodoList < ActiveRecord::Base
|
15
|
-
# has_many :todo_items, :order => "position"
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# class TodoItem < ActiveRecord::Base
|
19
|
-
# belongs_to :todo_list
|
20
|
-
# acts_as_list :scope => :todo_list
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# todo_list.first.move_to_bottom
|
24
|
-
# todo_list.last.move_higher
|
25
|
-
module ClassMethods
|
26
|
-
# Configuration options are:
|
27
|
-
#
|
28
|
-
# * +column+ - specifies the column name to use for keeping the position integer (default: +position+)
|
29
|
-
# * +scope+ - restricts what is to be considered a list. Given a symbol, it'll attach <tt>_id</tt>
|
30
|
-
# (if it hasn't already been added) and use that as the foreign key restriction. It's also possible
|
31
|
-
# to give it an entire string that is interpolated if you need a tighter scope than just a foreign key.
|
32
|
-
# Example: <tt>acts_as_list :scope => 'todo_list_id = #{todo_list_id} AND completed = 0'</tt>
|
33
|
-
def acts_as_list(options = {})
|
34
|
-
configuration = { :column => "position", :scope => "1 = 1" }
|
35
|
-
configuration.update(options) if options.is_a?(Hash)
|
36
|
-
|
37
|
-
configuration[:scope] = "#{configuration[:scope]}_id".intern if configuration[:scope].is_a?(Symbol) && configuration[:scope].to_s !~ /_id$/
|
38
|
-
|
39
|
-
if configuration[:scope].is_a?(Symbol)
|
40
|
-
scope_condition_method = %(
|
41
|
-
def scope_condition
|
42
|
-
if #{configuration[:scope].to_s}.nil?
|
43
|
-
"#{configuration[:scope].to_s} IS NULL"
|
44
|
-
else
|
45
|
-
"#{configuration[:scope].to_s} = \#{#{configuration[:scope].to_s}}"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
)
|
49
|
-
else
|
50
|
-
scope_condition_method = "def scope_condition() \"#{configuration[:scope]}\" end"
|
51
|
-
end
|
52
|
-
|
53
|
-
class_eval <<-EOV
|
54
|
-
include ActiveRecord::Acts::List::InstanceMethods
|
55
|
-
|
56
|
-
def acts_as_list_class
|
57
|
-
::#{self.name}
|
58
|
-
end
|
59
|
-
|
60
|
-
def position_column
|
61
|
-
'#{configuration[:column]}'
|
62
|
-
end
|
63
|
-
|
64
|
-
#{scope_condition_method}
|
65
|
-
|
66
|
-
before_destroy :remove_from_list
|
67
|
-
before_create :add_to_list_bottom
|
68
|
-
EOV
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# All the methods available to a record that has had <tt>acts_as_list</tt> specified. Each method works
|
73
|
-
# by assuming the object to be the item in the list, so <tt>chapter.move_lower</tt> would move that chapter
|
74
|
-
# lower in the list of all chapters. Likewise, <tt>chapter.first?</tt> would return +true+ if that chapter is
|
75
|
-
# the first in the list of all chapters.
|
76
|
-
module InstanceMethods
|
77
|
-
# Insert the item at the given position (defaults to the top position of 1).
|
78
|
-
def insert_at(position = 1)
|
79
|
-
insert_at_position(position)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Swap positions with the next lower item, if one exists.
|
83
|
-
def move_lower
|
84
|
-
return unless lower_item
|
85
|
-
|
86
|
-
acts_as_list_class.transaction do
|
87
|
-
lower_item.decrement_position
|
88
|
-
increment_position
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# Swap positions with the next higher item, if one exists.
|
93
|
-
def move_higher
|
94
|
-
return unless higher_item
|
95
|
-
|
96
|
-
acts_as_list_class.transaction do
|
97
|
-
higher_item.increment_position
|
98
|
-
decrement_position
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# Move to the bottom of the list. If the item is already in the list, the items below it have their
|
103
|
-
# position adjusted accordingly.
|
104
|
-
def move_to_bottom
|
105
|
-
return unless in_list?
|
106
|
-
acts_as_list_class.transaction do
|
107
|
-
decrement_positions_on_lower_items
|
108
|
-
assume_bottom_position
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
# Move to the top of the list. If the item is already in the list, the items above it have their
|
113
|
-
# position adjusted accordingly.
|
114
|
-
def move_to_top
|
115
|
-
return unless in_list?
|
116
|
-
acts_as_list_class.transaction do
|
117
|
-
increment_positions_on_higher_items
|
118
|
-
assume_top_position
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
# Removes the item from the list.
|
123
|
-
def remove_from_list
|
124
|
-
if in_list?
|
125
|
-
decrement_positions_on_lower_items
|
126
|
-
update_attribute position_column, nil
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
# Increase the position of this item without adjusting the rest of the list.
|
131
|
-
def increment_position
|
132
|
-
return unless in_list?
|
133
|
-
update_attribute position_column, self.send(position_column).to_i + 1
|
134
|
-
end
|
135
|
-
|
136
|
-
# Decrease the position of this item without adjusting the rest of the list.
|
137
|
-
def decrement_position
|
138
|
-
return unless in_list?
|
139
|
-
update_attribute position_column, self.send(position_column).to_i - 1
|
140
|
-
end
|
141
|
-
|
142
|
-
# Return +true+ if this object is the first in the list.
|
143
|
-
def first?
|
144
|
-
return false unless in_list?
|
145
|
-
self.send(position_column) == 1
|
146
|
-
end
|
147
|
-
|
148
|
-
# Return +true+ if this object is the last in the list.
|
149
|
-
def last?
|
150
|
-
return false unless in_list?
|
151
|
-
self.send(position_column) == bottom_position_in_list
|
152
|
-
end
|
153
|
-
|
154
|
-
# Return the next higher item in the list.
|
155
|
-
def higher_item
|
156
|
-
return nil unless in_list?
|
157
|
-
acts_as_list_class.find(:first, :conditions =>
|
158
|
-
"#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}"
|
159
|
-
)
|
160
|
-
end
|
161
|
-
|
162
|
-
# Return the next lower item in the list.
|
163
|
-
def lower_item
|
164
|
-
return nil unless in_list?
|
165
|
-
acts_as_list_class.find(:first, :conditions =>
|
166
|
-
"#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}"
|
167
|
-
)
|
168
|
-
end
|
169
|
-
|
170
|
-
# Test if this record is in a list
|
171
|
-
def in_list?
|
172
|
-
!send(position_column).nil?
|
173
|
-
end
|
174
|
-
|
175
|
-
private
|
176
|
-
def add_to_list_top
|
177
|
-
increment_positions_on_all_items
|
178
|
-
end
|
179
|
-
|
180
|
-
def add_to_list_bottom
|
181
|
-
self[position_column] = bottom_position_in_list.to_i + 1
|
182
|
-
end
|
183
|
-
|
184
|
-
# Overwrite this method to define the scope of the list changes
|
185
|
-
def scope_condition() "1" end
|
186
|
-
|
187
|
-
# Returns the bottom position number in the list.
|
188
|
-
# bottom_position_in_list # => 2
|
189
|
-
def bottom_position_in_list(except = nil)
|
190
|
-
item = bottom_item(except)
|
191
|
-
item ? item.send(position_column) : 0
|
192
|
-
end
|
193
|
-
|
194
|
-
# Returns the bottom item
|
195
|
-
def bottom_item(except = nil)
|
196
|
-
conditions = scope_condition
|
197
|
-
conditions = "#{conditions} AND #{self.class.primary_key} != #{except.id}" if except
|
198
|
-
acts_as_list_class.find(:first, :conditions => conditions, :order => "#{position_column} DESC")
|
199
|
-
end
|
200
|
-
|
201
|
-
# Forces item to assume the bottom position in the list.
|
202
|
-
def assume_bottom_position
|
203
|
-
update_attribute(position_column, bottom_position_in_list(self).to_i + 1)
|
204
|
-
end
|
205
|
-
|
206
|
-
# Forces item to assume the top position in the list.
|
207
|
-
def assume_top_position
|
208
|
-
update_attribute(position_column, 1)
|
209
|
-
end
|
210
|
-
|
211
|
-
# This has the effect of moving all the higher items up one.
|
212
|
-
def decrement_positions_on_higher_items(position)
|
213
|
-
acts_as_list_class.update_all(
|
214
|
-
"#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} <= #{position}"
|
215
|
-
)
|
216
|
-
end
|
217
|
-
|
218
|
-
# This has the effect of moving all the lower items up one.
|
219
|
-
def decrement_positions_on_lower_items
|
220
|
-
return unless in_list?
|
221
|
-
acts_as_list_class.update_all(
|
222
|
-
"#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} > #{send(position_column).to_i}"
|
223
|
-
)
|
224
|
-
end
|
225
|
-
|
226
|
-
# This has the effect of moving all the higher items down one.
|
227
|
-
def increment_positions_on_higher_items
|
228
|
-
return unless in_list?
|
229
|
-
acts_as_list_class.update_all(
|
230
|
-
"#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} < #{send(position_column).to_i}"
|
231
|
-
)
|
232
|
-
end
|
233
|
-
|
234
|
-
# This has the effect of moving all the lower items down one.
|
235
|
-
def increment_positions_on_lower_items(position)
|
236
|
-
acts_as_list_class.update_all(
|
237
|
-
"#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} >= #{position}"
|
238
|
-
)
|
239
|
-
end
|
240
|
-
|
241
|
-
# Increments position (<tt>position_column</tt>) of all items in the list.
|
242
|
-
def increment_positions_on_all_items
|
243
|
-
acts_as_list_class.update_all(
|
244
|
-
"#{position_column} = (#{position_column} + 1)", "#{scope_condition}"
|
245
|
-
)
|
246
|
-
end
|
247
|
-
|
248
|
-
def insert_at_position(position)
|
249
|
-
remove_from_list
|
250
|
-
increment_positions_on_lower_items(position)
|
251
|
-
self.update_attribute(position_column, position)
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|
@@ -1,332 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
gem 'activerecord', '>= 1.15.4.7794'
|
5
|
-
require 'active_record'
|
6
|
-
|
7
|
-
require "#{File.dirname(__FILE__)}/../init"
|
8
|
-
|
9
|
-
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
|
10
|
-
|
11
|
-
def setup_db
|
12
|
-
ActiveRecord::Schema.define(:version => 1) do
|
13
|
-
create_table :mixins do |t|
|
14
|
-
t.column :pos, :integer
|
15
|
-
t.column :parent_id, :integer
|
16
|
-
t.column :created_at, :datetime
|
17
|
-
t.column :updated_at, :datetime
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def teardown_db
|
23
|
-
ActiveRecord::Base.connection.tables.each do |table|
|
24
|
-
ActiveRecord::Base.connection.drop_table(table)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class Mixin < ActiveRecord::Base
|
29
|
-
end
|
30
|
-
|
31
|
-
class ListMixin < Mixin
|
32
|
-
acts_as_list :column => "pos", :scope => :parent
|
33
|
-
|
34
|
-
def self.table_name() "mixins" end
|
35
|
-
end
|
36
|
-
|
37
|
-
class ListMixinSub1 < ListMixin
|
38
|
-
end
|
39
|
-
|
40
|
-
class ListMixinSub2 < ListMixin
|
41
|
-
end
|
42
|
-
|
43
|
-
class ListWithStringScopeMixin < ActiveRecord::Base
|
44
|
-
acts_as_list :column => "pos", :scope => 'parent_id = #{parent_id}'
|
45
|
-
|
46
|
-
def self.table_name() "mixins" end
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
class ListTest < Test::Unit::TestCase
|
51
|
-
|
52
|
-
def setup
|
53
|
-
setup_db
|
54
|
-
(1..4).each { |counter| ListMixin.create! :pos => counter, :parent_id => 5 }
|
55
|
-
end
|
56
|
-
|
57
|
-
def teardown
|
58
|
-
teardown_db
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_reordering
|
62
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
63
|
-
|
64
|
-
ListMixin.find(2).move_lower
|
65
|
-
assert_equal [1, 3, 2, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
66
|
-
|
67
|
-
ListMixin.find(2).move_higher
|
68
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
69
|
-
|
70
|
-
ListMixin.find(1).move_to_bottom
|
71
|
-
assert_equal [2, 3, 4, 1], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
72
|
-
|
73
|
-
ListMixin.find(1).move_to_top
|
74
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
75
|
-
|
76
|
-
ListMixin.find(2).move_to_bottom
|
77
|
-
assert_equal [1, 3, 4, 2], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
78
|
-
|
79
|
-
ListMixin.find(4).move_to_top
|
80
|
-
assert_equal [4, 1, 3, 2], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_move_to_bottom_with_next_to_last_item
|
84
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
85
|
-
ListMixin.find(3).move_to_bottom
|
86
|
-
assert_equal [1, 2, 4, 3], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_next_prev
|
90
|
-
assert_equal ListMixin.find(2), ListMixin.find(1).lower_item
|
91
|
-
assert_nil ListMixin.find(1).higher_item
|
92
|
-
assert_equal ListMixin.find(3), ListMixin.find(4).higher_item
|
93
|
-
assert_nil ListMixin.find(4).lower_item
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_injection
|
97
|
-
item = ListMixin.new(:parent_id => 1)
|
98
|
-
assert_equal "parent_id = 1", item.scope_condition
|
99
|
-
assert_equal "pos", item.position_column
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_insert
|
103
|
-
new = ListMixin.create(:parent_id => 20)
|
104
|
-
assert_equal 1, new.pos
|
105
|
-
assert new.first?
|
106
|
-
assert new.last?
|
107
|
-
|
108
|
-
new = ListMixin.create(:parent_id => 20)
|
109
|
-
assert_equal 2, new.pos
|
110
|
-
assert !new.first?
|
111
|
-
assert new.last?
|
112
|
-
|
113
|
-
new = ListMixin.create(:parent_id => 20)
|
114
|
-
assert_equal 3, new.pos
|
115
|
-
assert !new.first?
|
116
|
-
assert new.last?
|
117
|
-
|
118
|
-
new = ListMixin.create(:parent_id => 0)
|
119
|
-
assert_equal 1, new.pos
|
120
|
-
assert new.first?
|
121
|
-
assert new.last?
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_insert_at
|
125
|
-
new = ListMixin.create(:parent_id => 20)
|
126
|
-
assert_equal 1, new.pos
|
127
|
-
|
128
|
-
new = ListMixin.create(:parent_id => 20)
|
129
|
-
assert_equal 2, new.pos
|
130
|
-
|
131
|
-
new = ListMixin.create(:parent_id => 20)
|
132
|
-
assert_equal 3, new.pos
|
133
|
-
|
134
|
-
new4 = ListMixin.create(:parent_id => 20)
|
135
|
-
assert_equal 4, new4.pos
|
136
|
-
|
137
|
-
new4.insert_at(3)
|
138
|
-
assert_equal 3, new4.pos
|
139
|
-
|
140
|
-
new.reload
|
141
|
-
assert_equal 4, new.pos
|
142
|
-
|
143
|
-
new.insert_at(2)
|
144
|
-
assert_equal 2, new.pos
|
145
|
-
|
146
|
-
new4.reload
|
147
|
-
assert_equal 4, new4.pos
|
148
|
-
|
149
|
-
new5 = ListMixin.create(:parent_id => 20)
|
150
|
-
assert_equal 5, new5.pos
|
151
|
-
|
152
|
-
new5.insert_at(1)
|
153
|
-
assert_equal 1, new5.pos
|
154
|
-
|
155
|
-
new4.reload
|
156
|
-
assert_equal 5, new4.pos
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_delete_middle
|
160
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
161
|
-
|
162
|
-
ListMixin.find(2).destroy
|
163
|
-
|
164
|
-
assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
165
|
-
|
166
|
-
assert_equal 1, ListMixin.find(1).pos
|
167
|
-
assert_equal 2, ListMixin.find(3).pos
|
168
|
-
assert_equal 3, ListMixin.find(4).pos
|
169
|
-
|
170
|
-
ListMixin.find(1).destroy
|
171
|
-
|
172
|
-
assert_equal [3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
173
|
-
|
174
|
-
assert_equal 1, ListMixin.find(3).pos
|
175
|
-
assert_equal 2, ListMixin.find(4).pos
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_with_string_based_scope
|
179
|
-
new = ListWithStringScopeMixin.create(:parent_id => 500)
|
180
|
-
assert_equal 1, new.pos
|
181
|
-
assert new.first?
|
182
|
-
assert new.last?
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_nil_scope
|
186
|
-
new1, new2, new3 = ListMixin.create, ListMixin.create, ListMixin.create
|
187
|
-
new2.move_higher
|
188
|
-
assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos')
|
189
|
-
end
|
190
|
-
|
191
|
-
|
192
|
-
def test_remove_from_list_should_then_fail_in_list?
|
193
|
-
assert_equal true, ListMixin.find(1).in_list?
|
194
|
-
ListMixin.find(1).remove_from_list
|
195
|
-
assert_equal false, ListMixin.find(1).in_list?
|
196
|
-
end
|
197
|
-
|
198
|
-
def test_remove_from_list_should_set_position_to_nil
|
199
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
200
|
-
|
201
|
-
ListMixin.find(2).remove_from_list
|
202
|
-
|
203
|
-
assert_equal [2, 1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
204
|
-
|
205
|
-
assert_equal 1, ListMixin.find(1).pos
|
206
|
-
assert_equal nil, ListMixin.find(2).pos
|
207
|
-
assert_equal 2, ListMixin.find(3).pos
|
208
|
-
assert_equal 3, ListMixin.find(4).pos
|
209
|
-
end
|
210
|
-
|
211
|
-
def test_remove_before_destroy_does_not_shift_lower_items_twice
|
212
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
213
|
-
|
214
|
-
ListMixin.find(2).remove_from_list
|
215
|
-
ListMixin.find(2).destroy
|
216
|
-
|
217
|
-
assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
218
|
-
|
219
|
-
assert_equal 1, ListMixin.find(1).pos
|
220
|
-
assert_equal 2, ListMixin.find(3).pos
|
221
|
-
assert_equal 3, ListMixin.find(4).pos
|
222
|
-
end
|
223
|
-
|
224
|
-
end
|
225
|
-
|
226
|
-
class ListSubTest < Test::Unit::TestCase
|
227
|
-
|
228
|
-
def setup
|
229
|
-
setup_db
|
230
|
-
(1..4).each { |i| ((i % 2 == 1) ? ListMixinSub1 : ListMixinSub2).create! :pos => i, :parent_id => 5000 }
|
231
|
-
end
|
232
|
-
|
233
|
-
def teardown
|
234
|
-
teardown_db
|
235
|
-
end
|
236
|
-
|
237
|
-
def test_reordering
|
238
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
239
|
-
|
240
|
-
ListMixin.find(2).move_lower
|
241
|
-
assert_equal [1, 3, 2, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
242
|
-
|
243
|
-
ListMixin.find(2).move_higher
|
244
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
245
|
-
|
246
|
-
ListMixin.find(1).move_to_bottom
|
247
|
-
assert_equal [2, 3, 4, 1], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
248
|
-
|
249
|
-
ListMixin.find(1).move_to_top
|
250
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
251
|
-
|
252
|
-
ListMixin.find(2).move_to_bottom
|
253
|
-
assert_equal [1, 3, 4, 2], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
254
|
-
|
255
|
-
ListMixin.find(4).move_to_top
|
256
|
-
assert_equal [4, 1, 3, 2], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
257
|
-
end
|
258
|
-
|
259
|
-
def test_move_to_bottom_with_next_to_last_item
|
260
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
261
|
-
ListMixin.find(3).move_to_bottom
|
262
|
-
assert_equal [1, 2, 4, 3], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
263
|
-
end
|
264
|
-
|
265
|
-
def test_next_prev
|
266
|
-
assert_equal ListMixin.find(2), ListMixin.find(1).lower_item
|
267
|
-
assert_nil ListMixin.find(1).higher_item
|
268
|
-
assert_equal ListMixin.find(3), ListMixin.find(4).higher_item
|
269
|
-
assert_nil ListMixin.find(4).lower_item
|
270
|
-
end
|
271
|
-
|
272
|
-
def test_injection
|
273
|
-
item = ListMixin.new("parent_id"=>1)
|
274
|
-
assert_equal "parent_id = 1", item.scope_condition
|
275
|
-
assert_equal "pos", item.position_column
|
276
|
-
end
|
277
|
-
|
278
|
-
def test_insert_at
|
279
|
-
new = ListMixin.create("parent_id" => 20)
|
280
|
-
assert_equal 1, new.pos
|
281
|
-
|
282
|
-
new = ListMixinSub1.create("parent_id" => 20)
|
283
|
-
assert_equal 2, new.pos
|
284
|
-
|
285
|
-
new = ListMixinSub2.create("parent_id" => 20)
|
286
|
-
assert_equal 3, new.pos
|
287
|
-
|
288
|
-
new4 = ListMixin.create("parent_id" => 20)
|
289
|
-
assert_equal 4, new4.pos
|
290
|
-
|
291
|
-
new4.insert_at(3)
|
292
|
-
assert_equal 3, new4.pos
|
293
|
-
|
294
|
-
new.reload
|
295
|
-
assert_equal 4, new.pos
|
296
|
-
|
297
|
-
new.insert_at(2)
|
298
|
-
assert_equal 2, new.pos
|
299
|
-
|
300
|
-
new4.reload
|
301
|
-
assert_equal 4, new4.pos
|
302
|
-
|
303
|
-
new5 = ListMixinSub1.create("parent_id" => 20)
|
304
|
-
assert_equal 5, new5.pos
|
305
|
-
|
306
|
-
new5.insert_at(1)
|
307
|
-
assert_equal 1, new5.pos
|
308
|
-
|
309
|
-
new4.reload
|
310
|
-
assert_equal 5, new4.pos
|
311
|
-
end
|
312
|
-
|
313
|
-
def test_delete_middle
|
314
|
-
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
315
|
-
|
316
|
-
ListMixin.find(2).destroy
|
317
|
-
|
318
|
-
assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
319
|
-
|
320
|
-
assert_equal 1, ListMixin.find(1).pos
|
321
|
-
assert_equal 2, ListMixin.find(3).pos
|
322
|
-
assert_equal 3, ListMixin.find(4).pos
|
323
|
-
|
324
|
-
ListMixin.find(1).destroy
|
325
|
-
|
326
|
-
assert_equal [3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
327
|
-
|
328
|
-
assert_equal 1, ListMixin.find(3).pos
|
329
|
-
assert_equal 2, ListMixin.find(4).pos
|
330
|
-
end
|
331
|
-
|
332
|
-
end
|