<pclass="last">You are reading an old version of the Evennia documentation. <ahref="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
<h1>Add a wiki on your website<aclass="headerlink"href="#add-a-wiki-on-your-website"title="Permalink to this headline">¶</a></h1>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>As of 2023, The <aclass="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>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>Before doing this tutorial you will probably want to read the intro in <aclass="reference internal"href="Web-Changing-Webpage.html"><spanclass="doc std std-doc">Basic Web tutorial</span></a>. Reading the three first parts of the <aclass="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 <aclass="reference external"href="https://django-wiki.readthedocs.io/">Django-wiki</a>.</p>
<p>The <aclass="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 <aclass="reference external"href="https://demo.django-wiki.org">demonstration of Django-wiki here</a>.</p>
<sectionid="basic-installation">
<h2>Basic installation<aclass="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 <codeclass="docutils literal notranslate"><spanclass="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>
<h3>Installing with pip<aclass="headerlink"href="#installing-with-pip"title="Permalink to this headline">¶</a></h3>
<p>Install the wiki using pip:</p>
<divclass="highlight-none notranslate"><divclass="highlight"><pre><span></span>pip install wiki
</pre></div>
</div>
<p>It might take some time, the Django-wiki having some dependencies.</p>
</section>
<sectionid="adding-the-wiki-in-the-settings">
<h3>Adding the wiki in the settings<aclass="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 <codeclass="docutils literal notranslate"><spanclass="pre">server/conf/settings.py</span></code> file and add the following at the bottom (but before importing <codeclass="docutils literal notranslate"><spanclass="pre">secret_settings</span></code>). Here’s an example of a settings file with the Django-wiki added:</p>
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># Use the defaults from Evennia unless explicitly overridden</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="s2">"secret_settings.py file not found or failed to import."</span><spanclass="p">)</span>
</pre></div>
</div>
<p>Everything in the section “Django-wiki settings” is what you’ll need to include.</p>
</section>
<sectionid="adding-the-new-urls">
<h3>Adding the new URLs<aclass="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 <codeclass="docutils literal notranslate"><spanclass="pre">web/urls.py</span></code>. You’ll do that by modifying
<codeclass="docutils literal notranslate"><spanclass="pre">urlpatterns</span></code> to look something like this:</p>
<p>Once that’s finished booting, go to your evennia website (e.g. <aclass="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. <aclass="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>
<sectionid="defining-wiki-permissions">
<h2>Defining wiki permissions<aclass="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>
<sectionid="group-permissions">
<h3>Group permissions<aclass="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>
<sectionid="settings-permissions">
<h3>Settings permissions<aclass="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 <codeclass="docutils literal notranslate"><spanclass="pre">settings.py</span></code> file:</p>
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># In server/conf/settings.py</span>
<spanclass="c1"># ...</span>
<spanclass="c1"># Custom methods to link wiki permissions to game perms</span>
<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 <aclass="reference external"href="https://django-wiki.readthedocs.io/en/latest/settings.html">the django-wiki documentation</a>.</p>
<pclass="last">You are reading an old version of the Evennia documentation. <ahref="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.