Skip to content

Commit 3eb48a7

Browse files
compscidrclaude
andcommitted
Show plugin-disabled status on admin pages
Admin pages list (/admin/pages): - Rows for pages with disabled plugins highlighted in yellow - "plugin disabled" badge shown next to the page type - Enabled column shows "Plugin disabled" instead of Yes/No Admin page editor (/admin/pages/:id): - Warning banner at top when the page's plugin is disabled, with link to Settings to enable it - Removed scholar-specific Google Scholar ID field (now in plugin settings) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent abe8e42 commit 3eb48a7

7 files changed

Lines changed: 75 additions & 47 deletions

File tree

admin/admin.go

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ func (a *Admin) getPluginSettings(c *gin.Context) interface{} {
6767
return nil
6868
}
6969

70+
// getDisabledPluginPageTypes returns a map of page types that belong to disabled plugins.
71+
func (a *Admin) getDisabledPluginPageTypes(c *gin.Context) map[string]bool {
72+
result := make(map[string]bool)
73+
if reg, exists := c.Get("plugin_registry"); exists {
74+
if r, ok := reg.(*gplugin.Registry); ok {
75+
for _, p := range r.Plugins() {
76+
for _, page := range p.Pages() {
77+
if !r.IsPluginEnabled(p.Name()) {
78+
result[page.PageType] = true
79+
}
80+
}
81+
}
82+
}
83+
}
84+
return result
85+
}
86+
7087
// UpdatePluginSettings saves plugin settings via the plugin registry.
7188
func (a *Admin) UpdatePluginSettings(c *gin.Context) {
7289
if !a.auth.IsAdmin(c) {
@@ -882,14 +899,15 @@ func (a *Admin) AdminPages(c *gin.Context) {
882899
var pages []blog.Page
883900
(*a.db).Order("nav_order asc").Find(&pages)
884901
c.HTML(http.StatusOK, "admin_pages.html", gin.H{
885-
"pages": pages,
886-
"logged_in": a.auth.IsLoggedIn(c),
887-
"is_admin": a.auth.IsAdmin(c),
888-
"version": a.version,
889-
"recent": a.b.GetLatest(),
890-
"admin_page": true,
891-
"settings": a.b.GetSettings(),
892-
"nav_pages": a.b.GetNavPages(),
902+
"pages": pages,
903+
"logged_in": a.auth.IsLoggedIn(c),
904+
"is_admin": a.auth.IsAdmin(c),
905+
"version": a.version,
906+
"recent": a.b.GetLatest(),
907+
"admin_page": true,
908+
"settings": a.b.GetSettings(),
909+
"nav_pages": a.b.GetNavPages(),
910+
"disabled_plugin_pages": a.getDisabledPluginPageTypes(c),
893911
})
894912
}
895913

@@ -928,15 +946,16 @@ func (a *Admin) AdminEditPage(c *gin.Context) {
928946
}
929947

930948
c.HTML(http.StatusOK, "admin_edit_page.html", gin.H{
931-
"page": page,
932-
"post_types": a.b.GetPostTypes(),
933-
"logged_in": a.auth.IsLoggedIn(c),
934-
"is_admin": a.auth.IsAdmin(c),
935-
"version": a.version,
936-
"recent": a.b.GetLatest(),
937-
"admin_page": true,
938-
"settings": a.b.GetSettings(),
939-
"nav_pages": a.b.GetNavPages(),
949+
"page": page,
950+
"post_types": a.b.GetPostTypes(),
951+
"logged_in": a.auth.IsLoggedIn(c),
952+
"is_admin": a.auth.IsAdmin(c),
953+
"version": a.version,
954+
"recent": a.b.GetLatest(),
955+
"admin_page": true,
956+
"settings": a.b.GetSettings(),
957+
"nav_pages": a.b.GetNavPages(),
958+
"disabled_plugin_pages": a.getDisabledPluginPageTypes(c),
940959
})
941960
}
942961

themes/default/templates/admin_edit_page.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ <h1>Edit Page: {{ .page.Title }}</h1>
66
<div id="ajax-error" class="alert alert-danger" role="alert" style="display: none;"></div>
77
<div id="ajax-success" class="alert alert-success" role="alert" style="display: none;"></div>
88

9+
{{ $disabledPlugins := .disabled_plugin_pages }}
10+
{{ if index $disabledPlugins .page.PageType }}
11+
<div class="alert alert-warning" role="alert">
12+
<strong>Plugin disabled.</strong> This page's type (<code>{{ .page.PageType }}</code>) is provided by a plugin that is currently disabled.
13+
The page will not be visible to visitors until the plugin is enabled in <a href="/admin/settings">Settings</a>.
14+
</div>
15+
{{ end }}
16+
917
<form id="page-form">
1018
<div class="mb-3">
1119
<label for="title" class="form-label">Title</label>
@@ -56,11 +64,6 @@ <h1>Edit Page: {{ .page.Title }}</h1>
5664
</select>
5765
</div>
5866

59-
<div class="mb-3" id="scholar-section" style="{{ if ne .page.PageType "research" }}display:none;{{ end }}">
60-
<label for="scholar_id" class="form-label">Google Scholar ID</label>
61-
<input type="text" class="form-control" id="scholar_id" value="{{ .page.ScholarID }}">
62-
</div>
63-
6467
<div class="mb-3" id="content-section" style="{{ if or (eq .page.PageType "writing") (eq .page.PageType "research") (eq .page.PageType "tags") (eq .page.PageType "archives") }}display:none;{{ end }}">
6568
<label for="content" class="form-label">Content (Markdown)</label>
6669
<textarea rows="15" class="form-control" id="content">{{ .page.Content }}</textarea>
@@ -100,7 +103,6 @@ <h1>Edit Page: {{ .page.Title }}</h1>
100103

101104
document.getElementById('page_type').addEventListener('change', function() {
102105
var type = this.value;
103-
document.getElementById('scholar-section').style.display = (type === 'research') ? '' : 'none';
104106
document.getElementById('content-section').style.display = (type === 'writing' || type === 'research' || type === 'tags' || type === 'archives') ? 'none' : '';
105107
document.getElementById('post-type-filter-section').style.display = (type === 'writing') ? '' : 'none';
106108
});
@@ -117,7 +119,6 @@ <h1>Edit Page: {{ .page.Title }}</h1>
117119
"hero_url": document.getElementById('hero_url').value,
118120
"hero_type": document.getElementById('hero_type').value,
119121
"content": document.getElementById('content').value,
120-
"scholar_id": document.getElementById('scholar_id').value,
121122
"nav_order": parseInt(document.getElementById('nav_order').value) || 0,
122123
"show_in_nav": document.getElementById('show_in_nav').checked,
123124
"enabled": document.getElementById('enabled').checked,

themes/default/templates/admin_pages.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ <h1>Pages</h1>
1818
</tr>
1919
</thead>
2020
<tbody>
21+
{{ $disabledPlugins := .disabled_plugin_pages }}
2122
{{ range .pages }}
22-
<tr>
23+
{{ $pluginDisabled := index $disabledPlugins .PageType }}
24+
<tr {{ if $pluginDisabled }}class="table-warning"{{ end }}>
2325
<td><a href="/admin/pages/{{ .ID }}">{{ .Title }}</a></td>
2426
<td>/{{ .Slug }}</td>
25-
<td>{{ .PageType }}</td>
27+
<td>{{ .PageType }}{{ if $pluginDisabled }} <span class="badge bg-warning text-dark">plugin disabled</span>{{ end }}</td>
2628
<td>{{ .NavOrder }}</td>
2729
<td>{{ if .ShowInNav }}Yes{{ else }}No{{ end }}</td>
28-
<td>{{ if .Enabled }}Yes{{ else }}No{{ end }}</td>
30+
<td>{{ if $pluginDisabled }}<span class="text-warning">Plugin disabled</span>{{ else if .Enabled }}Yes{{ else }}No{{ end }}</td>
2931
<td>
3032
<a href="/admin/pages/{{ .ID }}" class="btn btn-sm btn-outline-primary">Edit</a>
3133
<button class="btn btn-sm btn-outline-danger" onclick="deletePage({{ .ID }})">Delete</button>

themes/forest/templates/admin_edit_page.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ <h1>Edit Page: {{ .page.Title }}</h1>
66
<div id="ajax-error" class="alert alert-danger" role="alert" style="display: none;"></div>
77
<div id="ajax-success" class="alert alert-success" role="alert" style="display: none;"></div>
88

9+
{{ $disabledPlugins := .disabled_plugin_pages }}
10+
{{ if index $disabledPlugins .page.PageType }}
11+
<div class="alert alert-warning" role="alert">
12+
<strong>Plugin disabled.</strong> This page's type (<code>{{ .page.PageType }}</code>) is provided by a plugin that is currently disabled.
13+
The page will not be visible to visitors until the plugin is enabled in <a href="/admin/settings">Settings</a>.
14+
</div>
15+
{{ end }}
16+
917
<form id="page-form">
1018
<div class="mb-3">
1119
<label for="title" class="form-label">Title</label>
@@ -56,11 +64,6 @@ <h1>Edit Page: {{ .page.Title }}</h1>
5664
</select>
5765
</div>
5866

59-
<div class="mb-3" id="scholar-section" style="{{ if ne .page.PageType "research" }}display:none;{{ end }}">
60-
<label for="scholar_id" class="form-label">Google Scholar ID</label>
61-
<input type="text" class="form-control" id="scholar_id" value="{{ .page.ScholarID }}">
62-
</div>
63-
6467
<div class="mb-3" id="content-section" style="{{ if or (eq .page.PageType "writing") (eq .page.PageType "research") (eq .page.PageType "tags") (eq .page.PageType "archives") }}display:none;{{ end }}">
6568
<label for="content" class="form-label">Content (Markdown)</label>
6669
<textarea rows="15" class="form-control" id="content">{{ .page.Content }}</textarea>
@@ -100,7 +103,6 @@ <h1>Edit Page: {{ .page.Title }}</h1>
100103

101104
document.getElementById('page_type').addEventListener('change', function() {
102105
var type = this.value;
103-
document.getElementById('scholar-section').style.display = (type === 'research') ? '' : 'none';
104106
document.getElementById('content-section').style.display = (type === 'writing' || type === 'research' || type === 'tags' || type === 'archives') ? 'none' : '';
105107
document.getElementById('post-type-filter-section').style.display = (type === 'writing') ? '' : 'none';
106108
});
@@ -117,7 +119,6 @@ <h1>Edit Page: {{ .page.Title }}</h1>
117119
"hero_url": document.getElementById('hero_url').value,
118120
"hero_type": document.getElementById('hero_type').value,
119121
"content": document.getElementById('content').value,
120-
"scholar_id": document.getElementById('scholar_id').value,
121122
"nav_order": parseInt(document.getElementById('nav_order').value) || 0,
122123
"show_in_nav": document.getElementById('show_in_nav').checked,
123124
"enabled": document.getElementById('enabled').checked,

themes/forest/templates/admin_pages.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ <h1>Pages</h1>
1818
</tr>
1919
</thead>
2020
<tbody>
21+
{{ $disabledPlugins := .disabled_plugin_pages }}
2122
{{ range .pages }}
22-
<tr>
23+
{{ $pluginDisabled := index $disabledPlugins .PageType }}
24+
<tr {{ if $pluginDisabled }}class="table-warning"{{ end }}>
2325
<td><a href="/admin/pages/{{ .ID }}">{{ .Title }}</a></td>
2426
<td>/{{ .Slug }}</td>
25-
<td>{{ .PageType }}</td>
27+
<td>{{ .PageType }}{{ if $pluginDisabled }} <span class="badge bg-warning text-dark">plugin disabled</span>{{ end }}</td>
2628
<td>{{ .NavOrder }}</td>
2729
<td>{{ if .ShowInNav }}Yes{{ else }}No{{ end }}</td>
28-
<td>{{ if .Enabled }}Yes{{ else }}No{{ end }}</td>
30+
<td>{{ if $pluginDisabled }}<span class="text-warning">Plugin disabled</span>{{ else if .Enabled }}Yes{{ else }}No{{ end }}</td>
2931
<td>
3032
<a href="/admin/pages/{{ .ID }}" class="btn btn-sm btn-outline-primary">Edit</a>
3133
<button class="btn btn-sm btn-outline-danger" onclick="deletePage({{ .ID }})">Delete</button>

themes/minimal/templates/admin_edit_page.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ <h1>Edit Page: {{ .page.Title }}</h1>
66
<div id="ajax-error" class="alert alert-danger" role="alert" style="display: none;"></div>
77
<div id="ajax-success" class="alert alert-success" role="alert" style="display: none;"></div>
88

9+
{{ $disabledPlugins := .disabled_plugin_pages }}
10+
{{ if index $disabledPlugins .page.PageType }}
11+
<div class="alert alert-warning" role="alert">
12+
<strong>Plugin disabled.</strong> This page's type (<code>{{ .page.PageType }}</code>) is provided by a plugin that is currently disabled.
13+
The page will not be visible to visitors until the plugin is enabled in <a href="/admin/settings">Settings</a>.
14+
</div>
15+
{{ end }}
16+
917
<form id="page-form">
1018
<div class="mb-3">
1119
<label for="title" class="form-label">Title</label>
@@ -56,11 +64,6 @@ <h1>Edit Page: {{ .page.Title }}</h1>
5664
</select>
5765
</div>
5866

59-
<div class="mb-3" id="scholar-section" style="{{ if ne .page.PageType "research" }}display:none;{{ end }}">
60-
<label for="scholar_id" class="form-label">Google Scholar ID</label>
61-
<input type="text" class="form-control" id="scholar_id" value="{{ .page.ScholarID }}">
62-
</div>
63-
6467
<div class="mb-3" id="content-section" style="{{ if or (eq .page.PageType "writing") (eq .page.PageType "research") (eq .page.PageType "tags") (eq .page.PageType "archives") }}display:none;{{ end }}">
6568
<label for="content" class="form-label">Content (Markdown)</label>
6669
<textarea rows="15" class="form-control" id="content">{{ .page.Content }}</textarea>
@@ -100,7 +103,6 @@ <h1>Edit Page: {{ .page.Title }}</h1>
100103

101104
document.getElementById('page_type').addEventListener('change', function() {
102105
var type = this.value;
103-
document.getElementById('scholar-section').style.display = (type === 'research') ? '' : 'none';
104106
document.getElementById('content-section').style.display = (type === 'writing' || type === 'research' || type === 'tags' || type === 'archives') ? 'none' : '';
105107
document.getElementById('post-type-filter-section').style.display = (type === 'writing') ? '' : 'none';
106108
});
@@ -117,7 +119,6 @@ <h1>Edit Page: {{ .page.Title }}</h1>
117119
"hero_url": document.getElementById('hero_url').value,
118120
"hero_type": document.getElementById('hero_type').value,
119121
"content": document.getElementById('content').value,
120-
"scholar_id": document.getElementById('scholar_id').value,
121122
"nav_order": parseInt(document.getElementById('nav_order').value) || 0,
122123
"show_in_nav": document.getElementById('show_in_nav').checked,
123124
"enabled": document.getElementById('enabled').checked,

themes/minimal/templates/admin_pages.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ <h1>Pages</h1>
1818
</tr>
1919
</thead>
2020
<tbody>
21+
{{ $disabledPlugins := .disabled_plugin_pages }}
2122
{{ range .pages }}
22-
<tr>
23+
{{ $pluginDisabled := index $disabledPlugins .PageType }}
24+
<tr {{ if $pluginDisabled }}class="table-warning"{{ end }}>
2325
<td><a href="/admin/pages/{{ .ID }}">{{ .Title }}</a></td>
2426
<td>/{{ .Slug }}</td>
25-
<td>{{ .PageType }}</td>
27+
<td>{{ .PageType }}{{ if $pluginDisabled }} <span class="badge bg-warning text-dark">plugin disabled</span>{{ end }}</td>
2628
<td>{{ .NavOrder }}</td>
2729
<td>{{ if .ShowInNav }}Yes{{ else }}No{{ end }}</td>
28-
<td>{{ if .Enabled }}Yes{{ else }}No{{ end }}</td>
30+
<td>{{ if $pluginDisabled }}<span class="text-warning">Plugin disabled</span>{{ else if .Enabled }}Yes{{ else }}No{{ end }}</td>
2931
<td>
3032
<a href="/admin/pages/{{ .ID }}" class="btn btn-sm btn-outline-primary">Edit</a>
3133
<button class="btn btn-sm btn-outline-danger" onclick="deletePage({{ .ID }})">Delete</button>

0 commit comments

Comments
 (0)