lentil 0.9.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -6
  3. data/app/assets/javascripts/active_admin.js +11 -0
  4. data/app/assets/javascripts/active_admin.js.coffee +1 -0
  5. data/app/assets/javascripts/lentil/addfancybox.js +5 -4
  6. data/app/assets/javascripts/lentil/buttonhandler.js +8 -0
  7. data/app/assets/javascripts/lentil/imageerrors.js +2 -0
  8. data/app/assets/javascripts/lentil/images.js +0 -1
  9. data/app/assets/javascripts/lentil.js +3 -0
  10. data/app/assets/stylesheets/{active_admin.css.scss → active_admin.scss} +0 -0
  11. data/app/assets/stylesheets/admin/{moderation.css.scss → moderation.scss} +0 -0
  12. data/app/assets/stylesheets/lentil/breakpoint/sass/_components.scss +0 -0
  13. data/app/assets/stylesheets/lentil/breakpoint/sass/_config.scss +0 -0
  14. data/app/assets/stylesheets/lentil/breakpoint/sass/_framework.scss +0 -0
  15. data/app/assets/stylesheets/lentil/breakpoint/sass/_structure.scss +0 -0
  16. data/app/assets/stylesheets/lentil/breakpoint/sass/config.rb +0 -0
  17. data/app/assets/stylesheets/lentil/breakpoint/sass/style.scss +0 -0
  18. data/app/assets/stylesheets/lentil/{iframe.css.scss → iframe.scss} +0 -0
  19. data/app/assets/stylesheets/lentil/{image_animation.css.scss → image_animation.scss} +0 -0
  20. data/app/assets/stylesheets/lentil/{images.css.scss → images.scss} +0 -0
  21. data/app/assets/stylesheets/lentil/{thisorthat.css.scss → thisorthat.scss} +0 -0
  22. data/app/assets/stylesheets/{lentil.css.scss → lentil.scss} +2 -1
  23. data/app/controllers/lentil/application_controller.rb +6 -1
  24. data/app/controllers/lentil/images_controller.rb +1 -0
  25. data/app/controllers/lentil/photographers_controller.rb +2 -2
  26. data/app/controllers/lentil/thisorthat_controller.rb +2 -2
  27. data/app/models/lentil/admin_user.rb +0 -4
  28. data/app/models/lentil/battle.rb +0 -2
  29. data/app/models/lentil/flag.rb +0 -1
  30. data/app/models/lentil/image.rb +7 -7
  31. data/app/models/lentil/license.rb +0 -2
  32. data/app/models/lentil/licensing.rb +0 -1
  33. data/app/models/lentil/like_vote.rb +0 -1
  34. data/app/models/lentil/service.rb +0 -2
  35. data/app/models/lentil/tag.rb +6 -7
  36. data/app/models/lentil/tagging.rb +0 -2
  37. data/app/models/lentil/tagset.rb +0 -3
  38. data/app/models/lentil/tagset_assignment.rb +0 -2
  39. data/app/models/lentil/user.rb +0 -2
  40. data/app/views/lentil/images/_flagging_modal.html.erb +2 -2
  41. data/app/views/lentil/thisorthat/_battle_form.html.erb +6 -6
  42. data/lib/generators/lentil/install_generator.rb +33 -4
  43. data/lib/generators/lentil/templates/README.md +7 -11
  44. data/lib/generators/lentil/upgrade_v1_generator.rb +54 -0
  45. data/lib/lentil/admin/admin_user.rb +27 -17
  46. data/lib/lentil/admin/images.rb +30 -9
  47. data/lib/lentil/admin/tags.rb +4 -0
  48. data/lib/lentil/admin/tagsets.rb +16 -1
  49. data/lib/lentil/version.rb +1 -1
  50. data/lib/lentil.rb +5 -2
  51. data/test/dummy/README.rdoc +15 -248
  52. data/test/dummy/Rakefile +0 -1
  53. data/test/dummy/app/{mailers/.gitkeep → assets/images/.keep} +0 -0
  54. data/test/dummy/app/assets/javascripts/application.js +4 -6
  55. data/test/dummy/app/controllers/application_controller.rb +3 -1
  56. data/test/dummy/app/{models/.gitkeep → controllers/concerns/.keep} +0 -0
  57. data/test/dummy/app/{views/layouts/.gitkeep → mailers/.keep} +0 -0
  58. data/test/dummy/{lib/assets/.gitkeep → app/models/.keep} +0 -0
  59. data/test/dummy/{log/.gitkeep → app/models/concerns/.keep} +0 -0
  60. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  61. data/test/dummy/config/application.rb +9 -39
  62. data/test/dummy/config/boot.rb +4 -9
  63. data/test/dummy/config/database.yml +3 -1
  64. data/test/dummy/config/environment.rb +2 -2
  65. data/test/dummy/config/environments/development.rb +21 -17
  66. data/test/dummy/config/environments/production.rb +45 -33
  67. data/test/dummy/config/environments/test.rb +20 -12
  68. data/test/dummy/config/initializers/assets.rb +11 -0
  69. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  70. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  71. data/test/dummy/config/initializers/formtastic.rb +2 -0
  72. data/test/dummy/config/initializers/inflections.rb +6 -5
  73. data/test/dummy/config/initializers/mime_types.rb +0 -1
  74. data/test/dummy/config/initializers/session_store.rb +0 -5
  75. data/test/dummy/config/initializers/wrap_parameters.rb +6 -6
  76. data/test/dummy/config/locales/devise.en.yml +60 -0
  77. data/test/dummy/config/locales/en.yml +20 -2
  78. data/test/dummy/config/routes.rb +2 -2
  79. data/test/dummy/config/secrets.yml +22 -0
  80. data/test/dummy/db/schema.rb +120 -120
  81. data/test/dummy/db/seeds.rb +2 -1
  82. data/test/dummy/lib/assets/.keep +0 -0
  83. data/test/dummy/log/.keep +0 -0
  84. data/test/dummy/public/404.html +54 -13
  85. data/test/dummy/public/422.html +54 -13
  86. data/test/dummy/public/500.html +53 -12
  87. data/test/dummy/test/fixtures +1 -0
  88. data/test/functional/admin/flags_controller_test.rb +2 -2
  89. data/test/functional/admin/images_controller_test.rb +8 -8
  90. data/test/functional/admin/tags_controller_test.rb +2 -2
  91. data/test/functional/admin/tagsets_controller_test.rb +3 -3
  92. data/test/functional/admin/users_controller_test.rb +2 -2
  93. data/test/functional/lentil/flags_controller_test.rb +3 -2
  94. data/test/functional/lentil/images_controller_test.rb +14 -10
  95. data/test/functional/lentil/like_votes_controller_test.rb +3 -2
  96. data/test/functional/lentil/photographers_controller_test.rb +6 -2
  97. data/test/functional/lentil/thisorthat_controller_test.rb +5 -1
  98. data/test/integration/lentil/javascript/event_tracking_test.rb +3 -2
  99. data/test/integration/lentil/thisorthat_test.rb +1 -1
  100. data/test/test_helper.rb +30 -17
  101. data/test/unit/lentil/user_test.rb +1 -1
  102. data/test/vcr_cassettes/instagram_bad_image_check.yml +0 -0
  103. data/test/vcr_cassettes/instagram_by_tag.yml +0 -0
  104. data/test/vcr_cassettes/instagram_by_tag_damaged.yml +0 -0
  105. data/test/vcr_cassettes/instagram_good_image_check.yml +0 -0
  106. data/test/vcr_cassettes/instagram_image_harvest.yml +0 -0
  107. data/test/vcr_cassettes/instagram_image_id.yml +0 -0
  108. data/test/vcr_cassettes/instagram_oembed.yml +0 -0
  109. data/vendor/assets/javascripts/animatedimages/css/demo.css +177 -177
  110. data/vendor/assets/javascripts/animatedimages/css/fallback.css +0 -0
  111. data/vendor/assets/javascripts/animatedimages/css/style.css +0 -0
  112. data/vendor/assets/javascripts/animatedimages/images/bg.jpg +0 -0
  113. data/vendor/assets/javascripts/animatedimages/images/light.png +0 -0
  114. data/vendor/assets/javascripts/animatedimages/images/loading.gif +0 -0
  115. data/vendor/assets/javascripts/html5historyapi/README.md +0 -0
  116. data/vendor/assets/javascripts/html5historyapi/component.json +0 -0
  117. data/vendor/assets/javascripts/html5historyapi/history.iegte8.js +0 -0
  118. data/vendor/assets/javascripts/html5historyapi/history.iegte8.min.js +0 -0
  119. data/vendor/assets/javascripts/html5historyapi/history.js +0 -0
  120. data/vendor/assets/javascripts/html5historyapi/history.min.js +0 -0
  121. data/vendor/assets/javascripts/html5historyapi/readme.en.txt +0 -0
  122. data/vendor/assets/javascripts/html5historyapi/readme.ru.txt +0 -0
  123. data/vendor/assets/javascripts/infinitescroll/Readme.md +0 -0
  124. data/vendor/assets/javascripts/infinitescroll/ajax-loader.gif +0 -0
  125. data/vendor/assets/javascripts/infinitescroll/behaviors/cufon.js +0 -0
  126. data/vendor/assets/javascripts/infinitescroll/behaviors/local.js +0 -0
  127. data/vendor/assets/javascripts/infinitescroll/behaviors/manual-trigger.js +0 -0
  128. data/vendor/assets/javascripts/infinitescroll/behaviors/masonry-isotope.js +0 -0
  129. data/vendor/assets/javascripts/infinitescroll/behaviors/sausage.js +0 -0
  130. data/vendor/assets/javascripts/infinitescroll/jquery.infinitescroll.js +0 -0
  131. data/vendor/assets/javascripts/infinitescroll/package.json +0 -0
  132. data/vendor/assets/javascripts/infinitescroll/site/assets/anivers_regular.otf +0 -0
  133. data/vendor/assets/javascripts/infinitescroll/site/assets/buttons.psd +0 -0
  134. data/vendor/assets/javascripts/infinitescroll/site/assets/logo.psd +0 -0
  135. data/vendor/assets/javascripts/infinitescroll/site/assets/mobius-strip2.ai +0 -0
  136. data/vendor/assets/javascripts/infinitescroll/site/assets/pattern.psd +0 -0
  137. data/vendor/assets/javascripts/infinitescroll/site/assets/selector spots.psd +0 -0
  138. data/vendor/assets/javascripts/infinitescroll/site/assets/sites.psd +0 -0
  139. data/vendor/assets/javascripts/infinitescroll/site/buttons.png +0 -0
  140. data/vendor/assets/javascripts/infinitescroll/site/infinite-scroll-pattern.gif +0 -0
  141. data/vendor/assets/javascripts/infinitescroll/site/logo.jpg +0 -0
  142. data/vendor/assets/javascripts/infinitescroll/site/screens.jpg +0 -0
  143. data/vendor/assets/javascripts/infinitescroll/site/selectors.jpg +0 -0
  144. data/vendor/assets/javascripts/infinitescroll/test/debug.js +0 -0
  145. data/vendor/assets/javascripts/infinitescroll/test/index.html +0 -0
  146. data/vendor/assets/javascripts/infinitescroll/test/index2.html +0 -0
  147. data/vendor/assets/javascripts/infinitescroll/test/index3.html +0 -0
  148. data/vendor/assets/javascripts/infinitescroll/test/jquery-1.6.1.js +0 -0
  149. data/vendor/assets/javascripts/infinitescroll/test/mobile.html +0 -0
  150. data/vendor/assets/javascripts/infinitescroll/test/mobile2.json +0 -0
  151. data/vendor/assets/javascripts/infinitescroll/test/mobile3.json +0 -0
  152. data/vendor/assets/javascripts/infinitescroll/test/mobile4.json +0 -0
  153. data/vendor/assets/javascripts/infinitescroll/test/style.css +0 -0
  154. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/img/ajax-loader.gif +0 -0
  155. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/includes/admin.php +0 -0
  156. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/includes/options.php +0 -0
  157. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/includes/presets.php +0 -0
  158. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/includes/submit.php +0 -0
  159. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/infinite-scroll.php +0 -0
  160. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/js/admin/infinite-scoll.js +0 -0
  161. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/js/admin/infinite-scroll.dev.js +0 -0
  162. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/js/front-end/jquery.infinitescroll.js +0 -0
  163. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/languages/infinite-scroll.pot +0 -0
  164. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/license.html +0 -0
  165. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/readme.md +0 -0
  166. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/readme.txt +0 -0
  167. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/screenshot-1.png +0 -0
  168. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/screenshot-2.png +0 -0
  169. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/screenshot-3.png +0 -0
  170. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/templates/footer.php +0 -0
  171. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/templates/manage-presets.php +0 -0
  172. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/templates/options.php +0 -0
  173. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/templates/preset-prompt.php +0 -0
  174. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/templates/submit-prompt.php +0 -0
  175. data/vendor/assets/javascripts/infinitescroll/wordpress-plugin/templates/submit.php +0 -0
  176. data/vendor/assets/javascripts/touchswipe/README.md +0 -0
  177. data/vendor/assets/javascripts/touchswipe/jquery.touchSwipe.js +0 -0
  178. metadata +85 -96
  179. data/test/dummy/config/initializers/secret_token.rb +0 -7
  180. data/test/dummy/script/rails +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 994cb248addc6f13b611d5f1f68bdf59b2a20d4b
4
- data.tar.gz: e72f1f95f5dbc3b1908b434c9bc74fee25592218
3
+ metadata.gz: 06a5c5e336b477d67cbbcfb421f23a7232ff13c0
4
+ data.tar.gz: 8cade0283c5c3aaa9cbbd4854874b9c0622e5d3e
5
5
  SHA512:
6
- metadata.gz: 47e831d220c60cbea05e1dcf226e67fb87ddbe59e853bb922de012993935077cece7be132583e7c300178da0d55556bafe7c930b85eaf7444c8f75a9d26f2377
7
- data.tar.gz: 0dfd7d0cae8b0940e5c557f5348a32aaf9f2cbf7f45d767aed649d1d18f15941c3cd2eac350892e56233078040eee19e7c87c4efaac81a926dc7591b4e84b951
6
+ metadata.gz: 3801a2db27015adfab01a1de57e2d80ce79adca4c3e0218e83221e06fc77713823edfc07d5abd102c3c4ceea16c270ff8e3658da74551eda7a48d291185f53c2
7
+ data.tar.gz: 415e66078b508188a6c6e49716f50bf86b39435cc3bed86e57eb42b659bd9ff705145cc2a45beb583c1f5d8f28a070d0c085e4eda86e15d88dcb83fb13ac8b16
data/README.md CHANGED
@@ -17,16 +17,16 @@ Although we are using this gem in production, **this gem should be considered an
17
17
 
18
18
  ## Installation
19
19
 
20
- lentil has been tested under Ruby 1.9.3 through 2.2.0.
20
+ lentil has been tested under Ruby 2.2.x through 2.3.x.
21
21
 
22
- ### Create a new Rails app with Rails 3.2.x
22
+ ### Create a new Rails app with Rails 4.2.x
23
23
 
24
24
  ```sh
25
- gem install rails -v '~> 3.2'
26
- rails _3.2.22_ new your_app_name
25
+ gem install rails -v '~> 4.2.7'
26
+ rails _4.2.7.1_ new --skip-turbolinks your_app_name
27
27
  cd your_app_name
28
28
  ```
29
- > In the example above, `3.2.22` should be the version of Rails 3.x that is installed by the `gem` command.
29
+ > In the example above, `4.2.7.1` should be the version of Rails 4.x that is installed by the `gem` command.
30
30
 
31
31
  ### Add lentil and therubyracer (or another ExecJS runtime) to your Gemfile and run `bundle update`
32
32
 
@@ -187,7 +187,6 @@ bundle install
187
187
 
188
188
  ```sh
189
189
  RAILS_ENV=test bundle exec rake app:db:migrate
190
- RAILS_ENV=test bundle exec rake app:db:test:prepare
191
190
  ```
192
191
 
193
192
  - Run the tests
@@ -5,6 +5,17 @@
5
5
  $(document).ready(function() {
6
6
  var url;
7
7
 
8
+ // Fix subdirectory deployment nav links
9
+ // https://github.com/activeadmin/activeadmin/issues/101#issuecomment-244028956
10
+ $('#header li a').each(function() {
11
+ var current_location, href, location_prefix, url_suffix;
12
+ href = $(this).attr('href');
13
+ url_suffix = href.replace(/.*\/admin\//, '');
14
+ current_location = document.location.pathname;
15
+ location_prefix = current_location.replace(/admin\/?.*/, "admin/");
16
+ return $(this).attr('href', location_prefix + url_suffix);
17
+ });
18
+
8
19
  if (window.location.pathname.indexOf('/lentil_tagsets/new') > -1) {
9
20
  url = '../lentil_tags/tags_api';
10
21
  } else {
@@ -0,0 +1 @@
1
+ #= require active_admin/base
@@ -32,7 +32,7 @@ function listenforpopstate() {
32
32
  };
33
33
  }
34
34
 
35
- function pushimageurl() {
35
+ function pushimageurl(imageId) {
36
36
 
37
37
  // extract application root url
38
38
  var approot = FancyBoxCloseFunctionState.pathname.replace(/(photographers\/\d+|images|thisorthat\/battle|thisorthat\/battle_leaders)\/\D*\/?/, "");
@@ -104,8 +104,9 @@ function addfancybox() {
104
104
  window.history.pushState(null,null,FancyBoxCloseFunctionState.pathname);
105
105
  },
106
106
  beforeShow : function() {
107
- this.title = $(this.element).next(".text-overlay").html();
108
- imageId = $(this.element).parents("div").attr("id");
107
+ var imgContainer = $(this.element).closest("div.battle-image-tile, div.image-tile");
108
+ this.title = $(imgContainer).find(".text-overlay").html();
109
+ imageId = $(imgContainer).attr("id");
109
110
  $(".fancybox-wrap").attr('id', imageId);
110
111
  pushimageurl(imageId);
111
112
  },
@@ -129,7 +130,7 @@ function addfancybox() {
129
130
  // this is to check that the fancybox is really visible
130
131
  // afterClose is fired off on fancybox open -- a bug
131
132
  FancyBoxCloseFunctionState.fancyboxvisible = true;
132
- imageId = $(this.element).parents("div").attr("id");
133
+ imageId = $(this.element).closest("div.image-tile, div.battle-image-tile").attr("id");
133
134
 
134
135
  // check whether we're on the last image in the gallery
135
136
  // and whether there's more than one page of images
@@ -3,6 +3,7 @@ function buttonhandler() {
3
3
  $("body").on("click", ".like-btn, .flag-confirm", function(e) {
4
4
  button = $(this);
5
5
  imageId = $(".fancybox-wrap, .image-show").attr("id");
6
+
6
7
  if (!$(button).is(".already-clicked")) {
7
8
  url = $(button).attr("href");
8
9
  $.post(url, function() {
@@ -20,4 +21,11 @@ function buttonhandler() {
20
21
  }
21
22
  e.preventDefault();
22
23
  });
24
+
25
+ // Show flag modal
26
+ $("body").on("click", ".flag-btn", function (e) {
27
+ var imageId = $(".fancybox-wrap, .image-show").attr("id");
28
+ var modalId = "#myModal-" + imageId;
29
+ $(modalId).modal('show');
30
+ });
23
31
  }
@@ -1,4 +1,6 @@
1
1
  function addimageerrors() {
2
+ $("a[target=_blank]").attr("rel", "noopener noreferrer");
3
+
2
4
  $(".instagram-img, .battle-img, .fancybox-img, .fancybox-video").off("error").on("error", function () {
3
5
  $(this).parents("div.image-tile, li.image-animate-tile").remove();
4
6
  });
@@ -4,7 +4,6 @@
4
4
  //= require fancybox
5
5
  //= require lentil/addfancybox
6
6
  //= require infinitescroll/jquery.infinitescroll
7
- //= require bootstrap
8
7
  //= require lentil/addinfinitescroll
9
8
  //= require lentil/imageerrors
10
9
  //= require lentil/addanimatedimages
@@ -1,3 +1,6 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require bootstrap
1
4
  //= require lentil/images
2
5
  //= require lentil/thisorthat
3
6
  //= require lentil/event_tracking
@@ -1,6 +1,7 @@
1
1
  @import "bootstrap";
2
2
  @import "bootstrap-responsive";
3
- @import "fancybox";
3
+ @import "jquery.fancybox";
4
+ @import "jquery.fancybox-buttons";
4
5
 
5
6
  @import "select2";
6
7
  @import "lentil/images";
@@ -2,5 +2,10 @@ module Lentil
2
2
  class ApplicationController < ActionController::Base
3
3
  # FIXME: I don't know why the engine isn't using its own application layout like it is supposed to.
4
4
  layout "lentil/application"
5
+
6
+ private
7
+ def allow_iframe
8
+ response.headers.delete "X-Frame-Options"
9
+ end
5
10
  end
6
- end
11
+ end
@@ -1,6 +1,7 @@
1
1
  module Lentil
2
2
  class ImagesController < Lentil::ApplicationController
3
3
  include ActionView::Helpers::TextHelper
4
+ after_filter :allow_iframe, only: [:iframe]
4
5
 
5
6
  def index
6
7
  respond_to do |format|
@@ -12,9 +12,9 @@ module Lentil
12
12
  if @images.empty?
13
13
  head :internal_server_error
14
14
  else
15
- @photographer = @images.find(:first).user
15
+ @photographer = @images.first!.user
16
16
  @title = @photographer.user_name + " - Photographers"
17
17
  end
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -25,7 +25,7 @@ module Lentil
25
25
  end
26
26
 
27
27
  def get_images
28
- images = Image.approved.random(20).sort_by{|i| i.battles_count}
28
+ images = Image.approved.order_by_rand.limit(20).sort_by{|i| i.battles_count}
29
29
  images = test_urls(images, 2).sort_by{ |i| i.id }
30
30
 
31
31
  session[:battle_images] = []
@@ -116,4 +116,4 @@ module Lentil
116
116
  end
117
117
  end
118
118
  end
119
- end
119
+ end
@@ -24,9 +24,5 @@ class Lentil::AdminUser < ActiveRecord::Base
24
24
  devise :database_authenticatable,
25
25
  :recoverable, :rememberable, :trackable, :validatable
26
26
 
27
- # Setup accessible (or protected) attributes for your model
28
- attr_accessible :email, :password, :password_confirmation, :remember_me
29
- # attr_accessible :title, :body
30
-
31
27
  has_many :moderated_images, :class_name => Lentil::Image, :foreign_key => :moderator_id
32
28
  end
@@ -10,8 +10,6 @@
10
10
  #
11
11
 
12
12
  class Lentil::Battle < ActiveRecord::Base
13
- attr_accessible :image_id, :loser_id, :loser
14
-
15
13
  belongs_to :image, :counter_cache => :wins_count, :autosave => true
16
14
  belongs_to :loser, :class_name => "Image", :counter_cache => :losses_count, :autosave => true
17
15
 
@@ -10,5 +10,4 @@
10
10
 
11
11
  class Lentil::Flag < ActiveRecord::Base
12
12
  belongs_to :image
13
- attr_accessible :image
14
13
  end
@@ -33,11 +33,6 @@
33
33
  #
34
34
 
35
35
  class Lentil::Image < ActiveRecord::Base
36
- attr_accessible :description, :title, :user_id, :state, :staff_like, :url, :long_url, :external_identifier,
37
- :original_datetime, :popular_score, :taggings, :tag_id, :moderator, :moderated_at, :second_moderation,
38
- :do_not_request_donation, :donor_agreement_rejected, :media_type, :video_url, :suppressed
39
-
40
- attr_protected :original_metadata
41
36
  stores_emoji_characters :description
42
37
 
43
38
  has_many :won_battles, :class_name => "Battle"
@@ -59,7 +54,7 @@ class Lentil::Image < ActiveRecord::Base
59
54
 
60
55
  belongs_to :moderator, :class_name => Lentil::AdminUser
61
56
 
62
- default_scope where("failed_file_checks < 3")
57
+ default_scope { where("failed_file_checks < 3") }
63
58
 
64
59
  validates_uniqueness_of :external_identifier, :scope => :user_id
65
60
  validates :url, :format => URI::regexp(%w(http https))
@@ -192,6 +187,11 @@ class Lentil::Image < ActiveRecord::Base
192
187
  end
193
188
 
194
189
  def original_metadata=(meta)
195
- write_attribute(:original_metadata, meta.to_hash)
190
+ write_attribute(:original_metadata, Oj.load(Emojimmy.emoji_to_token(meta.to_hash.to_json)))
191
+ end
192
+
193
+ def original_metadata
194
+ Oj.load(Emojimmy.token_to_emoji(super.to_json))
196
195
  end
196
+
197
197
  end
@@ -12,8 +12,6 @@
12
12
  #
13
13
 
14
14
  class Lentil::License < ActiveRecord::Base
15
- attr_accessible :description, :short_name, :name, :url
16
-
17
15
  has_many :licensings
18
16
  has_many :images, :through=>:licensings
19
17
 
@@ -12,5 +12,4 @@
12
12
  class Lentil::Licensing < ActiveRecord::Base
13
13
  belongs_to :image
14
14
  belongs_to :license
15
- # attr_accessible :title, :body
16
15
  end
@@ -10,5 +10,4 @@
10
10
 
11
11
  class Lentil::LikeVote < ActiveRecord::Base
12
12
  belongs_to :image, counter_cache: true
13
- attr_accessible :image
14
13
  end
@@ -10,8 +10,6 @@
10
10
  #
11
11
 
12
12
  class Lentil::Service < ActiveRecord::Base
13
- attr_accessible :name, :url
14
-
15
13
  has_many :users
16
14
  has_many :images, :through => :users
17
15
  end
@@ -9,20 +9,19 @@
9
9
  #
10
10
 
11
11
  class Lentil::Tag < ActiveRecord::Base
12
- attr_accessible :name, :staff_tag
13
-
14
12
  stores_emoji_characters :name
13
+
15
14
  has_many :tagset_assignments
16
- has_many :tagsets, :through=>:tagset_assignments
15
+ has_many :tagsets, :through => :tagset_assignments
17
16
 
18
17
  has_many :taggings
19
- has_many :images, :through=>:taggings
18
+ has_many :images, :through => :taggings
20
19
 
21
20
  validates_presence_of :name
22
21
 
23
- scope :harvestable, where(:lentil_tagsets => {:harvest => true}).includes(:tagsets)
24
- scope :not_harvestable, where(:lentil_tagsets => {:harvest => false}).includes(:tagsets)
25
- scope :no_tagsets, where(:lentil_tagset_assignments => {:tag_id => nil}).includes(:tagset_assignments)
22
+ scope :harvestable, -> {where(:lentil_tagsets => {:harvest => true}).includes(:tagsets)}
23
+ scope :not_harvestable, -> {where(:lentil_tagsets => {:harvest => false}).includes(:tagsets)}
24
+ scope :no_tagsets, -> {where(:lentil_tagset_assignments => {:tag_id => nil}).includes(:tagset_assignments)}
26
25
 
27
26
  #Stripping tags on write
28
27
  def name=(new_name)
@@ -14,7 +14,5 @@ class Lentil::Tagging < ActiveRecord::Base
14
14
  belongs_to :image
15
15
  belongs_to :tag
16
16
 
17
- attr_accessible :tag, :staff_tag, :tag_id
18
-
19
17
  validates :image_id, :uniqueness => {:scope => :tag_id}
20
18
  end
@@ -11,9 +11,6 @@
11
11
  #
12
12
 
13
13
  class Lentil::Tagset < ActiveRecord::Base
14
- attr_accessible :description, :title, :harvest, :tag_ids
15
-
16
- attr_accessor :remove_tagset
17
14
 
18
15
  has_many :tagset_assignments, :dependent => :destroy
19
16
  has_many :tags, :through => :tagset_assignments
@@ -10,8 +10,6 @@
10
10
  #
11
11
 
12
12
  class Lentil::TagsetAssignment < ActiveRecord::Base
13
- attr_accessible :tag_id, :tagset_id
14
-
15
13
  belongs_to :tag
16
14
  belongs_to :tagset
17
15
  end
@@ -14,8 +14,6 @@
14
14
  #
15
15
 
16
16
  class Lentil::User < ActiveRecord::Base
17
- attr_accessible :banned, :full_name, :user_name, :bio
18
-
19
17
  stores_emoji_characters :full_name, :bio
20
18
 
21
19
  has_many :images
@@ -1,5 +1,5 @@
1
1
  <!-- Flagging Modal -->
2
- <div id="myModal-<%= image.id %>" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
2
+ <div id="myModal-image_<%= image.id %>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
3
3
  <div class="modal-header">
4
4
  <h3 id="myModalLabel"><%= t 'lentil.flagging_modal.header' %></h3>
5
5
  </div>
@@ -11,4 +11,4 @@
11
11
  <button href="<%= tally_flag_path(image.id) %>" method="post" type="submit" class="btn btn-danger flag-confirm" data-image-id="<%= image.id %>">
12
12
  <%= t 'lentil.flagging_modal.yes_report_title' %></button>
13
13
  </div>
14
- </div>
14
+ </div>
@@ -14,9 +14,9 @@
14
14
  <% end %>
15
15
  </a>
16
16
  </div>
17
- <div class="battle-image-desc trunc-small"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 35) %></div></div>
18
- <div class="battle-image-desc trunc-medium"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 50) %></div></div>
19
- <div class="battle-image-desc trunc-large"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 70) %></div></div>
17
+ <div class="battle-image-desc trunc-small"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 22) %></div></div>
18
+ <div class="battle-image-desc trunc-medium"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 35) %></div></div>
19
+ <div class="battle-image-desc trunc-large"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 45) %></div></div>
20
20
  <%= render "/layouts/lentil/image_popup", :image => image %>
21
21
  <%= f.input :id, :as => :hidden %>
22
22
 
@@ -41,9 +41,9 @@
41
41
  <% end %>
42
42
  </a>
43
43
  </div>
44
- <div class="battle-image-desc trunc-small"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 35) %></div></div>
45
- <div class="battle-image-desc trunc-medium"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 50) %></div></div>
46
- <div class="battle-image-desc trunc-large"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 70) %></div></div>
44
+ <div class="battle-image-desc trunc-small"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 22) %></div></div>
45
+ <div class="battle-image-desc trunc-medium"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 35) %></div></div>
46
+ <div class="battle-image-desc trunc-large"><div class="battle-image-inner-desc"><%= truncate(image.description, :length => 45) %></div></div>
47
47
  </a>
48
48
  <%= render "/layouts/lentil/image_popup", :image => image %>
49
49
  </div>
@@ -13,9 +13,31 @@ module Lentil
13
13
  insert_into_file "config/application.rb", "\n # Inserted by lentil\n # End of lentil changes\n\n", :after => "class Application < Rails::Application\n"
14
14
  end
15
15
 
16
+ desc "Remove test/performance/browsing_test.rb"
17
+ def remove_test_performance_browsing_test
18
+ remove_file("test/performance/browsing_test.rb")
19
+ end
20
+
21
+ desc "Remove gems"
22
+ def lentil_remove_gems
23
+ gsub_file "Gemfile", /^.*rails-perftest.*$/, ""
24
+ gsub_file "Gemfile", /^.*ruby-prof.*$/, ""
25
+ gsub_file "Gemfile", /^.*ruby-prof.*$/, ""
26
+ end
27
+
28
+ desc "Enable raise_in_transactions_callbacks"
29
+ def enable_raise_trans_cb
30
+ insert_into_file "config/application.rb", " config.active_record.raise_in_transactional_callbacks = true", :after => "# Inserted by lentil\n"
31
+ end
32
+
33
+ desc "Randomize tests"
34
+ def randomize_tests
35
+ insert_into_file "config/environments/test.rb", " config.active_support.test_order = :random", :before => "end"
36
+ end
37
+
16
38
  desc 'precompile additional assets'
17
39
  def precompile_assets
18
- insert_into_file "config/application.rb", " config.assets.precompile += %w( lentil/iframe.js lentil/iframe.css addanimatedimages.js animatedimages/css/style.css )\n", :after => "# Inserted by lentil\n"
40
+ append_to_file "config/initializers/assets.rb", "Rails.application.config.assets.precompile += %w( *.js ^[^_]*.css *.css.erb lentil/iframe.js lentil/iframe.css addanimatedimages.js animatedimages/css/style.css )\n"
19
41
  end
20
42
 
21
43
  desc 'do not enforce available locales'
@@ -50,12 +72,12 @@ module Lentil
50
72
  routes = <<-ROUTES
51
73
 
52
74
  root :to => 'lentil/images#index'
53
- ActiveAdmin.routes(self)
54
75
  devise_for :admin_users, ActiveAdmin::Devise.config.merge(:class_name => 'Lentil::AdminUser')
76
+ ActiveAdmin.routes(self)
55
77
  mount Lentil::Engine => "/"
56
78
 
57
79
  ROUTES
58
- insert_into_file "config/routes.rb", routes, :after => "Application.routes.draw do\n"
80
+ insert_into_file "config/routes.rb", routes, :after => "Rails.application.routes.draw do\n"
59
81
  end
60
82
 
61
83
  desc 'create application configuration file'
@@ -76,7 +98,14 @@ ROUTES
76
98
 
77
99
  desc 'add javascript'
78
100
  def add_javascript
79
- gsub_file('app/assets/javascripts/application.js', '//= require_tree .', '//= require lentil')
101
+ gsub_file('app/assets/javascripts/application.js', '//= require_tree .',
102
+ '//= require lentil')
103
+ end
104
+
105
+ desc 'disable turbolinks'
106
+ def disable_turbolinks
107
+ gsub_file "app/assets/javascripts/application.js", "//= require turbolinks", ""
108
+ gsub_file "Gemfile", /^.*turbolinks.*$/, ""
80
109
  end
81
110
 
82
111
  desc 'add a dummy admin user to the development database?'
@@ -4,22 +4,18 @@
4
4
 
5
5
  You will need to make the following changes:
6
6
 
7
- 1. If you haven't already, create an administrative user in development. See the project README.md.
7
+ 1. Re-run `bundle update`.
8
8
 
9
- 2. You may need to configure config/initializers/devise.rb
9
+ 2. If you haven't already, create an administrative user in development. See the project README.md.
10
10
 
11
- 3. From the Devise documentation: "Ensure you have defined default url options in your environments files. Here is an example of default_url_options appropriate for a development environment in config/environments/development.rb:
11
+ 3. You may need to configure config/initializers/devise.rb
12
+
13
+ 4. From the Devise documentation: "Ensure you have defined default url options in your environments files. Here is an example of default_url_options appropriate for a development environment in config/environments/development.rb:
12
14
 
13
15
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
14
16
 
15
17
  In production, :host should be set to the actual host of your application."
16
18
 
17
- 3. Update that config/lentil_config.yml with your information. It is probably a good idea to add that file to your .gitignore too. You'll definitely want to change your instagram values and the default_image_search_tag.
18
-
19
- 4. Look at the README.md for how to begin harvesting images and customizing your application.
20
-
21
- 5. Enjoy!
22
-
23
-
24
-
19
+ 5. Update that config/lentil_config.yml with your information. It is probably a good idea to add that file to your .gitignore too. You'll definitely want to change your instagram values and the default_image_search_tag.
25
20
 
21
+ 6. Look at the README.md for how to begin harvesting images and customizing your application.
@@ -0,0 +1,54 @@
1
+ module Lentil
2
+ module Generators
3
+ class UpgradeV1Generator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ desc "Remove test/performance/browsing_test.rb"
7
+ def remove_test_performance_browsing_test
8
+ remove_file("test/performance/browsing_test.rb")
9
+ end
10
+
11
+ desc "Update gems"
12
+ def lentil_update_gems
13
+ gsub_file "Gemfile", /^.*sass-rails.*$/, "gem 'sass-rails'"
14
+ gsub_file "Gemfile", /^.*coffee-rails.*$/, "gem 'coffee-rails'"
15
+ end
16
+
17
+ desc "Remove gems"
18
+ def lentil_remove_gems
19
+ gsub_file "Gemfile", /^.*rails-perftest.*$/, ""
20
+ gsub_file "Gemfile", /^.*ruby-prof.*$/, ""
21
+ end
22
+
23
+ desc "Enable raise_in_transactions_callbacks"
24
+ def enable_raise_trans_cb
25
+ insert_into_file "config/application.rb", " config.active_record.raise_in_transactional_callbacks = true", :after => "# Inserted by lentil\n"
26
+ end
27
+
28
+ desc "Randomize tests"
29
+ def randomize_tests
30
+ insert_into_file "config/environments/test.rb", " config.active_support.test_order = :random", :before => "end"
31
+ end
32
+
33
+ desc "Update precompilation paths"
34
+ def update_precompilation_paths
35
+ gsub_file "config/application.rb", /^.*Rails.application.config.assets.precompile.*$/, ""
36
+ append_to_file "config/initializers/assets.rb", "Rails.application.config.assets.precompile += %w( *.js ^[^_]*.css *.css.erb lentil/iframe.js lentil/iframe.css addanimatedimages.js animatedimages/css/style.css )\n"
37
+ end
38
+
39
+ desc 'insert routes'
40
+ def insert_routes
41
+ routes = <<-ROUTES
42
+
43
+ root :to => 'lentil/images#index'
44
+ devise_for :admin_users, ActiveAdmin::Devise.config.merge(:class_name => 'Lentil::AdminUser')
45
+ ActiveAdmin.routes(self)
46
+ mount Lentil::Engine => "/"
47
+
48
+ ROUTES
49
+ insert_into_file "config/routes.rb", routes, :after => "Rails.application.routes.draw do\n"
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -1,24 +1,34 @@
1
1
  if defined?(ActiveAdmin)
2
2
  ActiveAdmin.register Lentil::AdminUser do
3
- config.batch_actions = false
3
+ permit_params :email, :password, :password_confirmation
4
4
 
5
- index do
6
- column :email
7
- column :current_sign_in_at
8
- column :last_sign_in_at
9
- column :sign_in_count
10
- default_actions
11
- end
5
+ index do
6
+ selectable_column
7
+ id_column
8
+ column :email
9
+ column :current_sign_in_at
10
+ column :sign_in_count
11
+ column :created_at
12
+ actions
13
+ end
12
14
 
13
- filter :email
15
+ filter :email
16
+ filter :current_sign_in_at
17
+ filter :sign_in_count
18
+ filter :created_at
14
19
 
15
- form do |f|
16
- f.inputs "Admin Details" do
17
- f.input :email
18
- f.input :password
19
- f.input :password_confirmation
20
- end
21
- f.buttons
20
+ controller do
21
+ resources_configuration[:self][:instance_name] = 'admin_user'
22
+ end
23
+
24
+ form do |f|
25
+ f.inputs "Admin Details" do
26
+ f.input :email
27
+ f.input :password
28
+ f.input :password_confirmation
22
29
  end
30
+ f.actions
23
31
  end
24
- end
32
+
33
+ end
34
+ end