On 2018-06-28 00:36, Chad Perrin wrote:
On Wed, Jun 27, 2018 at 11:31:57PM -0500, Lester L. Martin II wrote:
This patch changes the way `void artifact_page(void)` renders a files
content.  Formerly a `<blockquote><pre>` was issued for content,
whereas now a `<blockquote><pre><code class=$ext>` is issued where
$ext is the file's extension (example, "blah.lua" extension would be
"lua").

This allows for proper integration with syntax highlighting systems
such as "highlight.js" and "prism.js" where only the former was
tested. This allows syntax highlighting without having to have
language detection.

It's pretty cool you did this.  I'm going to look over this and the
syntax highlighting tools that might work with it to see if I want to
start using it, though I guess I'd have to compile my own Fossil if I
wanted to do it sooner rather than later.  Thanks for the work.

Glad you may find it useful, the steps to get it working with highlightjs
is just to edit a Skin/Theme you like and add the following lines:
<link rel="stylesheet" href="https://your_domain/agate.min.css";>
<script src="https://your_domain/highlight.min.js";></script>
<script>
hljs.configure({languages: []})
hljs.initHighlightingOnLoad();
</script>

You'll need to download highlightjs, and the corresponding CSS theme
for it that you like of course, and either configure nginx, or your
webserver or choice, to serve a static directory on the same domain,
or to use fossil's "--files" param to get fossil to serve those files.

Remaining work likely includes changing the CSS of all themes to take
this into account. Other things that might be considered is to
conditionally remove the `<blockquote>` part from all but the content
rendering. Another part would be rendering syntax highlights with line
numbers (currently unimplemented).

Have you checked it against any themese to see if it affects them at
all?  If so, which themes did you find weren't problematic?  I'm
guessing that if you found some that were you'd mention it.

The only themes it doesn't look visually opinion with this IMO are
Ardoise and Bootstrap. Note I didn't test all themes in a dark mode. The
following is a review of each theme.

Works:
Default, Blitz, Original, Enhanced Original, Black and White (menu on the
left), Plain Gray no Logo

Works with comment:
Blitz (looks decent)
Xekri (doubled border, looks decent still)
Shadow Boxes and Rounded Corners (doubled border, looks decent still)

Doesn't work:
Ardoise (my fav theme at the moment, doubled borders look horrid)
Bootstrap (not bad, but the doubled border isn't great either)

If a theme is left unmentioned it probably worked, the list of what worked
was growing far too long.

Below is the output of 'fossil diff' ran against checkout
'6a7d2ad8f1dd5c542eba0b885418328803d8d802' with my changes:

Index: src/info.c
==================================================================
--- /home/masky/misc/fossil/src/info.c~0        2018-06-27 23:21:48.520779000
-0500
+++ /home/masky/misc/fossil/src/info.c  2018-06-27 16:48:28.683256000
-0500
@@ -670 +670 @@
-
+
@@ -2157 +2157,2 @@
-        const char *z;
+        const char *z, *ext, *name;
+        char *tmp;
@@ -2158,0 +2160,3 @@
+        name = blob_str(&downloadName);
+
+        ext = (tmp = strrchr(name, '.')) == NULL ? "" : tmp+1;
@@ -2162 +2166 @@
-          @ <pre>
+          @ <pre><code class="%h(ext)">
@@ -2164 +2168 @@
-          @ </pre>
+          @ </code></pre>
@@ -2232 +2236 @@
-      ? db_text("(No title)",
+      ? db_text("(No title)",

!!END!!

I'm unsure why "@@ -2232 +2236 @@" section got included as no changes
were
made to that.

I haven't looked at the code in context; I've only seen the patch you
inlined in the email so far. It looks sane to me, though. I might come
back and look at it again in the morning, and check it against the
Fossil source code for context.



I would like to submit a contributor agreement to make it official. This
change is so small that my previous post to the list serv considered,
one could have implemented it in less time than it would take for a
contributor agreement to finally be filed but as there was no reply
I didn't wait upon such.

Even if they want the contributor agreement on file before incorporating
it, I'm glad you sent it to the list for people who might want to start
using it sooner than the next Fossil release.

Thanks, really hope someone (or lots of people) find this a great,
easy enhancement.

--
Lester L. Martin II
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to