diff --git a/src/article.py b/src/article.py index c809054..8132f6e 100644 --- a/src/article.py +++ b/src/article.py @@ -8,7 +8,7 @@ class LexiconArticle: A Lexicon article and its metadata. Members: - author string: the author of the article + player string: the player of the article turn integer: the turn the article was written for title string: the article title title_filesafe string: the title, escaped, used for filenames @@ -20,11 +20,11 @@ class LexiconArticle: The last three are filled in by populate(). """ - def __init__(self, author, turn, title, content, citations): + def __init__(self, player, turn, title, content, citations): """ Creates a LexiconArticle object with the given parameters. """ - self.author = author + self.player = player self.turn = turn self.title = title self.title_filesafe = utils.titleescape(title) @@ -44,12 +44,12 @@ class LexiconArticle: if len(headers) != 4: print("Header read error") return None - author_header, turn_header, title_header, content_raw = headers - # Validate and sanitize the author header - if not author_header.startswith("# Author:"): - print("Author header missing or corrupted") + player_header, turn_header, title_header, content_raw = headers + # Validate and sanitize the player header + if not player_header.startswith("# Player:"): + print("Player header missing or corrupted") return None - author = author_header[9:].strip() + player = player_header[9:].strip() # Validate and sanitize the turn header if not turn_header.startswith("# Turn:"): print("Turn header missing or corrupted") @@ -99,7 +99,7 @@ class LexiconArticle: else: para = "

" + para + "

\n" content += para - return LexiconArticle(author, turn, title, content, citations) + return LexiconArticle(player, turn, title, content, citations) @staticmethod def parse_from_directory(directory): @@ -142,7 +142,7 @@ class LexiconArticle: if target not in article_by_title: article_by_title[target] = LexiconArticle(None, sys.maxsize, target, "

This entry hasn't been written yet.

", {}) # Interlink citations - if article_by_title[target].author is None: + if article_by_title[target].player is None: article.pcites.add(target) else: article.wcites.add(target) diff --git a/src/build.py b/src/build.py index 7c783d6..476b6aa 100644 --- a/src/build.py +++ b/src/build.py @@ -13,7 +13,7 @@ def build_contents_page(articles, config): """ content = "" # Article counts - phantom_count = len([article for article in articles if article.author is None]) + phantom_count = len([article for article in articles if article.player is None]) if phantom_count == 0: content = "

There are {0} entries in this lexicon.

\n".format(len(articles)) else: @@ -22,7 +22,7 @@ def build_contents_page(articles, config): # Prepare article links link_by_title = {article.title : "{0}".format( article.title, article.title_filesafe, - "" if article.author is not None else " class=\"phantom\"") + "" if article.player is not None else " class=\"phantom\"") for article in articles} # Write the articles in alphabetical order content += utils.load_resource("contents.html") @@ -47,7 +47,7 @@ def build_contents_page(articles, config): content += "\n\n" # Write the articles in turn order content += "
\n
\n" - # Top numebr of citations made + # Top number of citations made content += "
\n" content += "

Most citations made from:
\n" citation_tally = [(kv[0], len(kv[1])) for kv in cite_map.items()] @@ -170,36 +170,38 @@ def build_statistics_page(articles, config): sorted(cited_count.items(), reverse=True)[:3])) content += "

\n" content += "
\n" - # Author pageranks + # player pageranks content += "
\n" - content += "

Author total page rank:
\n" - authors = sorted(set([article.author for article in articles if article.author is not None])) - articles_by = {author : [a for a in articles if a.author == author] for author in authors} - author_rank = {author : sum(map(lambda a: ranks[a.title], articles)) for author, articles in articles_by.items()} + content += "

Player total page rank:
\n" + players = sorted(set([article.player for article in articles if article.player is not None])) + articles_by = {player : [a for a in articles if a.player == player] for player in players} + player_rank = {player : sum(map(lambda a: ranks[a.title], articles)) for player, articles in articles_by.items()} content += "
\n".join(map( lambda kv: "{0} – {1}".format(kv[0], round(kv[1], 3)), - sorted(author_rank.items(), key=lambda t:-t[1]))) + sorted(player_rank.items(), key=lambda t:t[1], reverse=True))) content += "

\n" content += "
\n" - # Author citations made + # Player citations made content += "
\n" - content += "

Citations made by author
\n" - author_cite_count = {author : sum(map(lambda a:len(a.wcites | a.pcites), articles)) for author, articles in articles_by.items()} + content += "

Citations made by player
\n" + player_cite_count = { + player : sum(map(lambda a:len(a.wcites | a.pcites), articles)) + for player, articles in articles_by.items()} content += "
\n".join(map( lambda kv: "{0} – {1}".format(kv[0], kv[1]), - sorted(author_cite_count.items(), key=lambda t:-t[1]))) + sorted(player_cite_count.items(), key=lambda t:t[1], reverse=True))) content += "

\n" content += "
\n" - # Author cited count + # player cited count content += "
\n" - content += "

Citations made to author
\n" - cited_times = {author : 0 for author in authors} + content += "

Citations made to player
\n" + cited_times = {player : 0 for player in players} for article in articles: - if article.author is not None: - cited_times[article.author] += len(article.citedby) + if article.player is not None: + cited_times[article.player] += len(article.citedby) content += "
\n".join(map( lambda kv: "{0} – {1}".format(kv[0], kv[1]), - sorted(cited_times.items(), key=lambda t:-t[1]))) + sorted(cited_times.items(), key=lambda t:t[1], reverse=True))) content += "

\n" content += "
\n" diff --git a/src/resources/example-page.txt b/src/resources/example-page.txt index c00028d..3f721ba 100644 --- a/src/resources/example-page.txt +++ b/src/resources/example-page.txt @@ -1,4 +1,4 @@ -# Author: AN +# Player: PN # Turn: 1 # Title: Example page diff --git a/src/resources/formatting.html b/src/resources/formatting.html index 9521423..ceaa19c 100644 --- a/src/resources/formatting.html +++ b/src/resources/formatting.html @@ -1,6 +1,6 @@

Lexipython provides support for a limited amount of Markdown-esque formatting.

-# Author: Authorname
+# Player: PN
 # Turn: 1
 # Title: Example page
 
@@ -16,7 +16,7 @@ This is an [[example citation|Phantom page]]. You can also cite a [[phantom page
 
 ~Dr. X. Amplepage
 
-

Each turn, fill out the header with your author information, the current turn, and the title of your entry. It doesn't really matter what the Author field is, except that it must be the same across all articles you write.

+

Each turn, fill out the header with your player information, the current turn, and the title of your entry. The Player field can be anything as long as it's the same for all articles you write (even when they're by different characters). Using your initials is recommended.

Two line breaks begins a new paragraph. A single line break does nothing, unless the line is neded by a double backslash (\\).

Text bounded by ** will be bolded: **bold** produces bold. Text bounded by // will be italicized: //italics// produces italics.

To cite another Lexicon entry, use double brackets. Text in double brackets will cite and link to the entry of the same name: [[Example page]] produces Example page. Text in double brackets split with a | will alias the link as the left text and link to the entry with the name of the right text: [[this text|Example page]] produces this text. You must be precise in the entry title you cite to. Citations to "Example" vs. "The Example" will point to different entries and create different phantoms, and your GM will probably have to clean up after you.