aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-05-30 19:40:02 -0300
committerEuAndreh <eu@euandre.org>2021-05-30 19:40:02 -0300
commitb8cf943fb17a750aaf9f567fb97e7392d9cfb455 (patch)
tree566499e8369922c8af63b574364c619755a02b7b /src
parentRemove empty Perl code (diff)
downloadgistatic-b8cf943fb17a750aaf9f567fb97e7392d9cfb455.tar.gz
gistatic-b8cf943fb17a750aaf9f567fb97e7392d9cfb455.tar.xz
WIP init Rust
Diffstat (limited to 'src')
-rw-r--r--src/cli/main.rs4
-rw-r--r--src/lib/lib.rs19
-rw-r--r--src/templates/commit.html0
-rw-r--r--src/templates/head.html12
-rw-r--r--src/templates/header.html46
-rw-r--r--src/templates/log.html34
6 files changed, 115 insertions, 0 deletions
diff --git a/src/cli/main.rs b/src/cli/main.rs
new file mode 100644
index 0000000..cdb964d
--- /dev/null
+++ b/src/cli/main.rs
@@ -0,0 +1,4 @@
+pub fn main() {
+ println!("Hello, World!");
+ println!("a_fn(): {}", gistatic::a_fn());
+}
diff --git a/src/lib/lib.rs b/src/lib/lib.rs
new file mode 100644
index 0000000..311a11f
--- /dev/null
+++ b/src/lib/lib.rs
@@ -0,0 +1,19 @@
+const t: &'static str = include_str!("../templates/log.html");
+
+pub fn a_fn() -> i32 {
+ // println!("log.html.tmpl: {}", t);
+ let template = mustache::compile_str(t).unwrap();
+ let _data = mustache::MapBuilder::new()
+ .insert_str("name", "Venus")
+ .build();
+
+ let mut d2 = std::collections::HashMap::new();
+ d2.insert("a", "b");
+ template.render(&mut std::io::stdout(), &d2). unwrap();
+
+ 0
+}
+
+#[test]
+fn a_test() {
+}
diff --git a/src/templates/commit.html b/src/templates/commit.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/templates/commit.html
diff --git a/src/templates/head.html b/src/templates/head.html
new file mode 100644
index 0000000..e6988ec
--- /dev/null
+++ b/src/templates/head.html
@@ -0,0 +1,12 @@
+<head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
+ <link rel="alternate" type="application/atom+xml" title="{{ name }} atom feed of commits" href="commits.xml" />
+ <link rel="alternate" type="application/atom+xml" title="{{ name }} atom feed of tags" href="tags.xml" />
+ <link rel="stylesheet" type="text/css" href="style.css" />
+
+ <title>Log - {{ name }} - {{ description }}</title>
+
+ <!-- FIXME: metadata tags -->
+</head>
diff --git a/src/templates/header.html b/src/templates/header.html
new file mode 100644
index 0000000..bbad31a
--- /dev/null
+++ b/src/templates/header.html
@@ -0,0 +1,46 @@
+<table>
+ <tr>
+ <td>
+ <a href="../">
+ <img src="logo.svg" alt="Logo of the project {{ name }}." width="32" height="32" />
+ </a>
+ </td>
+ <td>
+ <h1>{{ name }}</h1>
+ <span class="desc">{{ description }}</span>
+ </td>
+ </tr>
+ <tr class="url">
+ <td>
+ <!-- facepalm -->
+ </td>
+ <td>
+ git clone
+ <a href="{{ clone-prefix }}/{{ name }}">
+ {{ clone-prefix }}/{{ name }}
+ </a>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <!-- y u no CSS? -->
+ </td>
+ <td>
+ <a href="index.html">
+ summary
+ </a>
+ |
+ <a href="files.html">
+ files
+ </a>
+ |
+ <a href="log.html">
+ log
+ </a>
+ |
+ <a href="refs.html">
+ refs
+ </a>
+ </td>
+ </tr>
+</table>
diff --git a/src/templates/log.html b/src/templates/log.html
new file mode 100644
index 0000000..7caa079
--- /dev/null
+++ b/src/templates/log.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang="en">
+ {{ > head.html.tmpl }}
+ <body>
+ {{ > header.html.tmpl }}
+ <hr />
+
+ <div id="content">
+ <table id="log">
+ <thead>
+ <tr>
+ <!-- y u not semantic? -->
+ <td><b>Date</b></td>
+ <td><b>Commit message</b></td>
+ <td><b>Author</b></td>
+ <td><b>Files</b></td>
+ <td><b>Lines</b></td>
+ </tr>
+ </thead>
+ <tbody>
+ {{ #commits }}
+ <tr>
+ <td>{{ date }}</td>
+ <td><a href="commit/{{ sha }}.html">{{ message_title }}</a></td>
+ <td>{{ author }}</td>
+ <td class="num" align="right">{{ files }}</td>
+ <td class="num" align="right"><span class="diff-removed">-{{ removed }}</span>/<span class="diff-added">+{{ added }}</span></td>
+ </tr>
+ {{ /commits }}
+ </tbody>
+ </table>
+ </div>
+ </body>
+</html>