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

Added a new setting #2

Merged
merged 1 commit into from Jun 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions config/locales/server.en.yml
Expand Up @@ -3,3 +3,4 @@ en:
topic_list_show_like_on_current_users_posts: "Show an inactive like button in topic list items previewing a post created by the current user (non-default Discourse behavior)."
topic_list_excerpt_length: "Character length of topic excerpts."
topic_list_excerpt_remove_links: "Remove links from excerpts."
topic_list_keep_link_text_content: "Keep text content inside link tags from excerpts"
2 changes: 2 additions & 0 deletions config/locales/server.fr.yml
Expand Up @@ -2,3 +2,5 @@ fr:
site_settings:
topic_list_show_like_on_current_users_posts: "Afficher un bouton semblable à inactif dans les éléments de la liste de sujets, prévisualisant un article créé par l'utilisateur actuel (comportement Discourse autre que par défaut)."
topic_list_excerpt_length: "Longueur de caractère des extraits de sujet."
topic_list_excerpt_remove_links: "Supprimer les liens des extraits de sujet"
topic_list_keep_link_text_content: "Conserver le texte à l'intérieur des balises de lien des extraits de sujet"
3 changes: 3 additions & 0 deletions config/settings.yml
Expand Up @@ -11,3 +11,6 @@ plugins:
topic_list_excerpt_remove_links:
default: true
client: false
topic_list_keep_link_text_content:
default: false
client: false
8 changes: 6 additions & 2 deletions lib/topic_list_serializer_lib.rb
Expand Up @@ -6,7 +6,11 @@ def self.remove_links (excerpt)
doc = Nokogiri::HTML excerpt
node = doc.at("a")
node.replace(node.text) if node
doc.to_str.gsub(/#{URI::regexp}/, '').gsub(/\s+/, ' ').strip
if SiteSetting.topic_list_keep_link_text_content
doc.to_str.strip
else
doc.to_str.gsub(/#{URI::regexp}/, '').gsub(/\s+/, ' ').strip
end
end

end