Skip to content

Commit

Permalink
Merge branch 'master' into feature/group-email-settings-ui-part-1
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-brennan committed May 25, 2021
2 parents e4305b7 + b8a08d2 commit da9051e
Show file tree
Hide file tree
Showing 14 changed files with 638 additions and 30 deletions.
15 changes: 14 additions & 1 deletion app/assets/javascripts/discourse/app/lib/plugin-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { addPostSmallActionIcon } from "discourse/widgets/post-small-action";
import { addQuickAccessProfileItem } from "discourse/widgets/quick-access-profile";
import { addTagsHtmlCallback } from "discourse/lib/render-tags";
import { addToolbarCallback } from "discourse/components/d-editor";
import { addTopicParticipantClassesCallback } from "discourse/widgets/topic-map";
import { addTopicTitleDecorator } from "discourse/components/topic-title";
import { addUserMenuGlyph } from "discourse/widgets/user-menu";
import { addUsernameSelectorDecorator } from "discourse/helpers/decorate-username-selector";
Expand All @@ -73,7 +74,7 @@ import { replaceTagRenderer } from "discourse/lib/render-tag";
import { setNewCategoryDefaultColors } from "discourse/routes/new-category";

// If you add any methods to the API ensure you bump up this number
const PLUGIN_API_VERSION = "0.11.3";
const PLUGIN_API_VERSION = "0.11.4";

class PluginApi {
constructor(version, container) {
Expand Down Expand Up @@ -763,6 +764,18 @@ class PluginApi {
addPostClassesCallback(callback);
}

/**
* Adds a callback to be called before rendering a topic participant that
* that returns custom classes to add to the participant element
*
* Example:
*
* addTopicParticipantClassesCallback((attrs) => {if (attrs.primary_group_name == "moderator") return ["important-participant"];})
**/
addTopicParticipantClassesCallback(callback) {
addTopicParticipantClassesCallback(callback);
}

/**
*
* Adds a callback to be executed on the "transformed" post that is passed to the post
Expand Down
21 changes: 20 additions & 1 deletion app/assets/javascripts/discourse/app/widgets/topic-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,30 @@ createWidget("topic-map-show-links", {
},
});

let addTopicParticipantClassesCallbacks = null;
export function addTopicParticipantClassesCallback(callback) {
addTopicParticipantClassesCallbacks =
addTopicParticipantClassesCallbacks || [];
addTopicParticipantClassesCallbacks.push(callback);
}
createWidget("topic-participant", {
buildClasses(attrs) {
const classNames = [];
if (attrs.primary_group_name) {
return `group-${attrs.primary_group_name}`;
classNames.push(`group-${attrs.primary_group_name}`);
}
if (addTopicParticipantClassesCallbacks) {
for (let i = 0; i < addTopicParticipantClassesCallbacks.length; i++) {
let pluginClasses = addTopicParticipantClassesCallbacks[i].call(
this,
attrs
);
if (pluginClasses) {
classNames.push.apply(classNames, pluginClasses);
}
}
}
return classNames;
},

html(attrs, state) {
Expand Down
15 changes: 13 additions & 2 deletions app/assets/stylesheets/common/base/menu-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,23 @@
}
}

&:hover,
&:focus {
&:hover {
background-color: var(--highlight-medium);
outline: none;
}

&:focus-within {
background: var(--highlight-medium);
a {
// we don't need the link focus because we're styling the parent
outline: 0;
}
.btn-flat:focus {
// undo default btn-flat style
background: transparent;
}
}

a {
display: flex;
margin: 0.25em;
Expand Down
5 changes: 2 additions & 3 deletions app/assets/stylesheets/common/components/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,9 @@

&:focus {
outline: none;
background: var(--primary-medium);
color: var(--secondary);
background: var(--primary-low);
.d-icon {
color: var(--primary-low);
color: var(--primary);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def complete
Discourse.redis.setex "#{Users::AssociateAccountsController::REDIS_PREFIX}_#{current_user.id}_#{token}", 10.minutes, auth.to_json
return redirect_to "#{Discourse.base_path}/associate/#{token}"
else
DiscourseEvent.trigger(:before_auth, authenticator, auth)
DiscourseEvent.trigger(:before_auth, authenticator, auth, session)
@auth_result = authenticator.after_authenticate(auth)
@auth_result.user = nil if @auth_result&.user&.staged # Treat staged users the same as unregistered users
DiscourseEvent.trigger(:after_auth, authenticator, @auth_result)
DiscourseEvent.trigger(:after_auth, authenticator, @auth_result, session)
end

preferred_origin = request.env['omniauth.origin']
Expand Down
22 changes: 11 additions & 11 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4078,38 +4078,38 @@ en:
Please treat this discussion forum with the same respect you would a public park. We, too, are a shared community resource &mdash; a place to share skills, knowledge and interests through ongoing conversation.
These are not hard and fast rules, merely guidelines to aid the human judgment of our community and keep this a clean and well-lighted place for civilized public discourse.
These are not hard and fast rules. They are guidelines to aid the human judgment of our community and keep this a kind, friendly place for civilized public discourse.
<a name="improve"></a>
## [Improve the Discussion](#improve)
Help us make this a great place for discussion by always working to improve the discussion in some way, however small. If you are not sure your post adds to the conversation, think over what you want to say and try again later.
The topics discussed here matter to us, and we want you to act as if they matter to you, too. Be respectful of the topics and the people discussing them, even if you disagree with some of what is being said.
Help us make this a great place for discussion by always adding something positive to the discussion, however small. If you are not sure your post adds to the conversation, think over what you want to say and try again later.
One way to improve the discussion is by discovering ones that are already happening. Spend time browsing the topics here before replying or starting your own, and you’ll have a better chance of meeting others who share your interests.
The topics discussed here matter to us, and we want you to act as if they matter to you, too. Be respectful of the topics and the people discussing them, even if you disagree with some of what is being said.
<a name="agreeable"></a>
## [Be Agreeable, Even When You Disagree](#agreeable)
You may wish to respond to something by disagreeing with it. That’s fine. But remember to _criticize ideas, not people_. Please avoid:
You may wish to respond by disagreeing. That’s fine. But remember to _criticize ideas, not people_. Please avoid:
* Name-calling
* Ad hominem attacks
* Responding to a post’s tone instead of its actual content
* Knee-jerk contradiction
Instead, provide reasoned counter-arguments that improve the conversation.
Instead, provide thoughtful insights that improve the conversation.
<a name="participate"></a>
## [Your Participation Counts](#participate)
The conversations we have here set the tone for every new arrival. Help us influence the future of this community by choosing to engage in discussions that make this forum an interesting place to be &mdash; and avoiding those that do not.
Discourse provides tools that enable the community to collectively identify the best (and worst) contributions: bookmarks, likes, flags, replies, edits, and so forth. Use these tools to improve your own experience, and everyone else’s, too.
Discourse provides tools that enable the community to collectively identify the best (and worst) contributions: bookmarks, likes, flags, replies, edits, watching, muting and so forth. Use these tools to improve your own experience, and everyone else’s, too.
Let’s leave our community better than we found it.
Expand All @@ -4119,7 +4119,7 @@ en:
Moderators have special authority; they are responsible for this forum. But so are you. With your help, moderators can be community facilitators, not just janitors or police.
When you see bad behavior, don’t reply. It encourages the bad behavior by acknowledging it, consumes your energy, and wastes everyone’s time. _Just flag it_. If enough flags accrue, action will be taken, either automatically or by moderator intervention.
When you see bad behavior, don’t reply. Replying encourages bad behavior by acknowledging it, consumes your energy, and wastes everyone’s time. _Just flag it_. If enough flags accrue, action will be taken, either automatically or by moderator intervention.
In order to maintain our community, moderators reserve the right to remove any content and any user account for any reason at any time. Moderators do not preview new posts; the moderators and site operators take no responsibility for any content posted by the community.
Expand All @@ -4134,7 +4134,7 @@ en:
* Respect each other. Don’t harass or grief anyone, impersonate people, or expose their private information.
* Respect our forum. Don’t post spam or otherwise vandalize the forum.
These are not concrete terms with precise definitions &mdash; avoid even the _appearance_ of any of these things. If you’re unsure, ask yourself how you would feel if your post was featured on the front page of the New York Times.
These are not concrete terms with precise definitions &mdash; avoid even the _appearance_ of any of these things. If you’re unsure, ask yourself how you would feel if your post was featured on the front page of a major news site.
This is a public forum, and search engines index these discussions. Keep the language, links, and images safe for family and friends.
Expand All @@ -4144,7 +4144,7 @@ en:
Make the effort to put things in the right place, so that we can spend more time discussing and less cleaning up. So:
* Don’t start a topic in the wrong category.
* Don’t start a topic in the wrong category; please read the category definitions.
* Don’t cross-post the same thing in multiple topics.
* Don’t post no-content replies.
* Don’t divert a topic by changing it midstream.
Expand All @@ -4162,7 +4162,7 @@ en:
## [Powered by You](#power)
This site is operated by your [friendly local staff](%{base_path}/about) and *you*, the community. If you have any further questions about how things should work here, open a new topic in the [site feedback category](%{base_path}/c/site-feedback) and let's discuss! If there's a critical or urgent issue that can't be handled by a meta topic or flag, contact us via the [staff page](%{base_path}/about).
This site is operated by your [friendly local staff](%{base_path}/about) and *you*, the community. If you have any further questions about how things should work here, open a new topic in the [site feedback category](%{base_path}/c/site-feedback) and lets discuss! If theres a critical or urgent issue that cant be handled by a meta topic or flag, contact us via the [staff page](%{base_path}/about).
<a name="tos"></a>
Expand Down
4 changes: 2 additions & 2 deletions lib/excerpt_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document

attr_reader :excerpt

SPAN_REGEX = /<\s*span[^>]*class\s*=\s*['|"]excerpt['|"][^>]*>/
CUSTOM_EXCERPT_REGEX = /<\s*(span|div)[^>]*class\s*=\s*['"]excerpt['"][^>]*>/

def initialize(length, options = nil)
@length = length
Expand All @@ -29,7 +29,7 @@ def initialize(length, options = nil)

def self.get_excerpt(html, length, options)
html ||= ''
length = html.length if html.include?('excerpt') && SPAN_REGEX === html
length = html.length if html.include?('excerpt') && CUSTOM_EXCERPT_REGEX === html
me = self.new(length, options)
parser = Nokogiri::HTML::SAX::Parser.new(me)
catch(:done) do
Expand Down

0 comments on commit da9051e

Please sign in to comment.