Page MenuHomePhabricator

Create OpenJsCad MediaWiki extension
Closed, ResolvedPublic

Description

The issue has been discussed in

The feasibility has been proven in http://wiki.bitplan.com/index.php/ParametricLampShade and http://wiki.bitplan.com/index.php/Template:Jscad but these prototypes use the html extension.

The idea is to have a separate extension. A first cut in "old style extension" php has been drafted as:

<?php
/**
 * Check if we are being called directly
 */
if ( !defined( 'MEDIAWIKI' ) ) {
  die( 'This file is an extension to MediaWiki and thus not a valid entry point.' );
}
 
/**
 * Register this extension on Special:Version
 */
$wgExtensionCredits['parserhook'][] = array(
  'name' => 'OpenJsCad',
  'description' => 'Allows embedding of OpenJsCad designs',
  'author' => array( 'Wolfgang Fahl' ),
  'url' => 'http://wiki.bitplan.com/OpenJsCadExtension',
  'version' => '0.0.1'
);

$wgHooks['ParserFirstCallInit'][] = 'wfRegisterOpenJsCad';
 
/**
 * Sets the tag <jscad></jscad> that this extension looks for and the function by which it
 * operates
 */
function wfRegisterOpenJsCad( Parser $parser ) {
  $parser->setHook( 'jscad', 'renderOpenJsCad' );
  return true;
}

/**
 * Renders a JSCAD design
 * <jscad title='MyDesign'>function main() { return cube ...}</jscad> 
 *   
 * @tagcontent code 
 *  The code is javascript in JSCAD format
 * 
 * @param title 
 *  The title is is the title e.g. 'previous'
 * 
 * @return string
 *  The necessary html code to render the design
 */
function renderOpenJsCad($input, array $args, Parser $parser, PPFrame $frame) {
  if (isset($args["nocache"])) {
    $parser->disableCache();
  }
  // in case WikiMarkup / Templates have been used to specify page ..
  $rawCode=$input;
  $input="<source lang='javascript'>".$input."</source>";
  $code = $parser->recursiveTagParse( $input, $frame );
  $title= "OpenJSCAD design";
  $target="_self";
  // title part
  if (isset($args["title"])) {
    $title=$args["title"];
    $title=$parser->recursiveTagParse( $title, $frame );
  }
  $result="<script src='/extensions/OpenJsCad/lightgl.js'></script>\n";
  $result.="<script src='/extensions/OpenJsCad/csg.js'></script>\n";
  $result.="<script src='/extensions/OpenJsCad/openjscad.js'></script>\n";
  $result.=$code;
  $result.="<textarea id='code'>".$rawCode."</textarea>\n";
  // make sure our result is not parsed
  return array($result,"markerType"=>'nowiki');
}

So that a <jscad> tag would be supported.

Event Timeline

Restricted Application added subscribers: Liuxinyu970226, jeblad, Aklapper. · View Herald TranscriptJun 11 2019, 3:45 PM
Reedy updated the task description. (Show Details)

The Request I put in https://www.mediawiki.org/wiki/Gerrit/New_repositories/Requests was in the meantime corrected to have the path mediawiki/extensions/OpenJsCad - thanks for that. For the code review model I am not sure what the difference between the two is. https://www.mediawiki.org/wiki/Gerrit/Privilege_policy#Other_MediaWiki_extensions does not even mention "open push". I am not familiar with the git repository of wikimedia as a contributor. In the past I worked with github projects where you can have a limited set of users with rights. How are the rights for extension git repositories managed?

Now the git repository is available but I do not have access rights to it.

wf@io:/srv/www/mediawiki/code/extensions/OpenJsCad$ git push
Username for 'https://gerrit.wikimedia.org': WolfgangFahl
Password for 'https://WolfgangFahl@gerrit.wikimedia.org': 
remote: Unauthorized
fatal: Authentication failed for 'https://gerrit.wikimedia.org/r/mediawiki/extensions/OpenJsCad/'
wf@io:/srv/www/mediawiki/code/extensions/OpenJsCad$ git push
Username for 'https://gerrit.wikimedia.org': Seppl2013
Password for 'https://Seppl2013@gerrit.wikimedia.org': 
remote: Unauthorized
fatal: Authentication failed for 'https://gerrit.wikimedia.org/r/mediawiki/extensions/OpenJsCad/'

I'd say that not being able to git push might be expected behavior as things should go through the CI via Gerrit (and better be reviewed by someone else)...

Thx for the hint. I still need more info to start working. How are the rights for extension git repositories managed? How do you get my initial code reviewed if i can't push it?

You propose your change in Gerrit via git review, and then someone needs to +2 the change to get the change merged. Do https://www.mediawiki.org/wiki/Gerrit/Tutorial and https://www.mediawiki.org/wiki/Gerrit/Privilege_policy#Requesting_Gerrit_privileges answer some questions?

git review
Your change was committed before the commit hook was installed.
Amending the commit to add a gerrit change id.
Username for 'https://gerrit.wikimedia.org': WolfgangFahl
Password for 'https://WolfgangFahl@gerrit.wikimedia.org': 
remote: Unauthorized
fatal: Authentication failed for 'https://gerrit.wikimedia.org/r/mediawiki/extensions/OpenJsCad/'

Do https://www.mediawiki.org/wiki/Gerrit/Tutorial and https://www.mediawiki.org/wiki/Gerrit/Privilege_policy#Requesting_Gerrit_privileges answer some questions?
Yes they do answer a few and raise a few dozen more ... is this seriously the procedure for extensions in alpha stage? I simply would like to have a repository to discuss the first stages of development with others. As it stands it's simpler to post the source code on the wiki page for the extension. I was hoping to avoid to setup a github repository just to point out a few days later that it's already obsolete ...

I think it would be much better if there would be a "one stop shopping" for getting an account and and extension up and running instead of having different places to "apply". Also the installation of git-review broke my package system on my ubuntu main server - i am not too happy about this.

@WolfgangFahl while I agree that this could be simpler, I think part of the problem is the username is not correct.

For instance, mine is "mah" but I log into the website with "MarkAHershberger".

You can see this by looking at the members of the extension-UserSnoop group:

$ ssh -p 29418 gerrit.wikimedia.org gerrit ls-members extension-UserSnoop
id	username	full name	email
13	mah	MarkAHershberger	mah@nichework.com

It looks like your username is "seppl2017":

$ ssh -p 29418 gerrit.wikimedia.org gerrit ls-members extension-OpenJsCad
id	username	full name	email
7283	seppl2017	WolfgangFahl	wf@bitplan.com

Does that username work for you?

WolfgangFahl added a comment.EditedJun 14 2019, 2:46 AM

@MarkAHershberger - thank you for looking into this. So at it looks there are currently four accounts for me:

  • the original account for wikipedia - seppl2013
  • the wikimedia bugzilla account wf@bitplan.com from 2010
  • the recently created account for wikipedia LDAP? - WolfgangFahl
  • the account from 2017 on wikimedia - seppl2017

the seppl2017 account is the result from the failure of the system two years ago to let me join my wikimedia bugzilla account with my wikipedia account - instead of having only one account i now have four!

Worse is that the https://gerrit.wikimedia.org/r/login does not seem to have a reset password option ...

I do not have a record in my password safe for the seppl2017 account.

So how and where to continue from here?

Worse is that the https://gerrit.wikimedia.org/r/login does not seem to have a reset password option ...

Gerrit account == LDAP account == wikitech.wikimedia.org account == developer account. Please use https://wikitech.wikimedia.org/wiki/Special:PasswordReset

WolfgangFahl added a comment.EditedJun 14 2019, 8:40 AM

@Aklapper: Thanks for the hint - Oh that one - that looked like a fifth account with still a different password - that one is in my password safe. - Indeed it is the seppl2017 account mentioned by @MarkAHershberger - the username is seppl2017 and the fullname WolfgangFahl.

So basically I have the same issue as Jakob Voss https://phabricator.wikimedia.org/T136448 but with a few more accounts ...

At least I can get into Gerrit now and go from there. Please stay tuned since given the broken package manager on my main server I need to move things to another server ...

WolfgangFahl added a comment.EditedJun 15 2019, 7:06 PM

http://s.bitplan.com/wiki/index.php/Template:Jscad has now an example for a template using the OpenJsCad alpha version extension.
see

Would there be any obvious obstacles to get this state of affairs reviewed and put into the gerrit repository?

Aklapper added a comment.EditedSep 12 2019, 12:57 PM

Would there be any obvious obstacles to get this state of affairs reviewed and put into the gerrit repository?

@WolfgangFahl: I'm not sure what you mean by "reviewed". Or where to review what. Please elaborate.

For the records, https://gerrit.wikimedia.org/g/mediawiki/extensions/OpenJsCad exists and is currently empty.
https://gerrit.wikimedia.org/r/#/q/project:mediawiki/extensions/OpenJsCad shows zero open changes proposed for OpenJsCad in Gerrit.

Seppl2013 added a comment.EditedSep 26 2019, 2:04 PM

There is a private git repository at git.bitplan.com:/srv/git/source/php/mediawiki-OpenJsCad - how to i get the contents into https://gerrit.wikimedia.org/g/mediawiki/extensions/OpenJsCad?

Mark is with me at SMWCon 2019 and helping with the gerrit setup which is totally confusing given that it does not use my mediawiki account and forces me to setup a new password and only then can I upload an ssh-key. The git review also is confusing since it is not so different from git push and then it is ... In the end there should be some content now in the https://gerrit.wikimedia.org/g/mediawiki/extensions/OpenJsCad repository.

In the last month i have seen https://www.mediawiki.org/wiki/Extension:3D which does for STL files what i'd like to do for OpenJSCAD files. I find the approach a bit awkward since it relies on xvfb and and external tool and therefore it's quite infrastructure heavy. On the other hand it would be much nicer if the OpenJsCad extension could be integrated with a node installation of OpenJsCad and simply reuse that instead of copying all the javascript stuff. Are there any other extensions using node based modules that have the same problem?

Indeed, there is content now in https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/OpenJsCad/+/master - congrats! :)

Are there any other extensions using node based modules that have the same problem?

Feel free to ask general question on e.g. mediawiki-l@ or wikitech-l@: https://lists.wikimedia.org/mailman/listinfo

Hi. Is there anything left to do in this task? Thanks.

Quite a bit - it needs to be decided how the OpenJSCAD javascript code is going to be integrated with Mediawiki.
Shall this be a separate e.g. npm or webpack based installation?
Shall it be somehow invoked from the MediaWiki infrastructure?

Unfortunately Mediawik is a too quickly moving target. Currently my migration to 1.33 from 1.27 does not work because quite a few extensions do not work anymore. For the new extension this means it has to wait a bit ...

Quite a bit - it needs to be decided how the OpenJSCAD javascript code is going to be integrated with Mediawiki.
Shall this be a separate e.g. npm or webpack based installation?
Shall it be somehow invoked from the MediaWiki infrastructure?

Unfortunately Mediawik is a too quickly moving target. Currently my migration to 1.33 from 1.27 does not work because quite a few extensions do not work anymore. For the new extension this means it has to wait a bit ...

Hello. I understand. But this task is about the creation of a repository for the OpenJSCAD extension on gerrit.wikimedia.org; which is already done. The rest of the objectives you mention deserve their own individual task, I think. If you plan to use Wikimedia Phabricator for tracking issues, I can create a project for your extension where you can organise your workflow, etc. If that path is okay with you, please let me know and I can create said project for you. Best regards.

@MarcoAurelio - oh - now i get it. Yes the repository is there and now its about how to get the extension into a useable state. Please create a project for that extension - it would be a good communication point for the Wikimedia community .

Aklapper closed this task as Resolved.Jan 28 2020, 2:04 PM
Aklapper moved this task from Incoming to Projects to create on the Project-Admins board.

@Seppl2013: Requested public project MediaWiki-extensions-OpenJsCad has been created: https://phabricator.wikimedia.org/project/view/4530/

Please encourage interested people to visit the project and to join the project as members, and to watch the project in order to receive updates!

Recommended practices for project and workboard management in Phabricator are available.

Feel free to bring up any questions you might have about Phabricator or about best ways to manage projects in Phabricator.

Enjoy!