pouët.net

Pouet.net BBCode toolbar script

category: general [glöplog]
 
You are sick and tired of typing these [ url ] and [ img ] tags all the time on pouet ?

Pouet.net 2.0 doesn't bring all promised features and you find it rather disappointing ?

So this greasmonkey script might be for you


What it does : it add a new toolbar to all pouet.net editing pages. No fancy wysiwyg edtior here, it just provide the bare minimum and helps you to insert tags in messages (just select some text and click on the corresponding tag button)

Tested on recent Chrome (OSX) + Tampermonkey only. I made this in a hurry so dont except too much.

@p01 : it would be nice if you decide to include this script to other useful pouet scripts (youtube, prod screenshot, ...) of github. Changes or improvements are welcome.
added on the 2013-09-19 14:53:10 by Tigrou Tigrou
Not to overshadow, but there already was one. I also refactored it a bit and turned it in to a pull request, so you might see it in core after proper review by a site developer, when they have time. (Which is just fine.) It runs just fine in plain Greasemonkey and as a normal user script in Chrome, nothing else needed. However the by-line fixing code (which didn't work in Chrome anyway) sorta doesn't work in Greasemonkey now, it inserts "undefined". I'll have to look in to that.

I think visibility of various options is a good thing :)
I should say, though, that mine explicitly only works on the BBS and prod-page textareas.
@AMcBain : thanks for reply. i didn't know there is something already existing. I will try it as soon as i can.

Sorry for my first message being a little agressive or arrogant but i'm really tired of typing these tags all the time, while adding such a thing to pouet.net would be very easy (we even have pouet source now) but nobody give a f*** and administrators seems do not want to change a single thing.
added on the 2013-09-19 19:36:59 by Tigrou Tigrou
Quote:
but nobody give a f*** and administrators seems do not want to change a single thing.

Well, now there's the possibility to say "go make a pull request about it" at least.
@Saga Musix : I asked this on official pouet 2.0 thread but without too much success. Well a pull request was an option that i didn't try (and didn't think about).
added on the 2013-09-19 19:48:51 by Tigrou Tigrou
There's already a pull request, I just didn't have the time to look at it so far.
added on the 2013-09-19 20:00:18 by Gargaj Gargaj
Quote:
byTigrou:
@Saga Musix : I asked this on official pouet 2.0 thread but without too much success.

Actually I think you and someone else were what prompted what I wrote back then, and I thought you'd seen it.

Quote:
byTigrou:
but nobody give a f*** and administrators seems do not want to change a single thing.

I don't agree with this, though. The pouet developers have only so much time to work on things, and last weekend Gargaj was busy with function ... I think we should cut them some slack. Also, he's already said he's willing to look at the pull request when he's available. The user script doesn't have a time limit, so I think we can stand to have a little patience.

The reason not a lot of new features came along with Pouet before 2.0 was that most people were being caretakers of the site, and the site's source made it very hard to add new features easily or without adding to the complexity. This was noted in the FAQ then, I think, and so it was quite a deterrent to wanting to act on any ideas.

However Gargaj worked on Poet 2.0 which will make it a much easier time to integrate new features. So you can't say they're unwilling, especially since the 2.0 rewrite even launched with some new features. Since launch we've gotten the watchlist feature you can see on the homepage and the button on prod pages. The more automated change request system also appeared after launch, to make things easier for moderators than a giant BBS thread people post to.

Anyway ... beyond all that, it's far easier to for open source projects to throw things back with "go do it yourself" or "well, then send a pull request" as people can suggest features all day long but if nobody has time or wants to work on them ... I normally dislike that sort of approach to things, as some feature suggestions can be universally useful to all or most users but there's no way I'd be able to meaningfully spin up on that project to do what I want with a decent level of quality. But, for Pouet, I don't think it is that hard to really pick up and get going on so it's not a bad answer here given that the main developers are busy too. (but maybe that's just because I sort of know PHP, JS, and so on ...)
I've noticed a slight issue which I'll get around to here shortly that if you select text that has a URL in it, but doesn't start with it, the toolbar does some odd stuff. Easy enough to fix.

This really only affects those who create an [img] tag, select that, then click one of the link buttons. Which is a reasonable thing to do if you embed a small version in posts and link out to the larger one.

Anyone else should let me know if there's stuff about this I should fix so I can update the script and pull request.
@AMcBain : not sure to understand the bug. Can you describe it again ?
added on the 2013-09-20 23:40:00 by Tigrou Tigrou
Quote:
by Tigrou:
@AMcBain : not sure to understand the bug. Can you describe it again ?

It has to do with my toolbar. It tries to do some "intelligent" things for you, to aid in writing bb-code. This is generally done by auto-selecting the dummy text it inserts after an operation (if there is any) so you can immediately start typing and erase it if you want. This should also make it easier to use this on a mobile device.

In the case of the link buttons they do something slightly different. The "link with text" (link + pencil icon) button will highlight the default argument (the part after the "[‌url=") so you can type or paste the intended URL. Unless it thinks what you selected is already a valid URL, then it makes that the argument to the URL and selects the dummy text inserted inside of it.

I'll just write it out long ... pipes indicate selection and each line is a step in the process. In between line one and two the button is clicked unless otherwise noted.

Case 1:
Code:text text |blah blah| text text text [‌url=|http://example.com|]blah blah[/url] text


Case 2:
Code:text text |http://example.com| text text text [‌url=http://example.com]|linky|[/url] text


Case 3:
Code:text text |example.com/foobar| text text text [‌url=http://example.com/foobar]|linky|[/url] text

The script auto-fixes the lack of of an "http://" so you don't end up with broken "http://www.pouet.net/example.com/foobar" links that so many people seem to have!

Now, that works. It's not broken at all. However, it is the code that the normal link button calls in some cases as shown below.

Case 1:
Code:text text |blah blah| text text text [‌url]blah blah[/url] text

Just wraps it, even though it's not a link.

Case 2:
Code:text text |http://example.com| text text text [‌url]http://example.com[/url] text


Case 3:
Code:text text |example.com/foobar| text text text [‌url=http://example.com/foobar]|example.com/foobar|[/url]

Here the script preserves the visual intent of the link, but converts it to a "link with text" so it can fix what would end up as a broken Pouet-relative link. This is it being helpful, but this is also where it breaks down in certain cases like I mentioned in my previous post. See the next case.

Case 4:
Code:text text |http://example.com/image.png| text text text [‌img]http://example.com/image.png[/img] text text text |[‌img]http://example.com/image.png[/img]| text text text [‌url=http://[‌img]http://google.com[/img]][‌img]http://google.com[/img][/url] text

So the first button used is the auto-image button. It doesn't select anything afterwards. Then if you select the output of that, and click the base link button you get the last line as output. It goes "hey, this looks like a URL, so let's promote it to a 'link with text' with that as the argument and add in the missing 'http://' ..." and it goes downhill from there. It should behave like case 1, and just wrap it even though the result wouldn't work as a link. The output should preferably be:

Code:text text [‌url][‌img]http://google.com[/img][/url] text


The "link with text" button when confronted with the same input doesn't do any better:
Code:text text [‌img]http://example.com/image.png[/img] text text text |[‌img]http://example.com/image.png[/img]| text text text [‌url=http://[‌img]http://example.com/image.png[/img]]|linky|[/url] text

Quite atrocious! Since you've asked to do a "link with text" and the originally selected contents as a whole aren't a link, it should generate some dummy text as the argument and select it:

Code:[‌url=|http://example.com|][‌img]http://example.com/image.png[/img][/url]


I hope that explains a bit what I mean, even though it's probably information overload.
Pretty moot at this point, though. I fixed it. :)

Well, except for cases like "http://example.com/ this is garbage here". You're on your own there. :P
Props to Gargaj for merging the bb-code helper toolbar. It should work the same as my user-script toolbar but uses links instead of images. Post here if you have issues or requests.

My user script won't go away for those who prefer images. The latest version has been updated to occupy the same space. However it is not likely to continue to be updated other than bug fixes.

Enjoy.
<3 it. Thanks!
added on the 2013-09-26 12:56:55 by raer raer

login