From: Antonio O. <an...@li...> - 2010-02-27 12:45:42
|
How the idea in the subject could be implemented? This would speed up a lot development, especially on Semantic wikis. Let me explain it straight with an example: Consider the page "Template:TestTemplate" in my wiki. Let's say it now has the following content: - - - --------------------- - - - <noinclude> This is a test template. </noinclude> <includeonly> __NOEDITSECTION__ =Test Title= {{#if: {{{TestField|}}} | [[TestProperty::{{{TestField|}}}]]</td> }} [[Category:TestCategory]] </includeonly> - - - --------------------- - - - I would like to know if it's possible, and how, to e.g. change the content in: - - - --------------------- - - - {{#content_from_file}} - - - --------------------- - - - ...and tell the MediaWiki engine to first load the content from a file (using some conventions, see below), and then parse and render it as usual. The conventions should be like: 1) the files are located into a "wiki_pages" folder 2) the name of the files are the same of the wiki pages, replacing ":" with ";", and with file extension ".wiki" So for the "Template:TestTemplate" page, the default file will be found into the "wiki_pages" folder, with the following file name: Template;;TestTemplate.wiki So the development localhost wiki would be easy to develop and update, with text editor, subversion, ide, edit file and immediately see effect by just pressing in browser, and whatever, while the remote one would work as usual and be easily updateable with the changes made on the local environment (e.g. a script could loop through the files in the "wiki_pages" folder, and automagically update with those contents the wiki pages on the remote server). I've searched for something already existing but I've found nothing but this piece of code that seems old (a comment states it doesn't work) and btw different from what I've written: http://www.builderau.com.au/program/php/soa/Extend-MediaWiki-with-custom-extensions/0,339028448,339273165,00.htm Someone here is willing/able to code a working solution that does exactly (or almost) what I've written? No need to manage all the possible cases, just the basic thing that could work e.g. at least with the pages holding Templates/Forms/etc. It would be very appreciated here and I think useful for others in the community. This would go far beyond the tiny speed up that can give e.g. the "It's All Text!" Firefox extension, or the WikEd javascript editor, etc. -- Antonio |
From: Thomas K. <tkr...@gm...> - 2010-02-27 13:18:44
|
Hello Antonio, please check the the Data Transfer extension ( http://www.mediawiki.org/wiki/Extension:Data_Transfer). I Imported for example all WPI Ports into my Wiki ( http://www.bluewater-info.net/wiki_/Main_Page) from a CSV-file. The Extension is great and maybe exactly what you need. Best regards, Thomas |
From: Antonio O. <an...@li...> - 2010-02-27 16:56:17
|
> please check the the Data Transfer extension ( > http://www.mediawiki.org/wiki/Extension:Data_Transfer). It's a useful extension, but it seems it doesn't fit what I wrote. To be more clear, let me summarize saying that I'm searching for a way where I can do and see changes in a wiki page with *just* the following steps (not one more): 1) edit a file in my favourite text editor 2) Alt-TAB to the web browser window with the wiki page shown 3) press F5 This can also be reduced to just two steps if a keyboard shortcut is configured to focus on the web browser and force a refresh. So, no more than those three steps to make and see changes in wiki pages on the local environment, My proposal was to achieve this "extreme" aim. Please feel free to suggest also a way that needs to change the MediaWiki core, it would be fine enough for me to use it. E.g. where in the MediaWiki code the page content is retrieved from the database? The code could be modified in a way that if the retrieved code starts with a special magic word (e.g. "__READ_FROM_FILE__") it reads the "real content" from the file, with those conventions I described in my previous message. -- Antonio > Hello Antonio, > > please check the the Data Transfer extension ( > http://www.mediawiki.org/wiki/Extension:Data_Transfer). > > I Imported for example all WPI Ports into my Wiki ( > http://www.bluewater-info.net/wiki_/Main_Page) from a CSV-file. > > The Extension is great and maybe exactly what you need. > > Best regards, > > Thomas |
From: Antonio O. <an...@li...> - 2010-02-28 18:59:57
|
Ok, I've done some steps, but don't know if I'm getting close to my aim or I'm still far away. I've hacked the "includes/parser/Parser.php" of MediaWiki (yes I know that hooks can be used, but I'm just making an attempt to see if and how it's feasible), putting some code into the parse() function: I check for the presence of the custom magic word "__GET_CONTENT_FROM_FILE__" at the beginning of the $text variable, and if yes I replace $text with the contents of a file. This does work well e.g. if I'm on "Template:Test" page in the browser, make an edit on the file "Template;Test.txt", hit F5 in the browser: I see the change in no time. Of course cache has to be disabled, but this is not a problem for a local development environment. The problem is: if I'm on page "Test Page" that uses the "Template:Test" template, I want also that if I edit the "Template;Test.txt" file, hitting F5 I do see the "Test Page" changed accordingly. Similarly, if page "Test Page" uses the "Aaaa" form, I want that hitting F5 into the "Edit with form" mode of the "Test Page", I do instantly see those changes that I do by simply editing the file "Form;Aaaa.txt". How could this be achieved? Maybe I could try putting the same code in another function (not parse())? Any suggestions? Here it is what I've written by now to accomplish what explained above: public function parse( $text, Title $title, ParserOptions $options, $linestart = true, $clearState = true, $revid = null ) { /* hack: Get Content From File */ if (substr($text, 0, 25) == '__GET_CONTENT_FROM_FILE__'){ $gcff__directory = 'extensions/ContentFromFile/sources'; // if the path has a slash at the end we remove it here if(substr($gcff__directory,-1) == '/') { $gcff__directory = substr($gcff__directory, 0, -1); } // if the path is not valid or is not a directory ... if(!file_exists($gcff__directory) || !is_dir($gcff__directory) || !is_readable($gcff__directory)) { // do nothing, go on with normal behaviour using the page content retrieved from the database } else { // we open the directory if($gcff__handle = opendir($gcff__directory)){ // calculate the file name (via conventions) $gcff__filename = str_replace(':', ';', $title->mPrefixedText) .'.txt'; $gcff__filepath = $gcff__directory .'/'. $gcff__filename; if(is_file($gcff__filepath)){ // get the page content from the file $text = utf8_encode(file_get_contents($gcff__filepath)); } // close the directory closedir($gcff__handle); } } } #.........(and then here follows the original code of MediaWiki parse function)............ } -- Antonio > To be more clear, let me summarize saying that I'm searching for a way > where I can do and see changes in a wiki page with *just* the following > steps (not one more): > 1) edit a file in my favourite text editor > 2) Alt-TAB to the web browser window with the wiki page shown > 3) press F5 > This can also be reduced to just two steps if a keyboard shortcut is > configured to focus on the web browser and force a refresh. > So, no more than those three steps to make and see changes in wiki pages > on the local environment, > My proposal was to achieve this "extreme" aim. > Please feel free to suggest also a way that needs to change the MediaWiki > core, it would be fine enough for me to use it. > E.g. where in the MediaWiki code the page content is retrieved from the > database? The code could be modified in a way that if the retrieved code > starts with a special magic word (e.g. "__READ_FROM_FILE__") it reads the > "real content" from the file, with those conventions I described in my > previous message. |
From: Yaron K. <ya...@gm...> - 2010-02-28 19:29:49
|
Hi, I think these questions are better asked on the mediawiki-l mailing list - this doesn't seem to have anything to do with SMW. -Yaron On Sun, Feb 28, 2010 at 1:59 PM, Antonio Orlando <an...@li...> wrote: > Ok, I've done some steps, but don't know if I'm getting close to my aim or > I'm still far away. > > I've hacked the "includes/parser/Parser.php" of MediaWiki (yes I know that > hooks can be used, but I'm just making an attempt to see if and how it's > feasible), putting some code into the parse() function: I check for the > presence of the custom magic word "__GET_CONTENT_FROM_FILE__" at the > beginning of the $text variable, and if yes I replace $text with the > contents of a file. > > This does work well e.g. if I'm on "Template:Test" page in the browser, > make an edit on the file "Template;Test.txt", hit F5 in the browser: I see > the change in no time. Of course cache has to be disabled, but this is not > a problem for a local development environment. > > The problem is: if I'm on page "Test Page" that uses the "Template:Test" > template, I want also that if I edit the "Template;Test.txt" file, hitting > F5 I do see the "Test Page" changed accordingly. > Similarly, if page "Test Page" uses the "Aaaa" form, I want that hitting > F5 into the "Edit with form" mode of the "Test Page", I do instantly see > those changes that I do by simply editing the file "Form;Aaaa.txt". > > How could this be achieved? Maybe I could try putting the same code in > another function (not parse())? Any suggestions? > > > Here it is what I've written by now to accomplish what explained above: > > public function parse( $text, Title $title, ParserOptions $options, > $linestart = true, $clearState = true, $revid = null ) { > > /* hack: Get Content From File */ > if (substr($text, 0, 25) == '__GET_CONTENT_FROM_FILE__'){ > > $gcff__directory = 'extensions/ContentFromFile/sources'; > > // if the path has a slash at the end we remove it here > if(substr($gcff__directory,-1) == '/') > { > $gcff__directory = substr($gcff__directory, 0, -1); > } > > // if the path is not valid or is not a directory ... > if(!file_exists($gcff__directory) || > !is_dir($gcff__directory) || > !is_readable($gcff__directory)) > { > // do nothing, go on with normal behaviour using the > page content > retrieved from the database > } else { > > // we open the directory > if($gcff__handle = opendir($gcff__directory)){ > > // calculate the file name (via conventions) > $gcff__filename = str_replace(':', ';', > $title->mPrefixedText) .'.txt'; > > $gcff__filepath = $gcff__directory .'/'. > $gcff__filename; > > if(is_file($gcff__filepath)){ > > // get the page content from the > file > $text = > utf8_encode(file_get_contents($gcff__filepath)); > } > > // close the directory > closedir($gcff__handle); > } > } > } > #.........(and then here follows the original code of MediaWiki parse > function)............ > } > > -- > Antonio > > > > To be more clear, let me summarize saying that I'm searching for a way > > where I can do and see changes in a wiki page with *just* the following > > steps (not one more): > > 1) edit a file in my favourite text editor > > 2) Alt-TAB to the web browser window with the wiki page shown > > 3) press F5 > > This can also be reduced to just two steps if a keyboard shortcut is > > configured to focus on the web browser and force a refresh. > > So, no more than those three steps to make and see changes in wiki pages > > on the local environment, > > My proposal was to achieve this "extreme" aim. > > Please feel free to suggest also a way that needs to change the MediaWiki > > core, it would be fine enough for me to use it. > > E.g. where in the MediaWiki code the page content is retrieved from the > > database? The code could be modified in a way that if the retrieved code > > starts with a special magic word (e.g. "__READ_FROM_FILE__") it reads the > > "real content" from the file, with those conventions I described in my > > previous message. > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Semediawiki-user mailing list > Sem...@li... > https://lists.sourceforge.net/lists/listinfo/semediawiki-user > -- WikiWorks · MediaWiki Consulting · http://wikiworks.com |