Remove the wiki mod

(Useless/Unused)
- add an aliases
This commit is contained in:
Ombridride 2015-03-19 16:16:49 +01:00
parent 970bc9fd72
commit 1ce54798fb
12 changed files with 3 additions and 613 deletions

View File

@ -53,3 +53,6 @@ minetest.register_alias("darkage:stair_straw", "farming:straw")
minetest.register_alias("darkage:straw", "farming:straw")
minetest.register_alias("darkage:straw_bale", "farming:straw")
minetest.register_alias("darkage:adobe", "farming:straw")
-- Remove "wiki:wiki"
minetest.register_alias("wiki:wiki", "default:bookshelf")

View File

@ -1,25 +0,0 @@
Copyright (c) 2013, Diego Martínez
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,35 +0,0 @@
Wiki Mod
--------
Another random mod by me.
This mod provides a "Wiki" block. You can create and edit pages with it.
The pages are saved as <worldpath>/wiki/<pagename>. All spaces in the page name
are converted to underscores, and all other characters not in [A-Za-z0-9-] are
converted to hex notation %XX.
The text can contain hyperlinks in the form of [link text] to other pages. Such
links are added at the bottom of the form.
You can craft a "Wiki block" by putting 9 bookshelves in the crafting grid.
Only players with the "wiki" priv can create/edit pages.
License
-------
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View File

@ -1 +0,0 @@
default

View File

@ -1,12 +0,0 @@
local MODPATH = minetest.get_modpath("wiki")
wikilib = { }
dofile(MODPATH.."/strfile.lua")
dofile(MODPATH.."/oshelpers.lua")
dofile(MODPATH.."/wikilib.lua")
dofile(MODPATH.."/internal.lua")
dofile(MODPATH.."/plugins.lua")
dofile(MODPATH.."/plugin_forum.lua")

View File

@ -1,144 +0,0 @@
wikilib.internal_pages = {
----------------------------------------------------------------
----------------------------------------------------------------
[".Intro"] = [[
Thank you for using the Wiki Mod.
This is a mod that allows one to edit pages via a block. You
can use it to document interesting places in a server, to provide
a place to post griefing reports, or any kind of text you want.
To create a new page, enter the name in the field at the top of the
form, then click "Go". If the page already exists, it's contents will
be displayed. Edit the page as you see fit, then click on "Save" to
write the changes to disk.
Please note that page names starting with a dot ('.') are reserved
for internal topics such as this one. Users cannot edit/create such
pages from the mod interface.
See also:
* [.Tags]
* [.License]
]],
----------------------------------------------------------------
----------------------------------------------------------------
[".Tags"] = [[
The wiki supports some special tags.
You can place hyperlinks to other pages in the Wiki, by surrounding
text in square brackets (for example, [.Intro]). Such links will
appear at the bottom of the form.
See also:
* [.Intro]
]],
----------------------------------------------------------------
----------------------------------------------------------------
[".License"] = [[
Copyright (c) 2013, Diego Martínez
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
* Go to [.Intro].
]],
----------------------------------------------------------------
----------------------------------------------------------------
[".NotFound_Internal"] = [[
The specified internal page cannot be found. You may want to:
* Back to [Main].
* Go to [.Intro].
]],
----------------------------------------------------------------
----------------------------------------------------------------
[".NotFound"] = [[
This page does not exist yet.
* Back to [Main].
]],
----------------------------------------------------------------
----------------------------------------------------------------
[".BadPageName"] = [[
The page name you entered is wrong. See [.Page Names] for more info.
* Back to [Main].
]],
----------------------------------------------------------------
----------------------------------------------------------------
[".Forbidden"] = [[
You have not enough privileges to view this page.
* Back to [Main].
]],
----------------------------------------------------------------
----------------------------------------------------------------
[".Help Index"] = [[
* [.Page Names]
* [.User Pages]
* Back to [Main].
]],
----------------------------------------------------------------
----------------------------------------------------------------
[".Page Names"] = [[
Page names must be in any of the following formats:
<pagename>
Display global page <pagename>.
:<n>
Display page <n> from your user space. <n> must be a number between
0 and 9. See [.User Pages] for more info.
:
This is equivalent to ":0" (shows your private page).
:<user>:<n>
Display page "Page Name" from the specified user's space. Note that page
number 0 is never accessible this way, even if you specify yourself as
<user>.
* Back to [.Help Index].
* Back to [Main].
]],
----------------------------------------------------------------
----------------------------------------------------------------
[".User Pages"] = [[
Users can have up to 10 pages in their "user space", numbered 0-9. These pages
are accessed through the special page names ":<n>", and ":<user>:<n>". Page 0
is your private page. This page is not accessible to anyone but you. You can
use it to write down secret locations, etc.
* Back to [.Help Index].
* Back to [Main].
]],
----------------------------------------------------------------
----------------------------------------------------------------
[".My Pages"] = [[
* Profile: [:profile]
* Private page: [:0]
* Pages: [:1] [:2] [:3] [:4] [:5] [:6] [:7] [:8] [:9]
]],
----------------------------------------------------------------
----------------------------------------------------------------
}

View File

@ -1,29 +0,0 @@
local WIN32, DIR_SEP
if os.getenv("WINDIR") then
WIN32 = true
DIR_SEP = "\\"
else
WIN32 = false
DIR_SEP = "/"
end
function os.mkdir(dir)
local f = io.open(dir..DIR_SEP..".dummy")
if f then
f:close()
else
if WIN32 then
dir = dir:gsub("/", "\\")
else
dir = dir:gsub("\\", "/")
end
os.execute("mkdir \""..dir.."\"")
local f = io.open(dir..DIR_SEP..".dummy", "w")
if f then
f:write("DO NOT DELETE!!!\n")
f:close()
end
end
end

View File

@ -1,83 +0,0 @@
--os.mkdir(WP.."/plugins")
--os.mkdir(WP.."/plugins/ml")
local posts = { }
local player_states = { }
local BACKLOG = 5
local function get_player_state(name)
if not player_states[name] then
player_states[name] = { }
end
return player_states[name]
end
wikilib.register_plugin({
regex = "^/ml/.*",
description = "Mailing List",
load_page = function(entry, player) --> text, allow_save
local state = get_player_state(player)
local what = entry:match("^/ml/(.*)")
if not what then
what = "recent"
end
what = what:lower()
if what == "recent" then
local text = "Recent Posts:\n\n"
for i = #posts - BACKLOG, #posts do
local p = posts[i]
if p then
local nl = ((p.text:sub(-1) == "\n") and "" or "\n")
text = (text
.. "[/ml/"..i.."] "
.. p.who..":\n"
.. p.text..nl
.. "\n"
)
end
end
text = text.."\n * [/ml/Post] a new message"
text = text.."\n * Back to [Main]"
return text, false
elseif what:match("[0-9]+") then
local n = tonumber(what)
local text
if posts[n] then
local nl = ((posts[n].text:sub(-1) == "\n") and "" or "\n")
text = ("Post #"..n.." "
.. posts[n].who..": [:"..posts[n].who..":profile]\n"
.. posts[n].text..nl
.. "\n"
)
else
text = "No such post.\n\n"
end
text = text.."\n * [/ml/Post] a new message"
text = text.."\n * View [/ml/Recent] messages"
text = text.."\n * Back to [Main]"
return text, false
elseif what == "post" then
return "Subject:\n\n<Edit this message and save to post>", true
end
return "Wrong request.", false
end,
save_page = function(entry, player, text) --> bool
local state = get_player_state(player)
local what = entry:match("^/ml/(.*)")
if not what then
what = "post"
end
what = what:lower()
if what == "post" then
posts[#posts + 1] = {
who = player,
text = text,
}
return "/ml/recent"
end
return true
end,
})

View File

@ -1,33 +0,0 @@
--[[
plugindef = {
regex = "^/foo/bar/.*",
description = "My Awesome Plugin",
load_page = func(entry, player),
^ Must return text, allow_save
save_page = func(entry, player),
^ Must return bool
}
]]
local plugin_defs = { }
function wikilib.register_plugin(def)
plugin_defs[#plugin_defs + 1] = def
end
local function do_handle(what, entry, player, text)
for _,pi in ipairs(plugin_defs) do
if entry:match(pi.regex) then
return pi[what](entry, player, text)
end
end
end
function wikilib.plugin_handle_load(entry, player)
return do_handle("load_page", entry, player)
end
function wikilib.plugin_handle_save(entry, player, text)
return do_handle("save_page", entry, player, text)
end

View File

@ -1,28 +0,0 @@
strfile = { }
function strfile.open(s)
return {
_buf = s,
_pos = 1,
_readline = function(self)
if self._pos == nil then
return nil
end
local nl = self._buf:find("\n", self._pos, true)
local line
if nl then
line = self._buf:sub(self._pos, nl - 1)
nl = nl + 1
else
line = self._buf:sub(self._pos)
end
self._pos = nl
return line
end,
lines = function(self)
return self._readline, self, true
end,
close = function(self) end,
}
end

View File

@ -1,222 +0,0 @@
local WP = minetest.get_worldpath().."/wiki"
wikilib.path = WP
local WIKI_FORMNAME = "wiki:wiki"
os.mkdir(WP)
os.mkdir(WP.."/users")
local function name_to_filename(name)
name = name:gsub("[^A-Za-z0-9-]", function(c)
if c == " " then
return "_"
else
return ("%%%02X"):format(c:byte(1))
end
end)
return name:lower()
end
wikilib.name_to_filename = name_to_filename
local function get_page_path(name, player) --> path, is_file, allow_save
local allow_save = minetest.check_player_privs(player, {wiki=true})
if name:sub(1, 1) == "." then
local text = wikilib.internal_pages[name] or wikilib.internal_pages[".NotFound_Internal"]
return text, false, false
elseif name:sub(1, 1) == ":" then
if name:match("^:[0-9]?$") then
local n = tonumber(name:sub(2,2)) or 0
path = "users/"..player.."/page"..n
os.mkdir(WP.."/users/"..player)
elseif name == ":profile" then
path = "users/"..player.."/profile"
os.mkdir(WP.."/users/"..player)
elseif name:match("^:.-:[0-9]$") then
local user, n = name:match("^:(.-):([0-9])$")
if user:find("..[/\\]") then
return wikilib.internal_pages[".BadPageName"], false, false
end
if (n == "0") and (not minetest.check_player_privs(player, {wiki_admin=true})) then
return wikilib.internal_pages[".Forbidden"], false, false
end
path = "users/"..user.."/page"..n
os.mkdir(WP.."/users/"..user)
allow_save = false
elseif name:match("^:.-:profile$") then
local user = name:match("^:(.-):.*$")
if user:find("..[/\\]") then
return wikilib.internal_pages[".BadPageName"], false, false
end
path = "users/"..user.."/profile"
os.mkdir(WP.."/users/"..user)
allow_save = false
else
return wikilib.internal_pages[".BadPageName"], false, false
end
else
path = name_to_filename(name)
end
return WP.."/"..path, true, allow_save
end
local function find_links(lines) --> links
local links = { }
local links_n = 0
for _,line in ipairs(lines) do
for link in line:gmatch("%[(.-)%]") do
links_n = links_n + 1
links[links_n] = link
end
end
return links
end
local function load_page(name, player) --> text, links, allow_save
local text, allow_save = wikilib.plugin_handle_load(name, player)
if text then
return text, find_links(text:split("\n")), allow_save
end
local path, is_file, allow_save = get_page_path(name, player)
local f
if is_file then
f = io.open(path)
if not f then
f = strfile.open(wikilib.internal_pages[".NotFound"])
end
else
f = strfile.open(path)
end
local lines = { }
local lines_n = 0
for line in f:lines() do
lines_n = lines_n + 1
lines[lines_n] = line
end
f:close()
local text = table.concat(lines, "\n")
local links = find_links(lines)
return text, links, allow_save
end
local function save_page(name, player, text)
local ok = wikilib.plugin_handle_save(name, player, text)
if ok then return ok end
local path, is_file, allow_save = get_page_path(name, player)
if (not is_file) or (not allow_save) then return end
local f = io.open(path, "w")
if not f then return end
f:write(text)
f:close()
end
local esc = minetest.formspec_escape
function wikilib.show_wiki_page(player, name)
if name == "" then name = "Main" end
local text, links, allow_save = load_page(name, player)
local buttons = ""
local bx = 0
local by = 7.5
for i, link in ipairs(links) do
if ((i - 1) % 5) == 0 then
bx = 0
by = by + 0.5
end
link = esc(link)
buttons = buttons..(("button[%f,%f;2.4,0.3;page_%s;%s]"):format(bx, by, link, link))
bx = bx + 2.4
end
local toolbar
if allow_save then
toolbar = "button[0,9;2.4,1;save;Save]"
else
toolbar = "label[0,9;You are not authorized to edit this page.]"
end
minetest.show_formspec(player, WIKI_FORMNAME, ("size[12,10]"
.. "field[0,1;11,1;page;Page;"..esc(name).."]"
.. "button[11,1;1,0.5;go;Go]"
.. "textarea[0,2;12,6;text;"..esc(name)..";"..esc(text).."]"
.. buttons
.. toolbar
))
end
minetest.register_node("wiki:wiki", {
description = "Wiki",
tiles = { "default_wood.png", "default_wood.png", "default_bookshelf.png" },
groups = { choppy=3, oddly_breakable_by_hand=2, flammable=3 },
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Wiki")
end,
on_rightclick = function(pos, node, clicker, itemstack)
if clicker then
wikilib.show_wiki_page(clicker:get_player_name(), "Main")
end
end,
})
minetest.register_privilege("wiki", {
description = "Allow editing wiki pages in the global space",
give_to_singleplayer = false,
})
minetest.register_privilege("wiki_admin", {
description = "Allow editing wiki pages in any space",
give_to_singleplayer = false,
})
local BS = "default:bookshelf"
local BSL = { BS, BS, BS }
minetest.register_craft({
output = "wiki:wiki",
recipe = { BSL, BSL, BSL },
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
if (not formname) or (formname ~= WIKI_FORMNAME) then return end
local plname = player:get_player_name()
if fields.save then
local r = save_page(fields.page, plname, fields.text)
if type(r) == "string" then
wikilib.show_wiki_page(plname, r)
else
wikilib.show_wiki_page(plname, fields.page)
end
elseif fields.go then
wikilib.show_wiki_page(plname, fields.page)
else
for k in pairs(fields) do
if type(k) == "string" then
local name = k:match("^page_(.*)")
if name then
wikilib.show_wiki_page(plname, name)
end
end
end
end
end)

View File

@ -114,7 +114,6 @@ load_mod_bobblocks = true
load_mod_pipeworks = true
load_mod_factions = true
load_mod_wiki = true
load_mod_intweak = true
load_mod_screwdriver = true