Class: MyMediaWiki

Inherits:
MyMediaWikiBase show all
Defined in:
lib/mymedia-wiki.rb

Direct Known Subclasses

WikiTester23

Instance Method Summary collapse

Methods inherited from MyMediaWikiBase

#copy_publish, #delete

Constructor Details

#initialize(media_type: 'wiki', config: nil, newpg_url: '', log: nil, debug: false) ⇒ MyMediaWiki

Returns a new instance of MyMediaWiki.



126
127
128
129
130
131
132
# File 'lib/mymedia-wiki.rb', line 126

def initialize(media_type: 'wiki', config: nil, newpg_url: '', log: nil,
               debug: false)
  
  puts 'inside MyMediaWik initialize' if debug
  @url4new = newpg_url
  super(media_type: media_type, config: config, log: log, debug: debug)
end

Instance Method Details

#writecopy_publish(raws) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/mymedia-wiki.rb', line 134

def writecopy_publish(raws)

  # The content to be published might contain 1 or more wiki link
  #    e.g. [[topic2022]] or [[topic2022url|topic2022
  # Here, the link will be transformed to an actual hyperlink which points
  # to a valid wiki page

  s = raws.gsub(/\[\[([^\]]+)\]\]/) do |x|

    puts 'x: ' + x.inspect if @debug
    title = $1
    puts 'searching for title ' + title.inspect  if @debug

    # does the title exist?
    r = find_title(title)

    puts 'r: ' + r.inspect  if @debug

    if r then
      '<a href="' + '/wiki/' + r.title[/^#{title}/i] + '">' + title +'</a>'
    else
      '<a href="' + @url4new + escape(title) + '" class="new" title="' \
          + title + ' (page does not exist)">' + title + '</a>'
    end

  end

  super(s)

end