MediaWiki alter default user signature - mediawiki-extensions

I've tried finding some info on this (found none), so trying the sages of SO before giving up.
I'm modifying Extension:AuthRemoteuser for a local SSO solution.
It would be a nice touch to change the default signature to a string other than the user name (which is an integer string at the moment for us), e g. Real Name.
Hoping someone knows the function call to set signature so that I'd be able to do something akin to:
$mySwellSignature = "Foobar";
$usr->setSignature($mySwellSignature); //This is what I'm looking for ;_;

You can customise the [[MediaWiki:Signature]] page on your wiki (see system message documentation) to alter how ~~~~ and ~~~ are parsed.
If you want to pass additional parameters, like real name, you can do so by altering the line(s) in the parser where this message is used; or by introducing a parser function which you can then use on [[MediaWiki:Signature]] like e.g. UserFunctions (only an example; I'm not recommending this extension).

Related

How to make variable custom data available to custom extension?

Maybe google haven't learned yet or I'm just not able to construct the correct magical search text or this is just not possible to do.
Short description. I'm creating a custom extension to Code. Code will be launched by another application. This other application needs to hand over some information to Code and to the extension dependent upon where Code is launched from but I have no idea how I can accomplish this. When a command is issued from the Pallette the extension will then use this information to do specific stuff.
I've been looking into commandline arguments but I cannot find documentation or google searches that show me how an extension can access the commandline and parse the arguments.
Arguments could be customerIDs and other specific data that neither Code nor the extension can find on its own unless some kind of value is pushed from the launching application into Code...
Am I to assume that its not possible for an extension to read commandline arguments or am I just stupidly bad at VS Code bla bla google searches?
I've added an argument to launch.json "--testparameter=testvalue" and I see that code.exe is launched with this parameter but how my extension gets access to this parameter is beyond me...
We solved this by having the other application add all the settings we need to the .code-workspace file. That data can easily be accessed by using the build in workspace configuration objects. Say the file contains a setting called 'extension.friendlyname' this is how we read it:
getFriendlyName(): string
{
return this.getConfig('extension.friendlyname');
}
private getConfig(configName:string): string
{
const configuration = vscode.workspace.getConfiguration();
const configValue = configuration.get(configName);
return String(configValue);
}

Indenting with Xtext IFormattableDocument formatter

I have noticed similar issues to this in multiple places with Xtext's formatter. I am not sure if it is my unfamiliarity with it or if it just has some general flaws. Hopefully someone can help me with this specific case and it will give me a better general understanding. In the language I have a variable declaration language piece and it contains an iterable of type 'Extensions'. The desired format looks like this:
varName:TypeName:=Value
[ext1Name:Value]
[ext2Name:Value]
So I am formatting the variable part correctly but when I attempt to format the extensions with this code:
def dispatch void format(Extension it, extension IFormattableDocument document) {
regionFor.keyword("[").surround[noSpace]
regionFor.keyword("]").surround[noSpace]
prepend[newLine] //This is doing something
prepend[indent] //This is not doing anything
}
Note that in the format method for the variable declaration format is being called on every extension like such extensions.forEach[format]
I know that this code is running on the appropriate piece because if I remove the prepend[newLine] my result is this:
varName:TypeName:=Value [ext1Name:Value] [ext2Name:Value]
The issue is that the prepend[indent] does not appear to be doing anything for with the full code I showed above my output is this:
varName:TypeName:=Value
[ext1Name:Value]
[ext2Name:Value]
Also If anyone knows of good documentation for this please point me to it as I have not been able to find anything helpful in the xtext documentation

How to make Flow understand code written for Node.js?

I'm just getting started with Flow, trying to introduce it into an existing Node codebase.
Here are two lines Flow complains about:
import Module from 'module';
const nodeVersion = Number(process.versions.node.split('.')[0]);
The warnings about these lines are, respectively:
module. Required module not found
call of method `split`. Method cannot be called on possibly null value
So it seems like Flow isn't aware of some things that are standard in a Node environment (e.g. process.versions.node is guaranteed to be a string, and there is definitely a Node builtin called module).
But then again, Flow's configuration docs suggest it's Node-aware by default. And I have plenty of other stuff like import fs from 'fs'; which does not cause any warning. So what am I doing wrong?
Module fs works as expected because Flow comes with built-in definitions for it, see declare module "fs" here: https://github.com/facebook/flow/blob/master/lib/node.js#L624
Regarding process.versions.node, you can see in the same file that the versions key is typed as a map of nullable strings, with no mention of the specific node property: versions : { [key: string] : ?string };. So you'll need to either make a PR to improve this definition, or adjust your code for the possibility of that value being null.
I guess the answer about module "module" is obvious now – there are no built-in definitions for that module in Flow in lib/node.js. You could write your own definitions, and optionally send a PR with them to the Flow team. You can also try searching github for these, someone might have done the work already.
That lib directory is very useful by the way, it has Flow definitions for DOM and other stuff as well.

How to force IntelliJ plugin to parse a file's PsiReference resolutions?

I have an IntelliJ plugin that is walking PsiReference resolutions to a "distant" class, and having trouble because the resolve() method is returning null if and only if i have not navigated to the distant file in the editor during the current IntelliJ session. I suspect that IntelliJ needs to be prodded to parse the file in some sense (when you navigate to the file, you can see that IntelliJ kicks off some sort of parsing run as a lot of the code goes from being minimally highlighted to fully highlighted) but I don't know how to do that. I looked in PsiManager and PsiFile, where I found some refresh() and reloadFromDisk() methods, but I'm guessing these have a lot of side-effects I don't want and probably won't kick off the parsing run anyways. Details/clarification below.
The code looks something like this:
File 1, in which I invoke a plugin action on foo:
#AnnotationReferringToAnotherType(File2.class)
class File1 {
String foo;
}
File 2, which the plugin must lookup in order to perform the action on foo:
class File2 {
#File3
void mustBeLookedUpToHandleAction() {}
}
File 3 must also be looked up:
#interface File3 {
public enum SomeEnum {
DEFAULT,
SOMETHING_ELSE
}
SomeEnum value() default SomeEnum.DEFAULT;
}
I perform the action on foo, and then the logic finds the #AnnotationReferringToAnotherType at the top of the containing file (File 1) and resolve()s to the definition of File2. Then it looks for a method in File2 that is annotated with #File3. Since the #File3 annotation on mustBeLookedUpToHandleAction does not specify its value, the plugin must now look up the definition of #File3 in order to determine what the default value is. All of this works completely smoothly after freshly loading IntelliJ. The part that fails is the resolve() from the PsiReferenceExpression SomeEnum.DEFAULT to the actual definition of DEFAULT in SomeEnum. It consistently returns null, until i navigate, in the editor, to File 3, and after that it works every time for the remainder of the session. It seems clear that the references' resolutions are being parsed lazily, and if i can just find some way to kick off that parsing everything should be OK?
You may be thinking "why the hell is this logic so complicated?". Most of the logic is actually in a library i'm using - it's internal, so i may be able to get some changes made but I doubt i'll be able to make fundamental changes on account of this issue unless this issue turns out to be completely unmanageable.
Turns out this is a bug in IntelliJ: https://youtrack.jetbrains.com/issue/IDEA-133994
the workaround is to call getText() on one of the annotation definition's PsiElements before calling resolve() - e.g. once you have the PsiAnnotationMethod for File3.value call getText() on it before calling getDefaultValue().resolve()
deets:
The definition for File3 is "stubbed", so only the core components of its psi tree are actually available. Whenever information is requested from the stub that the stub doesn't have (e.g. by calling getText), the file containing the stubbed psi tree will be fully parsed and the stub replaced with a complete psi tree (see https://confluence.jetbrains.com/display/IDEADEV/Indexing+and+PSI+Stubs+in+IntelliJ+IDEA). The particular implementation of PsiAnnotationMethod.getDefaultValue will return a dummy PsiAnnotationMemberValue if the annotation is stubbed, and that dummy element is apparently not knowledgeable to honor the resolve().

How to access predefined variables within cfscript?

The following code works:
<cfoutput>#$.currentURL()#</cfoutput>
However, within a function, "$" is not available.
<cfscript>
function myTest() {
return $.currentURL();
}
</cfscript>
Does anyone know what actually is the equivalent of $ within a function?
Likewise, #pluginConfig.getDirectory()# works when used directly in cfoutput. However, within a cfscript function, it reports "unknown variable pluginConfig."
Thank you for advance for guiding me in the right direction.
When writing code outside the Mura Event Scope (like you do with that function), you have to obtain an instance of the Mura Scope ($) yourself. This can be done using the following code:
$ = application.serviceFactory.getBean('$');
Next you'll have to initialise the instance using an event object, a struct with value pairs or a 'siteID':
$.init(event);
$.init(myStruct);
$.init(siteID);
The same counts for the pluginConfig, this you can abtain via the Mura Scope. You'll have to pass the pluginID, moduleID, name or package of the plugin:
$.getPlugin(pluginID);
$.getPlugin(moduleID);
$.getPlugin(name);
$.getPlugin(package);
An other option you have is to pass the Mura Scope and the pluginConfig as arguments to the function. When writing a small plugin, this might be the easier way. But when writting medium or large plugins, it will get a bit messy when you're passing along these objects all the time.
The $ is used as a special framework variable in some CF frameworks (like Mura). You will need to figure out the framework context (if any) your code is executing in

Resources