tkh_mailing_list 0.10 → 0.10.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2caf6bc1d6e75f3b4453e161d2e457e1e2f5f650
4
- data.tar.gz: ed54427b977379f9841f9998c1c7590eb98fcf5b
3
+ metadata.gz: 104c30052016f291682421644430d9fee2494c6e
4
+ data.tar.gz: f6274f06be8db3e74ecbeda8c9a895bafb4821f9
5
5
  SHA512:
6
- metadata.gz: 5cc9b34dd1067c20b7a520d6abbbc4c3889b8cb739876904bcc6c762c888008ccfaed9b1c61449229cb10ab9b7d83df3255486767b16bd40cfa773c693e4d9d6
7
- data.tar.gz: 2b7e4afc6d5cdfe4dc0f3af22538d1815e97367b701022ba894196dad01f2ae91fe42ebde145e736548f858eafccd59c85fa0cc74d46b0bb988cc1b0aaa3b5c9
6
+ metadata.gz: 36c0f9beca6534bd765b8aeff82b82ceffb26a1b00bb4800cd3e64287fd82d5f87082ea46fba91561d068f265bfb29ee69b7766911999b2a08ed6a1d812c264a
7
+ data.tar.gz: 31b1ccf7b3cefb0c4545f2e6a13f45a7e5f15c6596f8fffb501a51c60fc2f5dca687d55412ebc1e4b08813e8f33ed812447618cbe15d3e0285018d06fc314c77
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
 
4
4
 
5
+ ## 0.10.1
6
+
7
+ * Private profile viewing and editing
8
+ * Public profile view
9
+ * User can add portrait photo to their profile and crop it on the fly
10
+
11
+
5
12
  ## 0.10
6
13
 
7
14
  * Added a member resource for admins to update user records. Users are scoped as members.
@@ -0,0 +1,24 @@
1
+ jQuery ->
2
+ new PortraitCropper()
3
+
4
+ class PortraitCropper
5
+ constructor: ->
6
+ $('#cropbox').Jcrop
7
+ aspectRatio: 1
8
+ setSelect: [50, 50, 300, 300]
9
+ onSelect: @update
10
+ onChange: @update
11
+
12
+ update: (coords) =>
13
+ $('#profile_crop_x').val(coords.x)
14
+ $('#profile_crop_y').val(coords.y)
15
+ $('#profile_crop_w').val(coords.w)
16
+ $('#profile_crop_h').val(coords.h)
17
+ @updatePreview(coords)
18
+
19
+ updatePreview: (coords) =>
20
+ $('#preview').css
21
+ width: Math.round(100/coords.w * $('#cropbox').width()) + 'px'
22
+ height: Math.round(100/coords.h * $('#cropbox').height()) + 'px'
23
+ marginLeft: '-' + Math.round(100/coords.w * coords.x) + 'px'
24
+ marginTop: '-' + Math.round(100/coords.h * coords.y) + 'px'
@@ -56,7 +56,7 @@ class MembersController < ApplicationController
56
56
 
57
57
  # Never trust parameters from the scary internet, only allow the white list through.
58
58
  def member_params
59
- params.require(:member).permit( :email, :first_name, :last_name, :other_name, :teacher_status )
59
+ params.require(:member).permit :email, :first_name, :last_name, :other_name, :teacher_status, :portrait, :website_url, :facebook_url, :twitter_handle, :google_plus_url, :allow_newsletter, :allow_daily_digests
60
60
  end
61
61
 
62
62
  end
@@ -12,7 +12,11 @@ class ProfilesController < ApplicationController
12
12
 
13
13
  def update
14
14
  if @profile.update_attributes(profile_params)
15
- redirect_to profile_path, notice: "<strong>Success!</strong> Your profile was updated.".html_safe
15
+ if params[:profile][:portrait].present?
16
+ render :crop ## Render the view for cropping
17
+ else
18
+ redirect_to profile_path, notice: "<strong><span class=\"glyphicon glyphicon-ok-sign\"></span>&nbsp;&nbsp;Success!</strong> Your profile was updated.".html_safe
19
+ end
16
20
  else
17
21
  render action: "edit", warning: "<strong>Attention!</strong> A problem occurred while trying to update your profile. Plese try again".html_safe
18
22
  end
@@ -31,7 +35,7 @@ class ProfilesController < ApplicationController
31
35
 
32
36
  # Never trust parameters from the scary internet, only allow the white list through.
33
37
  def profile_params
34
- params.require(:profile).permit( :first_name, :last_name, :other_name )
38
+ params.require(:profile).permit :email, :first_name, :last_name, :other_name, :teacher_status, :portrait, :website_url, :facebook_url, :twitter_handle, :google_plus_url, :allow_newsletter, :allow_daily_digests, :crop_x, :crop_y, :crop_w, :crop_h
35
39
  end
36
40
 
37
41
  end
@@ -1,3 +1,14 @@
1
1
  class Profile < User
2
2
 
3
+ mount_uploader :portrait, PortraitUploader
4
+ # crop_uploaded :portrait
5
+
6
+ attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
7
+
8
+ after_update :crop_portrait
9
+
10
+ def crop_portrait
11
+ portrait.recreate_versions! if crop_x.present?
12
+ end
13
+
3
14
  end
@@ -0,0 +1,60 @@
1
+ class PortraitUploader < CarrierWave::Uploader::Base
2
+
3
+ include CarrierWave::RMagick
4
+ storage :file
5
+ def store_dir
6
+ # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" --- that was the suggested one
7
+ "system/portraits/#{model.class.to_s.underscore}/#{model.id}"
8
+ end
9
+
10
+ # this is used by jcrop as a source photo
11
+ # better not modify this code.
12
+ version :xl do
13
+ process resize_to_limit: [550, 550]
14
+ end
15
+ # these 4 vorsions are cropped square by the user
16
+ version :thumbnail do
17
+ process :crop
18
+ resize_to_fill(125,125)
19
+ end
20
+ version :small do
21
+ process :crop
22
+ resize_to_fill(225, 225)
23
+ end
24
+ version :medium do
25
+ process :crop
26
+ resize_to_fill(350, 350)
27
+ end
28
+ version :large do
29
+ process :crop
30
+ resize_to_fill(450, 450)
31
+ end
32
+ # version(:xxl) { process :resize_to_limit => [900, 900] }
33
+
34
+ def crop
35
+ if model.crop_x.present?
36
+ resize_to_limit(550, 550)
37
+ manipulate! do |img|
38
+ x = model.crop_x.to_i
39
+ y = model.crop_y.to_i
40
+ w = model.crop_w.to_i
41
+ h = model.crop_h.to_i
42
+ img.crop!(x, y, w, h)
43
+ end
44
+ end
45
+ end
46
+
47
+ # Add a white list of extensions which are allowed to be uploaded.
48
+ # For images you might use something like this:
49
+ def extension_white_list
50
+ %w(jpg jpeg png)
51
+ end
52
+
53
+ # got this from http://stackoverflow.com/questions/9561641/carrierwave-temp-directory-set-to-uploads-tmp-folder
54
+ # without this all tmp files would go to /public/uploads/tmp which is not cool at all.
55
+ def cache_dir
56
+ # should return path to cache dir
57
+ Rails.root.join 'tmp/uploads'
58
+ end
59
+
60
+ end
@@ -1,10 +1,19 @@
1
- <%= simple_form_for @member do |f| %>
1
+ <%= simple_form_for @member, :html => { multipart: true } do |f| %>
2
2
  <%= f.error_notification %>
3
3
 
4
+ <h2>Private Fields</h2>
5
+ <%= f.input :email, label: t('activerecord.attributes.users.email'), hint: 'change with caution!!!! the email is used to login.' %>
6
+ <%= f.input :allow_newsletter %>
7
+ <%= f.input :allow_daily_digests %>
8
+
9
+ <h2>Public Fields</h2>
4
10
  <%= f.input :first_name, label: t('activerecord.attributes.users.first_name') %>
5
11
  <%= f.input :last_name, label: t('activerecord.attributes.users.last_name') %>
6
12
  <%= f.input :other_name, label: t('activerecord.attributes.users.other_name'), hint: 'nickname, spiritual name, etc.' %>
7
- <%= f.input :email, label: t('activerecord.attributes.users.email'), hint: 'change with caution!!!! the email is used to login.' %>
13
+ <%= f.input :website_url %>
14
+ <%= f.input :facebook_url %>
15
+ <%= f.input :twitter_handle %>
16
+ <%= f.input :google_plus_url, label: "Google+ url" %>
8
17
 
9
18
  <%= f.button :submit, :class => 'btn btn-primary' %>
10
19
  <% end %>
@@ -10,10 +10,17 @@
10
10
  <% else %>
11
11
  <h1><%= student.name %></h1>
12
12
  <% end %>
13
+ <% if Profile.find(@member.id).portrait.present? %>
14
+ <p id="profile-portrait"><%= image_tag Profile.find(@member.id).portrait_url(:small), title: student.name, alt: student.name, id: 'profile-portrait' %></p>
15
+ <% end %>
13
16
  </div>
14
17
 
15
18
  <table id="profile-attributes">
16
19
  <tbody>
20
+ <tr><td class="key">website</td><td class="value"><%= link_to student.website_url, student.website_url %></td></tr>
21
+ <tr><td class="key">facebook</td><td class="value"><%= link_to student.facebook_url, student.facebook_url %></td></tr>
22
+ <tr><td class="key">twitter</td><td class="value"><%= link_to student.twitter_handle, "https://twitter.com/#{student.twitter_handle}" %></td></tr>
23
+ <tr><td class="key">google+</td><td class="value"><%= link_to student.google_plus_url, student.google_plus_url %></td></tr>
17
24
  <%= render 'profiles/custom_public_profile_attributes' %>
18
25
  </tbody>
19
26
  </table>
@@ -0,0 +1,21 @@
1
+ <% content_for :meta_title, "Crop your profile portrait" %>
2
+ <% content_for :meta_description, "Exact cropping of the profile portrait picture." %>
3
+
4
+ <h1>Crop Portrait Photo</h1>
5
+
6
+ <%= form_for @profile, url: profile_path, method: :patch do |f| %>
7
+ <% %w[x y w h].each do |attribute| %>
8
+ <%= f.hidden_field "crop_#{attribute}" %>
9
+ <% end %>
10
+ <%= f.submit "Crop" %>
11
+ <% end %>
12
+ &nbsp;&nbsp;&nbsp;
13
+ <div style="width:100px; height:100px; overflow:hidden; display: inline-block; margin-bottom: -8px;">
14
+ <%= image_tag @profile.portrait.url(:xl), id: "preview" %>
15
+ </div>
16
+
17
+ <br /><br />
18
+
19
+ <%= image_tag @profile.portrait_url(:xl), id: "cropbox" %>
20
+
21
+
@@ -6,11 +6,20 @@
6
6
  <%= simple_form_for @profile, url: profile_path do |f| %>
7
7
  <%= f.error_notification %>
8
8
 
9
+ <h1>Private Information</h1>
9
10
  <p>Email: <strong><%= @profile.email %></strong>. Unfortunately, you cannot yet change your email address. This feature is coming soon.</p>
11
+ <%= f.input :allow_newsletter, label: "Allow rare newsletter?&nbsp;&nbsp;".html_safe, hint: 'never more than once a month' %>
12
+ <%= f.input :allow_daily_digests, label: "Allow daily activity digests?&nbsp;&nbsp;".html_safe, hint: "replies to your comments, etc." %>
10
13
 
14
+ <h1>Public Information</h1>
11
15
  <%= f.input :first_name, label: t('activerecord.attributes.users.first_name') %>
12
16
  <%= f.input :last_name, label: t('activerecord.attributes.users.last_name') %>
13
17
  <%= f.input :other_name, label: render( 'shared/other_name_label') %>
18
+ <%= f.input :portrait %>
19
+ <%= f.input :website_url %>
20
+ <%= f.input :facebook_url %>
21
+ <%= f.input :twitter_handle %>
22
+ <%= f.input :google_plus_url, label: "Google+ url" %>
14
23
 
15
24
  <%= f.button :submit, :class => 'btn btn-primary' %>
16
25
  <% end %>
@@ -12,18 +12,35 @@
12
12
  <% else %>
13
13
  <h1><%= @profile.name %></h1>
14
14
  <% end %>
15
+ <% if @profile.portrait.present? %>
16
+ <p id="profile-portrait"><%= image_tag @profile.portrait_url(:small), title: @profile.name, alt: @profile.name, id: 'profile-portrait' %></p>
17
+ <% end %>
15
18
  </div>
16
19
 
17
20
  <table id="profile-attributes">
18
21
  <tbody>
22
+
19
23
  <tr><td class="section" colspan="2"><span class="label label-danger">private information</span></td></tr>
20
24
  <tr><td class="key"><span class="glyphicon glyphicon-envelope"></span> email address</td><td class="value"><%= @profile.email %></td></tr>
25
+ <tr><td class="key">get rare newsletter</td>
26
+ <td class="value"><%= @profile.allow_newsletter == true ? "<span class=\"glyphicon glyphicon-ok\"".html_safe : "<span class=\"glyphicon glyphicon-remove\"".html_safe %></td>
27
+ </tr>
28
+ <tr>
29
+ <td class="key">get your daily activity digests</td>
30
+ <td class="value"><%= @profile.allow_daily_digests == true ? "<span class=\"glyphicon glyphicon-ok\"".html_safe : "<span class=\"glyphicon glyphicon-remove\"".html_safe %></td>
31
+ </tr>
21
32
  <%= render 'custom_private_profile_attributes' %>
33
+
22
34
  <tr><td class="section" colspan="2"><span class="label label-success">public information</span></td></tr>
23
35
  <tr><td class="key">first name</td><td class="value"><%= @profile.first_name %></td></tr>
24
36
  <tr><td class="key">last name</td><td class="value"><%= @profile.last_name %></td></tr>
25
37
  <tr><td class="key"><%= render 'shared/other_name_label' %></td><td class="value"><%= @profile.other_name %></td></tr>
38
+ <tr><td class="key">website</td><td class="value"><%= link_to student.website_url, student.website_url %></td></tr>
39
+ <tr><td class="key">facebook</td><td class="value"><%= link_to student.facebook_url, student.facebook_url %></td></tr>
40
+ <tr><td class="key">twitter</td><td class="value"><%= link_to student.twitter_handle, "https://twitter.com/#{student.twitter_handle}" %></td></tr>
41
+ <tr><td class="key">google+</td><td class="value"><%= link_to student.google_plus_url, student.google_plus_url %></td></tr>
26
42
  <%= render 'custom_public_profile_attributes' %>
43
+
27
44
  </tbody>
28
45
  </table>
29
46
 
@@ -18,6 +18,7 @@ module TkhMailingList
18
18
  def copy_migrations
19
19
  puts 'creating user migration'
20
20
  migration_template "add_teacher_status_to_users.rb", "db/migrate/add_teacher_status_to_users.rb"
21
+ migration_template "add_profile_fields_to_users.rb", "db/migrate/add_profile_fields_to_users.rb"
21
22
  end
22
23
 
23
24
  end
@@ -0,0 +1,12 @@
1
+ class AddProfileFieldsToUsers < ActiveRecord::Migration
2
+ # profile attributes
3
+ def change
4
+ add_column :users, :portrait, :string
5
+ add_column :users, :allow_newsletter, :boolean, default: true
6
+ add_column :users, :allow_daily_digests, :boolean, default: true
7
+ add_column :users, :website_url, :string
8
+ add_column :users, :facebook_url, :string
9
+ add_column :users, :twitter_handle, :string
10
+ add_column :users, :google_plus_url, :string
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module TkhMailingList
2
- VERSION = "0.10"
2
+ VERSION = "0.10.1"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require "tkh_mailing_list/version"
2
2
 
3
+
3
4
  module TkhMailingList
4
5
  class Engine < ::Rails::Engine
5
6
  end
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ # spec.add_dependency 'jcrop-rails-v2'
22
+
21
23
  spec.add_development_dependency "bundler", "~> 1.3"
22
24
  spec.add_development_dependency "rake"
23
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tkh_mailing_list
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.10'
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swami Atma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-29 00:00:00.000000000 Z
11
+ date: 2014-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,12 +52,14 @@ files:
52
52
  - LICENSE.txt
53
53
  - README.md
54
54
  - Rakefile
55
+ - app/assets/javascripts/profiles.js.coffee
55
56
  - app/controllers/details_controller.rb
56
57
  - app/controllers/members_controller.rb
57
58
  - app/controllers/profiles_controller.rb
58
59
  - app/models/detail.rb
59
60
  - app/models/member.rb
60
61
  - app/models/profile.rb
62
+ - app/uploaders/portrait_uploader.rb
61
63
  - app/views/details/_form.html.erb
62
64
  - app/views/details/_tab_admin_menu.html.erb
63
65
  - app/views/details/edit.html.erb
@@ -74,6 +76,7 @@ files:
74
76
  - app/views/profiles/_custom_private_profile_attributes.html.erb
75
77
  - app/views/profiles/_custom_public_profile_attributes.html.erb
76
78
  - app/views/profiles/_tab_menu.html.erb
79
+ - app/views/profiles/crop.html.erb
77
80
  - app/views/profiles/edit.html.erb
78
81
  - app/views/profiles/history.html.erb
79
82
  - app/views/profiles/show.html.erb
@@ -85,6 +88,7 @@ files:
85
88
  - lib/generators/tkh_mailing_list/create_or_update_locales/templates/fr.yml
86
89
  - lib/generators/tkh_mailing_list/create_or_update_locales/templates/it.yml
87
90
  - lib/generators/tkh_mailing_list/create_or_update_migrations/create_or_update_migrations_generator.rb
91
+ - lib/generators/tkh_mailing_list/create_or_update_migrations/templates/add_profile_fields_to_users.rb
88
92
  - lib/generators/tkh_mailing_list/create_or_update_migrations/templates/add_teacher_status_to_users.rb
89
93
  - lib/tasks/tkh_mailing_list_tasks.rake
90
94
  - lib/tkh_mailing_list.rb