muck-friends 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +51 -0
- data/Rakefile +101 -0
- data/VERSION +1 -0
- data/app/controllers/muck/friends_controller.rb +70 -0
- data/app/helpers/muck_friends_helper.rb +93 -0
- data/app/models/friend_mailer.rb +25 -0
- data/app/views/activity_templates/follow.html.erb +1 -0
- data/app/views/activity_templates/friends_with.html.erb +1 -0
- data/app/views/friend_mailer/follow.text.html.erb +8 -0
- data/app/views/friend_mailer/follow.text.plain.erb +8 -0
- data/app/views/friend_mailer/friend_request.text.html.erb +8 -0
- data/app/views/friend_mailer/friend_request.text.plain.erb +8 -0
- data/app/views/friends/_friend_simple.html.erb +4 -0
- data/app/views/friends/_friends.html.erb +8 -0
- data/app/views/friends/_notifications.html.erb +32 -0
- data/app/views/friends/friend_or_follow_request.html.erb +8 -0
- data/app/views/friends/index.html.erb +1 -0
- data/config/muck_friends_routes.rb +4 -0
- data/db/migrate/20090608073052_create_friends.rb +16 -0
- data/install.rb +1 -0
- data/lib/active_record/acts/muck_friend.rb +141 -0
- data/lib/active_record/acts/muck_friend_user.rb +103 -0
- data/lib/muck_friends.rb +12 -0
- data/lib/muck_friends/initialize_routes.rb +8 -0
- data/lib/muck_friends/tasks.rb +27 -0
- data/locales/ar.yml +31 -0
- data/locales/bg.yml +31 -0
- data/locales/ca.yml +31 -0
- data/locales/cs.yml +31 -0
- data/locales/da.yml +31 -0
- data/locales/de.yml +31 -0
- data/locales/el.yml +31 -0
- data/locales/en.yml +31 -0
- data/locales/es.yml +31 -0
- data/locales/et.yml +31 -0
- data/locales/fa.yml +31 -0
- data/locales/fi.yml +31 -0
- data/locales/fr.yml +31 -0
- data/locales/gl.yml +31 -0
- data/locales/hi.yml +31 -0
- data/locales/hr.yml +31 -0
- data/locales/hu.yml +31 -0
- data/locales/id.yml +31 -0
- data/locales/it.yml +31 -0
- data/locales/iw.yml +31 -0
- data/locales/ja.yml +31 -0
- data/locales/ko.yml +31 -0
- data/locales/lt.yml +31 -0
- data/locales/lv.yml +31 -0
- data/locales/mt.yml +31 -0
- data/locales/nl.yml +31 -0
- data/locales/no.yml +32 -0
- data/locales/pl.yml +31 -0
- data/locales/pt-PT.yml +31 -0
- data/locales/pt.yml +6 -0
- data/locales/ro.yml +31 -0
- data/locales/ru.yml +31 -0
- data/locales/sk.yml +31 -0
- data/locales/sl.yml +31 -0
- data/locales/sq.yml +31 -0
- data/locales/sr.yml +31 -0
- data/locales/sv.yml +31 -0
- data/locales/th.yml +31 -0
- data/locales/tl.yml +31 -0
- data/locales/tr.yml +31 -0
- data/locales/uk.yml +31 -0
- data/locales/vi.yml +31 -0
- data/locales/zh-CN.yml +31 -0
- data/locales/zh-TW.yml +31 -0
- data/locales/zh.yml +31 -0
- data/muck-friends.gemspec +381 -0
- data/rails/init.rb +4 -0
- data/tasks/rails.rake +1 -0
- data/test/rails_root/.gitignore +8 -0
- data/test/rails_root/.rake_tasks +103 -0
- data/test/rails_root/Capfile +3 -0
- data/test/rails_root/Rakefile +15 -0
- data/test/rails_root/app/controllers/application_controller.rb +21 -0
- data/test/rails_root/app/controllers/default_controller.rb +7 -0
- data/test/rails_root/app/helpers/application_helper.rb +3 -0
- data/test/rails_root/app/models/.keep +0 -0
- data/test/rails_root/app/models/activity.rb +3 -0
- data/test/rails_root/app/models/friend.rb +4 -0
- data/test/rails_root/app/models/user.rb +8 -0
- data/test/rails_root/app/models/user_session.rb +2 -0
- data/test/rails_root/app/views/default/index.html.erb +1 -0
- data/test/rails_root/app/views/layouts/default.html.erb +26 -0
- data/test/rails_root/config/amazon_s3.yml +14 -0
- data/test/rails_root/config/boot.rb +109 -0
- data/test/rails_root/config/database.yml +14 -0
- data/test/rails_root/config/environment.rb +27 -0
- data/test/rails_root/config/environments/development.rb +19 -0
- data/test/rails_root/config/environments/production.rb +1 -0
- data/test/rails_root/config/environments/test.rb +34 -0
- data/test/rails_root/config/global_config.yml +72 -0
- data/test/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails_root/config/initializers/requires.rb +13 -0
- data/test/rails_root/config/initializers/session_store.rb +8 -0
- data/test/rails_root/config/routes.rb +3 -0
- data/test/rails_root/db/.keep +0 -0
- data/test/rails_root/db/migrate/20090320174818_create_muck_permissions_and_roles.rb +16 -0
- data/test/rails_root/db/migrate/20090402033319_add_muck_activities.rb +36 -0
- data/test/rails_root/db/migrate/20090602041838_create_users.rb +39 -0
- data/test/rails_root/db/migrate/20090608073052_create_friends.rb +16 -0
- data/test/rails_root/features/step_definitions/webrat_steps.rb +99 -0
- data/test/rails_root/features/support/env.rb +14 -0
- data/test/rails_root/public/.htaccess +40 -0
- data/test/rails_root/public/404.html +30 -0
- data/test/rails_root/public/422.html +30 -0
- data/test/rails_root/public/500.html +30 -0
- data/test/rails_root/public/dispatch.rb +10 -0
- data/test/rails_root/public/favicon.ico +0 -0
- data/test/rails_root/public/images/arrow_left.gif +0 -0
- data/test/rails_root/public/images/arrow_right.gif +0 -0
- data/test/rails_root/public/images/blue/preview.gif +0 -0
- data/test/rails_root/public/images/icons/accept.png +0 -0
- data/test/rails_root/public/images/icons/add.png +0 -0
- data/test/rails_root/public/images/icons/delete.png +0 -0
- data/test/rails_root/public/images/icons/vote.png +0 -0
- data/test/rails_root/public/images/loading.gif +0 -0
- data/test/rails_root/public/images/profile_default.jpg +0 -0
- data/test/rails_root/public/images/rails.png +0 -0
- data/test/rails_root/public/images/red/preview.gif +0 -0
- data/test/rails_root/public/images/spinner.gif +0 -0
- data/test/rails_root/public/images/sprites.png +0 -0
- data/test/rails_root/public/javascripts/application.js +2 -0
- data/test/rails_root/public/javascripts/builder.js +136 -0
- data/test/rails_root/public/javascripts/controls.js +963 -0
- data/test/rails_root/public/javascripts/dragdrop.js +972 -0
- data/test/rails_root/public/javascripts/effects.js +1120 -0
- data/test/rails_root/public/javascripts/fancyzoom.min.js +1 -0
- data/test/rails_root/public/javascripts/jquery/jquery-ui.js +273 -0
- data/test/rails_root/public/javascripts/jquery/jquery.form.js +637 -0
- data/test/rails_root/public/javascripts/jquery/jquery.jgrowl.js +2 -0
- data/test/rails_root/public/javascripts/jquery/jquery.js +19 -0
- data/test/rails_root/public/javascripts/jquery/jquery.tips.js +69 -0
- data/test/rails_root/public/javascripts/muck.js +76 -0
- data/test/rails_root/public/javascripts/muck_activities.js +108 -0
- data/test/rails_root/public/javascripts/prototype.js +4225 -0
- data/test/rails_root/public/javascripts/scriptaculous.js +58 -0
- data/test/rails_root/public/javascripts/slider.js +277 -0
- data/test/rails_root/public/javascripts/sound.js +60 -0
- data/test/rails_root/public/robots.txt +1 -0
- data/test/rails_root/public/stylesheets/.keep +0 -0
- data/test/rails_root/public/stylesheets/admin.css +12 -0
- data/test/rails_root/public/stylesheets/blueprint/ie.css +26 -0
- data/test/rails_root/public/stylesheets/blueprint/liquid_screen.css +203 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/icons/key.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/readme.txt +32 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/screen.css +97 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/fancy-type/screen.css +71 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/readme.txt +18 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/screen.css +40 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/liquid/liquid.css +134 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/liquid/src/liquid.css +197 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/rtl/readme.txt +10 -0
- data/test/rails_root/public/stylesheets/blueprint/plugins/rtl/screen.css +109 -0
- data/test/rails_root/public/stylesheets/blueprint/print.css +30 -0
- data/test/rails_root/public/stylesheets/blueprint/screen.css +251 -0
- data/test/rails_root/public/stylesheets/blueprint/sprite.css +1 -0
- data/test/rails_root/public/stylesheets/blueprint/src/forms.css +49 -0
- data/test/rails_root/public/stylesheets/blueprint/src/grid.css +213 -0
- data/test/rails_root/public/stylesheets/blueprint/src/grid.png +0 -0
- data/test/rails_root/public/stylesheets/blueprint/src/ie.css +59 -0
- data/test/rails_root/public/stylesheets/blueprint/src/print.css +85 -0
- data/test/rails_root/public/stylesheets/blueprint/src/reset.css +38 -0
- data/test/rails_root/public/stylesheets/blueprint/src/typography.css +105 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_diagonals-small_0_aaaaaa_40x40.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_diagonals-thick_15_444444_40x40.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_100_f0f0f0_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_50_99c2ff_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_55_fbf5d0_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_80_e6e6e6_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_highlight-hard_100_f9f9f9_1x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_highlight-soft_100_e7eef3_1x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_222222_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_2694e8_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_2e83ff_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_72a7cf_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_888888_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_ffffff_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/cupertino/jquery-ui-1.7.1.custom.css +404 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_217bc0_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_2e83ff_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_469bdd_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_6da8d5_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_d8e7f3_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_f9bd01_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/redmond/jquery-ui-1.7.1.custom.css +404 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/smoothness/jquery-ui-1.7.1.custom.css +404 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/jquery/ui-lightness/jquery-ui-1.7.1.custom.css +404 -0
- data/test/rails_root/public/stylesheets/reset.css +0 -0
- data/test/rails_root/public/stylesheets/styles.css +79 -0
- data/test/rails_root/public/stylesheets/themes/blue/styles.css +1 -0
- data/test/rails_root/public/stylesheets/themes/red/styles.css +1 -0
- data/test/rails_root/script/about +3 -0
- data/test/rails_root/script/breakpointer +3 -0
- data/test/rails_root/script/console +3 -0
- data/test/rails_root/script/create_project.rb +52 -0
- data/test/rails_root/script/cucumber +7 -0
- data/test/rails_root/script/dbconsole +3 -0
- data/test/rails_root/script/destroy +3 -0
- data/test/rails_root/script/generate +3 -0
- data/test/rails_root/script/performance/benchmarker +3 -0
- data/test/rails_root/script/performance/profiler +3 -0
- data/test/rails_root/script/performance/request +3 -0
- data/test/rails_root/script/plugin +3 -0
- data/test/rails_root/script/process/inspector +3 -0
- data/test/rails_root/script/process/reaper +3 -0
- data/test/rails_root/script/process/spawner +3 -0
- data/test/rails_root/script/runner +3 -0
- data/test/rails_root/script/server +3 -0
- data/test/rails_root/test/factories.rb +50 -0
- data/test/rails_root/test/functional/.keep +0 -0
- data/test/rails_root/test/functional/friends_controller_test.rb +171 -0
- data/test/rails_root/test/integration/.keep +0 -0
- data/test/rails_root/test/mocks/development/.keep +0 -0
- data/test/rails_root/test/mocks/test/.keep +0 -0
- data/test/rails_root/test/shoulda_macros/controller.rb +45 -0
- data/test/rails_root/test/shoulda_macros/forms.rb +32 -0
- data/test/rails_root/test/shoulda_macros/models.rb +50 -0
- data/test/rails_root/test/shoulda_macros/pagination.rb +53 -0
- data/test/rails_root/test/shoulda_macros/plugins.rb +34 -0
- data/test/rails_root/test/test_helper.rb +38 -0
- data/test/rails_root/test/unit/.keep +0 -0
- data/test/rails_root/test/unit/friend_mailer_test.rb +37 -0
- data/test/rails_root/test/unit/friend_test.rb +186 -0
- data/test/rails_root/test/unit/user_test.rb +170 -0
- data/test/rails_root/vendor/plugins/ssl_requirement/README +43 -0
- data/test/rails_root/vendor/plugins/ssl_requirement/lib/ssl_requirement.rb +62 -0
- data/test/rails_root/vendor/plugins/ssl_requirement/test/ssl_requirement_test.rb +132 -0
- data/test/rails_root/vendor/plugins/validation_reflection/CHANGELOG +24 -0
- data/test/rails_root/vendor/plugins/validation_reflection/LICENSE +20 -0
- data/test/rails_root/vendor/plugins/validation_reflection/README +64 -0
- data/test/rails_root/vendor/plugins/validation_reflection/Rakefile +22 -0
- data/test/rails_root/vendor/plugins/validation_reflection/about.yml +7 -0
- data/test/rails_root/vendor/plugins/validation_reflection/init.rb +8 -0
- data/test/rails_root/vendor/plugins/validation_reflection/lib/boiler_plate/validation_reflection.rb +129 -0
- data/test/rails_root/vendor/plugins/validation_reflection/test/test_helper.rb +36 -0
- data/test/rails_root/vendor/plugins/validation_reflection/test/validation_reflection_test.rb +126 -0
- data/uninstall.rb +1 -0
- metadata +416 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
<% if !GlobalConfig.allow_following -%>
|
2
|
+
<% @user.followers.each do |follower| %>
|
3
|
+
<li>
|
4
|
+
<%= _("%{profile} requests to be your Friend %{accept} %{ignore}") % {:profile => link_to(h(follower.full_name), profile_path(follower)),
|
5
|
+
:accept => accept_follower_link(current_user, follower),
|
6
|
+
:ignore => ignore_friend_request_link(current_user, follower) } -%></li>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= all_friends(current_user) %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateFriends < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :friends, :force => true do |t|
|
4
|
+
t.integer "inviter_id"
|
5
|
+
t.integer "invited_id"
|
6
|
+
t.integer "status", :default => 0
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
add_index :friends, ["inviter_id", "invited_id"]
|
10
|
+
add_index :friends, ["invited_id", "inviter_id"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :friends
|
15
|
+
end
|
16
|
+
end
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Acts #:nodoc:
|
3
|
+
module MuckFriend #:nodoc:
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
def acts_as_muck_friend(options = {})
|
12
|
+
|
13
|
+
belongs_to :inviter, :class_name => 'User'
|
14
|
+
belongs_to :invited, :class_name => 'User'
|
15
|
+
|
16
|
+
include ActiveRecord::Acts::MuckFriend::InstanceMethods
|
17
|
+
extend ActiveRecord::Acts::MuckFriend::SingletonMethods
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# class methods
|
23
|
+
module SingletonMethods
|
24
|
+
|
25
|
+
# When allow_following is true this will setup a follower. When allow_following is false
|
26
|
+
# the system only allows friends and so this becomes a friend request
|
27
|
+
def add_follower(inviter, invited)
|
28
|
+
return false if inviter.blank? || invited.blank? || inviter == invited
|
29
|
+
success = false
|
30
|
+
transaction do
|
31
|
+
friend = Friend.create(:inviter => inviter, :invited => invited, :status => MuckFriends::PENDING)
|
32
|
+
friend.add_follow_activity
|
33
|
+
success = !friend.new_record?
|
34
|
+
end
|
35
|
+
success
|
36
|
+
end
|
37
|
+
|
38
|
+
# Called after add_follower. This establishes a friend relationship between the two parties
|
39
|
+
def make_friends(user, target)
|
40
|
+
return false if user.blank? || target.blank? || user == target
|
41
|
+
transaction do
|
42
|
+
begin
|
43
|
+
Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id, :status => MuckFriends::PENDING}).update_attribute(:status, MuckFriends::ACCEPTED)
|
44
|
+
friend = Friend.create!(:inviter_id => target.id, :invited_id => user.id, :status => MuckFriends::ACCEPTED)
|
45
|
+
friend.add_friends_with_activity
|
46
|
+
rescue Exception
|
47
|
+
return make_friends(target, user) if user.followed_by?(target)
|
48
|
+
return add_follower(user, target)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
true
|
52
|
+
end
|
53
|
+
|
54
|
+
# Destroy the frienship :(
|
55
|
+
def stop_being_friends(user, target)
|
56
|
+
return false if user.blank? || target.blank?
|
57
|
+
transaction do
|
58
|
+
begin
|
59
|
+
Friend.find(:first, :conditions => {:inviter_id => target.id, :invited_id => user.id}).destroy
|
60
|
+
Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id}).destroy
|
61
|
+
rescue Exception
|
62
|
+
return false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
# Stop friendship with another user. This will turn the other user into a follower
|
69
|
+
def revert_to_follower(user, target)
|
70
|
+
return false if user.blank? || target.blank?
|
71
|
+
transaction do
|
72
|
+
begin
|
73
|
+
Friend.find(:first, :conditions => {:inviter_id => target.id, :invited_id => user.id}).update_attribute(:status, MuckFriends::PENDING)
|
74
|
+
Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id}).destroy
|
75
|
+
rescue Exception
|
76
|
+
return false
|
77
|
+
end
|
78
|
+
end
|
79
|
+
true
|
80
|
+
end
|
81
|
+
|
82
|
+
def stop_following(user, target)
|
83
|
+
return false if user.blank? || target.blank?
|
84
|
+
transaction do
|
85
|
+
begin
|
86
|
+
Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id}).destroy
|
87
|
+
rescue Exception
|
88
|
+
return false
|
89
|
+
end
|
90
|
+
end
|
91
|
+
true
|
92
|
+
end
|
93
|
+
|
94
|
+
def block_user(user, target)
|
95
|
+
return false if user.blank? || target.blank?
|
96
|
+
Friend.find(:first, :conditions => {:inviter_id => target.id, :invited_id => user.id}).update_attribute(:status, MuckFriends::BLOCKED)
|
97
|
+
friend = Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id})
|
98
|
+
friend.destroy if friend
|
99
|
+
end
|
100
|
+
|
101
|
+
def unblock_user(user, target)
|
102
|
+
return false if user.blank? || target.blank?
|
103
|
+
friend = Friend.find(:first, :conditions => {:inviter_id => target.id, :invited_id => user.id})
|
104
|
+
friend.update_attribute(:status, MuckFriends::PENDING) if friend
|
105
|
+
end
|
106
|
+
|
107
|
+
def has_network?(user)
|
108
|
+
!self.find(:first, :conditions => ["invited_id = ? or inviter_id = ?", user.id, user.id]).blank?
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
# All the methods available to a record that has had <tt>acts_as_muck_friend</tt> specified.
|
114
|
+
module InstanceMethods
|
115
|
+
|
116
|
+
def after_create
|
117
|
+
FriendMailer.deliver_follow(inviter, invited)
|
118
|
+
end
|
119
|
+
|
120
|
+
#
|
121
|
+
def add_follow_activity
|
122
|
+
return unless GlobalConfig.enable_friend_activity
|
123
|
+
content = I18n.t('muck.friends.follow_activity', :inviter => self.inviter.full_name, :invited => self.invited.full_name)
|
124
|
+
add_activity(self.inviter.feed_to, self.inviter, self, 'follow', '', content)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Add an activity that indicates the users have become friends
|
128
|
+
def add_friends_with_activity
|
129
|
+
return unless GlobalConfig.enable_friend_activity
|
130
|
+
content = I18n.t('muck.friends.friends_with', :inviter => self.inviter.full_name, :invited => self.invited.full_name)
|
131
|
+
add_activity(self.inviter.feed_to + self.invited.feed_to, self.inviter, self, 'friends_with', '', content)
|
132
|
+
end
|
133
|
+
|
134
|
+
def validate
|
135
|
+
errors.add('inviter', I18n.t('muck.friends.same_inviter_error_message')) if invited == inviter
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Acts #:nodoc:
|
3
|
+
module MuckFriendUser #:nodoc:
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
def acts_as_muck_friend_user(options = {})
|
12
|
+
|
13
|
+
has_many :friendships, :class_name => "Friend", :foreign_key => 'inviter_id', :conditions => "status = #{MuckFriends::ACCEPTED}", :dependent => :destroy
|
14
|
+
has_many :follower_friends, :class_name => "Friend", :foreign_key => "invited_id", :conditions => "status = #{MuckFriends::PENDING}", :dependent => :destroy
|
15
|
+
has_many :following_friends, :class_name => "Friend", :foreign_key => "inviter_id", :conditions => "status = #{MuckFriends::PENDING}", :dependent => :destroy
|
16
|
+
has_many :blocked_friends, :class_name => "Friend", :foreign_key => "invited_id", :conditions => "status = #{MuckFriends::BLOCKED}", :dependent => :destroy
|
17
|
+
|
18
|
+
has_many :friends, :through => :friendships, :source => :invited
|
19
|
+
has_many :followers, :through => :follower_friends, :source => :inviter
|
20
|
+
has_many :followings, :through => :following_friends, :source => :invited
|
21
|
+
has_many :blocked_users, :through => :blocked_friends, :source => :inviter
|
22
|
+
|
23
|
+
has_many :initiated_by_me, :class_name => "Friend", :foreign_key => "inviter_id"
|
24
|
+
has_many :not_initiated_by_me, :class_name => "Friend", :foreign_key => "invited_id"
|
25
|
+
|
26
|
+
has_many :friendships_initiated_by_me, :through => :initiated_by_me, :source => :invited
|
27
|
+
has_many :friendships_not_initiated_by_me, :through => :not_initiated_by_me, :source => :inviter
|
28
|
+
|
29
|
+
has_many :occurances_as_friend, :class_name => "Friend", :foreign_key => "invited_id"
|
30
|
+
|
31
|
+
include ActiveRecord::Acts::MuckFriendUser::InstanceMethods
|
32
|
+
extend ActiveRecord::Acts::MuckFriendUser::SingletonMethods
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# class methods
|
38
|
+
module SingletonMethods
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# All the methods available to a record that has had <tt>acts_as_muck_friend</tt> specified.
|
43
|
+
module InstanceMethods
|
44
|
+
|
45
|
+
# Feed to friends and followers
|
46
|
+
def feed_to
|
47
|
+
@feed_to_users ||= [self] | self.friends | self.followers # prevent duplicates in the array
|
48
|
+
end
|
49
|
+
|
50
|
+
# Indicates whether or not the give user is a friend
|
51
|
+
def friend_of?(user)
|
52
|
+
friends.include?(user)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Assume that 'user' is already following the current user
|
56
|
+
def become_friends_with(user)
|
57
|
+
Friend.make_friends(self, user)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Follow the given user
|
61
|
+
def follow(user)
|
62
|
+
Friend.add_follower(self, user)
|
63
|
+
end
|
64
|
+
|
65
|
+
def stop_following(user)
|
66
|
+
Friend.stop_following(self, user)
|
67
|
+
end
|
68
|
+
|
69
|
+
def drop_friend(user)
|
70
|
+
if GlobalConfig.allow_following
|
71
|
+
Friend.revert_to_follower(self, user)
|
72
|
+
else
|
73
|
+
Friend.stop_being_friends(self, user)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def block_user(user)
|
78
|
+
Friend.block_user(self, user)
|
79
|
+
end
|
80
|
+
|
81
|
+
def unblock_user(user)
|
82
|
+
Friend.unblock_user(self, user)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Indicates whether the given user is following the current user
|
86
|
+
def followed_by?(user)
|
87
|
+
followers.include?(user)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Indicates whether the given user is being followed by the current user
|
91
|
+
def following?(user)
|
92
|
+
followings.include?(user)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Indicates whether the user has any followers or friends or if they are following anybody
|
96
|
+
def has_network?
|
97
|
+
Friend.has_network?(self)
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/muck_friends.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module MuckFriends
|
2
|
+
# Statuses Array
|
3
|
+
BLOCKED = 2
|
4
|
+
ACCEPTED = 1
|
5
|
+
PENDING = 0
|
6
|
+
end
|
7
|
+
|
8
|
+
ActiveRecord::Base.class_eval { include ActiveRecord::Acts::MuckFriend }
|
9
|
+
ActiveRecord::Base.class_eval { include ActiveRecord::Acts::MuckFriendUser }
|
10
|
+
ActionController::Base.send :helper, MuckFriendsHelper
|
11
|
+
|
12
|
+
I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '..', 'locales', '*.{rb,yml}') ]
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class ActionController::Routing::RouteSet
|
2
|
+
def load_routes_with_muck_friends!
|
3
|
+
muck_friends_routes = File.join(File.dirname(__FILE__), *%w[.. .. config muck_friends_routes.rb])
|
4
|
+
add_configuration_file(muck_friends_routes) unless configuration_files.include? muck_friends_routes
|
5
|
+
load_routes_without_muck_friends!
|
6
|
+
end
|
7
|
+
alias_method_chain :load_routes!, :muck_friends
|
8
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module MuckFriends
|
6
|
+
class Tasks < ::Rake::TaskLib
|
7
|
+
def initialize
|
8
|
+
define
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def define
|
13
|
+
|
14
|
+
namespace :muck do
|
15
|
+
namespace :friends do
|
16
|
+
desc "Sync files from muck friends."
|
17
|
+
task :sync do
|
18
|
+
path = File.join(File.dirname(__FILE__), *%w[.. ..])
|
19
|
+
system "rsync -ruv #{path}/db ."
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
MuckFriends::Tasks.new
|
data/locales/ar.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
ar:
|
3
|
+
muck:
|
4
|
+
activity_templates:
|
5
|
+
follow: أتباع
|
6
|
+
friends_with: أصدقاء
|
7
|
+
friends:
|
8
|
+
acccept_friend_request: "قبول طلب صديق"
|
9
|
+
accept: (قبول)
|
10
|
+
delete: (حذف)
|
11
|
+
follow_activity: "{{inviter}} is now following {{invited}}"
|
12
|
+
following_you: "{{name}} is now following you on {{application_name}}"
|
13
|
+
friend_request: "طلب صديق"
|
14
|
+
friend_request_pending: "طلب صديق في انتظار {{link}}"
|
15
|
+
friend_request_sent: "تم إرسال طلب صديق"
|
16
|
+
friends_title: أصدقائي
|
17
|
+
friends_with: "{{inviter}} is now friends with {{invited}}"
|
18
|
+
ignore: (تجاهل)
|
19
|
+
no_followers: "أنت ليست لديها حاليا أي أتباع"
|
20
|
+
no_friends: "أنت ليست لديها حاليا أي الأصدقاء"
|
21
|
+
not_following_anyone: "انك لم تتابع حاليا أحدا"
|
22
|
+
problem_adding_follow: "هناك مشكلة واضاف {{user}}لمتابعة القائمة الخاصة بك. يرجى المحاولة مرة أخرى."
|
23
|
+
problem_sending_friend_request: "هناك مشكلة في ارسال طلب لصديق {{user}}. يرجى المحاولة مرة أخرى."
|
24
|
+
removed_friendship: "إزالة العلاقة صديق"
|
25
|
+
same_inviter_error_message: "المستخدم لا يمكن أن يصبح صديقا لذاتهما."
|
26
|
+
sign_up_to_follow: "تسجيل الدخول لمتابعة"
|
27
|
+
start_following: "وبعد بدء"
|
28
|
+
stop_being_friends: "الكف عن أصدقاء"
|
29
|
+
stop_following: "وبعد توقف"
|
30
|
+
view_all: "وبالنظر إلى جميع"
|
31
|
+
you_are_now_following: "أنت الآن بعد {{user}}"
|
data/locales/bg.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
bg:
|
3
|
+
muck:
|
4
|
+
activity_templates:
|
5
|
+
follow: Последователи
|
6
|
+
friends_with: Приятели
|
7
|
+
friends:
|
8
|
+
acccept_friend_request: "Приеми приятел Запитване"
|
9
|
+
accept: (приеме)
|
10
|
+
delete: (изтриване)
|
11
|
+
follow_activity: "{{inviter}} is now following {{invited}}"
|
12
|
+
following_you: "{{name}} is now following you on {{application_name}}"
|
13
|
+
friend_request: "Приятел Запитване"
|
14
|
+
friend_request_pending: "Приятел запитване до {{link}}"
|
15
|
+
friend_request_sent: "Приятел Искане Изпратени"
|
16
|
+
friends_title: "Моите приятели"
|
17
|
+
friends_with: "{{inviter}} is now friends with {{invited}}"
|
18
|
+
ignore: (пренебрегни)
|
19
|
+
no_followers: "Не е в момента имате някакви последователите"
|
20
|
+
no_friends: "Вие в момента не са никакви приятели"
|
21
|
+
not_following_anyone: "Вие сте в момента не след никого"
|
22
|
+
problem_adding_follow: "Имаше проблем при добавянето {{user}} да ви следват списък. Моля опитайте отново."
|
23
|
+
problem_sending_friend_request: "Имаше проблем при изпращането на молба за приятелство с {{user}}. Моля опитайте отново."
|
24
|
+
removed_friendship: "Премахнато приятел отношения"
|
25
|
+
same_inviter_error_message: "Потребителят може да не станат приятели с themself."
|
26
|
+
sign_up_to_follow: "Sign-до Следвайте"
|
27
|
+
start_following: "Започнете След"
|
28
|
+
stop_being_friends: "Спри приятелство"
|
29
|
+
stop_following: "Спри След"
|
30
|
+
view_all: "View All"
|
31
|
+
you_are_now_following: "Сега след {{user}}"
|
data/locales/ca.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
ca:
|
3
|
+
muck:
|
4
|
+
activity_templates:
|
5
|
+
follow: Seguidors
|
6
|
+
friends_with: Amics
|
7
|
+
friends:
|
8
|
+
acccept_friend_request: "Acceptar la sol licitud d'amistat"
|
9
|
+
accept: (acceptar)
|
10
|
+
delete: (eliminar)
|
11
|
+
follow_activity: "{{inviter}} is now following {{invited}}"
|
12
|
+
following_you: "{{name}} is now following you on {{application_name}}"
|
13
|
+
friend_request: "Sol licitud amic"
|
14
|
+
friend_request_pending: "A l'espera de sol licitud d'amistat {{link}}"
|
15
|
+
friend_request_sent: "La sol licitud s'ha enviat un amic"
|
16
|
+
friends_title: "Els meus amics"
|
17
|
+
friends_with: "{{inviter}} is now friends with {{invited}}"
|
18
|
+
ignore: (ignorar)
|
19
|
+
no_followers: "Que actualment no té cap seguidors"
|
20
|
+
no_friends: "Vostè no té actualment cap amic"
|
21
|
+
not_following_anyone: "Vostè no està actualment següents a ningú"
|
22
|
+
problem_adding_follow: "Hi ha hagut un problema {{user}} afegir a la seva llista de seguiment. Torneu-ho de nou."
|
23
|
+
problem_sending_friend_request: "Hi ha hagut un problema l'enviament d'una sol licitud d'amistat {{user}}. Torneu-ho de nou."
|
24
|
+
removed_friendship: "Esborrat relació amic"
|
25
|
+
same_inviter_error_message: "L'usuari no pot convertir-se en amics amb ell mateix."
|
26
|
+
sign_up_to_follow: "Subscriu-te a seguir"
|
27
|
+
start_following: "Després d'iniciar"
|
28
|
+
stop_being_friends: "Deixar de ser amics"
|
29
|
+
stop_following: "Després de deixar de"
|
30
|
+
view_all: "Veure tots"
|
31
|
+
you_are_now_following: "Ara està després {{user}}"
|
data/locales/cs.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
cs:
|
3
|
+
muck:
|
4
|
+
activity_templates:
|
5
|
+
follow: Následovníci
|
6
|
+
friends_with: Kamarádi
|
7
|
+
friends:
|
8
|
+
acccept_friend_request: "Přijměte přátelství"
|
9
|
+
accept: (přijmout)
|
10
|
+
delete: (smazat)
|
11
|
+
follow_activity: "{{inviter}} is now following {{invited}}"
|
12
|
+
following_you: "{{name}} is now following you on {{application_name}}"
|
13
|
+
friend_request: "Zaslat příteli"
|
14
|
+
friend_request_pending: "Přátelství čeká {{link}}"
|
15
|
+
friend_request_sent: "Zaslat příteli Posláno"
|
16
|
+
friends_title: "Moji kamarádi"
|
17
|
+
friends_with: "{{inviter}} is now friends with {{invited}}"
|
18
|
+
ignore: (ignorovat)
|
19
|
+
no_followers: "Nemusíte mít v současné době žádné následovníky"
|
20
|
+
no_friends: "Nemusíte mít v současné době žádné přátele"
|
21
|
+
not_following_anyone: "Ty v současné době nejsou tyto kdokoliv"
|
22
|
+
problem_adding_follow: "Došlo k problému {{user}} přidáte do svého seznamu následovat. Prosím, zkuste to znovu."
|
23
|
+
problem_sending_friend_request: "Došlo k problému při odesílání příteli žádost {{user}}. Prosím, zkuste to znovu."
|
24
|
+
removed_friendship: "Odstraněny příteli vztah"
|
25
|
+
same_inviter_error_message: "Uživatel se nemůže stát přítelem themself."
|
26
|
+
sign_up_to_follow: "Zaregistruj-až Následná"
|
27
|
+
start_following: "Start Po"
|
28
|
+
stop_being_friends: "Stop Být Přátelé"
|
29
|
+
stop_following: "Stop Po"
|
30
|
+
view_all: "Zobrazit vše"
|
31
|
+
you_are_now_following: "Ty jsou nyní tyto {{user}}"
|