{{define "headScripts"}}<script src="/_/page/actions.js"></script>{{end}}

{{define "headerActions"}}{{if .CanEdit}}
<span class="dropdown">
    <button type="button" class="btn" data-action="page-actions" aria-haspopup="true" aria-expanded="false" title="Page actions">ACTIONS</button>
    <div class="dropdown-menu align-right">
        <button class="btn btn-block" onclick="newPage()" title="New page (N)">NEW PAGE</button>
        <a class="btn btn-block" href="?edit" title="Edit page (E)">EDIT PAGE</a>
        <button class="btn btn-block" data-companion-reveal hidden title="Reveal in file manager">REVEAL ON CLIENT</button>
        {{if not .IsRoot}}
        <button class="btn btn-block" onclick="movePage()" title="Move page (M)">MOVE PAGE</button>
        {{end}}
        {{if not .IsRoot}}
        <button class="btn btn-block danger" onclick="deletePage()" title="Delete page">DELETE PAGE</button>
        {{end}}
    </div>
</span>
<script src="/_/page/header-actions.js"></script>
{{end}}{{end}}

{{define "content"}}
{{if .Content}}
<div class="content">{{.Content}}</div>
{{end}}
{{if .SpecialContent}}
<div class="content">{{.SpecialContent}}</div>
{{end}}
{{if .Entries}}
<h2 id="files">Files <button class="btn btn-small" data-companion-reveal hidden title="Open folder in file manager">open</button>{{if .CanEdit}} <button class="btn btn-small" id="view-settings-btn" onclick="openViewSettings()" title="View &amp; sorting" data-view="{{.View}}" data-sort="{{.Sort}}" data-order="{{.Order}}">view</button>{{end}}</h2>
{{if eq .View "thumbnail"}}
<div class="thumb-grid">
    {{range .Entries}}
    <a class="thumb-tile" href="{{.URL}}" title="{{.Name}}">
        {{if .ThumbURL}}<span class="thumb-media"><img class="thumb-img" src="{{.ThumbURL}}" alt="" loading="lazy" width="300">{{if .IsVideo}}<span class="thumb-play" aria-hidden="true">▶</span>{{end}}</span>{{else}}<span class="thumb-icon">{{.Icon}}</span>{{end}}
        <span class="thumb-label truncate">{{.Name}}</span>
    </a>
    {{end}}
</div>
{{else}}
<table class="data-table panel">
    <tbody>
    {{range .Entries}}
    <tr class="list-item" data-path="{{.URL}}">
        <td class="icon">{{.Icon}}</td>
        <td class="name"><a href="{{.URL}}">{{.Name}}</a></td>
        <td class="meta">{{.Meta}}</td>
    </tr>
    {{end}}
    </tbody>
</table>
{{end}}
{{if .CanEdit}}<script src="/_/page/view-settings.js"></script>{{end}}
{{else if not .Content}}
{{if not .SpecialContent}}
<p class="empty">Empty folder — <a href="?edit">[CREATE]</a></p>
{{end}}
{{end}}
{{if or .Content .SpecialContent}}
<script src="/_/page/content.js"></script>
<script src="/_/page/anchors.js"></script>
{{if not .SuppressTOC}}<script src="/_/page/toc.js"></script>{{end}}
<script src="/_/page/tasks.js"></script>
{{end}}
{{if .Content}}
<script src="/_/page/sections.js"></script>
{{end}}
<script src="/_/page/sidebar-fab.js"></script>
{{end}}

{{define "sidebar"}}{{if .SidebarWidget}}{{.SidebarWidget}}{{end}}{{end}}
