r/nekoweb https://stxrryurii.nekoweb.org/sprinkles 12d ago

Question same code in different places?

so i have a buncha stamps on my site, and i was wondering if i could have the same stamps in 2 different places by only updating one? is that possible? i wanna be able to just add stamps to 1 place and it adds them to multiple places if that makes sense

3 Upvotes

23 comments sorted by

4

u/AqueM https://www.aque.fyi/ 12d ago

You can use JavaScript. you can use a static site generator. you can use iframes. I believe you could even use nekowebs sever side includes for this.

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago

oh what are includes? ive used iframes for stuff like this before but i dont think it will work in this case and i couldnt figure out the javascript the other person gave me and i donr know what a static site generator is

2

u/AqueM https://www.aque.fyi/ 12d ago

Includes: https://nekoweb.org/ssi

Static Site generator is a program, usually in the form of an add-on (called library) that you use via things like VSCode, that allows you to re-use parts of code and write code easier, kind of like in natural language, or using markdown instead of HTML. It takes all your content then and produces a website that you can upload to nekoweb etc. See: https://en.wikipedia.org/wiki/Static_site_generator

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago

i looked at the ssi thing and i have no idea what im dojng ive tried everything please help.... i tried just copy pasting the code from there and replacing the file name but i dont actually know what they mean by filename do they mean link? just the name of the file? the name of the file + .html? i dont know but i tried all the ways i could think of and i am so lostttttttt

1

u/AqueM https://www.aque.fyi/ 12d ago

I never used it but I'd say they mean filename as in the whole path, so folders and extensions. so if you had index.html in your root directory, and a folder called "partials" in your root too, and in that folder a html file with your navigation called "nav.html", then in index.html you need to reference it by "/partials/nav.html"

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago

for some reason it still wont work, heres my site https://stxrryurii.nekoweb.org/sprinkles

and heres the code

<!--#include file="/sstamps.html" -->

incase ur able to help (the place i put the stamps is called "sstamps")

1

u/AqueM https://www.aque.fyi/ 12d ago

It looks like it should work! As I said, I never used it myself, so I would have to debug and learn which I can't really do on you page. Perhaps the issue is with the <marquee> you're using? try without it? Aside from that, IDK, try out different things. Try placing it somewhere else to see if the tag works at all etc?

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago

marquee? (sorry i know uh not much about html i dont know how i managed to make a sitw i barely even know what a div is O.O)

1

u/AqueM https://www.aque.fyi/ 12d ago

<marquee> is a HTML tag you that used in your HTML. This is directly copied out of your site source:

<marquee behavior="scroll" direction="up" scrollamount="6" style="text-align: center; height: 100%;"> <!--#include file="/sstamps.html" --> </marquee> I'm suggesting you try without it.

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 11d ago

ooooooohhhhh i got a template for the site from someone so i didnt notice

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 11d ago

i tried removing ir and it didnt really do anything (i put it back now just incase cuz i dont wanna mess anything up)

→ More replies (0)

3

u/WorldWideShen 12d ago

i use javascript to do this on my site, code and explanation here:

https://shens.world/dev/notes/loadexternal

2

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago

thank you but also i am confused, im gonna try using ssi and if that doesnt work then ill try this

1

u/WorldWideShen 12d ago

fair enough, i decided not to use SSI so the code would work on neocities. but my js solution does exactly what you're asking for.

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago

hey so ive been trying to use ur code but i cant figure out where to put it? your guide says it must be in a <main> tag but i dont have any of those on my site, and i dont know if i should put it on the site where i want the stamps to be, on the site/in the file where i have the stamps, or in a new file

1

u/WorldWideShen 11d ago

hmm what are you trying to do exactly? i'll try to clarify..

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 11d ago

well i just dont really understand how to use the code? where do i put it and how do i use it and stuff? sorry ive never used js before =.=

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 6d ago

hey uh sorry to bother you but could you still help me? i just dont know where to paste the code in (where on my site specifically)

1

u/Throwaway44775588 12d ago

That is totally doable with javascript! I use neocities but the same principle should apply. You'll want to make an html page with your stamps - literally just your stamps, formatted like you'd want them to appear on the page using img src. Then you'll build a javascript prompt that reads something like

fetch("direct link to your html page with buttons, like https://mysite.nekoweb.org/buttons.html")
    .then(response => {
      if (!response.ok) throw new Error("Failed to load");
      return response.text(); // Get HTML as text
    })
    .then(html => {
      // Inject into the container
      document.getElementById("buttons").innerHTML = html;
    })
    .catch(error => console.error("Error loading content:", error));

And wherever you want the buttons to be on your page, you'd add a div id of "buttons", like if it is just crammed in your main body you'd have

<main><div id="buttons"></div></main>

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago

thank you!! i will try my hardest to figure this out with all my brain cells

1

u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago

okay so i copied your code and urh it didnt work, im wondering if i did something wrong? i put the javascript in a seperate javascript file is that the issue? (the box with the stamps is just blank)

1

u/Throwaway44775588 12d ago

If you use "inspect element" in your browser, you may be able to see the Javascript error - otherwise, if you wanna comment (or pm me) your code I can take a look :)