[00:02:29] This isn't exactly MediaWiki specific, but I am asking relevant to the wikitext portion of user input https://dpaste.org/kwcuJ -- I'm working on parser for syntax of arguments, notably passing JSON within the value of an argument of a extension tag element. Regarding quotation handling: ", ', \", \', etcetera, what is the optimal way for user input for complex strings of text data in wikitext? [00:02:52] For example, the options argument value [00:05:01] In PHP from $parser->setHook( 'photoswipe', [ self::class, 'renderTagPhotoSwipe' ] ); one of the $args array values for options, I'm trying to confirm/validate that the value is an object, but parsing from string to convert into object [00:06:53] Umm, generally you have to escape them - either via html ' " or json \u0027 and \u0022 [00:07:35] That's generally a pain, so people usually make json stuff be in the body of the tag where you don't have to do that, or have a bunch of non-json attributes that they turn into json later [00:08:17] (err, actually, only can use \u0027 and \u0022 for quotes in string, not for the delmiter quotes, you have to use html for that [00:08:53] Sometimes you can do things like {{#tag:nowiki|stuff here}}, although whether or not that works depends on a lot of factors [03:48:17] Alright. I got a fairly functional extension code base. Now comparing to my initial working nonMediaWiki implementation of working with ESM import module JS library, --> import PhotoSwipeLightbox from './photoswipe-lightbox.esm.js';console.log(PhotoSwipeLightbox); this shows `class PhotoSwipeLightbox extends PhotoSwipeBase {...}` and comparing that to MediaWiki extension implementation, from the main ResourceModules [03:48:17] "ext.photoSwipe" -> packageFiles script: ext.photoSwipe.js, in that file 9output client side in web browser) -> `var PhotoSwipeLightBox = require('js.photoswipe-lightbox');console.log(PhotoSwipeLightBox);` shows -> {__esModule: true} [03:49:58] my understanding is that the requiring of the 'js.photoswipe-lightbox' is the extension module, and not the actual packageFiles JS script that is referenced by the module [03:56:16] Ooooh playing with directory path references in another require statement, I am seeing different error messages! [03:57:22] Firstly, here is my extension.json - https://dpaste.org/NfqeR (I probably messed up some things still) [04:00:54] And here is file/directory structure of extension environment https://dpaste.org/iPyqd [04:02:08] In ext.photoSwipe.js --> var test = require('/ext.photoSwipe/lib/photoswipe-lightbox.cjs.js'); // Error: Module "/ext.photoSwipe/lib/photoswipe-lightbox.cjs.js" is not loaded [04:02:38] In ext.photoSwipe.js --> var test = require('ext.photoSwipe/lib/photoswipe-lightbox.cjs.js'); // Error: Module "ext.photoSwipe/lib/photoswipe-lightbox.cjs.js" is not loaded [04:03:10] In ext.photoSwipe.js --> var test = require('/lib/photoswipe-lightbox.cjs.js'); // Error: Module "/lib/photoswipe-lightbox.cjs.js" is not loaded [04:03:36] In ext.photoSwipe.js --> var test = require('lib/photoswipe-lightbox.cjs.js'); // Error: Module "lib/photoswipe-lightbox.cjs.js" is not loaded [04:03:46] actually I'm confused now, cuz it was a bit different just a minute ago [04:04:21] In ext.photoSwipe.js --> var test = require('/photoswipe-lightbox.cjs.js'); // Error: Module "/photoswipe-lightbox.cjs.js" is not loaded [04:04:41] In ext.photoSwipe.js --> var test = require('photoswipe-lightbox.cjs.js'); // Error: Module "photoswipe-lightbox.cjs.js" is not loaded [04:05:53] In ext.photoSwipe.js --> var test = require('./ext.photoSwipe/lib/photoswipe-lightbox.cjs.js'); // Error: Cannot require undefined file ext.photoSwipe/lib/photoswipe-lightbox.cjs.js [04:06:05] There we go! That's the different error message, if I prefix with a . [04:06:49] In ext.photoSwipe.js --> var test = require('./lib/photoswipe-lightbox.cjs.js'); // Error: Cannot require undefined file lib/photoswipe-lightbox.cjs.js [04:07:28] In ext.photoSwipe.js --> var test = require('./photoswipe-lightbox.cjs.js'); // Error: Cannot require undefined file photoswipe-lightbox.cjs.js [04:07:37] so basically I'm doing this wrong, lol [04:09:29] oh https://mediawiki.org/wiki/ResourceLoader/Package_files suggests using two dots "To invoke a non-main file, use require( './foo.js' ). The path must start with ./ or ../ to indicate that it's a file in the same module (as opposed to the name of another module), and the path must be relative to the current file." [04:10:40] Nope! i tried all possibilities with two dots [04:16:32] now trying 9 try {} catch {} blocks in JavaScript client side, to see all fails at once for each change to path references in extension.json [04:19:27] Nope! 81 possibilities, all failed [04:24:09] quote from few days back: "with the above command you'd be good to go and can `var Photoshipe = require('./lib/photoswipe-lightbox.cjs.js')` from your JS code." [04:24:31] so, maybe there's something about the var PhotoSwipeLightBox that I can do with it somehow [04:25:57] 1 key 'default' and 1 value: function [04:28:09] Hmmmmmm, interesting: `console.log(PhotoSwipeLightBox['default']);` // class extends PhotoSwipeBase{constructor(options){super();this.options=options||{};this._uid=0;}init(){this.onThumbnailsClick=this.onThumbnailsClick.bind(this);getElementsFromOption(this.options.gallery,th… [04:28:37] oh sweet, that looks similar to what I said above! [04:32:58] Hmmmmmmmmmmm, let test = PhotoSwipeLightbox['default']; // ReferenceError: PhotoSwipeLightbox is not defined [04:33:17] but...but... it IS defined? lol what? [04:36:14] Hmmm, B vs b, case [04:36:30] my bad [04:37:15] Yay! i'm making progress now! [12:24:25] Can I parse wiki tags inside theme templates. It appears I can not with a simple echo. [17:48:22] No one knows how to or if one can use a MW extension in a MW skin? [17:52:11] faktor: You can do whatever you want [17:52:48] Reedy, If I echo a ext tag , it wont pre processit and just show the raw text. [17:53:02] That sounds right [17:53:11] You'd need to call the parser to parse it [17:53:30] How do I get it to pre-process the ext tag example. [18:16:25] afk [19:35:57] So I'm building a wiki page for my orginization that has two images side by side. I want to lock the left image, and create a button that makes a simple user interface to upload, and change the second image. Is this possible? How? [19:39:19] it's not possible without JavaScript [19:39:25] or an extension [19:41:52] I'm looking at common.js I can just build a function that requests a file, or url, and then does the update manually in the background, no? [19:45:34] faktor, re parsing wiki tags inside theme templates, I'm not sure, but I started learning writing my first extension and hook ParserFirstCallInit https://mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit can be used to create a new tag [19:46:14] it's a bit more involved than just that, lol, but that's one starting point. [19:46:26] ryzenda, Thanks looks like a good function to do what I was after. [19:46:47] faktor, Sure! Also check out https://doc.wikimedia.org/mediawiki-core/master/php/interfaceMediaWiki_1_1Hook_1_1ParserFirstCallInitHook.html in case it might be helpful too [22:02:07] wfMessage( 'message-key' )->parseAsBlock(); // How do I pass a "class='classnamehere'" attribute to the p html element that is created? [22:06:14] not very easily [22:06:27] you can probably hack it in with str_replace() though [22:11:58] Also in i18n/lang.json, when using $*, the html uses
...
instead of

...

https://mediawiki.org/wiki/Manual:Messages_API doesn't mention about $* [22:14:44] ryzenda: you can't. just wrap it in another element [22:14:57] ryzenda: if you use ->parse(), then there won't be a p wrapper, and you can add your own [22:15:50] hmm, and I'm just guessing, but it appears there is some special syntax if the message-key value begins with : [22:15:57] and I confirmed my guess too [22:16:07] (but beware that people could override the message to have lists and stuff, which would break that. whether that's a concern depends on your particular case. i'd recomment adding a
wrapper around it) [22:21:17] ryzenda: leading : is used for indentation in mediawiki, and I think does indeed make
elements internally to achieve that [22:21:28] ^ [22:21:37] (there is also a leading ; to create the corresponding
) [22:22:13] "Indentation" [22:22:50] perryprog: well seeing as its most common usage is on talk pages, and there people only use various numbers of leading :::'s rather than the full ; term : definition syntax, yeah :P [22:22:52] Be warned that it's incredible buggy and will easily emit completely inaccessible HTML if you basically do anything [22:23:06] No, not anything wrong—just /anything/ :P [22:23:23] lol [22:23:35] At the least, ol's syntax /tries/ to be semantically correct, but still likes to poop out nonsense sometimes. [22:23:54] (this is my biggest, and nearly only, gripe with wikitext :P) [22:24:18] gripes of wraith! [22:54:28] Aha! line 119 https://doc.wikimedia.org/mediawiki-core/master/php/BlockLevelPass_8php_source.html#l00001 [22:54:57] *, #, :, and ; [22:59:54] so did you try str_replace( '

', '

', wfMessage( 'message-key' )->parseAsBlock() ) out? based on a quick test it oughta work the way you want it to, even if it's not considered "pretty" ;) (I've used the same approach a few times to change some MW-generated links from to since setting the target attr on links originating from wikitext instead of PHP code is otherwise not really [22:59:54] possible) [23:01:10] as a note, I am just tinkering/exploring right now, slight break from important dev things [23:01:37] always good to explore :) [23:02:46] for example in i18n/lang.json files ": test1\n: test2\ntest3" the 3rd line breaks the list sequence, which seems good (note usage of the word "break" is not implying anything is broken, lol) [23:05:11] also I see the relation of ; and : now [23:08:28] "* test1\n# test2\ntestbreak\n# test3\n* test4\ntestbreak" // 1 and 2 looks like #2 is indented to be child of #1 because o fthe MASSIVE left padding, but as seen in 3 and 4, #3 still has the massive padding [23:09:12] sorry, margin, not padding [23:10:52] at least using vector skin [23:11:46] I'm not sure if this is intentional or not, but I think the *s and the #s should align equally if they are the same level of depth [23:13:31] they never have [23:24:02] they do since a while.... [23:24:21] since it used to be in en.wp css and now it's not [23:24:45] I created a bug report for it in case it may ever be considered to fix/improve https://phabricator.wikimedia.org/T306733 [23:25:27] that said, if you're making a message, you probably should use some sort of html (whether the class or raw i guess), not rely on wikitext [23:25:44] I'm just exploring/learning for now [23:26:33] slight break from the extension development grind (to try to be smarter to get a final working release without being too incompetent) [23:27:02] initial* working release