1

I have a page which uses the MediaWiki gem to extract wiki details and show it to the user. The user enters what they want to search for and then using MediaWiki gem I fetch the data and image.

I am able to show the images but unable to render the data as it's in wiki markup.

So what should I use? I googled and think that the redcloth gem can help me out. Should I try it or there are any other gems/logic that I am missing?

Below is the code that I am using:

my gemfile..

gem 'mediawiki-gateway'
gem 'wikipedia-client'
gem 'wikitext', '~> 2.1.1'
# gem 'red-cloth'

my controller..

  require 'media_wiki'
  require 'wikipedia'

   @page = Wikipedia.find('BMW')
   #using this parser ..should i change this>??
   @page=Wikitext::Parser.new.parse(@page.content)

my view file

<h1><%= @page.title%></h1>

<div id="image_container">  
    <% @page.image_urls[1..3].each do |image| %>


    <%= image_tag(image) %>
    <% end %>
</div>

<div id="content_class">

    <%=h @page.html_safe %>
</div>
<!-- purposely usign html safe as without it the view looks really bad(atleast now i can see the links highlighted in blue color) -->

A quick view of what my problem is---please refer the attached imageenter image description here

I want to improve the UI. How can i do it?

Nemo
  • 2,441
  • 2
  • 29
  • 63
Milind
  • 4,535
  • 2
  • 26
  • 58
  • Are you sure that the wikitext parser works with that syntax? Did you try one of those libraries? http://www.mediawiki.org/wiki/Alternative_parsers – phoet Dec 23 '13 at 13:00
  • 1
    MediaWiki API can parse the markup for you. Doesn't the library let you do that? – svick Dec 23 '13 at 13:03
  • @phoet That still won't help with parsing templates. – svick Dec 23 '13 at 13:04
  • @svick I have no clue. The wikitext docs just had examples in a different syntax style. – phoet Dec 23 '13 at 13:08

1 Answers1

0

Please don't parse wikitext yourself. The TextExtracts and PageImages web APIs exist for a reason. There's plenty of web API client libraries too.

Nemo
  • 2,441
  • 2
  • 29
  • 63