Skip to content

Commit

Permalink
Fix theme from upstream (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
abtris authored Jul 11, 2024
2 parents 25b73f6 + c18daf8 commit 7f8cabc
Show file tree
Hide file tree
Showing 18 changed files with 225 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ resources/_gen
.hugo_build.lock
.vscode
.DS_Store

# Local Netlify folder
.netlify
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
command = "hugo --gc --minify -b $URL"

[build.environment]
HUGO_VERSION = "0.122.0"
HUGO_VERSION = "0.128.2"
HUGO_ENABLEGITINFO = "true"

[context.production.environment]
Expand Down
3 changes: 2 additions & 1 deletion themes/academia/layouts/authors/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ <h1 itemprop="name">{{ .Title }}</h1>
{{/* Show the About widget if an account exists for this user. */}}
{{ if .File }}
{{ $widget := "widgets/about.html" }}
{{ $username := (path.Base (path.Split .Path).Dir) }}{{/* Alternatively, use `index .Params.authors 0` */}}
{{ $baseExcluded := strings.TrimLeft site.BaseURL .Permalink }}
{{ $username := index (split $baseExcluded "/") 1 }}
{{ $params := dict "root" $ "page" . "author" $username }}
{{ partial $widget $params }}
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion themes/academia/layouts/partials/comments.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ if and site.DisqusShortname (not (or site.Params.disable_comments .Params.disable_comments)) }}
{{ if and site.Config.Services.Disqus.Shortname (not (or site.Params.disable_comments .Params.disable_comments)) }}
<section id="comments">
{{ template "_internal/disqus.html" . }}
</section>
Expand Down
5 changes: 4 additions & 1 deletion themes/academia/layouts/partials/docs_sidebar.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{{ $current_page := . }}

{{/* Dynamically load menu for this docs page. */}}
{{ $menu_name := path.Base (path.Split .CurrentSection.File).Dir }}
{{/* {{ $menu_name := path.Base (path.Split .CurrentSection.File).Dir }} */}}
{{ $baseExcluded := strings.TrimLeft site.BaseURL .Permalink }}
{{ $menu_name := index (split $baseExcluded "/") 1 }}

{{ if not (index site.Menus $menu_name) }}
{{ errorf "Please define menu items named `menu: %s:` in your %s front matter or define `[[menu.%s]]` in `config/default/menus.toml`. See https://sourcethemes.com/academic/docs/managing-content/#menus" $menu_name .Path $menu_name }}
{{ end }}
Expand Down
4 changes: 2 additions & 2 deletions themes/academia/layouts/partials/li_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{{ end }}

<div class="card-simple" itemscope itemtype="http://schema.org/{{$microdata_type}}">
{{ $resource := ($item.Resources.ByType "image").GetMatch "*page-featured*" }}
{{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }}
{{ $anchor := $item.Params.image.focal_point | default "Smart" }}
{{ with $resource }}
{{ $image := .Fill (printf "918x517 q90 %s" $anchor) }}
Expand Down Expand Up @@ -78,4 +78,4 @@ <h3 class="article-title mb-1 mt-0" itemprop="name">
</div>
{{ end }}
</div>
</div>
</div>
6 changes: 2 additions & 4 deletions themes/academia/layouts/partials/li_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
{{ $show_buttons = true }}
{{ end }}

<div class="view-list-item" itemscope itemtype="http://schema.org/{{$microdata_type}}">
<div class="view-list-item col-lg-8 mx-auto" itemscope itemtype="http://schema.org/{{$microdata_type}}">
<i class="far {{$icon}} pub-icon" aria-hidden="true"></i>
<a href="{{ $item.RelPermalink }}" itemprop="url"><span itemprop="name">{{ $item.Title }}</span></a>
{{ if eq $item.Type "post" }}
<div class="postListSummary">{{ $item.Summary }}</div>
{{ end }}

{{ if eq $item.Type "talk" }}
<div class="article-metadata">
<span itemprop="startDate">
Expand Down
4 changes: 1 addition & 3 deletions themes/academia/layouts/partials/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
{{- end -}}
</a>
{{ if or site.Menus.main .IsTranslated }}
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="{{ i18n "toggle_navigation" }}"><span><i class="fas fa-bars"></i></span>
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="{{ i18n `toggle_navigation` }}"><span><i class="fas fa-bars"></i></span>
</button>
{{ end }}

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbar">

<!-- Left Nav Bar -->
{{ $align_right := site.Params.menu_align_right | default true }}
<ul class="navbar-nav {{ if $align_right }}ml-auto{{ else }}mr-auto{{ end }}">
Expand Down Expand Up @@ -127,7 +126,6 @@
{{ end }}

</ul>

</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
2 changes: 1 addition & 1 deletion themes/academia/layouts/partials/page_links_div.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{ $cite_link = true }}
{{ end }}

{{ if $cite_link | or $pdf_link | or .Params.external_link | or .Params.url_preprint | or .Params.url_pdf | or .Params.url_slides | or .Params.url_video | or .Params.url_source | or .Params.url_code | or .Params.url_dataset | or .Params.url_poster | or .Params.url_project | or .Params.links | or .Params.projects | or .Params.slides }}
{{ if $cite_link | or $pdf_link | or .Params.external_link | or .Params.doi | or .Params.url_preprint | or .Params.url_pdf | or .Params.url_slides | or .Params.url_video | or .Params.url_source | or .Params.url_code | or .Params.url_dataset | or .Params.url_poster | or .Params.url_project | or .Params.links | or .Params.projects | or .Params.slides }}
<div class="btn-links mb-3">
{{ with .Params.external_link }}
<a class="btn btn-outline-primary my-1" href="{{ . }}" target="_blank" rel="noopener">{{ i18n "open_project_site" }}</a>
Expand Down
2 changes: 1 addition & 1 deletion themes/academia/layouts/partials/page_metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</span>
{{ end }}

{{ $comments_enabled := and site.DisqusShortname (not (or site.Params.disable_comments (eq $page.Params.comments false))) }}
{{ $comments_enabled := and site.Config.Services.Disqus.Shortname (not (or site.Params.disable_comments (eq $page.Params.comments false))) }}
{{ if and $comments_enabled (site.Params.comment_count | default true) }}
<span class="middot-divider"></span>
<a href="{{ $page.RelPermalink }}#disqus_thread"><!-- Count will be inserted here --></a>
Expand Down
15 changes: 7 additions & 8 deletions themes/academia/layouts/partials/site_footer.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<footer class="site-footer">

<div class="container">
<div class="row">
<div class="col-md-6">
<div class="row align-items-center">
<div class="col-md-6 mb-4 mb-md-0">
{{ with site.GetPage "privacy.md" }}
<p class="powered-by">
{{ printf "<a href=\"%s\">%s</a>" .RelPermalink .Title | safeHTML }}
</p>
{{ end }}
<p>
<p class="mb-0">
{{ with site.Copyright }}{{ replace . "{year}" now.Year | markdownify}} &middot; {{ end }}
Powered by
<a href="https://gethugothemes.com" target="_blank" rel="noopener">Gethugothemes</a>
</p>
</div>
<div class="col-md-6">
<ul class="list-inline network-icon text-right">
<ul class="list-inline network-icon text-right mb-0">
{{/* Contact links. */}}
{{ range site.Params.contact_links }}
{{ $pack := or .icon_pack "fas" }}
Expand All @@ -29,14 +28,14 @@
{{ if not $scheme }}
{{ $link = .link | relLangURL }}
{{ else if in (slice "http" "https") $scheme }}
{{ $target = "target=\"_blank\""}}
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
{{ end }}
<li class="list-inline-item">
<a href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }} rel="{{.rel | safeHTMLAttr }}" title="{{.name}}"><i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }}" aria-hidden="true"></i></a>
<a href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }} title="{{.name}}"><i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }}" aria-hidden="true"></i></a>
</li>
{{ end }}
</ul>
</div>
</div>
</div>
</footer>
</footer>
21 changes: 14 additions & 7 deletions themes/academia/layouts/partials/site_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Source Themes Academia {{ site.Data.academia.version }}">
{{ hugo.Generator}}
<meta name="theme-name" content="academia-hugo"/>

{{ $scr := .Scratch }}

Expand Down Expand Up @@ -117,11 +117,20 @@
<link rel="stylesheet" href="{{ $css_bundle.RelPermalink }}">
{{ end }}

{{ if not site.IsServer }}
{{ if site.GoogleAnalytics }}
{{ if not hugo.IsServer }}
{{ if site.Params.microsoft_clarity }}
<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "{{ site.Params.microsoft_clarity }}");
</script>
{{ end }}
{{ if site.Config.Services.GoogleAnalytics.ID }}
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', '{{ site.GoogleAnalytics }}', 'auto');
ga('create', '{{ site.Config.Services.GoogleAnalytics.ID }}', 'auto');
{{ if site.Params.privacy_pack }}ga('set', 'anonymizeIp', true);{{ end }}
ga('require', 'eventTracker');
ga('require', 'outboundLinkTracker');
Expand Down Expand Up @@ -177,9 +186,7 @@
{{- end -}}
<meta property="og:locale" content="{{ site.LanguageCode | default "en-us" }}">
{{ if .IsPage }}
{{ if not .PublishDate.IsZero }}
<meta property="og:type" content="article">
<meta property="article:published_time" content="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">
{{ if not .PublishDate.IsZero }}<meta property="article:published_time" content="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">
{{ else if not .Date.IsZero }}<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}
{{ if not .Lastmod.IsZero }}<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}
{{ else }}
Expand Down
4 changes: 2 additions & 2 deletions themes/academia/layouts/partials/site_js.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
{{ end }}

{{/* Comments JS. */}}
{{ $comments_enabled := and site.DisqusShortname (not (or site.Params.disable_comments $.Params.disable_comments)) }}
{{ $comments_enabled := and site.Config.Services.Disqus.Shortname (not (or site.Params.disable_comments $.Params.disable_comments)) }}
{{ if and $comments_enabled (site.Params.comment_count | default true) }}
<script id="dsq-count-scr" src="//{{ site.DisqusShortname }}.disqus.com/count.js" async></script>
<script id="dsq-count-scr" src="//{{ site.Config.Services.Disqus.Shortname }}.disqus.com/count.js" async></script>
{{ end }}

{{/* Initialise code highlighting. */}}
Expand Down
4 changes: 2 additions & 2 deletions themes/academia/layouts/partials/widgets/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@

<div class="portrait-title">
<h2 itemprop="name">{{ $person.name }}</h2>
{{ with $person.role }}<h3 class="d-inline-block" itemprop="jobTitle">{{ . | markdownify | emojify }}</h3>{{ end }}
{{ with $person.role }}<h3 class="d-inline-block" itemprop="jobTitle">{{ . | markdownify | emojify }},</h3>{{ end }}

{{ range $person.organizations }}
<h3 class="d-inline-block" itemprop="worksFor" itemscope itemtype="http://schema.org/Organization">
{{ with .url }}<a href="{{ . }}" target="_blank" itemprop="url" rel="noopener">{{ end }}
<span itemprop="name">, {{ .name }}</span>
<span itemprop="name">{{ .name }}</span>
{{ if .url }}</a>{{ end }}
</h3>
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion themes/academia/layouts/partials/widgets/pages.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ <h1>{{ with $st.Title }}{{ . | markdownify | emojify }}{{ end }}</h1>

</div>
</div>
</div>
</div>
17 changes: 17 additions & 0 deletions themes/academia/layouts/shortcodes/expand.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ $_hugo_config := `{ "version": 1 }` }}
<div class="expand">
<div class="expand-label" style="cursor: pointer;" onclick="$h = $(this);$h.next('div').slideToggle(100,function () {$h.children('i').attr('class',function () {return $h.next('div').is(':visible') ? 'fas fa-chevron-down' : 'fas fa-chevron-right';});});">
<i style="font-size:x-small;" class="fas fa-chevron-right"></i>
<span>
{{$expandMessage := T "Expand-title"}}
{{ if .IsNamedParams }}
{{.Get "default" | default $expandMessage}}
{{else}}
{{.Get 0 | default $expandMessage}}
{{end}}
</span>
</div>
<div class="expand-content" style="display: none;">
{{.Inner | safeHTML}}
</div>
</div>
77 changes: 77 additions & 0 deletions themes/academia/scripts/projectSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const fs = require("fs");
const path = require("path");

const getFolderName = (rootfolder) => {
const configPath = path.join(
rootfolder,
"exampleSite/config/_default/hugo.toml"
);
const getConfig = fs.readFileSync(configPath, "utf8");
const match = getConfig.match(/theme\s*=\s*\[?"([^"\]]+)"\]?/);
let selectedTheme = null;
if (match && match[1]) {
selectedTheme = match[1];
}
return selectedTheme;
};

const deleteFolder = (folderPath) => {
if (fs.existsSync(folderPath)) {
fs.rmSync(folderPath, { recursive: true, force: true });
}
};

const createNewfolder = (rootfolder, folderName) => {
const newFolder = path.join(rootfolder, folderName);
fs.mkdirSync(newFolder, { recursive: true });
return newFolder;
};

const iterateFilesAndFolders = (rootFolder, { destinationRoot }) => {
const directory = path.join(rootFolder);
const items = fs.readdirSync(directory, { withFileTypes: true });
items.forEach((item) => {
if (item.isDirectory()) {
createNewfolder(destinationRoot, item.name);
iterateFilesAndFolders(path.join(directory, item.name), {
currentFolder: item.name,
destinationRoot: path.join(destinationRoot, item.name),
});
} else {
const sourceFile = path.join(directory, item.name);
const destinationFile = path.join(destinationRoot, item.name);
fs.renameSync(sourceFile, destinationFile);
}
});
};

const setupProject = () => {
const rootfolder = path.join(__dirname, "../");
if (!fs.existsSync(path.join(rootfolder, "themes"))) {
const folderList = ["layouts", "assets", "static"];
const folderName = getFolderName(rootfolder);
const newfolderName = createNewfolder(
path.join(rootfolder, "themes"),
folderName
);

folderList.forEach((folder) => {
const source = path.join(rootfolder, folder);
const destination = path.join(newfolderName, folder);
if (fs.existsSync(source)) {
fs.mkdirSync(destination, { recursive: true });
iterateFilesAndFolders(source, {
currentFolder: folder,
destinationRoot: destination,
});
deleteFolder(source);
}
});

const exampleSite = path.join(rootfolder, "exampleSite");
iterateFilesAndFolders(exampleSite, { destinationRoot: rootfolder });
deleteFolder(exampleSite);
}
};

setupProject();
Loading

0 comments on commit 7f8cabc

Please sign in to comment.