Modifying the Web Request

The first step is to get the data from the game to the website. This is done through a Web Request.

The actual web request can be found in aresmush/plugins/profile/web/character_request_handler.rb, but since there’s a custom code hook available we don’t need to modify that file directly.

Instead we edit aresmush/plugins/profile/custom_char_fields.rb and modify the get_fields_for_viewing method.

  def self.get_fields_for_viewing(char, viewer)
    return { goals: Website.format_markdown_for_html(char.goals) }

Here we’re using the format_markdown_for_html helper method to turn ansi, carriage returns and other formatting codes into HTML-friendly equivalents for display on the web portal.

Note that this code makes goals visible to everybody. You could optionally use the viewer parameter to limit who can see them.

This article is part of the Modifying the Web Portal tutorial.