// Experimental to handle #REDIRECT [[Template:Foo]]
Matcher m = REDIRECT_PATTERN.matcher(rawWikitext);
if (m.matches()) {
String redirectTemplate = m.group(1);
rawWikitext = m.replaceAll("{{" + redirectTemplate + "}}");
}
There has to be a better way to implement this, I don't really like mixing
in the regex matcher with the rest of the template parser based on the fact
the template parser operates on the character level.
Also, currently this works because the parser will replace the redirect
reference with the actual template markup and recurse on it - therefore the
redirect is followed and content is evaluated/parsed. The template parser
will also not stop and continue parsing the rest of the main template which
is opposite to how page redirects are handled where the page parser stops
processing the rest of the content after running into a redirect construct.
I also allow for whitespace between #REDIRECT keyword and the first outer
"[[" brackets as there are many Wikipedia articles that do this instead of
the proper #REDIRECT[[...]] syntax.
In any case, the above change works for now - this was a big deal for me
when parsing Wikipedia pages & templates.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
-- You received this message because you are subscribed to the Google Groups "Bliki - Java/Eclipse Wikipedia API" group.
To post to this group, send email to bliki@googlegroups.com
To unsubscribe from this group, send email to bliki-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/bliki?hl=en or visit the projects homepage at http://matheclipse.org/en/Eclipse_Wikipedia_Editor
The parsing of redirects, at least the way implemented above, requires that
it is the
first recursive call - see attached file for details.
Attachments:
TemplateParser.java 26.8 KB
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
-- You received this message because you are subscribed to the Google Groups "Bliki - Java/Eclipse Wikipedia API" group.
To post to this group, send email to bliki@googlegroups.com
To unsubscribe from this group, send email to bliki-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/bliki?hl=en or visit the projects homepage at http://matheclipse.org/en/Eclipse_Wikipedia_Editor
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
-- You received this message because you are subscribed to the Google Groups "Bliki - Java/Eclipse Wikipedia API" group.
To post to this group, send email to bliki@googlegroups.com
To unsubscribe from this group, send email to bliki-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/bliki?hl=en or visit the projects homepage at http://matheclipse.org/en/Eclipse_Wikipedia_Editor
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
-- You received this message because you are subscribed to the Google Groups "Bliki - Java/Eclipse Wikipedia API" group.
To post to this group, send email to bliki@googlegroups.com
To unsubscribe from this group, send email to bliki-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/bliki?hl=en or visit the projects homepage at http://matheclipse.org/en/Eclipse_Wikipedia_Editor
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
-- You received this message because you are subscribed to the Google Groups "Bliki - Java/Eclipse Wikipedia API" group.
To post to this group, send email to bliki@googlegroups.com
To unsubscribe from this group, send email to bliki-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/bliki?hl=en or visit the projects homepage at http://matheclipse.org/en/Eclipse_Wikipedia_Editor
-- You received this message because you are subscribed to the Google Groups "Bliki - Java/Eclipse Wikipedia API" group.
To post to this group, send email to bliki@googlegroups.com
To unsubscribe from this group, send email to bliki-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/bliki?hl=en or visit the projects homepage at http://code.google.com/p/gwtwiki/
Hi axelclk,
Im new on Bliki, and I have the same problem sfisla is talking about - with
the redirections... I saw that you amde some changes to the bliki.core
library.
can you please explain me how to update me files with your file in order to
handle the redirection issue.
Im using maven (I didnt succed to activate my project without making it a
maven project.)
Yes, I checked out the bliki code and saw that these changes have already
been added to the library.
I followed this tutorial exactly:
http://www.integratingstuff.com/2012/04/06/hook-into-wikipedia-using-... and still, when I search for "Machester United football club" I don't get
anything, but when I use the dibugger I notice I have
a "#REDIRECT[[Machester United F.C.]]", means that it doesn't do the
recursive call for redirections.
Can you explain what I have to do in order to pass over all those
redirection and just get the value of what I search for? (please refer to
the tutorial in your answer as I am not an expert in bliki...)
Its just a typo in the comment...
When I search for "Machester United Football Club" and use the debugger,
I notice that after doing the next line:
List<Page> listOfPages = user.queryContent(listOfTitleStrings);
I get the next value for listOfPages:
[PageID: 2983919; NS: 0; Title: Manchester United Football Club;
Image url:
Content:
#REDIRECT [[Manchester United F.C.]]]
OK.
There's a IWikModel#getRedirectLink() method which returns the parsed
redircet link after parsing the first wiki text.
With this redirect title string you can again use the Wikipedia API.
See the modified HTMLCreatorExample I've commited in r5527.
The Example creates two files.
The first file
C:\temp\Manchester_United_Football_Club.html
contains no visible HTML.
The second file
C:\temp\Manchester_United_F.C..html
contains the rendered redirect title.