lib/caramelize/input_wiki/wikkawiki.rb in caramelize-1.1.1 vs lib/caramelize/input_wiki/wikkawiki.rb in caramelize-1.2.0
- old
+ new
@@ -1,43 +1,53 @@
+# frozen_string_literal: true
+
require 'caramelize/database_connector'
+require 'caramelize/filters/add_newline_on_page_end'
+require 'caramelize/filters/camel_case_to_wiki_links'
require 'caramelize/filters/wikka_to_markdown'
module Caramelize
module InputWiki
class WikkaWiki < Wiki
include DatabaseConnector
- SQL_PAGES = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'.freeze
- SQL_AUTHORS = 'SELECT name, email FROM wikka_users;'.freeze
+ SQL_PAGES = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'
+ SQL_AUTHORS = 'SELECT name, email FROM wikka_users;'
+ FUNCTION_PAGES = %w[AdminBadWords AdminPages AdminUsers AdminSpamLog Callbacks CategoryAdmin CategoryCategory CategoryWiki DatabaseInfo FormattingRules HighScores InterWiki MyChanges MyPages OrphanedPages OwnedPages PageIndex PasswordForgotten RecentChanges RecentlyCommented Sandbox SysInfo TextSearch TextSearchExpanded UserSettings WantedPages WikiCategory WikkaInstaller WikkaConfig WikkaDocumentation WikkaMenulets WikkaReleaseNotes].freeze
def initialize(options = {})
super(options)
@options[:markup] = :wikka
+ @options[:filters] << Caramelize::AddNewlineOnPageEnd
@options[:filters] << Caramelize::Wikka2Markdown
+ @options[:filters] << Caramelize::CamelCaseToWikiLinks
end
# after calling this action, titles and @revisions are expected to be filled
def read_pages
pages.each do |row|
titles << row['tag']
page = Page.new(build_properties(row))
revisions << page
end
titles.uniq!
- #revisions.sort! { |a,b| a.time <=> b.time }
+ # revisions.sort! { |a,b| a.time <=> b.time }
revisions
end
def read_authors
results = database.query(authors_query)
results.each do |row|
- authors[row['name']] = OpenStruct.new(name: row['name'],
- email: row['email'] )
+ authors[row['name']] = { name: row['name'], email: row['email'] }
end
end
+ def excluded_pages
+ FUNCTION_PAGES
+ end
+
private
def pages_query
SQL_PAGES
end
@@ -51,18 +61,17 @@
end
def build_properties(row)
author = authors[row['user']]
{
- id: row["id"],
- title: row["tag"],
- body: row["body"],
+ id: row['id'],
+ title: row['tag'],
+ body: row['body'],
markup: :wikka,
- latest: row["latest"] == "Y",
- time: row["time"],
- message: row["note"],
- author: author,
- author_name: row["user"]
+ latest: row['latest'] == 'Y',
+ time: row['time'],
+ message: row['note'],
+ author:
}
end
end
end
end