Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from malparty/release/0.4.0
Release - 0.4.0
- Loading branch information
Showing
39 changed files
with
4,490 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,6 @@ | |
@import 'layouts/default'; | ||
|
||
// Components | ||
@import 'components/list_keywords_group'; | ||
|
||
// Screens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.list-keyword-group { | ||
&__header { | ||
min-width: 3em; | ||
color: $gray-500; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class KeywordsController < ApplicationController | ||
def index; end | ||
include Pagy::Backend | ||
|
||
def index | ||
pagy, keywords_list = pagy(keywords) | ||
|
||
render locals: { | ||
pagy: pagy, keywords: KeywordsCollectionPresenter.new(keywords_list) | ||
} | ||
end | ||
|
||
private | ||
|
||
def keywords | ||
KeywordsQuery.new(current_user).call | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
class RegistrationsController < Devise::RegistrationsController | ||
# Override user hard-delete (from Devise) with user soft-delete | ||
def destroy | ||
resource.discard | ||
|
||
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name) | ||
|
||
set_flash_message :notice, :destroyed | ||
|
||
yield resource if block_given? | ||
|
||
respond_with_navigational(resource) { redirect_to after_sign_out_path_for(resource_name) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module ApplicationHelper | ||
include Pagy::Frontend | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class Keyword < ApplicationRecord | ||
include Discard::Model | ||
|
||
validates :name, presence: true, length: { maximum: 255 } | ||
|
||
belongs_to :user, inverse_of: :keywords | ||
|
||
default_scope -> { kept } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class KeywordsCollectionPresenter | ||
def initialize(keywords) | ||
@keywords = keywords | ||
end | ||
|
||
def groups | ||
keywords.group_by { |keyword| keyword.name[0].upcase.to_sym } | ||
end | ||
|
||
private | ||
|
||
attr_reader :keywords | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class KeywordsQuery | ||
def initialize(user) | ||
@keywords = user.keywords | ||
end | ||
|
||
def call | ||
order_by_name | ||
end | ||
|
||
private | ||
|
||
attr_reader :keywords | ||
|
||
def order_by_name | ||
keywords.order(:name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
module Google | ||
class ParserService | ||
NON_ADS_RESULT_SELECTOR = 'a[data-ved]:not([role]):not([jsaction]):not(.adwords):not(.footer-links)' | ||
AD_CONTAINER_ID = 'tads' | ||
ADWORDS_CLASS = 'adwords' | ||
|
||
def initialize(html_response:) | ||
raise ArgumentError, 'response.body cannot be blank' if html_response.body.blank? | ||
|
||
@html = html_response | ||
|
||
@document = Nokogiri::HTML.parse(html_response) | ||
|
||
# Add a class to all AdWords link for easier manipulation | ||
document.css('div[data-text-ad] a[data-ved]').add_class(ADWORDS_CLASS) | ||
|
||
# Mark footer links to identify them | ||
document.css('#footcnt a').add_class('footer-links') | ||
end | ||
|
||
# Parse html data and return a hash with the results | ||
def call | ||
{ | ||
ads_top_count: ads_top_count, | ||
ads_page_count: ads_page_count, | ||
ads_top_url: ads_top_url, | ||
ads_page_url: ads_page_url, | ||
non_ads_result_count: non_ads_result_count, | ||
non_ads_url: non_ads_url, | ||
total_link_count: total_link_count, | ||
html: html | ||
} | ||
end | ||
|
||
private | ||
|
||
attr_reader :html, :document | ||
|
||
def ads_top_count | ||
document.css("##{AD_CONTAINER_ID} .#{ADWORDS_CLASS}").count | ||
end | ||
|
||
def ads_page_count | ||
document.css(".#{ADWORDS_CLASS}").count | ||
end | ||
|
||
def ads_top_url | ||
document.css("##{AD_CONTAINER_ID} .#{ADWORDS_CLASS}").map { |a_tag| a_tag['href'] } | ||
end | ||
|
||
def ads_page_url | ||
document.css(".#{ADWORDS_CLASS}").map { |a_tag| a_tag['href'] } | ||
end | ||
|
||
def non_ads_result_count | ||
document.css(NON_ADS_RESULT_SELECTOR).count | ||
end | ||
|
||
def non_ads_url | ||
document.css(NON_ADS_RESULT_SELECTOR).map { |a_tag| a_tag['href'] } | ||
end | ||
|
||
def total_link_count | ||
document.css('a').count | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
<h2>Forgot your password?</h2> | ||
<div class="container"> | ||
<div class="row justify-content-center"> | ||
<div class="col col-md-8 col-lg-6"> | ||
<div class="card"> | ||
<section class="card-body"> | ||
<h2><%= t('auth.forgot_password') %></h2> | ||
|
||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> | ||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> | ||
<%= render "devise/shared/error_messages", resource: resource %> | ||
<%= render 'devise/shared/error_messages', resource: resource %> | ||
|
||
<div class="field"> | ||
<%= f.label :email %><br /> | ||
<%= f.email_field :email, autofocus: true, autocomplete: "email" %> | ||
</div> | ||
<div class="form-group"> | ||
<%= f.label :email %><br/> | ||
<%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= f.submit "Send me reset password instructions" %> | ||
</div> | ||
<% end %> | ||
<%= f.submit t('auth.btn_reset_password'), class: 'btn btn-primary btn-block' %> | ||
<% end %> | ||
<%= render "devise/shared/links" %> | ||
<%= render 'devise/shared/links' %> | ||
</section> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<section class="list-keyword"> | ||
<% if keywords.groups.any? %> | ||
<% keywords.groups.each do |group_key, group_keywords| %> | ||
<%= render 'list_keywords_group', group_key: group_key, group_keywords: group_keywords %> | ||
<% end %> | ||
<div class="d-flex justify-content-around"> | ||
<%== pagy_bootstrap_nav(pagy) %> | ||
</div> | ||
<% else %> | ||
<div class="alert alert-light"><%= t('keywords.empty_list') %></div> | ||
<% end %> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="d-flex flex-row list-keyword-group mb-2"> | ||
<div class="list-keyword-group__header"> | ||
<h2 class="mb-0"> | ||
<%= group_key %> | ||
</h2> | ||
</div> | ||
<ul class="list-inline mb-0"> | ||
<% group_keywords.each do |keyword| %> | ||
<li class="list-inline-item list-keyword-item"><%= keyword.name %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<hr/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<h1>Keywords#index</h1> | ||
<p>Find me in app/views/keyword/index.html.erb</p> | ||
<div class="container"> | ||
<%= render 'list_keywords', keywords: keywords, pagy: pagy %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.