mirror of
https://github.com/evennia/evennia.git
synced 2026-03-18 13:56:30 +01:00
332 lines
No EOL
23 KiB
HTML
332 lines
No EOL
23 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<title>Add a wiki on your website — Evennia 2.x documentation</title>
|
||
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/language_data.js"></script>
|
||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="Web Character Generation" href="Web-Character-Generation.html" />
|
||
<link rel="prev" title="Changing the Game Website" href="Web-Changing-Webpage.html" />
|
||
</head><body>
|
||
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="Web-Character-Generation.html" title="Web Character Generation"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="Web-Changing-Webpage.html" title="Changing the Game Website"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 2.x</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="Howtos-Overview.html" accesskey="U">Tutorials and Howto’s</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">Add a wiki on your website</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
<div class="document">
|
||
|
||
<div class="documentwrapper">
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="../index.html">
|
||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
|
||
</a></p>
|
||
<div id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="../search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script>$('#searchbox').show(0);</script>
|
||
<h3><a href="../index.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">Add a wiki on your website</a><ul>
|
||
<li><a class="reference internal" href="#basic-installation">Basic installation</a><ul>
|
||
<li><a class="reference internal" href="#installing-with-pip">Installing with pip</a></li>
|
||
<li><a class="reference internal" href="#adding-the-wiki-in-the-settings">Adding the wiki in the settings</a></li>
|
||
<li><a class="reference internal" href="#adding-the-new-urls">Adding the new URLs</a></li>
|
||
<li><a class="reference internal" href="#running-migrations">Running migrations</a></li>
|
||
<li><a class="reference internal" href="#initializing-the-wiki">Initializing the wiki</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#defining-wiki-permissions">Defining wiki permissions</a><ul>
|
||
<li><a class="reference internal" href="#group-permissions">Group permissions</a></li>
|
||
<li><a class="reference internal" href="#settings-permissions">Settings permissions</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="Web-Changing-Webpage.html"
|
||
title="previous chapter">Changing the Game Website</a></p>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="Web-Character-Generation.html"
|
||
title="next chapter">Web Character Generation</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/Howtos/Web-Add-a-wiki.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
||
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
||
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
|
||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||
<li>
|
||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section class="tex2jax_ignore mathjax_ignore" id="add-a-wiki-on-your-website">
|
||
<h1>Add a wiki on your website<a class="headerlink" href="#add-a-wiki-on-your-website" title="Permalink to this headline">¶</a></h1>
|
||
<div class="admonition warning">
|
||
<p class="admonition-title">Warning</p>
|
||
<p>As of 2023, The <a class="reference external" href="https://django-wiki.readthedocs.io/en/main/">django wiki</a> only supports Django 4.0. Evennia requires Django 4.1+. While the django-wiki is still active and will hopefully be updated eventually, for now there is likely to be issues or trouble to install. This tutorial will probably not work out of the gate.</p>
|
||
</div>
|
||
<div class="admonition note">
|
||
<p class="admonition-title">Note</p>
|
||
<p>Before doing this tutorial you will probably want to read the intro in <a class="reference internal" href="Web-Changing-Webpage.html"><span class="doc std std-doc">Basic Web tutorial</span></a>. Reading the three first parts of the <a class="reference external" href="https://docs.djangoproject.com/en/4.1/intro/tutorial01/">Django tutorial</a> might help as well.</p>
|
||
</div>
|
||
<p>This tutorial will provide a step-by-step process to installing a wiki on your website.
|
||
Fortunately, you don’t have to create the features manually, since it has been done by others, and we can integrate their work quite easily with Django. I have decided to focus on
|
||
the <a class="reference external" href="https://django-wiki.readthedocs.io/">Django-wiki</a>.</p>
|
||
<p>The <a class="reference external" href="https://django-wiki.readthedocs.io/">Django-wiki</a> offers a lot of features associated with wikis, is actively maintained (at this time, anyway), and isn’t too difficult to install in Evennia. You can see a <a class="reference external" href="https://demo.django-wiki.org">demonstration of Django-wiki here</a>.</p>
|
||
<section id="basic-installation">
|
||
<h2>Basic installation<a class="headerlink" href="#basic-installation" title="Permalink to this headline">¶</a></h2>
|
||
<p>You should begin by shutting down the Evennia server if it is running. We will run migrations and alter the virtual environment just a bit. Open a terminal and activate your Python environment, the one you use to run the <code class="docutils literal notranslate"><span class="pre">evennia</span></code> command.</p>
|
||
<p>If you used the default location from the Evennia installation instructions, it should be one of the following:</p>
|
||
<ul>
|
||
<li><p>On Linux:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">source</span> <span class="n">evenv</span><span class="o">/</span><span class="nb">bin</span><span class="o">/</span><span class="n">activate</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>Or Windows:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">evenv</span>\<span class="nb">bin</span>\<span class="n">activate</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
<section id="installing-with-pip">
|
||
<h3>Installing with pip<a class="headerlink" href="#installing-with-pip" title="Permalink to this headline">¶</a></h3>
|
||
<p>Install the wiki using pip:</p>
|
||
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>pip install wiki
|
||
</pre></div>
|
||
</div>
|
||
<p>It might take some time, the Django-wiki having some dependencies.</p>
|
||
</section>
|
||
<section id="adding-the-wiki-in-the-settings">
|
||
<h3>Adding the wiki in the settings<a class="headerlink" href="#adding-the-wiki-in-the-settings" title="Permalink to this headline">¶</a></h3>
|
||
<p>You will need to add a few settings to have the wiki app on your website. Open your <code class="docutils literal notranslate"><span class="pre">server/conf/settings.py</span></code> file and add the following at the bottom (but before importing <code class="docutils literal notranslate"><span class="pre">secret_settings</span></code>). Here’s an example of a settings file with the Django-wiki added:</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Use the defaults from Evennia unless explicitly overridden</span>
|
||
<span class="kn">from</span> <span class="nn">evennia.settings_default</span> <span class="kn">import</span> <span class="o">*</span>
|
||
|
||
<span class="c1">######################################################################</span>
|
||
<span class="c1"># Evennia base server config</span>
|
||
<span class="c1">######################################################################</span>
|
||
|
||
<span class="c1"># This is the name of your game. Make it catchy!</span>
|
||
<span class="n">SERVERNAME</span> <span class="o">=</span> <span class="s2">"demowiki"</span>
|
||
|
||
<span class="c1">######################################################################</span>
|
||
<span class="c1"># Django-wiki settings</span>
|
||
<span class="c1">######################################################################</span>
|
||
<span class="n">INSTALLED_APPS</span> <span class="o">+=</span> <span class="p">(</span>
|
||
<span class="s1">'django.contrib.humanize.apps.HumanizeConfig'</span><span class="p">,</span>
|
||
<span class="s1">'django_nyt.apps.DjangoNytConfig'</span><span class="p">,</span>
|
||
<span class="s1">'mptt'</span><span class="p">,</span>
|
||
<span class="s1">'sorl.thumbnail'</span><span class="p">,</span>
|
||
<span class="s1">'wiki.apps.WikiConfig'</span><span class="p">,</span>
|
||
<span class="s1">'wiki.plugins.attachments.apps.AttachmentsConfig'</span><span class="p">,</span>
|
||
<span class="s1">'wiki.plugins.notifications.apps.NotificationsConfig'</span><span class="p">,</span>
|
||
<span class="s1">'wiki.plugins.images.apps.ImagesConfig'</span><span class="p">,</span>
|
||
<span class="s1">'wiki.plugins.macros.apps.MacrosConfig'</span><span class="p">,</span>
|
||
<span class="p">)</span>
|
||
|
||
<span class="c1"># Disable wiki handling of login/signup</span>
|
||
<span class="n">WIKI_ACCOUNT_HANDLING</span> <span class="o">=</span> <span class="kc">False</span>
|
||
<span class="n">WIKI_ACCOUNT_SIGNUP_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span>
|
||
|
||
<span class="c1">######################################################################</span>
|
||
<span class="c1"># Settings given in secret_settings.py override those in this file.</span>
|
||
<span class="c1">######################################################################</span>
|
||
<span class="k">try</span><span class="p">:</span>
|
||
<span class="kn">from</span> <span class="nn">server.conf.secret_settings</span> <span class="kn">import</span> <span class="o">*</span>
|
||
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="s2">"secret_settings.py file not found or failed to import."</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Everything in the section “Django-wiki settings” is what you’ll need to include.</p>
|
||
</section>
|
||
<section id="adding-the-new-urls">
|
||
<h3>Adding the new URLs<a class="headerlink" href="#adding-the-new-urls" title="Permalink to this headline">¶</a></h3>
|
||
<p>Next you will need to add two URLs to the file <code class="docutils literal notranslate"><span class="pre">web/urls.py</span></code>. You’ll do that by modifying
|
||
<code class="docutils literal notranslate"><span class="pre">urlpatterns</span></code> to look something like this:</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># add patterns</span>
|
||
<span class="n">urlpatterns</span> <span class="o">=</span> <span class="p">[</span>
|
||
<span class="c1"># website</span>
|
||
<span class="n">path</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s2">"web.website.urls"</span><span class="p">)),</span>
|
||
<span class="c1"># webclient</span>
|
||
<span class="n">path</span><span class="p">(</span><span class="s2">"webclient/"</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s2">"web.webclient.urls"</span><span class="p">)),</span>
|
||
<span class="c1"># web admin</span>
|
||
<span class="n">path</span><span class="p">(</span><span class="s2">"admin/"</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s2">"web.admin.urls"</span><span class="p">)),</span>
|
||
<span class="c1"># wiki</span>
|
||
<span class="n">path</span><span class="p">(</span><span class="s2">"wiki/"</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s2">"wiki.urls"</span><span class="p">)),</span>
|
||
<span class="n">path</span><span class="p">(</span><span class="s2">"notifications/"</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s2">"django_nyt.urls"</span><span class="p">)),</span>
|
||
<span class="p">]</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The last two lines are what you’ll need to add.</p>
|
||
</section>
|
||
<section id="running-migrations">
|
||
<h3>Running migrations<a class="headerlink" href="#running-migrations" title="Permalink to this headline">¶</a></h3>
|
||
<p>Next you’ll need to run migrations, since the wiki app adds a few tables in our database:</p>
|
||
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>evennia migrate
|
||
</pre></div>
|
||
</div>
|
||
</section>
|
||
<section id="initializing-the-wiki">
|
||
<h3>Initializing the wiki<a class="headerlink" href="#initializing-the-wiki" title="Permalink to this headline">¶</a></h3>
|
||
<p>Last step! Go ahead and start up your server again.</p>
|
||
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>evennia start
|
||
</pre></div>
|
||
</div>
|
||
<p>Once that’s finished booting, go to your evennia website (e.g. <a class="reference external" href="http://localhost:4001">http://localhost:4001</a> ) and log in with your superuser account, if you aren’t already. Then, go to your new wiki (e.g. <a class="reference external" href="http://localhost:4001/wiki">http://localhost:4001/wiki</a> ). It’ll prompt you to create a starting page - put whatever you want, you can change it later.</p>
|
||
<p>Congratulations! You’re all done!</p>
|
||
</section>
|
||
</section>
|
||
<section id="defining-wiki-permissions">
|
||
<h2>Defining wiki permissions<a class="headerlink" href="#defining-wiki-permissions" title="Permalink to this headline">¶</a></h2>
|
||
<p>A wiki is usually intended as a collaborative effort - but you probably still want to set some rules about who is allowed to do what. Who can create new articles? Edit them? Delete them? Etc.</p>
|
||
<p>The two simplest ways to do this are to use Django-wiki’s group-based permissions
|
||
system - or, since this is an Evennia site, to define your own custom permission rules tied to Evennia’s permissions system in your settings file.</p>
|
||
<section id="group-permissions">
|
||
<h3>Group permissions<a class="headerlink" href="#group-permissions" title="Permalink to this headline">¶</a></h3>
|
||
<p>The wiki itself controls reading/editing permissions per article. The creator of an article will always have read/write permissions on that article. Additionally, the article will have Group-based permissions and general permissions.</p>
|
||
<p>By default, Evennia’s permission groups <em>won’t</em> be recognized by the wiki, so you’ll have to create your own. Go to the Groups page of your game’s Django admin panel and add whichever permission groups you want for your wiki here.</p>
|
||
<p><em><strong>Note:</strong></em> <em>If you want to connect those groups to your game’s permission levels, you’ll need to modify the game to apply both to accounts.</em></p>
|
||
<p>Once you’ve added those groups, they’ll be usable in your wiki right away!</p>
|
||
</section>
|
||
<section id="settings-permissions">
|
||
<h3>Settings permissions<a class="headerlink" href="#settings-permissions" title="Permalink to this headline">¶</a></h3>
|
||
<p>Django-wiki also allows you to bypass its article-based permissions with custom site-wide permissions rules in your settings file. If you don’t want to use the Group system, or if you want a simple solution for connecting the Evennia permission levels to wiki access, this is the way to go.</p>
|
||
<p>Here’s an example of a basic set-up that would go in your <code class="docutils literal notranslate"><span class="pre">settings.py</span></code> file:</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># In server/conf/settings.py</span>
|
||
<span class="c1"># ...</span>
|
||
|
||
<span class="c1"># Custom methods to link wiki permissions to game perms</span>
|
||
<span class="k">def</span> <span class="nf">is_superuser</span><span class="p">(</span><span class="n">article</span><span class="p">,</span> <span class="n">user</span><span class="p">):</span>
|
||
<span class="w"> </span><span class="sd">"""Return True if user is a superuser, False otherwise."""</span>
|
||
<span class="k">return</span> <span class="ow">not</span> <span class="n">user</span><span class="o">.</span><span class="n">is_anonymous</span><span class="p">()</span> <span class="ow">and</span> <span class="n">user</span><span class="o">.</span><span class="n">is_superuser</span>
|
||
|
||
<span class="k">def</span> <span class="nf">is_builder</span><span class="p">(</span><span class="n">article</span><span class="p">,</span> <span class="n">user</span><span class="p">):</span>
|
||
<span class="w"> </span><span class="sd">"""Return True if user is a builder, False otherwise."""</span>
|
||
<span class="k">return</span> <span class="ow">not</span> <span class="n">user</span><span class="o">.</span><span class="n">is_anonymous</span><span class="p">()</span> <span class="ow">and</span> <span class="n">user</span><span class="o">.</span><span class="n">locks</span><span class="o">.</span><span class="n">check_lockstring</span><span class="p">(</span><span class="n">user</span><span class="p">,</span> <span class="s2">"perm(Builders)"</span><span class="p">)</span>
|
||
|
||
<span class="k">def</span> <span class="nf">is_player</span><span class="p">(</span><span class="n">article</span><span class="p">,</span> <span class="n">user</span><span class="p">):</span>
|
||
<span class="w"> </span><span class="sd">"""Return True if user is a builder, False otherwise."""</span>
|
||
<span class="k">return</span> <span class="ow">not</span> <span class="n">user</span><span class="o">.</span><span class="n">is_anonymous</span><span class="p">()</span> <span class="ow">and</span> <span class="n">user</span><span class="o">.</span><span class="n">locks</span><span class="o">.</span><span class="n">check_lockstring</span><span class="p">(</span><span class="n">user</span><span class="p">,</span> <span class="s2">"perm(Players)"</span><span class="p">)</span>
|
||
|
||
<span class="c1"># Create new users</span>
|
||
<span class="n">WIKI_CAN_ADMIN</span> <span class="o">=</span> <span class="n">is_superuser</span>
|
||
|
||
<span class="c1"># Change the owner and group for an article</span>
|
||
<span class="n">WIKI_CAN_ASSIGN</span> <span class="o">=</span> <span class="n">is_superuser</span>
|
||
|
||
<span class="c1"># Change the GROUP of an article, despite the name</span>
|
||
<span class="n">WIKI_CAN_ASSIGN_OWNER</span> <span class="o">=</span> <span class="n">is_superuser</span>
|
||
|
||
<span class="c1"># Change read/write permissions on an article</span>
|
||
<span class="n">WIKI_CAN_CHANGE_PERMISSIONS</span> <span class="o">=</span> <span class="n">is_superuser</span>
|
||
|
||
<span class="c1"># Mark an article as deleted</span>
|
||
<span class="n">WIKI_CAN_DELETE</span> <span class="o">=</span> <span class="n">is_builder</span>
|
||
|
||
<span class="c1"># Lock or permanently delete an article</span>
|
||
<span class="n">WIKI_CAN_MODERATE</span> <span class="o">=</span> <span class="n">is_superuser</span>
|
||
|
||
<span class="c1"># Create or edit any pages</span>
|
||
<span class="n">WIKI_CAN_WRITE</span> <span class="o">=</span> <span class="n">is_builder</span>
|
||
|
||
<span class="c1"># Read any pages</span>
|
||
<span class="n">WIKI_CAN_READ</span> <span class="o">=</span> <span class="n">is_player</span>
|
||
|
||
<span class="c1"># Completely disallow editing and article creation when not logged in</span>
|
||
<span class="n">WIKI_ANONYMOUS_WRITE</span> <span class="o">=</span> <span class="kc">False</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The permission functions can check anything you like on the accessing user, so long as the function returns either True (they’re allowed) or False (they’re not).</p>
|
||
<p>For a full list of possible settings, you can check out <a class="reference external" href="https://django-wiki.readthedocs.io/en/latest/settings.html">the django-wiki documentation</a>.</p>
|
||
</section>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="Web-Character-Generation.html" title="Web Character Generation"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="Web-Changing-Webpage.html" title="Changing the Game Website"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 2.x</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="Howtos-Overview.html" >Tutorials and Howto’s</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">Add a wiki on your website</a></li>
|
||
</ul>
|
||
</div>
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2023, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||
</div>
|
||
</body>
|
||
</html> |