Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: nemwar on July 25, 2022, 09:44:20 AM

Title: Where to add a script (GWBBCode)
Post by: nemwar on July 25, 2022, 09:44:20 AM
Hello,

not new to SMF, but because of a new project i wanna start a new forum ... of course with SMF2.1, as it is the latest version.

The old GWBBCode Modification was for SMF1.1 but meanwhile somebody programmed this from the scratch as a Javascript.

So... now my problem... where i have to add the Code-Snippet to get this to work?

<script type="text/javascript" src="https://gwbbcode.arnapou.net/gwbbcode/api.js"></script>
<script type="text/javascript" >
    GWConfig.lang = 'de'; // oder 'en'
    GWOnLoad(Funktion(){
    GWBBCodeParse('.post_body, .postbody');
    });
</script>

Before i begin to work with SMF, some Modifications this should work first.

I hosted the fully site here (if you wanna take a look): http://gw4ever.bplaced.net/

Thanks for your time and help.

NemWar
Title: Re: Where to add a script (GWBBCode)
Post by: Arantor on July 25, 2022, 01:06:24 PM
The logical place for this would be in your theme's index.template.php, in just before the </body> tag - though you'll need to be careful about the single quotes because SMF uses single quotes too. In your case they can all be replaced with double quotes.

It would also be possible to write this as a proper add-on that doesn't require file edits but as a 'just getting it running' step I think it would be simpler to just edit the theme.

Also note that in 2.1 the markup is a bit different and I think your selector should be ".postarea .post" rather than ".post_body, .postbody" assuming the point is to target the content of a post.
Title: Re: Where to add a script (GWBBCode)
Post by: nemwar on July 26, 2022, 02:35:53 AM
Thanks for your help @Arantor.

I will try your changes and add it.
Would love to see an add-on but i'm no programmer nor can i progamm.

I will also let you know if it works.

Title: Re: Where to add a script (GWBBCode)
Post by: Doug Heffernan on July 26, 2022, 04:15:48 AM
Quote from: nemwar on July 26, 2022, 02:35:53 AMWould love to see an add-on but i'm no programmer nor can i progamm.

You can request it at our Mod Request board:

https://www.simplemachines.org/community/index.php?board=79.0
Title: Re: Where to add a script (GWBBCode)
Post by: Arantor on July 26, 2022, 04:34:21 AM
I'll be honest, I didn't realise folks were still running forums for Guild Wars 1, seeing that the game is mostly on life support (though I really must finish the Flameseeker Prophecies sometime, rather enjoyed Nightfall and Factions, and it was jarring to see how much of Nightfall was retrodden during GW2 Path of Fire, I though End of Dragons was a better retread of Cantha though)
Title: Re: Where to add a script (GWBBCode)
Post by: nemwar on July 26, 2022, 07:57:30 AM
Well, i started a few days ago... there are a handful german guilds still active...
i think in the rest of the world it is the same...

There are still active Facebook-Groups...
The idea behind my project is to collect all of the wide spread infos and store it online.
So you see... the BBCode would be nice to collect the builds.

I didn't manage to get it to work...  :-\

Themes/default/index.template.php - added bevor </body>
<script type="text/javascript" src="http://gw4ever.bplaced.net/gwbbcode/api.js"></script>
<script type="text/javascript" >
    GWConfig.lang = "en";
    GWOnLoad(Funktion(){
    GWBBCodeParse(".postarea, .post");
    });
</script>

With Google-Dev-Tools i get following Error-Message:

Uncaught SyntaxError: missing ) after argument list

on this line:
    GWOnLoad(Funktion(){

Ah, before i forget... pathes in api.js also changed to point to right places on my webspace/path/file.
Title: Re: Where to add a script (GWBBCode)
Post by: Arantor on July 26, 2022, 08:08:34 AM
Think that should be written as function() rather than Funktion() and also take the comma out of the code parse, your original code looked at two different places, my suggestion looks at one more specifically (post bodies).
Title: Re: Where to add a script (GWBBCode)
Post by: nemwar on July 26, 2022, 09:02:37 AM
@Arantor

It works.... thank you very much.
And if you ever want to go for a ride through Tyria, get in touch... we'll find something together.



Solution for all others:

Get your files from github: https://github.com/arnapou/gwbbcode
Theres also a updated fork: https://github.com/call-cc/gwbbcode

Copy \public\gwbbcode to your webspace (i choose \gwbbcode)

Modify: \Themes\default\index.template.php
before: </body>
<script type="text/javascript" src="http://youradress.bsp/gwbbcode/api.js"></script>
<script type="text/javascript" >
    GWConfig.lang = "en";
    GWOnLoad(function(){
    GWBBCodeParse(".postarea .post");
    });
</script>   


Modify: api.js

find: var GWConfig = {
css: {
theme: 'http://yoursite.bsp/gwbbcode/themes/arnapou/theme.css',
skills: 'http://yousite.bsp/gwbbcode/skills/skills.css'
},
js: {
data: {
en: 'http://yoursite.bsp/gwbbcode/data/en.js'


Change every shown link to your site / right location on your site.




That's it... now it 'should' work... mine did...
Title: Re: Where to add a script (GWBBCode)
Post by: Arantor on July 26, 2022, 09:21:04 AM
I haven't been to GW1 in a long time, must see if I cam dig out my login details :)
Title: Re: Where to add a script (GWBBCode)
Post by: nemwar on July 27, 2022, 10:26:36 AM
Last add/note:

It also works for 2.0.

I had to "downgrade" because of a other mod.