Forums | Mahara Community

Developers /
Plugin to share the page on twitter, facebook, evernote


anonymous profile picture
Account deleted
Posts: 30

02 May 2011, 8:21

I had a shot at writing a plugin for Mahara. A difficulty I am having is to figure out how to get the script included in the header of a page template, within the Mahara environment (I have just downloaded it, I am not really familiar with it).

I manually modified web,php to add a reference to both jQuery (isn't jQuery, at least partially embedded in the tiny_mce directory?) and the jquery plugin in use. I would assume that this is not the expected way to do this (ideally, the plugin should be added to the blocktype folder and no other file modified).

If one wanted to use jQuery to write mahara blocks in the form of jQuery modules, what would be the best way to proceed?

Here is a zip file with the socialbuttons plugin. Mahara 1.3.3 was used during development.

Plugin Preview:

plugin preview

anonymous profile picture
Account deleted
Posts: 30

02 May 2011, 10:09

Quick look at Mahara 1.4 on gitorious. jQuery 1.3.2 is included and, within the creativecommons blocktype, there is a function 

public static function get_instance_config_javascript() {        
   return array('js/creativecommons.js');    
}

With a quick try, I couldn't get it to work in 1.3.3. I will try with 1.4 tomorrow. 

Gregor Anželj's profile picture
Posts: 349

03 May 2011, 1:23

Please check http://mahara.org/view/view.php?id=35645

No everlast support though :(

Regards,
Gregor

anonymous profile picture
Account deleted
Posts: 30

03 May 2011, 9:19

Thanks Gregor! I had run a search for plugins on mahara.org but didn't come across these ones. 

Though the social buttons was really a pretense. I wanted to check if blocktypes could be created that run jQuery plugins. There are huge numbers of jQuery plugins that would help make the portfolio more dynamic / modern / engaging.

For instance, agile carousel which provides an advanced image gallery, with the option to load images from a flickr account .

I have been playing with jQuery quite a bit recently, and it really is not too difficult to write or rewrite its plugins in a way that the interactive content can be provided by not very technical users. Check out the widgeds project for examples. 

I was researching how difficult it would be to turn them into Mahara blocktypes with customizable content.

Gregor Anželj's profile picture
Posts: 349

03 May 2011, 14:30

Could you please explain in more detail, what blocktypes will do (what you want to achieve)?

G

anonymous profile picture
Account deleted
Posts: 30

03 May 2011, 17:49

Hi Gregor,

I was trying to figure out if (a) there was any plan to provide an easy way to edit the headers and (b) if there was any strategy to ensure that javascript/jquery based community contributed plugins play nicely with one another.

a.

If the user added 4 gallery blocks on his page, the gallery plugin should be added once and only once to the header of the document.

The only way I have found to guarantee that outcome in 1.3.3 was to add two lines to the web.php file.

mahara/view/web.php line 96, added

% $javascript_array[] = 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'; 

% $javascript_array[] = $wwwroot . 'blocktype/socialbuttons/js/socialbuttons.js';

 

To include the jQuery library there makes sense (though it needs to be checked that doing so is not gonna break any of the mochikit functionalities).

However, to include "socialbuttons.js" in web.php clearly breaks the plugin logic. It should be possible to add new blocktypes that rely on javascript files without having to modify any Mahara core file. The core files / mahara framework should have no knowledge of the plugins that could be added in the future.

What Rusian mentioned would do perfectly Smile: "adding header modification methods to Mahara few month ago. I did not have a chance to implement that though. Hopefully soon Mahara will have that functionality "

b.

If different community members contribute different javascript based plugins (because Mahara is meant to be an open system, right?), how do they need to go about writing their mahara blocktype so to minimize the chance of conflict between the code dynamically loaded at runtime? 

Where it starts to be tricky is deciding what to do with third party plugins. Two frequent dependencies are on jquery.timer and jquery.scrollTo. If different plugins, written by different authors that cannot be expected to have any knowledge of each other contributions, both use these plugins but different version numbers of it, what does happen?

To guarantee the absence of conflict, you can require to have them included in the private scope of the plugin. But this may lead to some performance hit, with code unnecessarily repeated across plugins.

The next best option would be to have a third party / vendor folder within the jquery folder that seems to be part of the distribution for the next version of Mahara. At least for third party helpers that are repeatedly used across plugins and can be of some size (jquery-ui). Developers encouraged to develop against these versions. But this option is not as full proof. Conflicts are bound to happen.

All in all, I am trying to understand what is possible, what discussions if any have already taken place on this topic, and what the roadmap is, if any Wink

Kristina Hoeppner's profile picture
Posts: 4863

03 May 2011, 15:15

Hello Marielle,

Nice to see you here in the forums. :-)

Gregor has been working on a blocktype to display flickr and picasa slideshows, but I don't think that this code is already live.

Cheers

Kristina

anonymous profile picture
Account deleted
Posts: 30

03 May 2011, 18:05

Hi Kristina,

Thanks for the kind words. I had run a few searches on this Mahara website or on Google to try and get an idea of what existed, but came out without much.

There was that mention, a few months ago of jQuery and an image plugin. Your bug db hinted is Evan Goldenberg contributing to Mahara but I couln't find the image gallery in any commits on Gitorious.

The 1.4version on gitorious is dated as of yesterday, includes jquery but not the twitter or the image gallery blockypes. What's the best way to find out about the community contributed plugins and the ones currently in development?

Kristina Hoeppner's profile picture
Posts: 4863

03 May 2011, 20:19

Hello Marielle,

I added Gregor's new plugins to the wiki page at http://wiki.mahara.org/Plugins so that they are not only accessible from his profile page.

Evan had worked on a flickr gallery when he was a Summer of Tech student some time ago. I don't think that he contributes to Mahara anymore. After Gregor mentioned his work on the slideshow plugin, we did not pursue Evan's code further as that would not have had the functionality that Gregor is putting into his slideshow plugin. I don't think the slideshow plugin is ready yet. Therefore, it's not yet on Gregor's page. He is very good in updating the community on any of his plugins.

Plugins that are not part of core Mahara are not on the 1.4 branch in GIT, but they are maintained by the developers themselves. I found a branch of Gregor on GIT, but it doesn't look like that there are any of his plugins.

Cheers

Kristina

anonymous profile picture
Account deleted
Posts: 30

04 May 2011, 3:11

Thanks Kristina, that's very helpful

17 results