-
-
Notifications
You must be signed in to change notification settings - Fork 421
Hashtags Feature applied to Proposals #3959
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
Conversation
@decidim/lot-core I would appreciate a pre-review of this PR. |
@@ -0,0 +1,16 @@ | |||
# frozen_string_literal: true | |||
|
|||
class CreateDecidimHashtagggings < ActiveRecord::Migration[5.2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's an extra g
here
description "hashtags list" | ||
|
||
interfaces [ | ||
-> { Decidim::Core::HashtagInterface } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this interface be used by other types? If it won't, then I suggest putting the fields definition directly to the type to reduce complexity.
t.references :decidim_hashtag, index: true | ||
t.references :decidim_hashtaggable, polymorphic: true, index: { name: "idx_hashtaggins_on_hashtaggable_type_and_hashtaggable_id" } | ||
end | ||
add_index :decidim_hashtaggings, %w(decidim_hashtaggable_id decidim_hashtaggable_type), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a duplicate from the index in line 7?
name "HashtagInterface" | ||
description "A hashtag" | ||
|
||
field :name, !types.String, "The hashtag's name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest moving this to the HashtagType
and deleting this file.
# hashtag with a global id. | ||
# | ||
# @return [String] the content with the hashtags replaced by a global id | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra white line
|
||
context "when hashtagging a non created hashtag" do | ||
let(:hashtag3) { create(:hashtag, organization: organization) } | ||
let(:content) { "This text hashtagiing a non created hashtag: ##{hashtag3.name}" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hashtag3
does exist in the DB, so this test is wrong.
title: @form.title, | ||
description: @form.description, | ||
# title: @form.title, | ||
title: parser.parse(@form.title), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can titles have hashtags? Won't this be weird when rendering?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a long time ago, @xabier said that fields were title and body...
Maybe @decidim/product can clarify
# parsed_title = Decidim::ContentProcessor.parse(form.title, current_organization: current_organization).rewrite | ||
# parsed_body = Decidim::ContentProcessor.parse(form.body, current_organization: current_organization).rewrite | ||
|
||
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: current_organization).rewrite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these 2 lines inside the attributes
method and you won't need to pass those as params
renderer.render.html_safe | ||
end | ||
|
||
# This methods return the plain title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong docs
@@ -6,7 +6,7 @@ | |||
<%= proposal.id %><br /> | |||
</td> | |||
<td> | |||
<%= proposal.title %><br /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing <br />
? Don't know if it's intended though.
}).fail(function() { | ||
cb([]) | ||
}).always(() => { | ||
// This function runs Tribute every single time you type somthing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/somthing/something 🤓
if ($(this.current.element).hasClass("editor-container")) { | ||
let quill = this.current.element.__quill; | ||
quill.insertText(cursor - 1, `#${item.original.name} `, Quill.sources.API); | ||
// cursor position + nickname length + "@" sign + space |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nickname or hashtag?
} | ||
}); | ||
|
||
function remoteSearch(text, cb) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated function?
end | ||
|
||
def hashtags | ||
Decidim::Hashtag.where(organization: @organization).where("name like ?", "#{@term}%") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use like
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to collect hashtags with the names thah begin with 'bla' for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then don't we need something like "name like ?%"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't see the %
at the end, sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry 😄
name "HashtagInterface" | ||
description "A hashtag" | ||
|
||
field :name, !types.String, "The hashtag's name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this interface won't be used anywhere else, you can drop it and move the field to the type
# | ||
# @see BaseRenderer Examples of how to use a content renderer | ||
class HashtagRenderer < BaseRenderer | ||
# Matches a global id representing a Decidim::User |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/User/Hashtag
decidim-core/lib/decidim/hashtag.rb
Outdated
HASHTAG_REGEX = /(^|\s)#([a-zA-Z0-9]\w*)/i | ||
|
||
def hashtaggables | ||
decidim_hashtaggings.includes(:decidim_hashtaggable).collect(&:decidim_hashtaggable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we memoize this?
decidim-core/lib/decidim/hashtag.rb
Outdated
decidim_hashtaggings.includes(:decidim_hashtaggable).collect(&:decidim_hashtaggable) | ||
end | ||
|
||
def hashtagged_types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods aren't used
@@ -40,17 +40,23 @@ def call | |||
attr_reader :form, :proposal, :attachment | |||
|
|||
def create_proposal | |||
# parsed_title = Decidim::ContentProcessor.parse(form.title, current_organization: current_organization).rewrite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this?
# parsed_title = Decidim::ContentProcessor.parse(form.title, current_organization: current_organization).rewrite | ||
# parsed_body = Decidim::ContentProcessor.parse(form.body, current_organization: current_organization).rewrite | ||
|
||
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: current_organization).rewrite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't a bit weird to allow hashtags at titles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@decidim/product clarify this please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isaacmg410 @oriolgual I have checked the conversation in the original issue and we agreed to ignore the hashtags in the title: #2458 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so that is what we are doing.
Show the hashtag on title ignoring the link 😄
@@ -17,6 +17,7 @@ class Meeting < Meetings::ApplicationRecord | |||
include Decidim::Searchable | |||
include Decidim::Traceable | |||
include Decidim::Loggable | |||
include Decidim::Hashtaggable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be in another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right!
@oriolgual requested changes applied, ready to review and merge |
🎩 What? Why?
This functionality will consist of the development of a new feature Hashtags provide a flexible way to search and filter content.
📌 Related Issues
📋 Subtasks
CHANGELOG
entry📷 Screenshots (optional)