Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed color of github icon and refactored code #3034 #3050

Merged
merged 24 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ env:

before_script:
- bundle install
- bundle exec rubocop

before_install:
- echo -e "repo_token:\n $COVERALLS_REPO_TOKEN" >> ./.coveralls.yml
Expand Down
1 change: 1 addition & 0 deletions app/controllers/user_sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def create
if User.where(email: auth["info"]["email"]).empty?
# Create a new user as email provided is not present in PL database
user = User.create_with_omniauth(auth)
WelcomeMailer.notify_newcomer(user).deliver_now
@identity = UserTag.create_with_omniauth(auth, user.id)
key = user.generate_reset_key
# send key to user email
Expand Down
29 changes: 14 additions & 15 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,25 @@
<i class="fa fa-user fa fa-white"></i>
<%= t('layout._header.login.login_title') %> <b class="caret"></b>
</a>
<ul id="login-dropdown" class="dropdown-menu" style="width:240px;">
<ul id="login-dropdown" class="dropdown-menu" style="width:245px;">
<li style="padding:6px;">
<%= form_for :user_session, :as => :user_session, :url => { :controller => "user_sessions", :action => "create" }, :html => {:class => "form"} do |f| %>

<div class="form-group">
<div class="form-group">
<% if Rails.env == "production" %>
<label style="display: block; text-align: center;">Log In with</label>
<div class="loginbutton" style="float:left">
<%= render :partial => "layouts/social_icons" %>
</div>
<br style="clear:both;"/>
<label style="display: block; text-align: center; margin-top:13px;">OR</label>
<% end %>
</div>
<div class="form-group">

<label for="username"><%= t('layout._header.login.username') %></label>
<%= f.text_field :username, { tabindex: 1, class: 'form-control', id: 'username-login' } %>

</div>

<div class="form-group">
<div class="form-group">

<label for="password"><%= t('layout._header.login.password') %></label>
<%= f.password_field :password, { tabindex: 2, class: 'form-control', id: 'password-login' } %>
Expand All @@ -183,15 +190,7 @@
</p>

<p><a href="/reset/"><%= t('layout._header.login.reset_password') %></a></p>
<% if Rails.env == "production"%>
<h5>Log In with</h5>
<div class="loginbutton" style="float:left">
<a href="/auth/google_oauth2" id="connect-google"><span class="btn btn-default" style="margin-right:2px"><i class="fa fa-google" style="font-size:20px;color:red;"></i></span></a>
<a href="/auth/github" id="connect-github"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-github" style="font-size:20px;color:green;"></i></span></a>
<a href="https://publiclab.org/auth/twitter" id="connect-twitter"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-twitter" style="font-size:20px;color:blue;margin-left:2px;"></i></span></div></a>
<a href="/auth/facebook" id="connect-facebook"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-facebook" style="font-size:20px;color:blue;"></i></span></a>
</div>
<% end %>

<% end %>
</li>
</ul>
Expand Down
4 changes: 4 additions & 0 deletions app/views/layouts/_social_icons.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<a href="/auth/google_oauth2" id="connect-google"><span class="btn btn-default" style="margin-right:2px;background-color: #d34836;"><i class="fa fa-google fa-fw" style="font-size:20px;color:white;"></i></span></a>
<a href="/auth/github" id="connect-github"><span class="btn btn-default" style="margin-left:2px;background-color: #333;"><i class="fa fa-github fa-fw" style="font-size:20px;color:white;"></i></span></a>
<a href="https://publiclab.org/auth/twitter" id="connect-twitter"><span class="btn btn-default" style="margin-left:2px;background-color: #1da1f2;"><i class="fa fa-twitter fa-fw" style="font-size:20px;color:white;margin-left:2px;"></i></span></a>
<a href="/auth/facebook" id="connect-facebook"><span class="btn btn-default" style="margin-left:2px;background-color: #3b5998"><i class="fa fa-facebook fa-fw" style="font-size:20px;color:white;"></i></span></a>
9 changes: 6 additions & 3 deletions app/views/notes/_comment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@
<i class="fa fa-pencil"></i>
</a>
<% end %>
<% if comment.comment_via == 1 %>
<a href="#" onclick="return false;" class="btn btn-default btn-sm"><i class="fa fa-envelope"></i></a>
<% end %>
<% if comment.comment_via == 1 %>
<a href="#" onclick="return false;" class="btn btn-default btn-sm"><i class="fa fa-envelope"></i></a>
<% end %>
<% if local_assigns[:is_answer] && current_user && (current_user.role == "admin" || current_user.role == "moderator" || comment.uid == current_user.uid) %>
<a class="btn btn-default btn-sm" id="comment-<%= comment.id %>-reorder-btn" data-remote="true" data-confirm="Are you sure? <% if current_user && comment.uid != current_user.uid %>Please exercise caution in promoting others' comments; this cannot be undone.<% end %>" rel="tooltip" title="<%= t('questions._comment.promotion') %>" data-placement="left" href="/comment/make_answer/<%= comment.id %>"><i class="fa fa-plus"></i></a>
<% end %>
<% if current_user &. can_moderate? %>
<a rel="tooltip" title="Mark as spam" class="btn btn-sm btn-default btn-flag-spam-<%= comment.id %>" data-confirm="Are you sure? The user will no longer be able to log in or publish, and their content will be hidden except comments." href="/admin/mark_comment_spam/<%= comment.id %>">
<i class="fa fa-ban"></i>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tag/_tags.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</span>
<% end %>

<% elsif tag.class == UserTag %>
<% elsif tag.class == UserTag && (tag.name[0..4] != "oauth" || (current_user && (current_user.uid == tag.uid || current_user.role == "admin"))) %>

<span id="tag_<%= tag.id %>" class="label <%= label_name %>" style="cursor:pointer" data-toggle="popover" data-trigger="manual" data-count=0 data-placement="top" data-content="<a href='/contributors/<%= tag.name %>'><%= Tag.tagged_node_count(tag.name) || 0 %> notes - <%= Tag.contributors(tag.name).count %> people <br></a>" data-html="true" title="<%= tag.name %>">
<%= tag.name %>
Expand Down
24 changes: 11 additions & 13 deletions app/views/user_sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@

<h2><%= raw t('user_sessions.new.log_in_or_sign_up', :url1 => "/signup") %></h2>
<% if f.error_messages != "" %><div class="alert alert-danger"><%= f.error_messages %></div><% end %>
<br style="clear:both;"/>
<% if Rails.env == "production" %>
<div class='col-lg-10 col-md-10 col-sm-10' style="display:flex; justify-content: center;">
<%= render :partial => "layouts/social_icons" %>
</div>


<br />
<% end %>
<div class='col-lg-10 col-md-10 col-sm-10' style="display:flex; justify-content: center;">
<h3>OR</h3>
</div>
<br style="clear:both;"/>

<div class="form-group">
Expand Down Expand Up @@ -32,23 +43,10 @@
<div class="input-group-inline">

<button class="btn btn-primary btn-lg" type="submit" tabindex="3"><%= t('user_sessions.new.log_in') %></button>
<a class="btn btn-default btn-lg" href="/signup" tabindex="4"><%= t('user_sessions.new.sign_up') %></a>

</div>
</br>
<% if Rails.env == "production"%>
<h5>OR </h5>
<h3> Login with </h3>
<div class="loginbutton" style="float:left">
<a href="/auth/google_oauth2" id="connect-google"><span class="btn btn-default" style="margin-right:2px"><i class="fa fa-google" style="font-size:20px;color:red;"></i></span></a>
<a href="/auth/github" id="connect-github"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-github" style="font-size:20px;color:green;"></i></span></a>
<a href="/auth/facebook" id="connect-facebook"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-facebook" style="font-size:20px;color:blue;"></i></span></a>
</div>

<a href="https://publiclab.org/auth/twitter" id="connect-twitter"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-twitter" style="font-size:20px;color:blue;margin-left:2px;"></i></span></a>

<br />
<% end %>
<p style="color: #888;"><%= raw t('user_sessions.new.reset_by_clicking_here', :url1 => "/reset/") %></p>
<% end %>

Expand Down
15 changes: 14 additions & 1 deletion app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@

<div class="col-lg-8 col-md-10 col-sm-10">
<% if params[:controller] == "users" && @action == "create" %>

<div class='col-lg-10 col-md-10 col-sm-10' style="display:flex; justify-content: center;">
<h3> Sign up with </h3>
</div>
<% if Rails.env == "production" %>
<div class='col-lg-10 col-md-10 col-sm-10' style="display:flex; justify-content: center;">
<%= render :partial => "layouts/social_icons" %>
<% end %>
</div>

<div class='col-lg-10 col-md-10 col-sm-10' style="display:flex; justify-content: center;">
<h3> OR</h3>

</div>
<br style="clear:both;"/>
<div class="form-group">

<label for="username"><%= t('users._form.username') %></label>
Expand Down
11 changes: 3 additions & 8 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@
<h2><%= t('users.edit.edit_profile') %></h2>

<hr />
<% if Rails.env == "production" %>
<% if Rails.env == "production"%>
<div class='col-lg-8 col-md-10 col-sm-10' style="display:flex; justify-content: flex-start; padding: 0;">
<label> Link your Public Lab account to providers</label>
</div>
<div class='col-lg-8 col-md-10 col-sm-10' style="display:flex; justify-content: flex-start; padding: 0; margin-bottom: 10px;">
<div class="loginbutton" >
<a href="/auth/google_oauth2" id="connect-google"><span class="btn btn-default" style="margin-right:2px"><i class="fa fa-google" style="font-size:20px;color:red;"></i></span></a>
<a href="/auth/github" id="connect-github"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-github" style="font-size:20px;color:green;"></i></span></a>
<a href="https://publiclab.org/auth/twitter" id="connect-twitter"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-twitter" style="font-size:20px;color:blue;margin-left:2px;"></i></span></a>
<a href="/auth/facebook" id="connect-facebook"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-facebook" style="font-size:20px;color:blue;"></i></span></a>
</div>
<%= render :partial => "layouts/social_icons" %>
</div>
<% end %>
<% end %>


<%= render 'form' %>
22 changes: 2 additions & 20 deletions app/views/users/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,9 @@
<% end %>

<br />
<div class='col-lg-8 col-md-10 col-sm-10' style="display:flex; justify-content: center;">
<h3> Sign up with </h3>
</div>
<% if Rails.env == "production"%>
<div class='col-lg-8 col-md-10 col-sm-10' style="display:flex; justify-content: center;">

<div class="loginbutton" >
<a href="/auth/google_oauth2" id="connect-google"><span class="btn btn-default" style="margin-right:2px"><i class="fa fa-google" style="font-size:20px;color:red;"></i></span></a>
<a href="/auth/github" id="connect-github"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-github" style="font-size:20px;color:green;"></i></span></a>
<a href="https://publiclab.org/auth/twitter" id="connect-twitter"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-twitter" style="font-size:20px;color:blue;margin-left:2px;"></i></span></a>
<a href="/auth/facebook" id="connect-facebook"><span class="btn btn-default" style="margin-left:2px"><i class="fa fa-facebook" style="font-size:20px;color:blue;"></i></span></a>
</div>
<% end %>
</div>
<div class='col-lg-8 col-md-10 col-sm-10' style="display:flex; justify-content: center;">
<h3> OR</h3>
</div>



<%= render 'form' %>

<% cache('feature_signup-notice', skip_digest: true) do %>
<%= feature('signup-notice') %>
<% end %>
Expand Down
22 changes: 21 additions & 1 deletion app/views/welcome_mailer/notify_newcomer.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<% if @body != "" %>
<%= raw auto_link(@body.latest.render_body_email(ActionMailer::Base.default_url_options[:host]), sanitize: false) %>
<% else %>

<%= raw auto_link(@body.latest.render_body_email(ActionMailer::Base.default_url_options[:host]), sanitize: false) %>
Welcome to Public Lab!

We're an open community dedicated to making environmental monitoring more accessible to all. In Public Lab, our public questions, ideas, and exploration help to build the resources available for everyone to use.

There’s a lot you can do in Public Lab: learn how to do environmental investigation in your community, help to build and develop research tools, and work with others to advocate for change.

Ready to jump in?

- Join an open call (https://publiclab.org/open-call)
- Find an upcoming event (www.publiclab.org/events)
- Ask a question (www.publiclab.org/questions)
- Follow Public Lab on social media (https://www.facebook.com/PublicLab/)
- Help support our work (www.publiclab.org/donate)

Looking forward to hearing from you soon,

The Public Lab Community
<% end %>

<%= @footer %>
4 changes: 2 additions & 2 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Per-model API endpoints are:
* Questions: https://publiclab.org/api/srch/questions?srchString=foo
* Tags: https://publiclab.org/api/srch/tags?srchString=foo
* Notes: https://publiclab.org/api/srch/notes?srchString=foo
* Locations: https://publiclab.org/api/srch/locations?srchString=lat,lon
* TagLocations: https://publiclab.org/api/srch/taglocations?srchString=lat,lon
* PeopleLocations: https://publiclab.org/api/srch/peoplelocations?srchString=QRY

****
Expand Down Expand Up @@ -104,4 +104,4 @@ https://github.com/publiclab/plots2/blob/master/app/controllers/comment_controll
"username": "user",
"body": "This is a comment made with a token"
}
```
```
2 changes: 1 addition & 1 deletion test/fixtures/revisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,5 +275,5 @@ email_body:
nid: 22
uid: 1
title: "welcome-email-body"
body: Welcome email body
body: Welcome to Public Lab
timestamp: <%= (Time.now - 1.week).to_i %>
19 changes: 12 additions & 7 deletions test/functional/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ def setup
user.generate_reset_key
user.save({})
assert_not_nil User.find(user.id).reset_key

get :profile, params: { id: user.username }

assert_select 'a#user-reset-key'
get :profile, params: { uid: user.username }
end

test 'should choose I18n for users controller' do
Expand Down Expand Up @@ -169,14 +166,15 @@ def setup
end

test 'creating new account' do
assert_difference 'ActionMailer::Base.deliveries.size', 1 do
assert_difference 'User.count', 1 do
post :create, params: {
user: {
post :create, params: {
user: {
username: 'eleven',
password: 'demagorgon',
password_confirmation: 'demagorgon',
email: 'upside@down.today',
bio: 'From Hawkins'
bio: 'From Hawkins'
},
spamaway: {
statement1: I18n.t('spamaway.human.statement1'),
Expand All @@ -186,11 +184,18 @@ def setup
}
}
end
end
assert_response :redirect
# a success here would mean sent back to form with errors
assert_redirected_to '/dashboard'
assert_equal 'From Hawkins', User.last.bio
assert_equal 'upside@down.today', User.last.email

assert !ActionMailer::Base.deliveries.empty?
email = ActionMailer::Base.deliveries.last
assert_equal ["notifications@#{request_host}"], email.from
assert_equal [User.last.email], email.to
assert_equal "Welcome to Public Lab", email.subject
end

test 'updating profile' do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/welcome_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class WelcomeMailerTest < ActionMailer::TestCase
assert_equal ["notifications@#{request_host}"], email.from
assert_equal [user.email], email.to
assert_equal "Welcome to Public Lab", email.subject
assert email.body.include?("Welcome email body")
assert email.body.include?("Welcome to Public Lab")
end
end