[Mediawiki-l] custom extension including <script> tags

Jamie Bliss astronouth7303 at gmail.com
Thu Dec 9 19:56:57 UTC 2004


That depends. You can do it as an inline style attribute (eg, <object
style="color: rgb(0, 0, 0);">), but only if you don't do multiple
classes and such. (This is the only way to garentee that it will work
in the next version).

If you can't do this, you can either write a sepperate Style Sheet (in
a new file), and reference that in the <head>, or inline it in the
current one. (which you have already done).

On Wed, 8 Dec 2004 11:15:33 +1300, Alistair Johnson
<johnsona at rembrandt.co.nz> wrote:
> Thanks Jamie, that works a charm!
> 
> You don't have any idea how I can resolve my css issues as well by any
> chance?
> 
> "2. I also need to include some custom css code for this extension.  I've
> done this by adding it to the monobook css file, but I'd prefer an option
> that wont get broken whenever MediaWiki is updated.  Is there an approved
> method of adding custom content within the <head></head> section?"
> 
> ;-)
> 
> 
> 
> al.
> 
> -----Original Message-----
> From: Jamie Bliss [mailto:astronouth7303 at gmail.com]
> Sent: Wednesday, 8 December 2004 8:54 a.m.
> To: MediaWiki announcements and site admin list
> Subject: Re: [Mediawiki-l] custom extension including <script> tags
> 
> Try placing the code in a seperate file and referencing it in a single
> line. This works for me:
> 
> function renderRandomQuote( $input )
> {
>       $output = '<script type="text/javascript"
> src="http://www.chiefdelphi.com/forums/xml/spotlight_js.php"></script>
> <a href="http://www.chiefdelphi.com/"
> title="http://www.chiefdelphi.com/"><img
> src="http://furc.zapto.org/wiki/stylesheets/monobook/external.png"></a><span
> class="urlexpansion"> (<i>http://www.chiefdelphi.com/</i>)</span>';
>    return $output;
> }
> 
> (This is actually in use on "http://furc.zapto.org/wiki/", using the
> tag <randomquote>) I think the code that handles the output doesn't
> preserve things within <script> tags, but it will preserve attributes.
> 
> On Tue, 7 Dec 2004 13:26:19 +1300, Alistair Johnson
> <johnsona at rembrandt.co.nz> wrote:
> > Hi Jamie,
> >
> > I have done exactly that, but to no avail - the code I have that is called
> > by a custom tag <CalendarPopUp> is:
> > function renderCalendarPopUp( $input )
> > {
> >    $output = "<pre>" . "<script language=\"JavaScript\"
> > type=\"text/JavaScript\">\n<!--\nfunction popupEvent(ev, w, h) {\n  var
> winl
> > = (screen.width - w) / 2;\n  var wint = (screen.height - h) / 2;\n  win =
> > window.open(\"/escal/popups/escalEV.php?ev=\" + ev +
> >
> \"&readFile=1&readSQL=0\",\"ESCalendar\",\"scrollbars=yes,status=no,location
> > =no,toolbar=no,menubar=no,directories=no,resizable=yes,width=\" + w +
> > \",height=\" + h + \",top=\" + wint + \",left=\" + winl + \"\");\n  if
> > (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }\n
> > }\n//-->\n</script>" . "</pre>";
> >    return $output;
> > }
> >
> > If I remove the <pre> </pre> tags from this code then when it is passed
> back
> > to mediawiki it gets mangled as outlined below.  Am I taking an incorrect
> > approach?
> >
> > Regards,
> >
> > al.
> >
> >
> > -----Original Message-----
> > From: Jamie Bliss [mailto:astronouth7303 at gmail.com]
> >
> > MediaWiki, for obvious security reasons, will treat scripts as random
> > text (meaning it will mangle it). What you have to do is make a tag
> > (say <popup>) that is translated by a simple extension into the needed
> > code. so
> > <popup>
> > is replaced by
> > <script language="JavaScript" type="text/JavaScript">
> > <!--
> > function popupEvent(ev, w, h) {
> >  [code here]
> >  }
> > //-->
> > </script>
> >
> > This is too protect wikis from more serious attacks than they already are.
> >
> > <johnsona at rembrandt.co.nz> wrote:
> > >
> > > We're using MediaWiki for a corporate Intranet and have developed a
> number
> > > of extensions which display dynamic data.  I'm currently having a couple
> > of
> > > problems integrating a php calendar (www.easilysimplecalendar.com/):
> > >
> > > 1. I have to include the following code in the page:
> > > <script language="JavaScript" type="text/JavaScript">
> > > <!--
> > > function popupEvent(ev, w, h) {
> > >  [code here]
> > >  }
> > > //-->
> > > </script>
> > >
> > > However MediaWiki is converting this to:
> > > <script language="JavaScript" type="text/JavaScript">
> > > <p><!--
> > > function popupEvent(ev, w, h) {
> > > </p>
> > > <pre>  [code here]
> > >  }
> > > </pre>
> > > <p>//-->
> > > </script>
> > > </p>
> > >
> > > If I manually wrap the code in the <pre> tags I can get it processed by
> > > MediaWiki in a non-mangled state, but then I end up with an ugly box on
> > the
> > > screen:
> > > ----
> > > |
> > > ----
> > >
> > > Any idea how I can work around this problem?  I'm probably missing
> > something
> > > obvious ...
> > _______________________________________________
> >
> >
> > MediaWiki-l mailing list
> > MediaWiki-l at Wikimedia.org
> > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> >
> 
> --
> -------------------------------------------------------------------
> http://endeavour.zapto.org/astro73/
> Thank you to JosephM for inviting me to Gmail!
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l at Wikimedia.org
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> _______________________________________________
> 
> 
> MediaWiki-l mailing list
> MediaWiki-l at Wikimedia.org
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> 


-- 
-------------------------------------------------------------------
http://endeavour.zapto.org/astro73/
Thank you to JosephM for inviting me to Gmail!



More information about the MediaWiki-l mailing list