2017-04-12 10:52:52 -04:00
|
|
|
<div class="show-current-style">
|
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
```
2022-01-06 15:38:17 -05:00
|
|
|
{{plugin-outlet name="admin-customize-themes-show-top" tagName="span" connectorTagName="div" args=(hash theme=model)}}
|
2018-08-30 15:23:15 -04:00
|
|
|
<div class="title">
|
2017-04-12 10:52:52 -04:00
|
|
|
{{#if editingName}}
|
|
|
|
{{text-field value=model.name autofocus="true"}}
|
2020-08-24 22:51:58 -04:00
|
|
|
{{d-button action=(action "finishedEditingName") class="btn-primary btn-small submit-edit" icon="check"}}
|
|
|
|
{{d-button action=(action "cancelEditingName") class="btn-small cancel-edit" icon="times"}}
|
2017-04-12 10:52:52 -04:00
|
|
|
{{else}}
|
2020-02-11 09:55:16 -05:00
|
|
|
<span>{{model.name}}</span>
|
|
|
|
{{d-button
|
|
|
|
action=(action "startEditingName")
|
|
|
|
icon="pencil-alt"
|
2020-08-24 22:51:58 -04:00
|
|
|
class="btn-small"
|
2020-02-11 09:55:16 -05:00
|
|
|
}}
|
2017-04-12 10:52:52 -04:00
|
|
|
{{/if}}
|
2018-08-30 15:23:15 -04:00
|
|
|
</div>
|
2017-04-12 10:52:52 -04:00
|
|
|
|
2018-10-03 17:03:06 -04:00
|
|
|
{{#each model.errors as |error|}}
|
2021-07-14 15:17:32 -04:00
|
|
|
<div class="alert alert-error">{{error}}</div>
|
2018-10-03 17:03:06 -04:00
|
|
|
{{/each}}
|
|
|
|
|
2019-07-03 04:18:11 -04:00
|
|
|
{{#unless model.supported}}
|
2019-01-25 09:19:01 -05:00
|
|
|
<div class="alert alert-error">
|
|
|
|
{{i18n "admin.customize.theme.required_version.error"}}
|
|
|
|
{{#if model.remote_theme.minimum_discourse_version}}
|
|
|
|
{{i18n "admin.customize.theme.required_version.minimum" version=model.remote_theme.minimum_discourse_version}}
|
|
|
|
{{/if}}
|
|
|
|
{{#if model.remote_theme.maximum_discourse_version}}
|
2019-02-28 09:40:33 -05:00
|
|
|
{{i18n "admin.customize.theme.required_version.maximum" version=model.remote_theme.maximum_discourse_version}}
|
2019-01-25 09:19:01 -05:00
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
{{/unless}}
|
|
|
|
|
2019-07-03 04:18:11 -04:00
|
|
|
{{#unless model.enabled}}
|
|
|
|
<div class="alert alert-error">
|
|
|
|
{{#if model.disabled_by}}
|
|
|
|
{{i18n "admin.customize.theme.disabled_by"}}
|
|
|
|
{{#user-link user=model.disabled_by}}
|
|
|
|
{{avatar model.disabled_by imageSize="tiny"}}
|
|
|
|
{{model.disabled_by.username}}
|
|
|
|
{{/user-link}}
|
|
|
|
{{format-date model.disabled_at leaveAgo="true"}}
|
|
|
|
{{else}}
|
|
|
|
{{i18n "admin.customize.theme.disabled"}}
|
|
|
|
{{/if}}
|
|
|
|
{{d-button
|
|
|
|
class="btn-default"
|
|
|
|
action=(action "enableComponent")
|
|
|
|
icon="check"
|
|
|
|
label="admin.customize.theme.enable"}}
|
|
|
|
</div>
|
|
|
|
{{/unless}}
|
|
|
|
|
2020-08-24 22:51:58 -04:00
|
|
|
<div class="metadata control-unit">
|
|
|
|
{{#if model.remote_theme}}
|
2020-09-25 20:34:29 -04:00
|
|
|
{{#if model.remote_theme.remote_url}}
|
|
|
|
{{#if sourceIsHttp}}
|
|
|
|
<a class="remote-url" href={{remoteThemeLink}}>{{i18n "admin.customize.theme.source_url"}}{{d-icon "link"}}</a>
|
|
|
|
{{else}}
|
2020-11-09 06:33:38 -05:00
|
|
|
<div class="remote-url">
|
|
|
|
<code>{{model.remote_theme.remote_url}}</code>
|
|
|
|
{{#if model.remote_theme.branch}}
|
|
|
|
(<code>{{model.remote_theme.branch}}</code>)
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
2020-08-24 22:51:58 -04:00
|
|
|
{{/if}}
|
2020-09-25 20:34:29 -04:00
|
|
|
{{/if}}
|
|
|
|
{{#if model.remote_theme.about_url}}
|
|
|
|
<a class="url about-url" href={{model.remote_theme.about_url}}>{{i18n "admin.customize.theme.about_theme"}}{{d-icon "link"}}</a>
|
|
|
|
{{/if}}
|
|
|
|
{{#if model.remote_theme.license_url}}
|
|
|
|
<a class="url license-url" href={{model.remote_theme.license_url}}>{{i18n "admin.customize.theme.license"}}{{d-icon "link"}}</a>
|
|
|
|
{{/if}}
|
2017-04-12 10:52:52 -04:00
|
|
|
|
2020-09-25 20:34:29 -04:00
|
|
|
{{#if model.description}}
|
|
|
|
<span class="theme-description">{{model.description}}</span>
|
|
|
|
{{/if}}
|
2019-01-25 09:19:01 -05:00
|
|
|
|
2020-09-25 20:34:29 -04:00
|
|
|
{{#if model.remote_theme.authors}}<span class="authors"><span class="heading">{{i18n "admin.customize.theme.authors"}}</span> {{model.remote_theme.authors}}</span>{{/if}}
|
|
|
|
{{#if model.remote_theme.theme_version}}<span class="version"><span class="heading">{{i18n "admin.customize.theme.version"}}</span> {{model.remote_theme.theme_version}}</span>{{/if}}
|
2019-01-25 09:19:01 -05:00
|
|
|
|
2020-08-24 22:51:58 -04:00
|
|
|
<div class="control-unit">
|
|
|
|
{{#if model.remote_theme.is_git}}
|
2021-02-17 10:24:34 -05:00
|
|
|
<div class="alert alert-info">
|
|
|
|
{{html-safe (i18n "admin.customize.theme.remote_theme_edits" repoURL=remoteThemeLink)}}
|
|
|
|
</div>
|
2019-02-08 08:01:14 -05:00
|
|
|
|
2020-08-24 22:51:58 -04:00
|
|
|
{{#if showRemoteError}}
|
|
|
|
<div class="error-message">
|
|
|
|
{{d-icon "exclamation-triangle"}} {{i18n "admin.customize.theme.repo_unreachable"}}
|
|
|
|
</div>
|
|
|
|
<div class="raw-error">
|
|
|
|
<code>{{model.remoteError}}</code>
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
2019-02-08 08:01:14 -05:00
|
|
|
|
2020-08-24 22:51:58 -04:00
|
|
|
{{#if model.remote_theme.commits_behind}}
|
|
|
|
{{d-button action=(action "updateToLatest") icon="download" class="btn-primary" label="admin.customize.theme.update_to_latest"}}
|
2019-12-04 01:13:41 -05:00
|
|
|
{{else}}
|
2020-08-24 22:51:58 -04:00
|
|
|
{{d-button action=(action "checkForThemeUpdates") icon="sync" class="btn-default" label="admin.customize.theme.check_for_updates"}}
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
<span class="status-message">
|
|
|
|
{{#if updatingRemote}}
|
|
|
|
{{i18n "admin.customize.theme.updating"}}
|
2019-12-04 01:13:41 -05:00
|
|
|
{{else}}
|
2020-08-24 22:51:58 -04:00
|
|
|
{{#if model.remote_theme.commits_behind}}
|
2020-11-23 08:29:22 -05:00
|
|
|
{{#if hasOverwrittenHistory}}
|
|
|
|
{{i18n "admin.customize.theme.has_overwritten_history"}}
|
|
|
|
{{else}}
|
|
|
|
{{i18n "admin.customize.theme.commits_behind" count=model.remote_theme.commits_behind}}
|
|
|
|
{{/if}}
|
2020-08-24 22:51:58 -04:00
|
|
|
{{#if model.remote_theme.github_diff_link}}
|
|
|
|
<a href={{model.remote_theme.github_diff_link}}>
|
|
|
|
{{i18n "admin.customize.theme.compare_commits"}}
|
|
|
|
</a>
|
|
|
|
{{/if}}
|
|
|
|
{{else}}
|
|
|
|
{{#unless showRemoteError}}
|
|
|
|
{{i18n "admin.customize.theme.up_to_date"}} {{format-date model.remote_theme.updated_at leaveAgo="true"}}
|
|
|
|
{{/unless}}
|
|
|
|
{{/if}}
|
2019-01-25 09:19:01 -05:00
|
|
|
{{/if}}
|
2020-08-24 22:51:58 -04:00
|
|
|
</span>
|
|
|
|
{{else}}
|
|
|
|
<span class="status-message">
|
|
|
|
{{d-icon "info-circle"}} {{i18n "admin.customize.theme.imported_from_archive"}}
|
|
|
|
</span>
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
{{else}}
|
2020-09-25 20:34:29 -04:00
|
|
|
<span class="heading">{{i18n "admin.customize.theme.creator"}}</span>
|
|
|
|
<span>
|
|
|
|
{{#user-link user=model.user}}
|
|
|
|
{{format-username model.user.username}}
|
|
|
|
{{/user-link}}
|
|
|
|
</span>
|
2020-08-24 22:51:58 -04:00
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
|
2020-11-16 07:44:09 -05:00
|
|
|
{{#if showCheckboxes}}
|
2020-04-30 10:02:38 -04:00
|
|
|
<div class="control-unit">
|
2020-11-16 07:44:09 -05:00
|
|
|
{{#unless model.component}}
|
2020-11-24 05:10:28 -05:00
|
|
|
{{inline-edit-checkbox action=(action "applyDefault") labelKey="admin.customize.theme.is_default" checked=model.default modelId=model.id}}
|
|
|
|
{{inline-edit-checkbox action=(action "applyUserSelectable") labelKey="admin.customize.theme.user_selectable" checked=model.user_selectable modelId=model.id}}
|
2020-11-16 07:44:09 -05:00
|
|
|
{{/unless}}
|
|
|
|
{{#if model.remote_theme}}
|
2020-11-24 05:10:28 -05:00
|
|
|
{{inline-edit-checkbox action=(action "applyAutoUpdateable") labelKey="admin.customize.theme.auto_update" checked=model.auto_update modelId=model.id}}
|
2020-11-16 07:44:09 -05:00
|
|
|
{{/if}}
|
2020-04-30 10:02:38 -04:00
|
|
|
</div>
|
2020-11-16 07:44:09 -05:00
|
|
|
{{/if}}
|
2020-08-24 22:51:58 -04:00
|
|
|
|
2018-08-23 21:30:00 -04:00
|
|
|
{{#unless model.component}}
|
2020-08-24 22:51:58 -04:00
|
|
|
{{#d-section class="form-horizontal theme settings control-unit"}}
|
2019-12-04 01:13:41 -05:00
|
|
|
<div class="row setting">
|
|
|
|
<div class="setting-label">
|
|
|
|
{{i18n "admin.customize.theme.color_scheme"}}
|
|
|
|
</div>
|
|
|
|
<div class="setting-value">
|
|
|
|
{{color-palettes
|
|
|
|
content=colorSchemes
|
|
|
|
value=colorSchemeId
|
2022-04-05 13:01:09 -04:00
|
|
|
icon="paint-brush"
|
|
|
|
options=(hash
|
|
|
|
filterable=true
|
|
|
|
)
|
|
|
|
}}
|
2019-02-08 08:01:14 -05:00
|
|
|
|
2019-12-04 01:13:41 -05:00
|
|
|
<div class="desc">{{i18n "admin.customize.theme.color_scheme_select"}}</div>
|
|
|
|
</div>
|
|
|
|
<div class="setting-controls">
|
|
|
|
{{#if colorSchemeChanged}}
|
|
|
|
{{d-button action=(action "changeScheme") class="ok submit-edit" icon="check"}}
|
|
|
|
{{d-button action=(action "cancelChangeScheme") class="cancel cancel-edit" icon="times"}}
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
2018-08-30 15:23:15 -04:00
|
|
|
</div>
|
2019-12-04 01:13:41 -05:00
|
|
|
{{/d-section}}
|
2018-08-23 21:30:00 -04:00
|
|
|
{{/unless}}
|
|
|
|
|
2019-01-25 09:19:01 -05:00
|
|
|
{{#if parentThemes}}
|
|
|
|
<div class="control-unit">
|
|
|
|
<div class="mini-title">{{i18n "admin.customize.theme.component_of"}}</div>
|
|
|
|
<ul>
|
|
|
|
{{#each parentThemes as |theme|}}
|
|
|
|
<li>{{#link-to "adminCustomizeThemes.show" theme replace=true}}{{theme.name}}{{/link-to}}</li>
|
|
|
|
{{/each}}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
|
|
|
|
2019-12-04 01:13:41 -05:00
|
|
|
{{#if model.component}}
|
2020-08-24 22:51:58 -04:00
|
|
|
{{#d-section class="form-horizontal theme settings control-unit"}}
|
2019-12-04 01:13:41 -05:00
|
|
|
<div class="row setting">
|
|
|
|
{{theme-setting-relatives-selector setting=relativesSelectorSettingsForComponent model=model class="theme-setting"}}
|
|
|
|
</div>
|
|
|
|
{{/d-section}}
|
|
|
|
{{else}}
|
2020-08-24 22:51:58 -04:00
|
|
|
{{#d-section class="form-horizontal theme settings control-unit"}}
|
2019-12-04 01:13:41 -05:00
|
|
|
<div class="row setting">
|
|
|
|
{{theme-setting-relatives-selector setting=relativesSelectorSettingsForTheme model=model class="theme-setting"}}
|
|
|
|
</div>
|
|
|
|
{{/d-section}}
|
2019-11-28 00:19:01 -05:00
|
|
|
{{/if}}
|
|
|
|
|
2020-12-09 14:41:42 -05:00
|
|
|
{{#unless model.remote_theme.is_git}}
|
2020-11-13 10:57:49 -05:00
|
|
|
<div class="control-unit">
|
|
|
|
<div class="mini-title">{{i18n "admin.customize.theme.css_html"}}</div>
|
|
|
|
{{#if model.hasEditedFields}}
|
|
|
|
<div class="description">{{i18n "admin.customize.theme.custom_sections"}}</div>
|
|
|
|
<ul>
|
|
|
|
{{#each editedFieldsFormatted as |field|}}
|
|
|
|
<li>{{field}}</li>
|
|
|
|
{{/each}}
|
|
|
|
</ul>
|
|
|
|
{{else}}
|
|
|
|
<div class="description">
|
|
|
|
{{i18n "admin.customize.theme.edit_css_html_help"}}
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
2018-08-23 21:30:00 -04:00
|
|
|
|
2020-11-13 10:57:49 -05:00
|
|
|
{{d-button
|
|
|
|
class="btn-default edit"
|
|
|
|
action=(action "editTheme")
|
|
|
|
label="admin.customize.theme.edit_css_html"}}
|
|
|
|
</div>
|
2017-05-09 17:20:28 -04:00
|
|
|
|
2020-11-13 10:57:49 -05:00
|
|
|
<div class="control-unit">
|
|
|
|
<div class="mini-title">{{i18n "admin.customize.theme.uploads"}}</div>
|
|
|
|
{{#if model.uploads}}
|
|
|
|
<ul class="removable-list">
|
|
|
|
{{#each model.uploads as |upload|}}
|
|
|
|
<li>
|
|
|
|
<span class="col">${{upload.name}}: <a href={{upload.url}} rel="noopener noreferrer" target="_blank">{{upload.filename}}</a></span>
|
|
|
|
<span class="col">
|
|
|
|
{{d-button action=(action "removeUpload") actionParam=upload class="second btn-default btn-default cancel-edit" icon="times"}}
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
{{/each}}
|
|
|
|
</ul>
|
|
|
|
{{else}}
|
|
|
|
<div class="description">{{i18n "admin.customize.theme.no_uploads"}}</div>
|
|
|
|
{{/if}}
|
|
|
|
{{d-button action=(action "addUploadModal") class="btn-default" icon="plus" label="admin.customize.theme.add"}}
|
|
|
|
</div>
|
|
|
|
{{/unless}}
|
2017-05-09 17:20:28 -04:00
|
|
|
|
2020-04-30 10:02:38 -04:00
|
|
|
{{#if extraFiles.length}}
|
|
|
|
<div class="control-unit">
|
|
|
|
<div class="mini-title">{{i18n "admin.customize.theme.extra_files"}}</div>
|
2020-05-01 14:19:17 -04:00
|
|
|
<details>
|
|
|
|
<summary>
|
|
|
|
{{#if model.remote_theme}}
|
|
|
|
{{i18n "admin.customize.theme.extra_files_remote"}}
|
|
|
|
{{else}}
|
|
|
|
{{i18n "admin.customize.theme.extra_files_upload"}}
|
|
|
|
{{/if}}
|
|
|
|
</summary>
|
|
|
|
<ul>
|
|
|
|
{{#each extraFiles as |extraFile|}}
|
|
|
|
<li>{{extraFile.name}}</li>
|
|
|
|
{{/each}}
|
|
|
|
</ul>
|
|
|
|
</details>
|
2020-04-30 10:02:38 -04:00
|
|
|
</div>
|
|
|
|
{{/if}}
|
|
|
|
|
2018-03-04 19:11:21 -05:00
|
|
|
{{#if hasSettings}}
|
2018-08-30 15:23:15 -04:00
|
|
|
<div class="control-unit">
|
|
|
|
<div class="mini-title">{{i18n "admin.customize.theme.theme_settings"}}</div>
|
2020-08-24 22:51:58 -04:00
|
|
|
{{#d-section class="form-horizontal theme settings control-unit"}}
|
2018-08-30 15:23:15 -04:00
|
|
|
{{#each settings as |setting|}}
|
2020-09-25 20:34:29 -04:00
|
|
|
{{theme-setting-editor setting=setting model=model class="theme-setting control-unit"}}
|
2019-01-17 06:46:11 -05:00
|
|
|
{{/each}}
|
|
|
|
{{/d-section}}
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{#if hasTranslations}}
|
|
|
|
<div class="control-unit">
|
|
|
|
<div class="mini-title">{{i18n "admin.customize.theme.theme_translations"}}</div>
|
2020-08-24 22:51:58 -04:00
|
|
|
{{#d-section class="form-horizontal theme settings translations control-unit"}}
|
2019-01-17 06:46:11 -05:00
|
|
|
{{#each translations as |translation|}}
|
|
|
|
{{theme-translation translation=translation model=model class="theme-translation"}}
|
2018-08-30 15:23:15 -04:00
|
|
|
{{/each}}
|
|
|
|
{{/d-section}}
|
|
|
|
</div>
|
2018-03-04 19:11:21 -05:00
|
|
|
{{/if}}
|
2018-03-04 19:04:23 -05:00
|
|
|
|
2020-08-24 22:51:58 -04:00
|
|
|
<div class="theme-controls">
|
2020-09-25 20:34:29 -04:00
|
|
|
|
2020-08-24 22:51:58 -04:00
|
|
|
<a href={{previewUrl}} title={{i18n "admin.customize.explain_preview"}} rel="noopener noreferrer" target="_blank" class="btn btn-default">{{d-icon "desktop"}}{{i18n "admin.customize.theme.preview"}}</a>
|
|
|
|
<a class="btn btn-default export" rel="noopener noreferrer" target="_blank" href={{downloadUrl}}>{{d-icon "download"}} {{i18n "admin.export_json.button_text"}}</a>
|
2017-04-12 10:52:52 -04:00
|
|
|
|
2021-02-10 19:20:13 -05:00
|
|
|
{{#if showConvert}}
|
2021-01-11 18:01:55 -05:00
|
|
|
{{d-button action=(action "switchType") label="admin.customize.theme.convert" icon=convertIcon class="btn-default btn-normal" title=convertTooltip}}
|
2021-02-10 19:20:13 -05:00
|
|
|
{{/if}}
|
2019-07-03 04:18:11 -04:00
|
|
|
|
2020-08-24 22:51:58 -04:00
|
|
|
{{#if model.component}}
|
|
|
|
{{#if model.enabled}}
|
|
|
|
{{d-button
|
|
|
|
class="btn-default"
|
|
|
|
action=(action "disableComponent")
|
|
|
|
icon="ban"
|
|
|
|
label="admin.customize.theme.disable"}}
|
|
|
|
{{else}}
|
|
|
|
{{d-button
|
|
|
|
class="btn-default"
|
|
|
|
action=(action "enableComponent")
|
|
|
|
icon="check"
|
|
|
|
label="admin.customize.theme.enable"}}
|
|
|
|
{{/if}}
|
2019-07-03 04:18:11 -04:00
|
|
|
{{/if}}
|
|
|
|
|
2020-08-24 22:51:58 -04:00
|
|
|
{{d-button action=(action "destroy") label="admin.customize.delete" icon="trash-alt" class="btn-danger"}}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2017-04-12 10:52:52 -04:00
|
|
|
</div>
|