Chat Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
May 10, 2026 - @426.44 (what is this?)
Activity rating: Three Stars Posts & Arts: 43/1k.beats ~ Boop! The forum will close in 574.beats! Random | Recent Posts | Guild Recents
News: It's the silly things you'll remember :trash: Guild Events: Spring Themed Projects

+  MelonLand Forum
|-+  Materials & Info
| |-+  ♺ ∙ Web Crafting Materials
| | |-+  neocities blogs made easier


« previous next »
Pages: [1] Print Embed
Author Topic: neocities blogs made easier  (Read 196 times)
april
Newbie ⚓︎
*
View Profile WWWArt


⛺︎ My Room

Artifacts:
Joined 2026!
« on: May 03, 2026 @533.56 » Embed

Bloggable
Ever since the restrictive content security policies were implemented on neocities it became increasingly difficult to implement dynamic features into the static sites. As the policy allows same site requests through iframe trickery i have put together a blogging (but can be used for arbitrary data) platform for free neocities accounts. It reduces the need to redo html and css by providing a simpler WYSIWYG editor to post messages. It is entierly up to the user to change the css and the js and templates are provided for some starting off points.

Here are some screenshots
https://64.media.tumblr.com/8162cf946021e13dd8df7e2ddf2ee8f8/34309051ddf655e4-9e/s1280x1920/e469ae1476c97c92d5a6796841b0e987c80c6523.pnj
https://64.media.tumblr.com/bd473581bec47af8f583be5e344fec94/34309051ddf655e4-f7/s1280x1920/a70fd819512fd0c02b2ada24bd218a20ce5af041.pnj
https://64.media.tumblr.com/5f941f34f0a18545fb8a570c26839983/34309051ddf655e4-ec/s1280x1920/5f53f33327f86cc7e382911581205c8535555773.pnj
« Last Edit: May 03, 2026 @535.29 by april » Logged
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
« Reply #1 on: May 03, 2026 @550.16 » Embed

Wow! I had no idea that Neocities had added connect-src 'self' data: blob:; form-action 'self'; to their CSP. What a nightmare!

I'm pretty sure an enterprising individual could work-around such things in anything they really wanted to implement a server-side-thing that Neocities users could embed using JS...

For example:

There's no fetch and no form submissions, but data can still be sent to a remote server in a media URL, right? So if you had a guestbook component or similar, the JS could take the submitted comment, put it into a URL as a GET request, then use that as the source of an image, remote JavaScript, iframe, or similar.

Similarly, data can be remotely-fetched via images, but it's a lot more-complicated! First, the dynamic server would need to encode the data in a way that allows it to be represented as an image. This could be pretty simple: just binary-encode the whole thing (possibly after compression) and treat each 8-bit block as a "pixel" of an 8-bit PNG image. Pad the end so you get a round number of 8-bit blocks. Render that as a PNG. The restricted site can use JS to render the PNG into a <canvas> element, extract the colors, convert it back to a binary string, and decode it. Tada: data!

Perhaps the best way to remotely-fetch data would be through self-evaluating JSON. This trick was quite popular when Ajax was just starting to use JSON but not all browsers supported it. A great thing about it is that it's really easy to bolt "on top" of an existing JSON endpoint! So if normally you'd request //example.com/api/something.json using fetch, now you'd request //example.com/api/something.json?call=functionName, using a <script> tag. The server generates the same JSON, but instead of sending it raw it puts it into a JavaScript that passed it to the specified function (functionName, in this case) to its value. With this, the restricted Neocities site can just say "run the script over there, which will execute my functionName with the response". It's old-school, but it should work.

I might put together a proof-of-concept to show it can be done.
Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif

Artifact Swap: I met Dan Q on Melonland!PolyamorousBouncy Egg!Joined 2025!Lurby
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
« Reply #2 on: May 03, 2026 @587.35 » Embed

JSONP! That's what we used to call the technique!

I completely forgot the name for a while there.
Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif

Artifact Swap: I met Dan Q on Melonland!PolyamorousBouncy Egg!Joined 2025!Lurby
april
Newbie ⚓︎
*
View Profile WWWArt


⛺︎ My Room

Artifacts:
Joined 2026!
« Reply #3 on: May 03, 2026 @633.97 » Embed

I think the pass through iframe method is relativey decent for get requests on data as it just puts all the posts in a posts array which the user can edit freely/do whatever they want with.

Code
window.parent.postMessage(
    { type: "POSTS_DATA", posts },
    "*"
);

this is the important part of the code which sends the message from the iframe to the parent website. Im not sure if posts requests through iframe would work... idk im not smart enough lol! If you do make a proof on concept please share i would love to see it!

https://content-security-policy.neocities.org/

btw if you havent seen heres a good website detailing the content security policy
Logged
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
« Reply #4 on: May 03, 2026 @669.68 » Embed

https://content-security-policy.neocities.org/

btw if you havent seen heres a good website detailing the content security policy

I found that first, but I wasn't happy with it so I just looked at the actual headers Neocities was sending. Thanks though, moderately good resource and well-researched!

this is the important part of the code which sends the message from the iframe to the parent website. Im not sure if posts requests through iframe would work... idk im not smart enough lol! If you do make a proof on concept please share i would love to see it!

Just threw one together! Take a look at https://embed-html.neocities.org/poc!

It's a chat room! If you look at the source for that page you'll see that the JS comes from a remote server... and (obviously) the chat room itself comes from a remote server. But it's not an iframe... and yet it still works on Neocities! Amazing!

It's using the JSONP architecture. Here's how it works:

1. The Neocities page includes some JS from the remote server. This bit's easy.
2. To fetch data (recent chat messages) from the remote server, the JS creates a new script tag that looks like this (tidying up any previous script tags it made along the way):


Code
<script src="https://danq.me/_q23u/neocities-fetch-workaround-poc/poll.php?callback=miniChat_callback_4b292b357e1d422bb7b586d643473a9c"></script>

Because it's a <script>, not a fetch, it doesn't get blocked by Neocities' CSP. The "callback=" at the end specifies the name of a function on the Neocities page to "give" the resulting JSON to: it's randomly-generated when the main JS runs.

The endpoint (e.g. poll.php) returns JSON, but wrapped in miniChat_callback_4b292b357e1d422bb7b586d643473a9c( ... ). This way, the JSON is the input to the function defined by the JS, and the data comes through.

3. To send data (new messages!) back to the server, I use the same technique: a <script> tag. These ones look a bit like this:


Code
<script src="https://danq.me/_q23u/neocities-fetch-workaround-poc/send.php?callback=miniChat_callback_4b292b357e1d422bb7b586d643473a9c&name=Your+Name&message=What+did+you+say"></script>

Same deal. It's done over a <script>'s GET request, which are not blocked by Neocities. It could equally work with an image or iframe src, of course: I'm using a script because I want to handle the response in the same way as I do when polling for new messages.

This approach isn't so suitable for very large payloads: they have to fit into a URL! For maximum compatibility, that means you're capping out at sending 2Kb of data at a time (you can receive as much as you want, of course). But for something larger, it'd be absolutely possible to break it up and send it in several chunks, I suppose! And you could add compression, too: JS implementations of deflate etc. are perfectly solid these days.

So yeah: it's 100% work-aroundable, I think!
Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif

Artifact Swap: I met Dan Q on Melonland!PolyamorousBouncy Egg!Joined 2025!Lurby
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
« Reply #5 on: May 03, 2026 @671.91 » Embed

Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif

Artifact Swap: I met Dan Q on Melonland!PolyamorousBouncy Egg!Joined 2025!Lurby
april
Newbie ⚓︎
*
View Profile WWWArt


⛺︎ My Room

Artifacts:
Joined 2026!
« Reply #6 on: May 03, 2026 @707.69 » Embed

This is very cool and def works well! I would implement something like it but i think there are better options for whatever people like to post data with blogs (e.g like guestbook or comment boxes as they have special allowances by neocities) also i think my firebase free plan would not enjoy even more reads/writes lol! Idk if you can do uhh continuous listeners... snapshot listeners i think thats the term for it like where the page doesnt need to refresh each time to load the data back but thats not really too big of an issue for like comment boxes and the like. The reason i actually made it an iframe is that i was talking to the guy who made https://iframe.chat/ chattable at the time and that was the way he did his chat box (also the reason i used firebase which was kinda a mistake cause i hate firebase). Anyway he seemed way more experience with webdev than me so i followed in his footsteps. I will def be putting this technique in my back pocket tho as it is a really nice workaround!

 :smile:

oh yeah all my code is on github uhhhh here https://github.com/apriltilde/bloggable yes!
Logged
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
« Reply #7 on: May 03, 2026 @714.58 » Embed

Nice. Thanks for dropping by.

Yeah: I remember I first started using Firebase shortly after it came out, long before it was acquired by Google. Initially what it did seemed like black magic. But now that websockets and data binding have become easier, it just feels cumbersome to use Firebase!

Yeah, a big weakness of my approach is it requires polling, so it's not great for realtime stuff (maybe a chat room wasn't the right example project!); it can't do a websocket like you can in an iframe. But for lightweight stuff and where you want it to be able to be styled by the end-user, I like my approach. E.g. a hit counter/like counter or even a guestbook would work wonderfully this way.
Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif

Artifact Swap: I met Dan Q on Melonland!PolyamorousBouncy Egg!Joined 2025!Lurby
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | ~ Send Feedback ~ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi

MelonLand Nav

@000

Want to Login or Join ?

Minecraft: Online
Join: craft.melonking.net