diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe4452125..379cf0a706 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - [Feature][issue3273]: Allow passing `text_kwargs` kwarg to `EvMore.msg` in order to expand the outputfunc used for every evmore page. +- [Feature][pull3278]: Refactor home page into multiple sub-parts for easier + overriding and composition (johnnyvoruz) - [Fix][pull3267]: Missing recache step in ObjectSessionHandler (InspectorCaracal) - [Fix][pull3270]: Evennia is its own MSSP family now, so we should return that instead of 'Custom' (InspectorCaracal) @@ -17,6 +19,7 @@ [pull3267]: https://github.com/evennia/evennia/pull/3267 [pull3270]: https://github.com/evennia/evennia/pull/3270 [pull3274]: https://github.com/evennia/evennia/pull/3274 +[pull3278]: https://github.com/evennia/evennia/pull/3278 [issue3272]: https://github.com/evennia/evennia/issues/3272 [issue3273]: https://github.com/evennia/evennia/issues/3273 diff --git a/evennia/comms/comms.py b/evennia/comms/comms.py index 9791e5a930..7e370b23f1 100644 --- a/evennia/comms/comms.py +++ b/evennia/comms/comms.py @@ -7,7 +7,6 @@ import re from django.contrib.contenttypes.models import ContentType from django.urls import reverse from django.utils.text import slugify - from evennia.comms.managers import ChannelManager from evennia.comms.models import ChannelDB from evennia.typeclasses.models import TypeclassBase @@ -188,7 +187,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase): # display listening subscribers in bold string = ", ".join( [ - account.key if account not in listening else "|w%s|n" % account.key + account.key if account not in listening else f"|w{account.key}|n" for account in subs ] ) diff --git a/evennia/comms/models.py b/evennia/comms/models.py index ec6037f23f..80dfa69d79 100644 --- a/evennia/comms/models.py +++ b/evennia/comms/models.py @@ -21,7 +21,6 @@ necessary to easily be able to delete connections on the fly). from django.conf import settings from django.db import models from django.utils import timezone - from evennia.comms import managers from evennia.locks.lockhandler import LockHandler from evennia.typeclasses.models import TypedObject @@ -104,8 +103,10 @@ class Msg(SharedMemoryModel): null=True, blank=True, db_index=True, - help_text="Identifier for single external sender, for use with senders " - "not represented by a regular database model.", + help_text=( + "Identifier for single external sender, for use with senders " + "not represented by a regular database model." + ), ) db_receivers_accounts = models.ManyToManyField( @@ -137,8 +138,10 @@ class Msg(SharedMemoryModel): null=True, blank=True, db_index=True, - help_text="Identifier for single external receiver, for use with recievers " - "not represented by a regular database model.", + help_text=( + "Identifier for single external receiver, for use with recievers " + "not represented by a regular database model." + ), ) # header could be used for meta-info about the message if your system needs @@ -167,8 +170,10 @@ class Msg(SharedMemoryModel): db_tags = models.ManyToManyField( Tag, blank=True, - help_text="tags on this message. Tags are simple string markers to " - "identify, group and alias messages.", + help_text=( + "tags on this message. Tags are simple string markers to " + "identify, group and alias messages." + ), ) # Database manager @@ -518,7 +523,7 @@ class TempMsg: # ------------------------------------------------------------ -class SubscriptionHandler(object): +class SubscriptionHandler: """ This handler manages subscriptions to the channel and hides away which type of entity is @@ -540,13 +545,13 @@ class SubscriptionHandler(object): def _recache(self): self._cache = { account: True - for account in self.obj.db_account_subscriptions.all() + for account in self.obj.db_account_subscriptions.all().order_by("pk") if hasattr(account, "pk") and account.pk } self._cache.update( { obj: True - for obj in self.obj.db_object_subscriptions.all() + for obj in self.obj.db_object_subscriptions.all().order_by("pk") if hasattr(obj, "pk") and obj.pk } ) diff --git a/evennia/scripts/manager.py b/evennia/scripts/manager.py index b0a57df162..c42866aa9e 100644 --- a/evennia/scripts/manager.py +++ b/evennia/scripts/manager.py @@ -4,7 +4,6 @@ The custom manager for Scripts. from django.conf import settings from django.db.models import Q - from evennia.server import signals from evennia.typeclasses.managers import TypeclassManager, TypedObjectManager from evennia.utils.utils import class_from_module, dbid_to_obj, make_iter diff --git a/evennia/scripts/tests.py b/evennia/scripts/tests.py index bd1d245a25..eb5f205d13 100644 --- a/evennia/scripts/tests.py +++ b/evennia/scripts/tests.py @@ -78,26 +78,28 @@ class TestScriptHandler(BaseEvenniaTest): def setUp(self): self.obj, self.errors = DefaultObject.create("test_object") + self.obj.scripts.add(TestingListIntervalScript) def tearDown(self): self.obj.delete() def test_start(self): "Check that ScriptHandler start function works correctly" - self.obj.scripts.add(TestingListIntervalScript) self.num = self.obj.scripts.start(self.obj.scripts.all()[0].key) - self.assertTrue(self.num == 1) + self.assertEqual(self.num, 1) def test_list_script_intervals(self): "Checks that Scripthandler __str__ function lists script intervals correctly" - self.obj.scripts.add(TestingListIntervalScript) self.str = str(self.obj.scripts) self.assertTrue("None/1" in self.str) self.assertTrue("1 repeats" in self.str) + def test_get_all_scripts(self): + "Checks that Scripthandler get_all returns correct number of scripts" + self.assertEqual([script.key for script in self.obj.scripts.all()], ["interval_test"]) + def test_get_script(self): "Checks that Scripthandler get function returns correct script" - self.obj.scripts.add(TestingListIntervalScript) script = self.obj.scripts.get("interval_test") self.assertTrue(bool(script)) diff --git a/evennia/web/templates/website/homepage/accounts-widget.html b/evennia/web/templates/website/homepage/accounts-widget.html new file mode 100644 index 0000000000..9e6e13ad99 --- /dev/null +++ b/evennia/web/templates/website/homepage/accounts-widget.html @@ -0,0 +1,14 @@ +
+

Accounts

+ +
+

+ There's currently {{num_accounts_connected}} connected out of a total of {{num_accounts_registered}} + account{{num_accounts_registered|pluralize}} registered. +

+

+ Of these, {{num_accounts_registered_recent}} were created this week, and {{num_accounts_connected_recent}} + have connected within the last seven days. +

+
+
\ No newline at end of file diff --git a/evennia/web/templates/website/homepage/database-stats-widget.html b/evennia/web/templates/website/homepage/database-stats-widget.html new file mode 100644 index 0000000000..747bef56d2 --- /dev/null +++ b/evennia/web/templates/website/homepage/database-stats-widget.html @@ -0,0 +1,13 @@ +
+

Database Stats

+ +
+ +
+
\ No newline at end of file diff --git a/evennia/web/templates/website/homepage/evennia-widget.html b/evennia/web/templates/website/homepage/evennia-widget.html new file mode 100644 index 0000000000..a4772d71bb --- /dev/null +++ b/evennia/web/templates/website/homepage/evennia-widget.html @@ -0,0 +1,12 @@ +
+

Evennia

+ +
+

Evennia is an open-source MUD/MU*-creation framework built in + Python, using + Twisted and + Django.
+ Create the text-based multiplayer-game of your dreams - as + simple or as complex as you like.

+
+
\ No newline at end of file diff --git a/evennia/web/templates/website/homepage/main-content.html b/evennia/web/templates/website/homepage/main-content.html new file mode 100644 index 0000000000..72c9208177 --- /dev/null +++ b/evennia/web/templates/website/homepage/main-content.html @@ -0,0 +1,62 @@ +

Welcome to Evennia!

+ +
+ +

The Python MUD/MU* creation system.

+ +

+ You are looking at the start of your game's website, generated out of + the box by Evennia.
It can be expanded into a full-fledged home for your game. +

+ +{% if webclient_enabled %} + +

Play in the browser!

+ +{% endif %} +{% if telnet_enabled %} +

+ Telnet: {{ server_hostname }}, port + {% for port in telnet_ports %} + {% if not forloop.first and forloop.last %} or + {% elif forloop.counter != 1 %}, + {% endif %} + {{ port }} + {% endfor %} +

+{% endif %} +{% if telnet_ssl_enabled %} +

+ Telnet (SSL): {{ server_hostname }}, port + {% for port in telnet_ssl_ports %} + {% if not forloop.first and forloop.last %} or + {% elif forloop.counter != 1 %}, + {% endif %} + {{ port }} + {% endfor %} +

+{% endif %} +{% if ssh_enabled %} +

+ SSH: {{ server_hostname }}, port + {% for port in ssh_ports %} + {% if not forloop.first and forloop.last %} or + {% elif forloop.counter != 1 %}, + {% endif %} + {{ port }} + {% endfor %} +

+{% endif %} +

+ For more info, see the Evennia homepage or check + out our extensive online documentation. +

+

+ Don't hesitate asking questions to the Evennia community!
Drop a message + in the Evennia forums + or come say hi in the Discord support channel. +

+

+ Evennia is Open source and can be found on GitHub. + If you find bugs, please report them to the Issue tracker. +

\ No newline at end of file diff --git a/evennia/web/templates/website/homepage/recently-connected-widget.html b/evennia/web/templates/website/homepage/recently-connected-widget.html new file mode 100644 index 0000000000..4ee1552bc0 --- /dev/null +++ b/evennia/web/templates/website/homepage/recently-connected-widget.html @@ -0,0 +1,11 @@ +
+

Recently Connected

+ +
+ +
+
\ No newline at end of file diff --git a/evennia/web/templates/website/index.html b/evennia/web/templates/website/index.html index 365f473a4d..49a9479d62 100644 --- a/evennia/web/templates/website/index.html +++ b/evennia/web/templates/website/index.html @@ -7,138 +7,44 @@ {% block content %}
-
-
-
+
+
+
-

Welcome to Evennia!

+ {% include "website/homepage/main-content.html" %} -
- -

- The Python MUD/MU* creation system. -

-

- You are looking at the start of your game's website, generated out of - the box by Evennia.
It can be expanded into a full-fledged home for your game. -

- {% if webclient_enabled %} -

- Play in the browser! -

- {% endif %} - {% if telnet_enabled %} -

- Telnet: {{ server_hostname }}, port - {% for port in telnet_ports %} - {% if not forloop.first and forloop.last %} or - {% elif forloop.counter != 1 %}, - {% endif %} - {{ port }} - {% endfor %} -

- {% endif %} - {% if telnet_ssl_enabled %} -

- Telnet (SSL): {{ server_hostname }}, port - {% for port in telnet_ssl_ports %} - {% if not forloop.first and forloop.last %} or - {% elif forloop.counter != 1 %}, - {% endif %} - {{ port }} - {% endfor %} -

- {% endif %} - {% if ssh_enabled %} -

- SSH: {{ server_hostname }}, port - {% for port in ssh_ports %} - {% if not forloop.first and forloop.last %} or - {% elif forloop.counter != 1 %}, - {% endif %} - {{ port }} - {% endfor %} -

- {% endif %} -

- For more info, see the Evennia homepage or check - out our extensive online documentation. -

-

- Don't hesitate asking questions to the Evennia community!
Drop a message - in the Evennia forums - or come say hi in the Discord support channel. -

-

- Evennia is Open source and can be found on GitHub. - If you find bugs, please report them to the Issue tracker. -

-
+
+
-
-
+
-
-
-

Accounts

+
+ + {% include "website/homepage/accounts-widget.html" %} -
-

- There's currently {{num_accounts_connected}} connected out of a total of {{num_accounts_registered}} account{{num_accounts_registered|pluralize}} registered. -

-

- Of these, {{num_accounts_registered_recent}} were created this week, and {{num_accounts_connected_recent}} have connected within the last seven days. -

-
-
-
-
-

Recently Connected

+
+ + {% include "website/homepage/recently-connected-widget.html" %} -
-
    - {% for account in accounts_connected_recent %} -
  • {{account.username}}—{{account.last_login|timesince}} ago
  • - {% endfor %} -
-
-
-
-
-

Database Stats

+
+ + {% include "website/homepage/database-stats-widget.html" %} -
-
    -
  • {{num_accounts_registered}} account{{num_accounts_registered|pluralize}} (+ {{num_characters}} character{{num_characters|pluralize}})
  • -
  • {{num_rooms}} room{{num_rooms|pluralize}} (+ {{num_exits}} exits)
  • -
  • {{num_others}} other objects
  • -
-
-
-
-
-

Evennia

+
+ + {% include "website/homepage/evennia-widget.html" %} -
-

Evennia is an open-source MUD/MU*-creation framework built in - Python, using - Twisted and - Django.
- Create the text-based multiplayer-game of your dreams - as - simple or as complex as you like.

-
-
{% endblock %}