Skip to content
Myr

Redesign website (#2628)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Bump up Bootstrap to v5.3.1, Bootstrap Icon to v1.10.5. * Use autoComplete.js to drop dependency on jQuery and typeahead.js. * Support dark mode. * New svg logo and icon with responsive color mode support. * Normalize section ids to lower kebab-case for easiness of linking. * Use relative paths for links for local development (--root /output). * Various markup cleanups and accessibility improvements.

authored by itchyny · committed by GitHub · parent 4af3f99 · Browse files · 26 files+401 added−655 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

26 files+401 added−655 removed

  • other:+401 added−655 removed

26 files+401 added−655 removed

modified:.github/workflows/website.yml+1 added-1 removed
modified:docs/content/download/default.yml+3 added-3 removed
194 unmodified lines
195196 #### Building the documentation197198 jq's documentation is compiled into static HTML using Python.199 To build the docs, run `pipenv run python3 build_website.py` from200 the docs/ subdirectory. To serve them locally, you can run201 `python3 -m SimpleHTTPServer`. You'll need a few Python dependencies,199 To build the docs, run `pipenv run python3 build_website.py --root /output`200 in the `docs/` directory. To serve them locally, you can run201 `python3 -m http.server`. You'll need a few Python dependencies,202 which can be installed by following the instructions in `docs/README.md`.203204 The man page is built by `make jq.1`, or just `make`, also from205 the YAML docs, and you'll still need the Python dependencies to
1 unmodified line
modified:docs/content/manual/v1.3/manual.yml+1 added-1 removed
2 unmodified lines
34history: |56 *The manual for the development version of jq can be found7 [here](/jq/manual).*7 [here](../).*89body: |1011 A jq program is a "filter": it takes an input, and produces an
1253 unmodified lines
modified:docs/content/manual/v1.4/manual.yml+1 added-1 removed
2 unmodified lines
34history: |56 *The manual for the development version of jq can be found7 [here](/jq/manual).*7 [here](../).*89body: |1011 A jq program is a "filter": it takes an input, and produces an
1659 unmodified lines
modified:docs/content/manual/v1.5/manual.yml+1 added-1 removed
2 unmodified lines
34history: |56 *The manual for the development version of jq can be found7 [here](/jq/manual).*7 [here](../).*89body: |1011 A jq program is a "filter": it takes an input, and produces an
2923 unmodified lines
modified:docs/content/manual/v1.6/manual.yml+1 added-1 removed
2 unmodified lines
34history: |56 *The manual for the development version of jq can be found7 [here](/jq/manual).*7 [here](../).*89body: |1011 A jq program is a "filter": it takes an input, and produces an
3357 unmodified lines
modified:docs/content/manual/manual.yml+2 added-3 removed
1 unmodified line
2headline: jq Manual (development version)34history: |56 *For released versions, see [jq 1.6](/jq/manual/v1.6),7 [jq 1.5](/jq/manual/v1.5), [jq 1.4](/jq/manual/v1.4)8 or [jq 1.3](/jq/manual/v1.3).*6 *For released versions, see [jq 1.6](./v1.6/), [jq 1.5](./v1.5/),7 [jq 1.4](./v1.4/) or [jq 1.3](./v1.3/).*89body: |1011 A jq program is a "filter": it takes an input, and produces an
3628 unmodified lines
modified:docs/content/index.yml+4 added-4 removed
deleted:docs/public/css/base.css-173 removed
1body {2 padding-top: 80px;3}45.container {6 max-width: 970px;7}89/* index.liquid *******************************************/10#blurb {11 padding-top: 40px;12}13#blurb p {14 font-size: 1.9em;15}16#blurb .btn-group {17 margin: 4px;18}1920#multiblurb {21 line-height: 1.7;22 text-align: center;23 font-size: 12pt;24}25#multiblurb code {26 border: 0;27 font-size: 12pt;28}2930#news {31 font-size: 12pt;32}33#news .date {34 font-style: italic;35}3637/* default.liquid *****************************************/38.tutorial-example {39 position: relative;40 margin-bottom: 10px;41}42.tutorial-example pre {43 margin-bottom: 0px;44}45.tutorial-example a {46 position: absolute;47 top: 0px;48 right: 0px;49 padding: 15px 8px;50 color: #777777;51 font-weight: bold;52 line-height: 10px;53 font-size: 12px;54 border-left: 1px solid #DDDDDD;55 display: block;56}57.tutorial-example .accordion-body pre {58 margin: 0 4px;59 border-top: 0;60 border-top-left-radius: 0;61 border-top-right-radius: 0;62}6364@media print {65 .tutorial-example a {66 display: none;67 }68}69/* manual.liquid ******************************************/70section {71 padding-top: 24px;72}7374h3 code {75 border: 0;76 font-size: 20px;77}7879@media (max-width: 991px) {80 #navcolumn {81 /* Put nav column above manual content */82 position: relative !important;83 margin-bottom: 60px;84 }85}86@media (min-width: 992px) {87 #manualcontent {88 /* Put nav column left of manual content */89 padding-left: 280px;90 }91}92.nav-pills {93 margin-bottom: 20px;94}95 .nav-pills li a {96 padding: 8px 12px;97}9899.manual-example table {100 border-top: 1px solid #E5E5E5;101}102.manual-example table td {103 white-space: pre-wrap;104 font-family: Monaco, Menlo, Consolas, "Courier New", monospace;105}106.manual-example table td.jqprogram {107 font-weight: bold;108}109.manual-example table th {110 text-align: right;111 padding-right: 10px;112}113114@media print {115 #navcolumn {116 display: none !important;117 }118119 .manual-example {120 display: block !important;121 height: auto !important;122 }123124 .jqplay-btn {125 display: none !important;126 }127}128/* shared/_footer.liquid **********************************/129footer {130 background-color: #F5F5F5;131 padding: 20px 0;132 margin-top: 40px;133 color: #999999;134 text-align: center;135}136footer p {137 margin: 8px 0;138}139140/* typeahead **********************************************/141.twitter-typeahead {142 width: 100%;143}144145.tt-menu {146 width: 100%;147 background-color: #fff;148 padding: 8px 0;149 border: 1px solid #ccc;150 border: 1px solid rgba(0, 0, 0, 0.2);151 -webkit-border-radius: 8px;152 -moz-border-radius: 8px;153 border-radius: 8px;154 -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);155 -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);156 box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);157}158159.tt-suggestion {160 padding: 3px 20px;161}162.tt-suggestion:hover {163 cursor: pointer;164 color: #fff;165 background-color: #446e9b;166}167.tt-suggestion.tt-cursor {168 color: #fff;169 background-color: #446e9b;170}171.tt-suggestion p {172 margin: 0;173}
deleted:docs/public/css/base.scss-181 removed
1@charset "utf-8";2body {3 padding-top: 80px;4}56.container {7 max-width: 970px;8}910/* index.liquid *******************************************/1112#blurb {13 padding-top: 40px;14 p {15 font-size: 1.9em;16 }17 .btn-group {18 margin: 4px;19 }20}2122#multiblurb {23 line-height: 1.7;24 text-align: center;25 font-size: 12pt;26 code {27 border: 0;28 font-size: 12pt;29 }30}3132#news {33 font-size: 12pt;34 .date {35 font-style: italic;36 }37}3839/* default.liquid *****************************************/4041.tutorial-example {42 position: relative;43 margin-bottom: 10px;44 pre {45 margin-bottom: 0px;46 }47 a {48 position: absolute;49 top: 0px;50 right: 0px;51 padding: 15px 8px;52 color: #777777;53 font-weight: bold;54 line-height: 10px;55 font-size: 12px;56 border-left: 1px solid #DDDDDD;57 display: block;58 }59 .accordion-body pre {60 margin: 0 4px;61 border-top: 0;62 border-top-left-radius: 0;63 border-top-right-radius: 0;64 }65}6667@media print {68 .tutorial-example a {69 display: none;70 }71}7273/* manual.liquid ******************************************/7475section {76 padding-top: 24px;77}7879h3 code {80 border: 0;81 font-size: 20px;82}8384@media(max-width: 991px){85 #navcolumn {86 /* Put nav column above manual content */87 position: relative !important;88 margin-bottom: 60px;89 }90}9192@media(min-width: 992px) {93 #manualcontent {94 /* Put nav column left of manual content */95 padding-left: 280px;96 }97}9899.nav-pills {100 li a {101 padding: 8px 12px;102 }103 margin-bottom: 20px;104}105106.manual-example table {107 border-top: 1px solid #E5E5E5;108 td {109 white-space: pre-wrap;110 font-family: Monaco, Menlo, Consolas, "Courier New", monospace;111 }112 td.jqprogram {113 font-weight: bold;114 }115 th {116 text-align: right;117 padding-right: 10px;118 }119}120121@media print {122 #navcolumn {123 display: none !important;124 }125 .manual-example {126 display: block !important;127 height: auto !important;128 }129 .jqplay-btn {130 display: none !important;131 }132}133134/* shared/_footer.liquid **********************************/135136footer {137 background-color: #F5F5F5;138 padding: 20px 0;139 margin-top: 40px;140 color: #999999;141 text-align: center;142 p {143 margin: 8px 0;144 }145}146147/* typeahead **********************************************/148149.twitter-typeahead {150 width: 100%;151}152153.tt-menu {154 width: 100%;155 background-color: #fff;156 padding: 8px 0;157 border: 1px solid #ccc;158 border: 1px solid rgba(0, 0, 0, 0.2);159 -webkit-border-radius: 8px;160 -moz-border-radius: 8px;161 border-radius: 8px;162 -webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);163 -moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);164 box-shadow: 0 5px 10px rgba(0,0,0,.2);165}166167.tt-suggestion {168 padding: 3px 20px;169 &:hover {170 cursor: pointer;171 color: #fff;172 background-color: #446e9b;173 }174 &.tt-cursor {175 color: #fff;176 background-color: #446e9b;177 }178 p {179 margin: 0;180 }181}
added:docs/public/css/style.css+99 added
1main {2 padding: 1rem;34 & * {5 scroll-margin-top: 4rem;6 }78 @media print {9 width: 100%!important;10 --bs-code-color: --bs-body-color;11 }12}1314header {15 z-index: 1050!important; /* higher than #contents */16}1718section[id] {19 display: flow-root;2021 > :first-child {22 .icon-link {23 opacity: 0;2425 &:focus {26 opacity: .8;27 }28 }2930 &:hover .icon-link {31 opacity: 1;32 }33 }34}3536.offcanvas[aria-modal=true] .nav-link {37 padding: .7rem;38}39.offcanvas-md {40 --bs-offcanvas-width: auto;41}4243ul {44 list-style: none;45 padding-left: 1rem;46}4748pre {49 margin: 0 .5rem 1rem;50 padding: .5rem 1rem;51 background-color: var(--bs-secondary-bg-subtle);52 border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);53}5455button{56 &[aria-expanded=false] .bi-chevron-down {57 display: none;58 }5960 &[aria-expanded=true] .bi-chevron-right {61 display: none;62 }63}6465mark {66 padding: 0;67}6869.container-searchbox {70 position: relative;7172 & input:focus ~ kbd {73 display: none;74 }7576 & ul {77 position: absolute;78 width: 100%;79 top: 100%;80 padding: 0;81 background-color: var(--bs-body-bg);82 border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);83 }8485 & li {86 padding: .3em .6em;87 white-space: nowrap;88 overflow-x: hidden;8990 &[aria-selected=true] {91 background-color: var(--bs-secondary-bg);92 }9394 &:hover {95 cursor: pointer;96 background-color: var(--bs-secondary-bg-subtle);97 }98 }99}
modified:docs/public/js/manual-search.js+31 added-49 removed
1var section_names = function(q) {2 if (!q) {3 return [];4 }5 var matches = [];6 q = q.toLowerCase();7 $.each(section_map, function(k, v) {8 if (k.toLowerCase().indexOf(q) != -1) {9 matches.push(k);10 }1(() => {2 const searchInput = document.querySelector('input#searchbox');3 const sectionIDs = JSON.parse(document.querySelector('#section-ids').innerText);4 const sanitize = (string) => string.replaceAll('<', '&lt;').replaceAll('>', '&gt;');5 new autoComplete({6 selector: `#${searchInput.id}`,7 wrapper: false,8 data: {9 src: Object.keys(sectionIDs),10 filter: (list) => list.sort((x, y) =>11 x.match.indexOf('<') - y.match.indexOf('<') || x.value.length - y.value.length),12 },13 searchEngine: (query, value) => {14 const index = value.toLowerCase().indexOf(query.toLowerCase());15 if (index >= 0) {16 return sanitize(value.substring(0, index)) +17 `<mark>${sanitize(value.substring(index, index + query.length))}</mark>` +18 sanitize(value.substring(index + query.length));19 }20 },21 });12 matches.sort(function(a, b) {13 // shortest to longest14 return a.length - b.length;22 searchInput.addEventListener('selection', (event) => {23 event.target.value = event.detail.selection.value;24 location.hash = `#${sectionIDs[event.detail.selection.value]}`;25 });16 return matches;17}18var section_names_cb = function(q, cb) {19 cb(section_names(q));20}21var go_to_section = function() {22 query = $('#searchbox').val();23 results = section_names(query);24 if (results.length == 0) {25 return;26 }27 result = results[0];28 location.hash = '#' + section_map[result];29 if (result != query) {30 $('#searchbox').val(result);31 }32}33$(function(){34 $('#searchbox').typeahead(35 {hint: false, highlight: true, minLength: 1},36 {name: "contents", source: section_names_cb, limit: 6}37 ).on('typeahead:selected', function(e, data) {38 go_to_section();26 document.addEventListener('keydown', (event) => {27 if (event.code === 'Slash' && !event.altKey && !event.ctrlKey && !event.metaKey28 && !event.shiftKey && !/^(INPUT|TEXTAREA)$/.test(event.target.nodeName)) {29 searchInput.focus();30 searchInput.select();31 event.preventDefault();32 }33 });40 $('#searchbox').change(go_to_section);41});34})();42// add "Run" button to execute examples on jqplay.org43$(function() {44 $.each($('.manual-example table'), function(index, value) {45 $value = $(value)46 var j = $value.find('tr:nth-child(2) td:first').text();47 var q = $value.find('.jqprogram').text().replace(/^jq /, '').replace(/(\r\n|\n|\r)/gm," ").replace(/^'(.+)'$/, '$1');48 var url = 'https://jqplay.org/jq?q=' + encodeURIComponent(q) +'&j=' + encodeURIComponent(j)49 var $last_tr = $value.find('tr:last');50 $last_tr.after('<tr class="jqplay-btn"><th><a href="' + url + '" class="btn btn-primary btn-sm">Run</a></th><th></th></tr><tr><th></th><th></th></tr>');51 });52});
added:docs/public/icon.pngbinary

A binary file, added.

added:docs/public/icon.svg+1 added
1<svg width="48" height="48" version="1.0" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><style>@media(prefers-color-scheme:dark){g[fill]{filter:invert(1)}}</style><g transform="matrix(.011 0 0 .011 1.94 12)"><g fill="#444"><circle cx="220" cy="1570" r="190"/><path d="m1330 312c-30 41-698 1492-710 1528s25 66 100 101c77 36 102 34 124 3s701-1477 716-1525c15-47-20-73-84-104s-116-44-146-3z"/></g><g fill="#111"><circle cx="2410" cy="200" r="190"/><path d="m1830 655c0 129 0 130 70 130h360v423c0 246-5 474-10 506-19 112-88 176-190 176-59 0-120-27-147-66-51-73-65-84-99-84-31 0-40 8-104 93-84 111-86 129-32 189 227 252 692 187 836-118 53-112 56-153 56-795v-514c0-64-30-100-100-100h-490c-149 0-150 0-150 160zM2867 1233c30 302 250 499 438 527 144 19 244 0 375-90v410c0 81 0 100 150 100 136 0 150-20 150-150v-1420c0-99-19-100-150-100s-139 15-139 82c-103-89-351-149-523-49s-342 278-301 690zm803-107c0 292-105 356-237 356-178 0-249-147-273-296-27-168 25-420 262-420 171 0 248 89 248 360z"/></g></g></svg>
deleted:docs/public/jq.pngbinary

A binary file, deleted.

added:docs/public/jq.svg+1 added
1<svg width="400" height="220" version="1.0" viewBox="0 0 400 220" xmlns="http://www.w3.org/2000/svg"><style>@media (prefers-color-scheme:dark){g[fill]{filter:invert(1);stroke:none}}</style><g transform="scale(.1)" stroke="#fff" stroke-width="10"><g fill="#444"><circle cx="220" cy="1570" r="190"/><path d="m1330 312c-30 41-698 1492-710 1528s25 66 100 101c77 36 102 34 124 3s701-1477 716-1525c15-47-20-73-84-104s-116-44-146-3z"/></g><g fill="#111"><circle cx="2410" cy="200" r="190"/><path d="m1830 655c0 129 0 130 70 130h360v423c0 246-5 474-10 506-19 112-88 176-190 176-59 0-120-27-147-66-51-73-65-84-99-84-31 0-40 8-104 93-84 111-86 129-32 189 227 252 692 187 836-118 53-112 56-153 56-795v-514c0-64-30-100-100-100h-490c-149 0-150 0-150 160zM2867 1233c30 302 250 499 438 527 144 19 244 0 375-90v410c0 81 0 100 150 100 136 0 150-20 150-150v-1420c0-99-19-100-150-100s-139 15-139 82c-103-89-351-149-523-49s-342 278-301 690zm803-107c0 292-105 356-237 356-178 0-249-147-273-296-27-168 25-420 262-420 171 0 248 89 248 360z"/></g></g></svg>
modified:docs/templates/shared/_footer.html.j2+12 added-8 removed
1 <footer>2 <div class="container">3 <p>This website is made with <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>4 <p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>1 <footer class="bd-footer bg-body-tertiary">2 <div class="py-3 text-center">3 <p>4 This website is made with <a href="https://getbootstrap.com" target="_blank" rel="noopener">Bootstrap</a>,5 themed with <a href="https://bootswatch.com" target="_blank" rel="noopener">Bootswatch</a>.6 </p>7 <p>8 jq is licensed under the MIT license (code) and the9 <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank" rel="noopener">CC-BY-3.0</a> license (docs).10 </p>11 </div>12 </footer>78 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>9 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>10 <script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>13 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"14 integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm" crossorigin="anonymous"></script>
modified:docs/templates/shared/_head.html.j2+19 added-13 removed
1 <head>2 <script>3 if ((window.location.host == "jqlang.github.io") && (window.location.protocol != "https:"))4 window.location.protocol = "https";5 </script>2 <meta charset="utf-8">7 <title>{{headline}}</title>3 <title>{{ headline }}</title>4 <meta name="viewport" content="width=device-width, initial-scale=1">9 <meta http-equiv="X-UA-Compatible" content="IE=edge" />10 <link rel="canonical" href="{{ url }}/{{ permalink }}" />11 <link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/spacelab/bootstrap.min.css" rel="stylesheet" integrity="sha256-j7Dtnd7ZjexEiPNbscbopFn9+Cs0b3TLipKsWAPHZIM= sha512-RFhfi6P8zWMAJrEGU+CPjuxPh3r/UUBGqQ+/o6WKPIVZmQqeOipGotH2ihRULuQ8wsMBoK15TSZqc/7VYWyuIw==" crossorigin="anonymous">12 <link rel="stylesheet" href="{{ root }}/css/base.css" type="text/css">13 <!--[if lt IE 9]>14 <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>15 <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>16 <![endif]-->5 <link rel="icon" href="{{ root }}/icon.svg" type="image/svg+xml">6 <link rel="apple-touch-icon" href="{{ root }}/icon.png" type="image/png">7 <link rel="canonical" href="{{ url }}/{{ permalink }}">8 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootswatch@5.3.1/dist/cosmo/bootstrap.min.css"9 integrity="sha384-dulfW0vmzZ638jigSgZXvDxMmd70GCnIv6oa+riKq6Kk4E0MKf7qmBfwP02wltv5" crossorigin="anonymous">10 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css"11 integrity="sha384-Ay26V7L8bsJTsX9Sxclnvsn+hkdiwRnrjZJXqKmkIDobPgIIWBOVguEcQQLDuhfN" crossorigin="anonymous">12 <link rel="stylesheet" href="{{ root }}/css/style.css" type="text/css">13 <script>14 (function() {15 function setTheme(mediaQuery) {16 document.documentElement.setAttribute('data-bs-theme',17 document.documentElement.style.colorScheme = mediaQuery.matches ? 'dark' : 'light');18 }19 const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');20 setTheme(mediaQuery); mediaQuery.addEventListener('change', setTheme);21 })();22 </script>23 </head>
modified:docs/templates/shared/_navbar.html.j2+38 added-25 removed
1 <div class="navbar navbar-default navbar-fixed-top" role="navigation">2 <div class="container">3 <div class="navbar-header">4 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#nav-collapse">5 <span class="sr-only">Toggle navigation</span>6 <span class="icon-bar"></span>7 <span class="icon-bar"></span>8 <span class="icon-bar"></span>9 </button>10 <a class="navbar-brand" href="{{root}}/">jq</a>11 </div>1213 <div class="navbar-collapse collapse" id="nav-collapse">14 <ul class="nav navbar-nav">15 {% for item in navigation %}16 <li {% if item == navitem %} class="active" {% endif %}>17 <a href="{{root}}/{{item}}/">{{item | capitalize}}</a>18 </li>19 {% endfor %}20 <li><a href="https://github.com/jqlang/jq/issues">Issues</a></li>21 <li><a href="https://github.com/jqlang/jq">Source</a></li>22 <li><a href="https://jqplay.org">Try online!</a></li>23 <li><a href="https://raw.githubusercontent.com/jqlang/jq/master/NEWS.md">News</a></li>1 <div class="container visually-hidden-focusable">2 <a class="d-inline-flex p-2" href="#main">Skip to main content</a>3 {%- if navitem.startswith('manual') %}4 <a class="d-inline-flex p-2 m-1" href="#contents">Skip to table of contents</a>5 {%- endif %}6 </div>7 <header class="navbar navbar-expand-md sticky-top bg-body-tertiary d-print-none">8 <nav class="container-lg" aria-label="Page navigation">9 <button type="button" class="navbar-toggler" data-bs-toggle="offcanvas" data-bs-target="#navbar-collapse"10 aria-controls="navbar-collapse" aria-expanded="false" aria-label="Toggle page navigation">11 <span class="navbar-toggler-icon"></span>12 </button>13 <a class="navbar-brand" href="{{ root }}/" aria-label="Top page"><img src="{{ root }}/jq.svg" alt="jq logo" style="height:1.5rem"></a>14 <div id="navbar-collapse" class="offcanvas offcanvas-start navbar-collapse w-auto" aria-labelledby="navbar-title">15 <div class="offcanvas-header">16 <h3 id="navbar-title" class="me-3">jq</h3>17 <button type="button" class="d-md-none btn-close" data-bs-dismiss="offcanvas" aria-label="Close page navigation"></button>18 </div>19 <ul class="offcanvas-body navbar-nav me-auto text-nowrap">20 <li class="nav-item d-md-none"><a class="nav-link{% if not navitem %} active{% endif %}"{% if not navitem %} aria-current="page"{% endif %} href="{{ root }}/">Top page</a></li>21 {%- for item in ['tutorial', 'download', 'manual'] %}22 <li class="nav-item"><a class="nav-link{% if item == navitem %} active{% endif %}"{% if item == navitem %} aria-current="page"{% endif %} href="{{ root }}/{{ item }}/">{{ item | capitalize }}</a></li>23 {%- endfor %}24 <li class="nav-item"><a class="nav-link" href="https://github.com/jqlang/jq" target="_blank" rel="noopener">GitHub</a></li>25 <li class="nav-item"><a class="nav-link" href="https://github.com/jqlang/jq/issues" target="_blank" rel="noopener">Issues</a></li>26 <li class="nav-item"><a class="nav-link" href="https://jqplay.org" target="_blank" rel="noopener">Try online!</a></li>27 <li class="nav-item"><a class="nav-link" href="https://raw.githubusercontent.com/jqlang/jq/master/NEWS.md" target="_blank" rel="noopener">News</a></li>28 </ul>29 </div>26 </div>27 </div>30 {%- if navitem.startswith('manual') %}31 <div class="container-searchbox form-control p-0 d-none d-md-flex d-print-none border" style="width:16rem">32 <span class="bi bi-search my-auto ms-2 me-1" aria-hidden="true"></span>33 <input type="text" id="searchbox" class="form-control border-0 px-1" placeholder="Search manual" role="combobox"34 aria-label="Search manual" aria-keyshortcuts="/" aria-expanded="false" autocomplete="off" spellcheck="false">35 <kbd class="mx-1 my-auto text-body bg-body rounded border" style="padding:.1rem .2rem" aria-hidden="true">/</kbd>36 </div>37 {%- endif %}38 <a class="d-md-none bi bi-github fs-4 text-body" href="https://github.com/jqlang/jq" target="_blank" rel="noopener" aria-label="GitHub"></a>39 </nav>40 </header>
modified:docs/templates/default.html.j2+19 added-22 removed
1<!DOCTYPE html>2<html lang="en">3{% include "shared/_head.html.j2" %}45 <body id="{{slug}}">5 <body>6{% include "shared/_navbar.html.j2" %}78 <div class="container">9 <div class="row">10 <h1>{{headline}}</h1>11 {% for item in body %}12 {% if item.text %}13 {{ item.text | replace('$JQ_VERSION', jq_version) | markdownify }}14 {% endif %}8 <main id="main" class="container-lg">9 <h1>{{ headline }}</h1>10 {%- for item in body %}11 {%- if item.text %}12 {{ item.text | markdownify }}13 {%- endif %}1416 {% if item.command %}17 {% set resultID = unique_id() %}18 <div class="tutorial-example">19 <div class="accordion-heading">20 <pre>{{item.command}}</pre>21 <a data-toggle="collapse" href="#result{{resultID}}">Show result</a>22 </div>23 <div id="result{{resultID}}" class="accordion-body collapse">24 <pre>{{item.result}}</pre>25 </div>26 </div>27 {% endif %}28 {% endfor %}15 {%- if item.command %}16 {%- set resultID = unique_id() %}17 <div class="tutorial-example mb-3">18 <div class="d-flex accordion-heading me-2">19 <pre class="flex-grow-1 me-0 mb-0" tabindex="0">{{ item.command }}</pre>20 <button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-secondary-subtle link-body-emphasis flex-shrink-0 d-flex align-items-center border border-start-0 d-print-none"21 data-bs-toggle="collapse" data-bs-target="#result{{ resultID }}" aria-expanded="false" aria-controls="result{{ resultID }}">Show result</button>22 </div>23 <pre id="result{{ resultID }}" class="accordion-body collapse p-3 border-top-0 d-print-block" tabindex="0">{{ item.result }}</pre>24 </div>30 </div>25 {%- endif %}26 {%- endfor %}27 </main>2829{% include "shared/_footer.html.j2" %}30 </body>31</html>
modified:docs/templates/index.html.j2+37 added-54 removed
1<!DOCTYPE html>2<html lang="en">3{% include "shared/_head.html.j2" %}45 <body id="{{ slug }}">5 <body>6{% include "shared/_navbar.html.j2" %}78 <div class="container">8 <main id="main" class="container-lg">9 <div class="row">10 <div class="jumbotron">11 <div class="row">12 <div class="col-sm-6">13 <img src="{{root}}/jq.png" class="img-responsive" alt="jq logo"14 width="400" height="220">15 </div>16 <div class="col-sm-6">17 <div id="blurb">18 {{blurb | markdownify}}1920 <div class="btn-toolbar" role="toolbar">21 <div class="btn-group" role="group">22 <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">23 Download jq 1.624 <span class="caret"></span>25 </a>26 <ul class="dropdown-menu">27 <li><a href="https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64">Linux (64-bit)</a></li>28 <li><a href="https://github.com/jqlang/jq/releases/download/jq-1.6/jq-osx-amd64">macOS (64-bit)</a></li>29 <li><a href="https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win64.exe">Windows (64-bit)</a></li>30 <li><a href="{{root}}/download/">Other platforms, older versions, and source</a></li>31 </ul>32 </div>3334 <div class="btn-group">35 <a class="btn btn-primary" href="https://jqplay.org">36 Try online at jqplay.org!37 </a>38 </div>39 </div>40 </div>41 </div>10 <div class="col-md-6 text-center p-3">11 <h1><img src="{{ root }}/jq.svg" class="img-fluid" alt="jq" width="400" height="220"></h1>12 </div>13 <div class="col-md-6 d-flex flex-column justify-content-center text-center align-items-center">14 <h2 class="px-1" style="width:16em">{{ blurb }}</h2>15 <div class="btn-group d-print-none" role="group">16 <button type="button" class="btn btn-primary dropdown-toggle text-nowrap" data-bs-toggle="dropdown" aria-expanded="false">17 Download jq 1.618 <span class="caret"></span>19 </button>20 <ul class="dropdown-menu">21 <li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64" aria-label="Link to download executable: Linux (64-bit)"><span class="bi bi-download me-2" aria-hidden="true"></span>Linux (64-bit)</a></li>22 <li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.6/jq-osx-amd64" aria-label="Link to download executable: macOS (64-bit)"><span class="bi bi-download me-2" aria-hidden="true"></span>macOS (64-bit)</a></li>23 <li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win64.exe" aria-label="Link to download executable: Windows (64-bit)"><span class="bi bi-download me-2" aria-hidden="true"></span>Windows (64-bit)</a></li>24 <li><a class="dropdown-item" href="{{ root }}/download/">Other platforms, older versions, and source</a></li>25 </ul>26 <a class="btn btn-primary text-nowrap" href="https://jqplay.org" target="_blank" rel="noopener">27 Try online at jqplay.org!<span class="bi bi-box-arrow-up-right ms-1" aria-hidden="true"></span>28 </a>29 </div>30 </div>31 </div>3246 <div class="row" id="multiblurb">47 <div class="col-sm-4">{{body1 | markdownify}}</div>48 <div class="col-sm-4">{{body2 | markdownify}}</div>49 <div class="col-sm-4">{{body3 | markdownify}}</div>33 <div class="row my-3">34 <div class="col-md-4">{{ body1 | markdownify }}</div>35 <div class="col-md-4">{{ body2 | markdownify }}</div>36 <div class="col-md-4">{{ body3 | markdownify }}</div>37 </div>3852 <div class="row" style="text-align:center; margin-top: 30px">53 {{tail | markdownify}}39 <div class="text-center my-3">40 {{ tail | markdownify }}41 </div>4256 <div class="row">57 <h2>News</h2>58 <div id="news">59 <ul>60 {% for item in news %}61 <li>62 <span class="date">{{item.date}}</span>63 {{item.body | markdownify}}64 </li>65 {% endfor %}66 </ul>67 </div>43 <h2>News</h2>44 <ul>45 {%- for item in news %}46 <li>47 <span class="fst-italic">{{ item.date }}</span>48 {{ item.body | markdownify }}49 </li>50 {%- endfor %}51 </ul>52 </main>68 </div>69 </div>5354{% include "shared/_footer.html.j2" %}55 </body>56</html>
modified:docs/templates/manual.html.j2+95 added-84 removed
1<!DOCTYPE html>2<html lang="en">3{% include "shared/_head.html.j2" %}45 <body id="{{slug}}" data-spy="scroll" data-target="#navcolumn" data-offset="100">5 <body>6{% include "shared/_navbar.html.j2" %}78 <div class="container">9 <div class="row">10 <div class="affix" id="navcolumn">8 <div class="container-lg row align-items-start mx-auto p-3">910 <button type="button" class="d-md-none w-auto position-fixed bottom-0 end-0 p-2 m-3 bg-body-secondary border-0 text-body d-print-none"11 data-bs-toggle="offcanvas" data-bs-target="#contents" aria-controls="contents" aria-expanded="false" aria-label="Toggle table of contents">12 <span class="bi bi-list" aria-hidden="true"></span>13 </button>14 <nav id="contents" class="col-md-3 sticky-md-top p-3 overflow-y-auto offcanvas-md offcanvas-end d-print-none" style="top:4.5rem; height:calc(100dvh - 5.5rem);" aria-label="Table of contents">15 <div class="d-flex justify-content-between">16 <h4>Contents</h4>12 <ul class="nav nav-pills nav-stacked">13 {% for section in sections %}14 <li>15 <a href="#{{section.title | section_id}}">{{section.title}}</a>16 </li>17 {% endfor %}18 </ul>19 <form class="form-group" onsubmit="go_to_section(); return false;">20 <input type="text"21 class="form-control"22 placeholder="Search"23 autocomplete="off"24 id="searchbox">25 </form>17 <button type="button" class="btn-close d-md-none" data-bs-dismiss="offcanvas" data-bs-target="#contents" aria-label="Close table of contents"></button>18 </div>19 <ul class="offcanvas-md-body nav nav-pills flex-column">20 {%- for section in sections %}21 <li class="nav-item" data-bs-dismiss="offcanvas" data-bs-target="#contents">22 <a class="nav-link" href="#{{ section.title | section_id }}">{{ section.title }}</a>23 </li>24 {%- endfor %}25 </ul>26 </nav>27 {%- set section_ids = {} %}28 {%- macro check_section_id(id) -%}29 {%- if section_ids.__contains__(id) %}30 {{- raise('Duplicate section id: ' ~ id) }}31 {%- endif %}32 {%- set _ = section_ids.__setitem__(id, true) %}33 {%- endmacro %}34 <main id="main" class="col-md-9" data-bs-spy="scroll" data-bs-target="#contents" data-bs-threshold="0,1" data-bs-root-margin="-30% 0% -70%">35 <h1>{{ headline }}</h1>36 {{ history | markdownify }}37 {{ body | markdownify }}38 {%- for section in sections %}39 <section id="{{ section.title | section_id }}">{{ check_section_id(section.title | section_id) }}40 <h2>{{ section.title }} <a href="#{{ section.title | section_id }}" class="icon-link" aria-label="Link to this section: {{ section.title }}"><span class="bi bi-link-45deg" aria-hidden="true"></span></a></h2>41 {{ section.body | markdownify if section.body }}42 {%- for entry in section.entries %}43 <section id="{{ entry.title | entry_id }}">{{ check_section_id(entry.title | entry_id) }}44 <h3>45 {{ entry.title | markdownify | no_paragraph }}46 <a href="#{{ entry.title | entry_id }}" class="icon-link" aria-label="Link to this section: {{ entry.title }}"><span class="bi bi-link-45deg" aria-hidden="true"></span></a>47 </h3>48 {{ entry.body | markdownify }}49 {%- if entry.examples %}50 <div class="pb-3">51 {%- set exampleID = unique_id() %}52 <button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-transparent link-body-emphasis border-0" data-bs-toggle="collapse" data-bs-target="#example{{ exampleID }}" aria-expanded="false" aria-controls="example{{ exampleID }}">53 <span class="me-1 d-print-none" aria-hidden="true"><span class="bi bi-chevron-right"></span><span class="bi bi-chevron-down"></span></span>Example{% if entry.examples | length > 1 %}s{% endif %}54 </button>55 <div id="example{{ exampleID }}" class="collapse mx-3 small d-print-block">56 {%- for example in entry.examples %}57 <table class="table table-borderless table-sm w-auto">58 <tr>59 <th class="pe-3">Command</th>60 <td class="font-monospace">jq '{{ example.program }}'</td>61 </tr>62 <tr>63 <th>Input</th>64 <td class="font-monospace">{{ example.input }}</td>65 </tr>66 {%- if not example.output[0] %}67 <tr>68 <th>Output</th>69 <td class="fst-italic">none</td>70 </tr>71 {%- endif %}72 {%- for output in example.output %}73 <tr>74 <th>{% if loop.first %}Output{% endif %}</th>75 <td class="font-monospace">{{ output }}</td>76 </tr>77 {%- endfor %}78 <tr class="d-print-none">79 <th><a href="https://jqplay.org/jq?q={{ example.program | urlencode }}&j={{ example.input | urlencode }}" class="btn btn-outline-primary btn-sm" target="_blank" rel="noopener">Run<span class="bi bi-box-arrow-up-right ms-2" aria-hidden="true"></span></a></th>80 <td></td>81 </tr>82 </table>83 {%- endfor %}84 </div>85 </div>86 {%- endif %}87 </section>88 {%- endfor %}89 </section>90 {%- endfor %}91 </main>9228 <div id="manualcontent">29 <h1>{{headline}}</h1>30 {{ history | markdownify }}31 {{ body | markdownify }}32 {% for section in sections %}33 <section id="{{section.title | section_id}}">34 <h2>{{section.title}}</h2>35 {{ (section.body | markdownify) if section.body }}36 {% for entry in section.entries %}37 <section id="{{entry.title | entry_id}}">38 <h3>39 {{entry.title | markdownify | no_paragraph }}40 {% if entry.subtitle %}<small>{{entry.subtitle}}</small>{% endif %}41 </h3>42 {{entry.body | markdownify}}4344 {% if entry.examples %}45 <div>46 {% set exampleID = unique_id() %}47 <a data-toggle="collapse" href="#example{{exampleID}}">48 <i class="glyphicon glyphicon-chevron-right"></i>49 {% if entry.examples | length > 1 %}Examples{%else%}Example{%endif%}50 </a>51 <div id="example{{exampleID}}" class="manual-example collapse">52 {% for example in entry.examples %}53 <table>54 <tr><th></th><td class="jqprogram">jq '{{ example.program }}'</td></tr>55 <tr><th>Input</th><td>{{ example.input }}</td></tr>56 {% if not example.output[0] %}57 <tr>58 <th>Output</th>59 <td><i>none</i></td>60 </tr>61 {% endif %}62 {% for output in example.output %}63 <tr>64 {% if loop.first %}65 <th>Output</th>66 {% else %}67 <th></th>68 {% endif %}69 <td>{{ output }}</td>70 </tr>71 {% endfor %}72 </table>73 {% endfor %}74 </div>75 </div>76 {% endif %}77 </section>78 {% endfor %}79 </section>80 {% endfor %}81 </div>82 </div>93 </div>9495{% include "shared/_footer.html.j2" %}86 <script>87 var section_map = {88 {% for section in sections %}89 {% for entry in section.entries %}90 {{entry.title | search_id | tojson }} : {{entry.title | entry_id | tojson }},91 {% endfor %}92 {{section.title | search_id | tojson }} : {{section.title | section_id | tojson }}93 {% if not loop.last %},{% endif %}94 {% endfor %}95 };96 <script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.min.js"97 integrity="sha384-xbzjoN6H5XHmAqoSSR42hZVRninPGx85y+XZQGlWxVu2y91lTmr/oD80i5cjeUBv" crossorigin="anonymous"></script>98 <script id="section-ids" type="application/json">99 {100 {%- for section in sections %}101 {%- for entry in section.entries %}102 {{ entry.title | search_id | tojson }}: {{ entry.title | entry_id | tojson }},103 {%- endfor %}104 {{ section.title | search_id | tojson }}: {{ section.title | section_id | tojson }}{{ "," if not loop.last }}105 {%- endfor %}106 }107 </script>97 <script src="{{root}}/js/manual-search.js"></script>108 <script src="{{ root }}/js/manual-search.js"></script>109 </body>110</html>
modified:docs/build_website.py+27 added-10 removed
1#!/usr/bin/env python32import argparse3import glob4import itertools5from jinja2 import Environment, FileSystemLoader, select_autoescape, pass_context6from markdown import markdown
3 unmodified lines
10import re11import shutil12import yaml1314parser = argparse.ArgumentParser()15parser.add_argument('--root', default='/jq')16args = parser.parse_args()1718env = Environment(19 loader=FileSystemLoader('templates'),20 autoescape=select_autoescape(['html.j2']),21)
3 unmodified lines
25 with open(fn) as f:26 return yaml.safe_load(f)272829env.globals['url'] = 'https://jqlang.github.io/jq'30env.globals['root'] = args.root3132env.filters['search_id'] = lambda input: input.replace(r'`', '')25env.filters['section_id'] = lambda input: re.sub(r"[^a-zA-Z0-9_]", '', input)26env.filters['entry_id'] = lambda input: re.sub(r"[ `]", '', input)33env.filters['section_id'] = lambda input: re.sub(34 r'[^-a-zA-Z0-9_]', '', input.replace(' ', '-')).lower()35env.filters['entry_id'] = lambda input: re.sub(36 r'^(split|first-last-nth)$',37 r'\1' + ('-1' if ';' not in input else '-2'), # avoid id conflict38 re.sub(39 r'\b([^-]+)(?:-\1)+\b',40 r'\1', # e.g. range-range-range -> range41 re.sub(r' ?/ ?|,? ', '-',42 re.sub(r'[`;]|: .*|\(.*?\)| \[.+\]', '', input)))).lower()43env.filters['markdownify'] = lambda input: Markup(markdown(input))28env.filters['no_paragraph'] = lambda input: Markup(re.sub(r"</?p>", '', input))44env.filters['no_paragraph'] = lambda input: Markup(re.sub(r'</?p>', '', input))4546env.globals['unique_id'] = pass_context(47 lambda ctx: str(next(ctx['unique_ctr'])))4833env.globals.update(load_yml_file('site.yml'))4935env.globals['navigation'] = ['tutorial', 'download', 'manual']50def raise_handler(message):51 raise Exception(message)525338def generate_file(env, fname='content/1.tutorial/default.yml'):54env.globals['raise'] = raise_handler555657def generate_file(env, fname):58 path, base = os.path.split(fname)59 path = os.path.relpath(path, 'content')60 if path == '.':61 path = ''43 slug = 'index'62 permalink = ''63 else:46 slug = os.path.basename(path)64 permalink = path + '/'6566 output_dir = os.path.join('output', path)67 output_path = os.path.join(output_dir, 'index.html')6852 template_name = re.sub(r".yml$", '.html.j2', base)69 template_name = re.sub(r'.yml$', '.html.j2', base)7071 ctx = load_yml_file(fname)72 ctx.update(unique_ctr=itertools.count(1),73 permalink=permalink,57 slug=slug,74 navitem=path)75 os.makedirs(output_dir, exist_ok=True)76 env.get_template(template_name).stream(ctx).dump(output_path,77 encoding='utf-8')
9 unmodified lines
87 else:88 shutil.copyfile(f.path, dst)899091os.makedirs('output', exist_ok=True)92copy_public_files()9394for fn in glob.glob('content/**/*.yml', recursive=True):95 generate_file(env, fn)
modified:docs/README.md+7 added-7 removed
9 unmodified lines
10 pip install pipenv1112Though, you may need to say `pip3` instead, depending on your system. Once13you have `pipenv` installed, you can install the dependencies by running14`pipenv sync` from the `docs` directory.14`pipenv sync` from the `docs/` directory.1516Also, you may need to run `virtualenv -p /usr/bin/python3 venv/` and17then `source venv/bin/activate`, and only then `pipenv sync`.1819Once this is done, rerun `./configure` in the jq root directory and then20the Makefile will be able to generate the jq manpage. You can also just21run `pipenv run build_manpage.py` in the `docs` directory to build the22`jq.1` page manually, and `pipenv run build_mantests.py` to build the23contents of `tests/man.test` and `tests/manonig.test`.20the `Makefile` will be able to generate the jq manpage. You can just run21`make jq.1` to build the manpage manually, and `make tests/man.test` to22update the manual tests.2325To build the website, run `pipenv run ./build_website.py` from inside26the `docs` directory.24To build the website, run `pipenv run python3 build_website.py --root /output`25in the `docs/` directory. To serve them locally, you can run26`python3 -m http.server`.
deleted:docs/site.yml-9 removed
1# The key value pairs found below are available within the templates.23url: https://jqlang.github.io/jq45# This line is modified by the Makefile. To change the version number,6# edit the Autoconf version number at the top of configure.ac7jq_version: "1.6-159-gcff5336-dirty"89root: '/jq'
modified:Makefile.am+1 added-5 removed
195 unmodified lines
196endif197198### Packaging199200docs/site.yml: configure.ac201 sed 's/^jq_version: .*/jq_version: "$(VERSION)"/' $@ > $@.new202 mv $@.new $@203200install-binaries: $(BUILT_SOURCES)201 $(MAKE) $(AM_MAKEFLAGS) install-exec202207DOC_FILES = docs/content docs/public docs/templates docs/site.yml \203DOC_FILES = docs/content docs/public docs/templates \204 docs/Pipfile docs/Pipfile.lock docs/build_manpage.py \205 docs/build_mantests.py docs/build_website.py docs/README.md \206 docs/validate_manual_schema.py docs/manual_schema.yml207
38 unmodified lines