diff --git a/icons/petition.png b/icons/petition.png
new file mode 100644
index 0000000..f04a332
Binary files /dev/null and b/icons/petition.png differ
diff --git a/modules/Email.py b/modules/Email.py
index f5b3e9a..c31335e 100644
--- a/modules/Email.py
+++ b/modules/Email.py
@@ -73,7 +73,7 @@ def VerifyPage(server):
'
+ # Petition
+
+ petition = Articles.get(article, {}).get("petition", "")
+ if petition:
+
+ html = html + ''
+
+ # License
License = Articles.get(article, {}).get("license", "")
if License:
html = html + ' '
@@ -1346,45 +1390,53 @@ def EditorPage(server):
"""
- # Optional release options
-
+ # Optional Petition
+
if rank(user.get("username","")) == 0:
+
+
+ petition = article.get("petition", {})
+ petition_goal = petition.get("goal", 0)
+
+
html = html + """
-
- Unlock
+
+ Petition
@@ -1456,6 +1508,15 @@ def ArticlePreview(article, Tabs, cookie=""):
if article.get("thumbnail"):
html = html + ''
+ petition = article.get("petition", "")
+ if petition:
+ try:
+ frac = petition.get("signed", 0) / int(petition.get("goal", 1))
+ except:
+ frac = 0
+
+ html = html + ProgressBar(frac)
+
author = article.get("author", "")
if author:
html = html + '
'+User( author )+''
@@ -1811,6 +1872,17 @@ def LoginButton(server):
return html
+def ProgressBar(frac):
+
+ title = str(round(frac*100,1))+"%"
+
+ frac = min(1, frac)
+ frac = max(0, frac)
+
+ html = ''
+ html = html + '
'
+ html = html + '
'
+ return html
def NotFound(server):
@@ -2329,7 +2401,13 @@ def Publish(server):
License = server.parsed.get("license", [""])[0]
recording = server.parsed.get("recording", [""])[0]
-
+
+ # Petition data
+ petition_goal = server.parsed.get("petition_goal", [""])[0]
+ petition_api = server.parsed.get("petition_api", [""])[0]
+ petition_api_key = server.parsed.get("petition_api_key", [""])[0]
+ petition_api_title = server.parsed.get("petition_api_title", [""])[0]
+ petition_api_link = server.parsed.get("petition_api_link", [""])[0]
# If this tab doesn't exist, this is an error.
if tab not in Tabs:
@@ -2384,6 +2462,22 @@ def Publish(server):
metadata["recording"] = recording
metadata["thumbnail"] = thumbnail
+ # Petition
+
+ if petition_goal:
+
+ petition = metadata.get("petition", {
+ "signed":0,
+ "signatures":[]
+ })
+
+ try:
+ petition["goal"] = int(petition_goal)
+ except:
+ petition["goal"] = 1
+
+ metadata["petition"] = petition
+
# Save the changes
try:
diff --git a/modules/Run.py b/modules/Run.py
index d3be2ff..21a640c 100644
--- a/modules/Run.py
+++ b/modules/Run.py
@@ -16,6 +16,7 @@ import os
from modules import Set
from modules import Render
+from modules import Email
from modules.Common import *
class handler(BaseHTTPRequestHandler):
@@ -172,8 +173,6 @@ class handler(BaseHTTPRequestHandler):
Render.EditorPage(self)
elif self.path[1:].startswith("email_verify"):
-
- from modules import Email
Email.VerifyPage(self)
elif self.path[1:].startswith("register"):
@@ -203,9 +202,8 @@ class handler(BaseHTTPRequestHandler):
elif self.path[1:].startswith("log_out"):
Render.LogOut(self)
-
-
-
+ elif self.path[1:].startswith("sign_petition"):
+ Email.SignPetition(self)
elif self.path[1:].startswith("read_notification"):
Render.ReadNotification(self)