Custom javascript in WriteFreely 0.81


#1

Created a local Windows 10 Development install of WriteFreely 0.81 to get familiar with it.

On the Customization page, I see how to input Custom CSS, but I don’t see anything for entering custom Javascript. Does this capability exist in WriteFreely 0.81?


#2

There’s no way to use custom Javascript in WriteFreely 0.8.1.

I left it out to prevent security issues that might come up on multi-user instances. But are you running a single-user instance?


#3

Yes, a single-user instance on a local machine with sqlite3, I might use it for keeping track of notes, references, links, to-do list items, items I won’t post online, etc. Got it up and running with no issues, instructions were very helpful.


#4

Maybe this can be an option for admin on a per instance (or per blog) basis. Personally I use JS on Write.as to insert non-breaking spaces used by French typographic rules… Very useful.


#5

I made a post on one of my blogs about custom JavaScript and French typography in Write.as… obviously it’s in French :sunglasses:


#6

Thanks for posting, Aris. I found that https://translate.google.com did a good job of converting it to English.


#7

Hi, I just set up a single instance blog on my VPS with WriteFreely… Can I place some JS into a template file or something? I am going to be poking around myself but thought I would ask if there was a best practice first.

Great blogging software! I love the ease of use and minimalist approach.


#8

I eventually just put my JS snippet into every template file and restated WF. It seems to have worked. I was trying to find a “footer” template (or any “every page” template) but nothing I found seemed to include the script on every page so I gave up and just put it everywhere. Not super-helpful to anyone else but hopefully, someone will figure out how to do this better than I have.


#9

Hey, sorry I never got back to you earlier. It’s true the templates aren’t really set up for this right now.

I think ultimately we’re moving towards having common elements like this stored in the database and editable from the admin interface – and ideally supporting this by v1.0. So if you don’t mind sharing, what was the JS for? This will help inform what kind of capabilities we build.


#10

Hi Matt, the JS was Google Analytics tracking code. I get NO traffic but I like to have analytics there just for fun. I am a web developer, though, and would like to have a way to add on JS I write if I want to make a custom widget or something for the front end.

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXX-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-XXXXXX-1');
</script>