mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 10:44:50 +08:00
c1f74cd92a
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
```
71 lines
2.3 KiB
Handlebars
71 lines
2.3 KiB
Handlebars
{{#if model.length}}
|
|
<h3>{{i18n "admin.plugins.installed"}}</h3>
|
|
|
|
<table class="admin-plugins grid">
|
|
<thead>
|
|
<tr>
|
|
<th></th>
|
|
<th>{{i18n "admin.plugins.name"}}</th>
|
|
<th>{{i18n "admin.plugins.version"}}</th>
|
|
<th>{{i18n "admin.plugins.enabled"}}</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{#each model as |plugin|}}
|
|
<tr>
|
|
<td>
|
|
{{#if plugin.is_official}}
|
|
{{d-icon "check-circle"
|
|
title="admin.plugins.official"
|
|
class="admin-plugins-official-badge"}}
|
|
{{/if}}
|
|
</td>
|
|
|
|
<td class="plugin-name">
|
|
<div class="name">
|
|
{{#if plugin.url}}
|
|
<a href={{plugin.url}} rel="noopener noreferrer" target="_blank">{{plugin.name}}</a>
|
|
{{else}}
|
|
{{plugin.name}}
|
|
{{/if}}
|
|
</div>
|
|
<div class="about">
|
|
{{plugin.about}}
|
|
</div>
|
|
</td>
|
|
<td class="version">
|
|
<div class="label">{{i18n "admin.plugins.version"}}</div>
|
|
{{plugin.version}}
|
|
</td>
|
|
<td class="col-enabled">
|
|
<div class="label">{{i18n "admin.plugins.enabled"}}</div>
|
|
{{#if plugin.enabled_setting}}
|
|
{{#if plugin.enabled}}
|
|
{{i18n "admin.plugins.is_enabled"}}
|
|
{{else}}
|
|
{{i18n "admin.plugins.not_enabled"}}
|
|
{{/if}}
|
|
{{else}}
|
|
{{i18n "admin.plugins.is_enabled"}}
|
|
{{/if}}
|
|
</td>
|
|
<td class="settings">
|
|
{{#if currentUser.admin}}
|
|
{{#if plugin.has_settings}}
|
|
{{d-button class="btn-default" action=(route-action "showSettings") actionParam=plugin icon="cog" label="admin.plugins.change_settings_short"}}
|
|
{{/if}}
|
|
{{/if}}
|
|
</td>
|
|
</tr>
|
|
{{/each}}
|
|
</tbody>
|
|
</table>
|
|
{{else}}
|
|
<p>{{i18n "admin.plugins.none_installed"}}</p>
|
|
{{/if}}
|
|
|
|
<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" tagName="span" connectorTagName="div" args=(hash model=model)}}
|