2020-12-15 00:17:03 -08:00
<!doctype html>
< html lang = "en" class = "no-js" >
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width,initial-scale=1" >
< link rel = "shortcut icon" href = "../../assets/images/favicon.png" >
< meta name = "generator" content = "mkdocs-1.1.2, mkdocs-material-6.1.7" >
< title > Rewrite Hugo Themes Report in Python - Trent's Blog< / title >
< link rel = "stylesheet" href = "../../assets/stylesheets/main.19753c6b.min.css" >
< link rel = "stylesheet" href = "../../assets/stylesheets/palette.196e0c26.min.css" >
< link href = "https://fonts.gstatic.com" rel = "preconnect" crossorigin >
< link rel = "stylesheet" href = "https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback" >
< style > body , input { font-family : "Roboto" , - apple-system , BlinkMacSystemFont , Helvetica , Arial , sans-serif } code , kbd , pre { font-family : "Roboto Mono" , SFMono-Regular , Consolas , Menlo , monospace } < / style >
< link rel = "stylesheet" href = "../../extra.css" >
< / head >
< body dir = "ltr" data-md-color-scheme = "default" data-md-color-primary = "" data-md-color-accent = "" >
< input class = "md-toggle" data-md-toggle = "drawer" type = "checkbox" id = "__drawer" autocomplete = "off" >
< input class = "md-toggle" data-md-toggle = "search" type = "checkbox" id = "__search" autocomplete = "off" >
< label class = "md-overlay" for = "__drawer" > < / label >
< div data-md-component = "skip" >
< a href = "#ranking-hugo-themes-by-stars-commit-date" class = "md-skip" >
Skip to content
< / a >
< / div >
< div data-md-component = "announce" >
< / div >
< header class = "md-header" data-md-component = "header" >
< nav class = "md-header-nav md-grid" aria-label = "Header" >
< a href = "../.." title = "Trent's Blog" class = "md-header-nav__button md-logo" aria-label = "Trent's Blog" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M12 8a3 3 0 003-3 3 3 0 00-3-3 3 3 0 00-3 3 3 3 0 003 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54z" / > < / svg >
< / a >
< label class = "md-header-nav__button md-icon" for = "__drawer" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z" / > < / svg >
< / label >
< div class = "md-header-nav__title" data-md-component = "header-title" >
< div class = "md-header-nav__ellipsis" >
< span class = "md-header-nav__topic md-ellipsis" >
Trent's Blog
< / span >
< span class = "md-header-nav__topic md-ellipsis" >
Rewrite Hugo Themes Report in Python
< / span >
< / div >
< / div >
< label class = "md-header-nav__button md-icon" for = "__search" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M9.5 3A6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z" / > < / svg >
< / label >
< div class = "md-search" data-md-component = "search" role = "dialog" >
< label class = "md-search__overlay" for = "__search" > < / label >
< div class = "md-search__inner" role = "search" >
< form class = "md-search__form" name = "search" >
< input type = "text" class = "md-search__input" name = "query" aria-label = "Search" placeholder = "Search" autocapitalize = "off" autocorrect = "off" autocomplete = "off" spellcheck = "false" data-md-component = "search-query" data-md-state = "active" required >
< label class = "md-search__icon md-icon" for = "__search" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M9.5 3A6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z" / > < / svg >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z" / > < / svg >
< / label >
< button type = "reset" class = "md-search__icon md-icon" aria-label = "Clear" data-md-component = "search-reset" tabindex = "-1" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" / > < / svg >
< / button >
< / form >
< div class = "md-search__output" >
< div class = "md-search__scrollwrap" data-md-scrollfix >
< div class = "md-search-result" data-md-component = "search-result" >
< div class = "md-search-result__meta" >
Initializing search
< / div >
< ol class = "md-search-result__list" > < / ol >
< / div >
< / div >
< / div >
< / div >
< / div >
< / nav >
< / header >
< div class = "md-container" data-md-component = "container" >
< nav class = "md-tabs md-tabs--active" aria-label = "Tabs" data-md-component = "tabs" >
< div class = "md-tabs__inner md-grid" >
< ul class = "md-tabs__list" >
< li class = "md-tabs__item" >
< a href = "../.." class = "md-tabs__link md-tabs__link--active" >
Home
< / a >
< / li >
< li class = "md-tabs__item" >
< a href = "../../links/" class = "md-tabs__link" >
Links
< / a >
< / li >
< / ul >
< / div >
< / nav >
< main class = "md-main" data-md-component = "main" >
< div class = "md-main__inner md-grid" >
< div class = "md-sidebar md-sidebar--primary" data-md-component = "navigation" >
< div class = "md-sidebar__scrollwrap" >
< div class = "md-sidebar__inner" >
< nav class = "md-nav md-nav--primary" aria-label = "Navigation" data-md-level = "0" >
< label class = "md-nav__title" for = "__drawer" >
< a href = "../.." title = "Trent's Blog" class = "md-nav__button md-logo" aria-label = "Trent's Blog" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M12 8a3 3 0 003-3 3 3 0 00-3-3 3 3 0 00-3 3 3 3 0 003 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54z" / > < / svg >
< / a >
Trent's Blog
< / label >
< ul class = "md-nav__list" data-md-scrollfix >
< li class = "md-nav__item md-nav__item--active md-nav__item--nested" >
< input class = "md-nav__toggle md-toggle" data-md-toggle = "nav-1" type = "checkbox" id = "nav-1" checked >
< label class = "md-nav__link" for = "nav-1" >
Home
< span class = "md-nav__icon md-icon" > < / span >
< / label >
< nav class = "md-nav" aria-label = "Home" data-md-level = "1" >
< label class = "md-nav__title" for = "nav-1" >
< span class = "md-nav__icon md-icon" > < / span >
Home
< / label >
< ul class = "md-nav__list" data-md-scrollfix >
< li class = "md-nav__item" >
< a href = "../.." class = "md-nav__link" >
Home
< / a >
< / li >
2020-12-15 03:11:33 -08:00
< li class = "md-nav__item" >
< a href = "../linux-move-cursor-with-keyboard/" class = "md-nav__link" >
Linux Move Cursor With Keyboard
2020-12-15 00:17:03 -08:00
< / a >
< / li >
< li class = "md-nav__item" >
2020-12-15 03:11:33 -08:00
< a href = "../simplified-raspberry-streaming/" class = "md-nav__link" >
Simplified Raspberry Streaming
2020-12-15 00:17:03 -08:00
< / a >
< / li >
< li class = "md-nav__item" >
2020-12-15 03:11:33 -08:00
< a href = "../clear-linux-encrypted-xfs-root/" class = "md-nav__link" >
Clear Linux Encrypted xfs Root
2020-12-15 00:17:03 -08:00
< / a >
< / li >
< li class = "md-nav__item" >
< a href = "../clear-linux-guest-virt-manager/" class = "md-nav__link" >
Clear Linux Guest Virt Manager
< / a >
< / li >
< li class = "md-nav__item" >
2020-12-15 03:11:33 -08:00
< a href = "../faster-partitioning-with-sgdisk/" class = "md-nav__link" >
Faster Partitioning With sgdisk
2020-12-15 00:17:03 -08:00
< / a >
< / li >
< li class = "md-nav__item" >
2020-12-15 03:11:33 -08:00
< a href = "../lmde3-xfs-full-disk-encryption/" class = "md-nav__link" >
LMDE3 xfs Full Disk Encryption
2020-12-15 00:17:03 -08:00
< / a >
< / li >
2020-12-15 03:11:33 -08:00
2020-12-15 00:17:03 -08:00
2020-12-15 03:11:33 -08:00
< li class = "md-nav__item md-nav__item--active" >
< input class = "md-nav__toggle md-toggle" data-md-toggle = "toc" type = "checkbox" id = "__toc" >
< label class = "md-nav__link md-nav__link--active" for = "__toc" >
Rewrite Hugo Themes Report in Python
< span class = "md-nav__icon md-icon" > < / span >
< / label >
< a href = "./" class = "md-nav__link md-nav__link--active" >
Rewrite Hugo Themes Report in Python
2020-12-15 00:17:03 -08:00
< / a >
2020-12-15 03:11:33 -08:00
< nav class = "md-nav md-nav--secondary" aria-label = "Table of contents" >
< label class = "md-nav__title" for = "__toc" >
< span class = "md-nav__icon md-icon" > < / span >
Table of contents
< / label >
< ul class = "md-nav__list" data-md-scrollfix >
< li class = "md-nav__item" >
< a href = "#ranking-hugo-themes-by-stars-commit-date" class = "md-nav__link" >
Ranking Hugo Themes by Stars, Commit Date
< / a >
< / li >
< li class = "md-nav__item" >
< a href = "#first-version-in-bash" class = "md-nav__link" >
First Version in Bash
< / a >
< / li >
< li class = "md-nav__item" >
< a href = "#rewrite-in-python" class = "md-nav__link" >
Rewrite in Python
< / a >
< / li >
< li class = "md-nav__item" >
< a href = "#building-an-html5-table-bootstrap-actually" class = "md-nav__link" >
Building an HTML5 Table (bootstrap, actually)
< / a >
< / li >
< / ul >
< / nav >
2020-12-15 00:17:03 -08:00
< / li >
< / ul >
< / nav >
< / li >
< li class = "md-nav__item md-nav__item--nested" >
< input class = "md-nav__toggle md-toggle" data-md-toggle = "nav-2" type = "checkbox" id = "nav-2" >
< label class = "md-nav__link" for = "nav-2" >
Links
< span class = "md-nav__icon md-icon" > < / span >
< / label >
< nav class = "md-nav" aria-label = "Links" data-md-level = "1" >
< label class = "md-nav__title" for = "nav-2" >
< span class = "md-nav__icon md-icon" > < / span >
Links
< / label >
< ul class = "md-nav__list" data-md-scrollfix >
< li class = "md-nav__item" >
< a href = "../../links/" class = "md-nav__link" >
Links
< / a >
< / li >
< / ul >
< / nav >
< / li >
< / ul >
< / nav >
< / div >
< / div >
< / div >
< div class = "md-sidebar md-sidebar--secondary" data-md-component = "toc" >
< div class = "md-sidebar__scrollwrap" >
< div class = "md-sidebar__inner" >
< nav class = "md-nav md-nav--secondary" aria-label = "Table of contents" >
< label class = "md-nav__title" for = "__toc" >
< span class = "md-nav__icon md-icon" > < / span >
Table of contents
< / label >
< ul class = "md-nav__list" data-md-scrollfix >
< li class = "md-nav__item" >
< a href = "#ranking-hugo-themes-by-stars-commit-date" class = "md-nav__link" >
Ranking Hugo Themes by Stars, Commit Date
< / a >
< / li >
< li class = "md-nav__item" >
< a href = "#first-version-in-bash" class = "md-nav__link" >
First Version in Bash
< / a >
< / li >
< li class = "md-nav__item" >
< a href = "#rewrite-in-python" class = "md-nav__link" >
Rewrite in Python
< / a >
< / li >
< li class = "md-nav__item" >
< a href = "#building-an-html5-table-bootstrap-actually" class = "md-nav__link" >
Building an HTML5 Table (bootstrap, actually)
< / a >
< / li >
< / ul >
< / nav >
< / div >
< / div >
< / div >
< div class = "md-content" >
< article class = "md-content__inner md-typeset" >
< h1 > Rewrite Hugo Themes Report in Python< / h1 >
< p > date: 2019-01-25T01:02:57-08:00< / p >
< h2 id = "ranking-hugo-themes-by-stars-commit-date" > < strong > Ranking Hugo Themes by Stars, Commit Date< / strong > < / h2 >
< p > A while back I was grazing the selfhosted subreddit, and noticed Hugo coming up in conversation.
I recalled that hugo requires a third-party theme in order to function. But was a bit of a challenge,
because how do you know what is a good Hugo theme?< / p >
< h2 id = "first-version-in-bash" > < strong > First Version in Bash< / strong > < / h2 >
< p > I ended up writing a little bash script (now deprecated) that scrapes the Github api and generates a little report about Hugo themes.
It basically curled json from the Github api, and parsed it with grep, awk, and sed, and eventually spat out a plain text file.< / p >
< h2 id = "rewrite-in-python" > < strong > Rewrite in Python< / strong > < / h2 >
< p > It was about a year later that I decided to rewrite the script in Python, using sqlite as a database.
I discovered how to use the python requests module, got some practice with sqlite,
and discovered how to make conditional request against the Github api using ETags and ‘ If-Modified-Since’ (ETags are easier).< / p >
< p > But this was my first time using python like this. And I have to tell you,
< strong > it’ s a lot moar fun than recursive fibonacci tutorials!< / strong > < / p >
< h2 id = "building-an-html5-table-bootstrap-actually" > < strong > Building an HTML5 Table (bootstrap, actually)< / strong > < / h2 >
< p > By the time I had figured out how to collect the data I needed, I realized that I could simply generate an html table right in the python script.< / p >
< p > < code > rank_hugo_themes.py< / code > runs in a cronjob every night, and you can view
< a href = "https://trentsonlinedocs.xyz/hugo-themes-report/hugo-themes-report.html" target = "_blank" > Hugo Themes Report< / a > here.< / p >
< p > And you can < a href = "https://github.com/TrentSPalmer/hugo_themes_report" target = "_blank" > see the script on Github< / a > .< / p >
< / article >
< / div >
< / div >
< / main >
< footer class = "md-footer" >
< div class = "md-footer-nav" >
< nav class = "md-footer-nav__inner md-grid" aria-label = "Footer" >
2020-12-15 03:11:33 -08:00
< a href = "../lmde3-xfs-full-disk-encryption/" class = "md-footer-nav__link md-footer-nav__link--prev" rel = "prev" >
2020-12-15 00:17:03 -08:00
< div class = "md-footer-nav__button md-icon" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z" / > < / svg >
< / div >
< div class = "md-footer-nav__title" >
< div class = "md-ellipsis" >
< span class = "md-footer-nav__direction" >
Previous
< / span >
2020-12-15 03:11:33 -08:00
LMDE3 xfs Full Disk Encryption
2020-12-15 00:17:03 -08:00
< / div >
< / div >
< / a >
2020-12-15 03:11:33 -08:00
< a href = "../../links/" class = "md-footer-nav__link md-footer-nav__link--next" rel = "next" >
2020-12-15 00:17:03 -08:00
< div class = "md-footer-nav__title" >
< div class = "md-ellipsis" >
< span class = "md-footer-nav__direction" >
Next
< / span >
2020-12-15 03:11:33 -08:00
Links
2020-12-15 00:17:03 -08:00
< / div >
< / div >
< div class = "md-footer-nav__button md-icon" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4z" / > < / svg >
< / div >
< / a >
< / nav >
< / div >
< div class = "md-footer-meta md-typeset" >
< div class = "md-footer-meta__inner md-grid" >
< div class = "md-footer-copyright" >
Made with
< a href = "https://squidfunk.github.io/mkdocs-material/" target = "_blank" rel = "noopener" >
Material for MkDocs
< / a >
< / div >
< / div >
< / div >
< / footer >
< / div >
< script src = "../../assets/javascripts/vendor.0ac82a11.min.js" > < / script >
< script src = "../../assets/javascripts/bundle.f81dfb4d.min.js" > < / script > < script id = "__lang" type = "application/json" > { "clipboard.copy" : "Copy to clipboard" , "clipboard.copied" : "Copied to clipboard" , "search.config.lang" : "en" , "search.config.pipeline" : "trimmer, stopWordFilter" , "search.config.separator" : "[\\s\\-]+" , "search.placeholder" : "Search" , "search.result.placeholder" : "Type to start searching" , "search.result.none" : "No matching documents" , "search.result.one" : "1 matching document" , "search.result.other" : "# matching documents" , "search.result.more.one" : "1 more on this page" , "search.result.more.other" : "# more on this page" , "search.result.term.missing" : "Missing" } < / script >
< script >
app = initialize({
base: "../..",
features: ['navigation.tabs'],
search: Object.assign({
worker: "../../assets/javascripts/worker/search.4ac00218.min.js"
}, typeof search !== "undefined" & & search)
})
< / script >
< / body >
< / html >