mygit

[UNMAINTAINED] A cgit/webgit alternative, written in Rust
Log | Files | Refs | README | LICENSE

commit 9c41992e4a4220ac4738b038e367eb112ff4a372
parent 03fe8f7198e239b27f43a6f9ccbaf39171e5148e
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun,  8 Aug 2021 12:07:30 -0700

Merge branch 'main' of git://qwertqwefsday.eu/mygit

Diffstat:
Msrc/errorpage.rs | 6++++--
Msrc/filters.rs | 2+-
Msrc/main.rs | 4+++-
Mtemplates/base.html | 2+-
Mtemplates/commit.html | 4++--
Mtemplates/last-commit.html | 4++--
Mtemplates/repo-navbar.html | 2+-
Mtemplates/repo.html | 2+-
Mtemplates/static/style.css | 32+++++++++++++++++++-------------
Mtemplates/tag.html | 2+-
10 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/src/errorpage.rs b/src/errorpage.rs @@ -27,13 +27,15 @@ impl<State: Clone + Send + Sync + 'static> Middleware<State> for ErrorToErrorpag } else { let message = match status { // don't expose 500 error - StatusCode::InternalServerError if !cfg!(debug_assertions) => "Internal Server Error".to_owned(), + StatusCode::InternalServerError if !cfg!(debug_assertions) => { + "Internal Server Error".to_owned() + } _ => err.into_inner().to_string(), }; response = ErrorTemplate { resource, status, - message: message + message, } .into(); response.set_status(status); diff --git a/src/filters.rs b/src/filters.rs @@ -3,7 +3,7 @@ use git2::{Commit, Repository, Signature, Time}; pub fn format_datetime(time: &Time, format: &str) -> askama::Result<String> { use chrono::{FixedOffset, TimeZone}; - let offset = FixedOffset::west(time.offset_minutes() * 60); + let offset = FixedOffset::east(time.offset_minutes() * 60); let datetime = offset.timestamp(time.seconds(), 0); Ok(datetime.format(format).to_string()) } diff --git a/src/main.rs b/src/main.rs @@ -173,7 +173,9 @@ fn repo_from_request(repo_name: &str) -> Result<Repository, tide::Error> { .decode_utf8_lossy() .into_owned(); - let repo_path = Path::new(&CONFIG.projectroot).join(repo_name).canonicalize()?; + let repo_path = Path::new(&CONFIG.projectroot) + .join(repo_name) + .canonicalize()?; // prevent path traversal if !repo_path.starts_with(&CONFIG.projectroot) { diff --git a/templates/base.html b/templates/base.html @@ -14,7 +14,7 @@ <div id="content"> {% block content %}{% endblock %} </div> - <hr class="thin"> + <hr/> <div class="footer"> Server running <a href="https://git.alexwennerberg.com/mygit">mygit</a> </div> diff --git a/templates/commit.html b/templates/commit.html @@ -21,8 +21,8 @@ <br> {% let stats = diff.stats().unwrap() %} {{stats.files_changed()}} files changed; {{stats.insertions()}} insertions {{stats.deletions()}} deletions - <hr class="thin"/> + <hr/> <pre class="commit-message">{{commit.message().unwrap()}}</pre> - <hr class="thin"/> + <hr/> <pre id="diff">{{self.diff()|safe}}</pre> {% endblock %} diff --git a/templates/last-commit.html b/templates/last-commit.html @@ -1,4 +1,4 @@ -<hr class="thin"/> +<hr/> <table> {% let commit = last_commit.clone() %} {% include "commit-tr.html" %} @@ -6,4 +6,4 @@ <td colspan="4"><a href="/{{repo|repo_name|urlencode_strict}}/log/{{spec}}/{{path.display()}}">...</a></td> </tr> </table> -<hr class="thin"/> +<hr/> diff --git a/templates/repo-navbar.html b/templates/repo-navbar.html @@ -2,4 +2,4 @@ <div>{{repo|description}}</div> <div class="clone-url">git clone <a>{{crate::CONFIG.clone_base}}/{{repo|repo_name}}</a></div> <div class="navbar"><a href="/{{repo|repo_name|urlencode_strict}}">README</a> | <a href="/{{repo|repo_name|urlencode_strict}}/tree">tree</a> | <a href="/{{repo|repo_name|urlencode_strict}}/log">log</a> | <a href="/{{repo|repo_name|urlencode_strict}}/refs">refs</a></div> -<hr class='thin'> +<hr/> diff --git a/templates/repo.html b/templates/repo.html @@ -12,7 +12,7 @@ <td colspan="4"><a href="/{{repo|repo_name|urlencode_strict}}/log/">...</a></td> </tr> </table> - <hr class="thin"/> + <hr/> <div class="readme"> {% if !readme_text.is_empty() -%} {{ readme_text|safe }} diff --git a/templates/static/style.css b/templates/static/style.css @@ -8,13 +8,22 @@ body { line-height: 1.5; } -body > hr { margin-left: -1ch; } - -table { border-spacing: 0.5em 0.1em; } +hr { + margin-left: -1ch; + margin-right: -1ch; + border: 0; + height: 0; + border-top: 1px solid; +} -.clone-url { font-size: 0.9em; } +table { + border-spacing: 0.5em 0.1em; +} -.clone-url { float: right; } +.clone-url { + font-size: 0.9em; + float: right; +} .readme { max-width: 80ch; @@ -22,6 +31,8 @@ table { border-spacing: 0.5em 0.1em; } .repo-last-updated { font-style: italic; + /* so digits of the dates are aligned */ + font-variant-numeric: tabular-nums; } .repo-link, .git-reference, .permissions, .commit-hash, .filename, .filesize, .commit-message{ @@ -58,12 +69,6 @@ a.line { user-select: all; /* Standard syntax */ } -hr.thin { - border: 0; - height: 0; - border-top: 1px solid; -} - h1, h2, h3 { margin: 0; } @@ -145,11 +150,12 @@ Light is the default color scheme, not using a media query for browser support. body { color: black; } + .code, .keyword.operator.comparison, .keyword.operator.assignment, .keyword.operator.arithmetic, .meta.brace.round, .meta.brace.curly, .punctuation.section, .punctuation.section.block, .punctuation.definition.parameters, .punctuation.section.group, .meta.selector.css, .text.html.basic, .meta.tag.other.html, .text.html.basic, .meta.tag.any.html, .text.html.basic, .meta.tag.block.any, .text.html.basic, .meta.tag.inline.any, .text.html.basic, .meta.tag.structure.any.html, .text.html.basic, .source.js.embedded.html, .punctuation.separator.key-value.html, .variable.other.readwrite.js, .variable.other.object.js, .variable.other.constant.js, .punctuation.definition.string { color: #4f5f5f; /* SolAArized main-light */ } -hr.thin { +hr { border-top-color: #4f5f5f; /* SolAArized main-light */ } @@ -217,7 +223,7 @@ a, .variable, .entity.other.inherited-class, .entity.name.tag, .storage.type, .m color: #919ea1; /* SolAArized main-dark */ } - hr.thin { + hr { border-top-color: #919ea1; /* SolAArized main-dark */ } diff --git a/templates/tag.html b/templates/tag.html @@ -12,6 +12,6 @@ <b>Date:</b> {{tag.tagger().unwrap().when()|format_datetime("%c %z")}} <br> {% endif %} - <hr class="thin"/> + <hr/> <pre class="commit-message">{{tag.message().unwrap()}}</pre> {% endblock %}