Hallo to all of you there.
I'm trying to have a way to speed up development of the initial setup of my wiki before moving to the remote server. I mean, I want to 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
(Of course this can also be reduced to just two steps if a keyboard shortcut is configured to focus on the web browser window and force a page refresh).
Summying up, what I would like to accomplish is editing all (or almost all) the wiki by editing plain .txt files, with all the wiki pages on localhost containing just the custom magic word "__GET_CONTENT_FROM_FILE__" (or a {{gcff:}} functions, or whatever).
So, first I've disabled cache in LocalSettings.php:
$wgEnableParserCache = false; $wgCachePages = false;
Then, I've tried hacking "includes/parser/Parser.php", function parse(), like specified in the bottom of this message [1] (yes I know that hooks probably can be used for this sort of things, but I've not studied them and I'm in a hurry, so just making an attempt to see if and how this is feasible: I need to speed up wiki development because I'm short of time ;)
There I check for the presence of the custom magic word "__GET_CONTENT_FROM_FILE__" at the beginning of the $text variable, and if found I replace $text with contents retrieved from a file following some conventions for the filename, if it exists.
This is sorta working, but not like I would like: let me explain.
I'm using SMW and Semantic Forms (but probably this is not important here); anyway, I have e.g. a template called "Test", and a form which generates pages that use the Test template when accessed and rendered. So let's say I have the page "Test Page", showing content using the "Test" template.
If I am with browser on page "Template:Test", I can immediately see any change I do into the "Template;Test.txt" file, just by hitting F5. But, if I am with browser on page "Test Page", it doesn't reflect changes done in the "Template;Test.txt" file: in fact, it uses the Test template content retrieved from the database, i.e. by MediaWiki standard behaviour.
So I'm here asking: how can I hack things in order to have everything retrieved from txt files, as long as the first word in the content is "__GET_CONTENT_FROM_FILE__" and the file (following a name convention, e.g. replacing ":" with ";" to the page name and appending ".txt") exists? I don't need a clean solution, just a way to make it work and let me continue development (i.e. fine-tuning templates, forms appearance, several start-up pages contents, etc.), without having to write code in the textarea and do a button click to save, and then another click to re-edit, etc.).
Or, is someone able to arrange an extension doing what I've explained?
I repeat the "summying up": what I would like to accomplish is editing all (or almost all) the wiki by editing plain .txt files, with all the wiki pages on localhost containing just the custom magic word "__GET_CONTENT_FROM_FILE__" (or a {{gcff:}} functions, or whatever).
I underline this is only for local development, then the "real" wiki (on the remote server) will be a standard one. So security issues and whatever are not a concern.
--------------------------------------------------------------------- [1] Here it is my hack attempt (works for simple page but fails for my main purposes as 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)............ }
On Mon, Mar 1, 2010 at 5:48 AM, Antonio Orlando ant.o@libero.it wrote:
I'm trying to have a way to speed up development of the initial setup of my wiki before moving to the remote server. I mean, I want to do and see changes in a wiki page with *just* the following steps (not one more!):
http://www.mediawiki.org/wiki/Extension:Purge if a mouse click is okay instead of F5.
http://www.mediawiki.org/wiki/Extension:Purge if a mouse click is okay instead of F5.
Sorry, I can't see how this could help towards the explained aim. It seems just an extension dealing with cache, which wasn't a problem at all for me since - as already written - I've completely turned it off from LocalSettings.php.
Antonio Orlando wrote:
Hallo to all of you there.
I'm trying to have a way to speed up development of the initial setup of my wiki before moving to the remote server. I mean, I want to do and see changes in a wiki page with *just* the following steps (not one more!):
edit a file in my favourite text editor
Alt-TAB to the web browser window with the wiki page shown
press F5
(Of course this can also be reduced to just two steps if a keyboard shortcut is configured to focus on the web browser window and force a page refresh).
Summying up, what I would like to accomplish is editing all (or almost all) the wiki by editing plain .txt files, with all the wiki pages on localhost containing just the custom magic word "__GET_CONTENT_FROM_FILE__" (or a {{gcff:}} functions, or whatever).
Too much complex. I'd use a background process with an inotify to the files folder which imported the .txt whenever you change the file.
May I ask what has your favourite text editor that misses mediawiki one? The usual procedure is to write the pages in the browser edit window, and press Preview to see the changes.
The usual procedure is to write the pages in the browser edit window, and press Preview to see the changes.
Doesn't fit, as what I would like to accomplish is e.g. (and especially) doing hard work on the templates and forms (I'm using Semantic Forms) and see the changes on the rendered pages using those templates and forms. Just to clarify: imagine "Test Page" is rendered by using three templates: "Template 1", "Template 2", Template 3". So I want to load "Test Page" in the browser, and "Template;Template_1.txt", "Template;Template_2.txt" and "Template;Template_3.txt" files into my text editor (ps: no inotify here, I'm on a windows platform). Then if I make changes in all those three .txt files, when I press F5 in the browser it should render the page according to my changes.
mediawiki-l@lists.wikimedia.org