Author:
Hash:
Timestamp:
+66 -43 +/-3 browse
Kevin Schoon [me@kevinschoon.com]
12436e1c79a20668c01a388e37f0723076e8a08c
Fri, 16 May 2025 16:46:35 +0000 (6 months ago)
| 1 | diff --git a/ayllu/src/highlight.rs b/ayllu/src/highlight.rs |
| 2 | index 49c6633..e21411b 100644 |
| 3 | --- a/ayllu/src/highlight.rs |
| 4 | +++ b/ayllu/src/highlight.rs |
| 5 | @@ -17,12 +17,27 @@ use crate::languages::{Hint, LANGUAGE_TABLE}; |
| 6 | |
| 7 | const PIXELS_PER_CHARACTER: usize = 8; |
| 8 | |
| 9 | + // the defaults shipped with tree-sitter-diff aren't suitable |
| 10 | + // for displaying in the Ayllu UI so we ship with our own. The |
| 11 | + // user can override them by setting [tree-sitter.hightlights] |
| 12 | + // in their config file. |
| 13 | + const DEFAULT_DIFF_HIGHLIGHTS: &str = r#" |
| 14 | + ; used to highlight diffs in the UI |
| 15 | + [(addition) (new_file)] @addition |
| 16 | + [(deletion) (old_file)] @removal |
| 17 | + |
| 18 | + (commit) @constant |
| 19 | + (location) @attribute |
| 20 | + (command) @variable.builtin |
| 21 | + "#; |
| 22 | + |
| 23 | lazy_static! { |
| 24 | // global containing all language parsers and syntax highlighter definitions |
| 25 | // this needs to be initialized one time at startup |
| 26 | static ref LANGUAGES: RwLock<HashMap<Hint, Language>> = RwLock::new(HashMap::new()); |
| 27 | // highlighter queries |
| 28 | - static ref HIGHLIGHTS: RwLock<HashMap<Hint, String>> = RwLock::new(HashMap::new()); |
| 29 | + static ref HIGHLIGHTS: RwLock<HashMap<Hint, String>> = RwLock::new(HashMap::from_iter( |
| 30 | + vec![(Hint(String::from("diff")), DEFAULT_DIFF_HIGHLIGHTS.to_string())].into_iter())); |
| 31 | // local queries |
| 32 | static ref LOCALS: RwLock<HashMap<Hint, String>> = RwLock::new(HashMap::new()); |
| 33 | // injection queries |
| 34 | @@ -146,7 +161,10 @@ impl Loader { |
| 35 | Ok::<Vec<std::fs::DirEntry>, std::io::Error>(accm) |
| 36 | })?; |
| 37 | if let Some(additional_modules) = self.extra_modules_path.as_ref() { |
| 38 | - tracing::debug!("Loading additional TS modules from {:?}", additional_modules); |
| 39 | + tracing::debug!( |
| 40 | + "Loading additional TS modules from {:?}", |
| 41 | + additional_modules |
| 42 | + ); |
| 43 | entries.extend(fs::read_dir(additional_modules.as_path())?.try_fold( |
| 44 | Vec::new(), |
| 45 | |mut accm, path| { |
| 46 | diff --git a/config.example.toml b/config.example.toml |
| 47 | index 3f0679d..f28eda9 100644 |
| 48 | --- a/config.example.toml |
| 49 | +++ b/config.example.toml |
| 50 | @@ -17,7 +17,7 @@ sysadmin = "admin@example.org" |
| 51 | # max_blocking_threads = 512 |
| 52 | |
| 53 | # logging level |
| 54 | - log_level = "info" |
| 55 | + log_level = "INFO" |
| 56 | |
| 57 | # enable when ayllu is being served from a "subpath". Clicking the home |
| 58 | # button will send the user back to /browse instead of /. This is useful if you |
| 59 | @@ -95,7 +95,7 @@ profiles = [ |
| 60 | |
| 61 | [http] |
| 62 | # interface and port to listen on |
| 63 | - address = "127.0.0.1:8080" |
| 64 | + address = "127.0.0.1:10000" |
| 65 | |
| 66 | [web] |
| 67 | # default theme that will be used when none is specified in user configuration. |
| 68 | @@ -126,42 +126,45 @@ enabled = false |
| 69 | |
| 70 | # tree-sitter highlighting keywords, these are attributes that will be |
| 71 | # exposed as CSS classes which can be used to create themes. |
| 72 | - keywords = [ |
| 73 | - "attribute", |
| 74 | - "comment", |
| 75 | - "constant", |
| 76 | - "function.builtin", |
| 77 | - "function", |
| 78 | - "keyword", |
| 79 | - "operator", |
| 80 | - "property", |
| 81 | - "punctuation", |
| 82 | - "punctuation.bracket", |
| 83 | - "punctuation.delimiter", |
| 84 | - "string", |
| 85 | - "string.special", |
| 86 | - "tag", |
| 87 | - "type", |
| 88 | - "type.builtin", |
| 89 | - "variable", |
| 90 | - "variable.builtin", |
| 91 | - "variable.parameter", |
| 92 | - ] |
| 93 | + # keywords = [ |
| 94 | + # "attribute", |
| 95 | + # "comment", |
| 96 | + # "constant", |
| 97 | + # "function.builtin", |
| 98 | + # "function", |
| 99 | + # "keyword", |
| 100 | + # "operator", |
| 101 | + # "property", |
| 102 | + # "punctuation", |
| 103 | + # "punctuation.bracket", |
| 104 | + # "punctuation.delimiter", |
| 105 | + # "string", |
| 106 | + # "string.special", |
| 107 | + # "tag", |
| 108 | + # "type", |
| 109 | + # "type.builtin", |
| 110 | + # "variable", |
| 111 | + # "variable.builtin", |
| 112 | + # "variable.parameter", |
| 113 | + # "keyword_insert", |
| 114 | + # "addition", |
| 115 | + # "removal" |
| 116 | + # ] |
| 117 | |
| 118 | # override system highlights with your own configuration as needed |
| 119 | - [tree-sitter.highlights] |
| 120 | + # [tree-sitter.highlights] |
| 121 | |
| 122 | # this results in two new CSS classes ts_addition and ts_removal which can |
| 123 | # be configured in theme stylesheets. |
| 124 | - diff = """ |
| 125 | - ; used to highlight diffs in the UI |
| 126 | - [(addition) (new_file)] @addition |
| 127 | - [(deletion) (old_file)] @removal |
| 128 | - |
| 129 | - (commit) @constant |
| 130 | - (location) @attribute |
| 131 | - (command) @variable.builtin |
| 132 | - """ |
| 133 | + # diff = """ |
| 134 | + # ; used to highlight diffs in the UI |
| 135 | + # [(addition) (new_file)] @addition |
| 136 | + # [(deletion) (old_file)] @removal |
| 137 | + # |
| 138 | + # (commit) @constant |
| 139 | + # (location) @attribute |
| 140 | + # (command) @variable.builtin |
| 141 | + # """ |
| 142 | |
| 143 | |
| 144 | # [[tree-sitter.parsers]] |
| 145 | diff --git a/containers/ayllu/Containerfile b/containers/ayllu/Containerfile |
| 146 | index 4194c46..f725572 100644 |
| 147 | --- a/containers/ayllu/Containerfile |
| 148 | +++ b/containers/ayllu/Containerfile |
| 149 | @@ -5,19 +5,19 @@ ARG CARGO_CACHE_OFFLINE="--mount=type=cache,target=/src/.cargo/registry,id=ayllu |
| 150 | |
| 151 | FROM $BUILD_IMAGE AS build |
| 152 | |
| 153 | - ARG TREE_SITTER_DIFF_UPSTREAM_URL="https://github.com/the-mikedavis/tree-sitter-diff/archive/refs/tags" |
| 154 | - ARG TREE_SITTER_DIFF_TAG="v0.1.0" |
| 155 | - ARG TREE_SITTER_DIFF_SHA256SUM="f84c575d5c4347f6dfeab6d05971d7d624396ee63d7bbbfc841d04ddfb0ab064" |
| 156 | + ARG TREE_SITTER_DIFF_UPSTREAM_URL="https://github.com/the-mikedavis/tree-sitter-diff/archive" |
| 157 | + ARG TREE_SITTER_DIFF_COMMIT="e42b8def4f75633568f1aecfe01817bf15164928" |
| 158 | + ARG TREE_SITTER_DIFF_SHA256SUM="43ad430fa097f353379e905f94f1393f782531d7c2341f3bee3b971602aabbb4" |
| 159 | |
| 160 | # TODO: tree-sitter-diff needs APK support |
| 161 | RUN \ |
| 162 | - curl -L "$TREE_SITTER_DIFF_UPSTREAM_URL/$TREE_SITTER_DIFF_TAG.tar.gz" \ |
| 163 | + curl -L "$TREE_SITTER_DIFF_UPSTREAM_URL/$TREE_SITTER_DIFF_COMMIT.tar.gz" \ |
| 164 | -o tree-sitter-diff.tar.gz \ |
| 165 | && echo "$TREE_SITTER_DIFF_SHA256SUM tree-sitter-diff.tar.gz" | sha256sum -c \ |
| 166 | && tar xvf tree-sitter-diff.tar.gz |
| 167 | |
| 168 | RUN cd tree-sitter-diff-* && abuild-tree-sitter build \ |
| 169 | - && cp src/diff.so ../ && cp queries/highlights.scm ../diff.scm |
| 170 | + && cp src/diff.so ../ |
| 171 | |
| 172 | # RUN $CARGO_CACHE_STATE cargo install --color=never --no-default-features --features sqlite sqlx-cli |
| 173 | # |
| 174 | @@ -96,12 +96,13 @@ RUN rm -v /usr/lib/libtree-sitter-cpp.so |
| 175 | # Manually install tree-sitter-diff |
| 176 | # See https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/tree-sitter/abuild-tree-sitter#L89 |
| 177 | COPY --from=build --chown=0:0 /src/diff.so /usr/lib/tree-sitter/ |
| 178 | - COPY --from=build --chown=0:0 /src/diff.scm /usr/share/tree-sitter/queries/diff.scm |
| 179 | + |
| 180 | + # Do not ship this because we override it at runtime |
| 181 | + # COPY --from=build --chown=0:0 /src/diff.scm /usr/share/tree-sitter/queries/diff/highlights.scm |
| 182 | |
| 183 | RUN \ |
| 184 | chmod 755 /usr/lib/tree-sitter/diff.so \ |
| 185 | - && chmod 744 /usr/share/tree-sitter/queries/diff.scm && \ |
| 186 | - ln -sv /usr/lib/tree-sitter/diff.so /usr/lib/libtree-sitter-diff.so |
| 187 | + && ln -sv /usr/lib/tree-sitter/diff.so /usr/lib/libtree-sitter-diff.so |
| 188 | |
| 189 | # COPY --from=build --chown=0:0 /src/rudolfs /usr/bin/ |
| 190 | COPY --from=build --chown=0:0 /src/target/release/ayllu /usr/bin/ |
| 191 | @@ -121,6 +122,7 @@ RUN adduser -D -s /bin/sh -h /home/ayllu ayllu |
| 192 | RUN \ |
| 193 | mkdir -p /etc/ayllu /var/lib/ayllu /var/lib/git && \ |
| 194 | ayllu config generate > /etc/ayllu/config.toml && \ |
| 195 | + ayllu config set "http.address" "'0.0.0.0:10000'" && \ |
| 196 | fc-cache -fv # update font cache which is required by plotters.rs |
| 197 | |
| 198 | # setup an unprivileged user for rudolfs |