mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Update default tagName and connectorTagName for plugin outlets (#13685)
This commit should be a no-op for all existing core outlets. Outlets which are introduced by themes/plugins may see a change in behavior, and should follow the steps below if they want to maintain their previous behavior.
`tagName="" connectorTagName=""` is almost always the correct choice for plugin outlets. 40eba8cd introduced a `noTags=true` shortcut which achieved this, and left a comment saying it should be the future default. This commit does exactly that. To avoid any breaking changes for plugins, all existing plugin outlets have been reviewed and adjusted by following this logic:
1) If `noTags=true`, remove the `noTags` parameter, and do not complete any further steps
2) If `tagName` is not specified, set `tagName="span"` (the previous default)
3) If `connectorTagName` is not specified, set `selectorTagName="div"` (the previous default)
4) If `tagName=""`, remove it
5) If `connectorTagName=""`, remove it
The updates were accomplished with the help of a ruby script:
```ruby
def removeAttr(tag, attribute)
tag = tag.sub /\s#{attribute}="?\w*"? /, " "
tag = tag.sub /\s#{attribute}="?\w*"?}}/, "}}"
tag = tag.sub /^\s*#{attribute}="?\w*"?\n/, ""
tag
end
files = Dir.glob("app/assets/javascripts/**/*.hbs")
puts "Checking #{files.count} files..."
files.each do |f|
content = File.read(f)
count = 0
edits = 0
content.gsub!(/{{\s*plugin-outlet.*?}}/m) do |match|
count += 1
result = match
noTags = result.include?("noTags=true")
tagName = result[/tagName="(\w*)"/, 1]
connectorTagName = result[/connectorTagName="(\w*)"/, 1]
if noTags
result = removeAttr(result, "noTags")
else
if connectorTagName == ""
result = removeAttr(result, "connectorTagName")
elsif connectorTagName.nil?
result = result.sub(/name="[\w-]+"/) { |m| "#{m} connectorTagName=\"div\"" }
end
if tagName == ""
result = removeAttr(result, "tagName")
elsif tagName.nil?
result = result.sub(/name="[\w-]+"/) { |m| "#{m} tagName=\"span\"" }
end
end
edits += 1 if match != result
result
end
puts "#{count} outlets, #{edits} edited -> #{f}"
File.write(f, content)
end
```
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{nav-item route="adminPlugins" label="admin.plugins.title"}}
|
||||
{{plugin-outlet name="admin-menu" connectorTagName="" tagName=""}}
|
||||
{{plugin-outlet name="admin-menu"}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<ul class="nav nav-pills">
|
||||
{{nav-item route="admin.backups.index" label="admin.backups.menu.backups"}}
|
||||
{{nav-item route="admin.backups.logs" label="admin.backups.menu.logs"}}
|
||||
{{plugin-outlet name="downloader" tagName=""}}
|
||||
{{plugin-outlet name="downloader" connectorTagName="div"}}
|
||||
<div class="admin-actions">
|
||||
{{#if model.canRollback}}
|
||||
{{d-button action=(route-action "rollback")
|
||||
@@ -32,7 +32,7 @@
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
{{plugin-outlet name="before-backup-list" tagName=""}}
|
||||
{{plugin-outlet name="before-backup-list" connectorTagName="div"}}
|
||||
|
||||
<div class="admin-container">
|
||||
{{outlet}}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="inner-wrapper">
|
||||
{{plugin-outlet name="admin-customize-themes-list-item" connectorTagName="span" args=(hash theme=theme)}}
|
||||
{{plugin-outlet name="admin-customize-themes-list-item" tagName="span" connectorTagName="span" args=(hash theme=theme)}}
|
||||
|
||||
<div class="info">
|
||||
<span class="name">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="show-current-style">
|
||||
{{plugin-outlet name="admin-customize-themes-show-top" args=(hash theme=model)}}
|
||||
{{plugin-outlet name="admin-customize-themes-show-top" tagName="span" connectorTagName="div" args=(hash theme=model)}}
|
||||
<div class="title">
|
||||
{{#if editingName}}
|
||||
{{text-field value=model.name autofocus="true"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{plugin-outlet name="admin-dashboard-top"}}
|
||||
{{plugin-outlet name="admin-dashboard-top" tagName="span" connectorTagName="div"}}
|
||||
|
||||
{{#if showVersionChecks}}
|
||||
<div class="section-top">
|
||||
@@ -53,4 +53,4 @@
|
||||
|
||||
{{dashboard-new-features tagName="div"}}
|
||||
|
||||
{{plugin-outlet name="admin-dashboard-bottom"}}
|
||||
{{plugin-outlet name="admin-dashboard-bottom" tagName="span" connectorTagName="div"}}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{{#conditional-loading-spinner condition=isLoading}}
|
||||
{{plugin-outlet name="admin-dashboard-general-top"}}
|
||||
{{plugin-outlet name="admin-dashboard-general-top" tagName="span" connectorTagName="div"}}
|
||||
|
||||
{{#if isCommunityHealthVisible}}
|
||||
<div class="community-health section">
|
||||
@@ -156,5 +156,5 @@
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{plugin-outlet name="admin-dashboard-general-bottom"}}
|
||||
{{plugin-outlet name="admin-dashboard-general-bottom" tagName="span" connectorTagName="div"}}
|
||||
{{/conditional-loading-spinner}}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="sections">
|
||||
{{plugin-outlet name="admin-dashboard-moderation-top"}}
|
||||
{{plugin-outlet name="admin-dashboard-moderation-top" tagName="span" connectorTagName="div"}}
|
||||
|
||||
{{#if isModeratorsActivityVisible}}
|
||||
<div class="moderators-activity section">
|
||||
@@ -40,6 +40,6 @@
|
||||
filters=lastWeekfilters
|
||||
reportOptions=userFlaggingRatioOptions}}
|
||||
|
||||
{{plugin-outlet name="admin-dashboard-moderation-bottom"}}
|
||||
{{plugin-outlet name="admin-dashboard-moderation-bottom" tagName="span" connectorTagName="div"}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="sections">
|
||||
{{plugin-outlet name="admin-dashboard-security-top"}}
|
||||
{{plugin-outlet name="admin-dashboard-security-top" tagName="span" connectorTagName="div"}}
|
||||
|
||||
<div class="main-section">
|
||||
{{admin-report
|
||||
@@ -10,6 +10,6 @@
|
||||
dataSourceName="staff_logins"
|
||||
filters=lastWeekfilters}}
|
||||
|
||||
{{plugin-outlet name="admin-dashboard-security-bottom"}}
|
||||
{{plugin-outlet name="admin-dashboard-security-bottom" tagName="span" connectorTagName="div"}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -67,4 +67,4 @@
|
||||
|
||||
<p class="admin-plugins-howto"><a href="https://meta.discourse.org/t/install-a-plugin/19157">{{i18n "admin.plugins.howto"}}</a></p>
|
||||
|
||||
{{plugin-outlet name="admin-below-plugins-index" args=(hash model=model)}}
|
||||
{{plugin-outlet name="admin-below-plugins-index" tagName="span" connectorTagName="div" args=(hash model=model)}}
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
{{plugin-outlet
|
||||
name="admin-user-controls-after"
|
||||
args=(hash model=model)
|
||||
tagName=""
|
||||
connectorTagName=""}}
|
||||
}}
|
||||
</div>
|
||||
|
||||
<div class="display-row username">
|
||||
@@ -48,8 +47,7 @@
|
||||
{{plugin-outlet
|
||||
name="admin-user-below-names"
|
||||
args=(hash user=model)
|
||||
tagName=""
|
||||
connectorTagName=""}}
|
||||
}}
|
||||
|
||||
{{#if canCheckEmails}}
|
||||
<div class="display-row email">
|
||||
@@ -235,7 +233,7 @@
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{plugin-outlet name="admin-user-details" args=(hash model=model)}}
|
||||
{{plugin-outlet name="admin-user-details" tagName="span" connectorTagName="div" args=(hash model=model)}}
|
||||
|
||||
<section class="details">
|
||||
<h1>{{i18n "admin.user.permissions"}}</h1>
|
||||
@@ -726,7 +724,7 @@
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{plugin-outlet name="after-user-details" args=(hash model=model)}}
|
||||
{{plugin-outlet name="after-user-details" tagName="span" connectorTagName="div" args=(hash model=model)}}
|
||||
|
||||
<section>
|
||||
<hr>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
{{#if user.second_factor_enabled}}
|
||||
{{d-icon "lock" title="admin.user.second_factor_enabled" }}
|
||||
{{/if}}
|
||||
{{plugin-outlet name="admin-users-list-icon" tagName="" args=(hash user=user query=query)}}
|
||||
{{plugin-outlet name="admin-users-list-icon" connectorTagName="div" args=(hash user=user query=query)}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{{nav-item route="adminUsersList.show" routeParam="silenced" label="admin.users.nav.silenced" class="silenced-users"}}
|
||||
{{nav-item route="adminUsersList.show" routeParam="staged" label="admin.users.nav.staged" class="staged-users"}}
|
||||
{{nav-item route="groups" label="groups.index.title" class="groups"}}
|
||||
{{plugin-outlet name="admin-users-list-nav-after" tagName="" connectorTagName=""}}
|
||||
{{plugin-outlet name="admin-users-list-nav-after"}}
|
||||
|
||||
<li class="admin-actions">
|
||||
{{#if currentUser.can_invite_to_forum}}
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{plugin-outlet name="web-hook-fields" args=(hash model=model)}}
|
||||
{{plugin-outlet name="web-hook-fields" tagName="span" connectorTagName="div" args=(hash model=model)}}
|
||||
|
||||
<div>
|
||||
{{input type="checkbox" name="verify_certificate" checked=model.verify_certificate}} {{i18n "admin.web_hooks.verify_certificate"}}
|
||||
|
||||
Reference in New Issue
Block a user