diff --git a/html/default_template b/html/default_template
new file mode 100644
index 0000000..6ac7489
--- /dev/null
+++ b/html/default_template
@@ -0,0 +1,11 @@
+
+
+
+
+Accouplement de chaussettes rurales
+--
+Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
+
+

+
+
+
+
diff --git a/html/script.js b/html/script.js
new file mode 100644
index 0000000..e69de29
diff --git a/html/style.css b/html/style.css
new file mode 100644
index 0000000..c46e8c4
--- /dev/null
+++ b/html/style.css
@@ -0,0 +1,32 @@
+.prev{
+ float:left
+}
+.next{
+ float:right
+}
+.content{
+ width:80%;
+ margin-left:10%;
+ padding-top:10px
+}
+img{
+ max-width:100%
+}
+
+.texte{
+ border:1px solid black;
+ padding:10px
+}
+
+.images{
+ margin-top:20px
+}
+
+a {
+ color: black;
+ font-size: 500%;
+ margin-left: 20px;
+ margin-right: 20px;
+ margin-top: 25%;
+ text-decoration: none;
+}
diff --git a/website.py b/website.py
index 04529af..b6fb5e5 100755
--- a/website.py
+++ b/website.py
@@ -3,7 +3,7 @@
import time
from subprocess import Popen, PIPE, STDOUT
-def extract_signature_content(lines) :
+def extract_signed_content(lines) :
gpg_boundary = None
gpg_boundary_stroke = 0;
lines_to_validate = []
@@ -21,6 +21,15 @@ def extract_signature_content(lines) :
lines_to_validate = lines_to_validate[:-1]
return lines_to_validate
+def get_mail_subject(lines) :
+ gpg_boundary = None
+ gpg_boundary_stroke = 0;
+ lines_to_validate = []
+ for line in mail_lines :
+ if "Subject:" in line :
+ return line.replace("Subject:", "");
+ return None
+
def munpack_extract(folder, file) :
p = Popen(["munpack", "-f", "-t", "-C", folder, file], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
out, err = p.communicate()
@@ -41,10 +50,112 @@ def validate_signature(to_validate) :
p = Popen(["gpg", "--verify", "signature.asc", "tmp"], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
out, err = p.communicate()
out = out.decode("utf-8", "strict")
+ rm_file("tmp")
return not("BAD" in out or "MAUVAISE" in out)
+def rm_file(filepath) :
+ p = Popen(["rm", filepath], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
+ p.communicate()
+
+def list_current_pages(html_folder) :
+ p = Popen(["ls",html_base], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
+ out, err = p.communicate()
+ out = out.decode("utf-8", "strict")
+ return out.split("\n")
+
+def get_bigger_file(html_content) :
+ greater = -1
+ for html_file in html_content :
+ try :
+ current = int(html_file)
+ if current > greater :
+ greater = current
+ except :
+ pass
+ return greater
+
+def hard_cleanup(temp_files, source) :
+ for f in temp_files :
+ print("rm {}".format(f))
+ try :
+ rm_file(f.split(" ")[0])
+ except:
+ pass
+ # TODO cleanup source mail too
+ # rm_file(source)
+
+def get_param(params, name, default=None) :
+ for param in params :
+ if name in param :
+ try :
+ return param.split("=")[1]
+ except :
+ return default
+ return default
+
+def create_new_page(extracted_files, order_type, order_template) :
+
+ # Les fichiers sans extension vont etre listes dans le but d'obtenir le
+ # prochain plus grand fichier.
+ html_content = list_current_pages(html_base)
+ print(html_content)
+
+ # The bigger file is going to be updated, with its prev pointing on
+ # the new bigger file which will be bigger+1
+
+ bigger_file = get_bigger_file(html_content)
+ new_bigger = bigger_file +1
+
+ template = open(html_base+"/{}_template".format(order_template), 'r')
+ template_lines = template.readlines()
+ template.close
+
+ if bigger_file > -1 :
+ # Update the bigger one, to add it a prev link to the next bigger we are
+ # creating
+ # Le precedent plus grand va etre mis a jour
+ actual_bigger = open(html_base+"/{}".format(bigger_file), 'r')
+ actual_bigger_lines = actual_bigger.readlines()
+ actual_bigger.close()
+ actual_bigger = open(html_base+"/{}".format(bigger_file), 'w')
+ for line in actual_bigger_lines :
+ actual_bigger.write(line)
+ if "class='next'" in line :
+ actual_bigger.write('\n')
- ## write the top of the file
- #for brut in extracted_files :
- # if not brut == "" :
- # split = brut.split(" ")
- # file_name = split[0]
- # file_type = split[1]
- # if "plain" in file_type :
- # p = Popen(["rm",new_base+"/"+file_name], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
- # out, err = p.communicate()
- # elif "html" in file_type :
- # f.write('
\n')
- # fh = open(new_base+"/"+file_name, 'r')
- # lines = fh.readlines()
- # for line in lines :
- # f.write(line)
- # fh.close
- # f.write('
\n')
- # p = Popen(["rm",new_base+"/"+file_name], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
- # out, err = p.communicate()
- # else :
- # f.write('
\n')
- # f.write('

\n'.format(file_name))
- # f.write('
\n')
- # p = Popen(["mv",new_base+"/"+file_name,
- # html_base+"/"+file_name], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
- # out, err = p.communicate()
- # try :
- # p = Popen(["chmod", "644", html_base+"/"+file_name], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
- # out, err = p.communicate()
- # except :
- # pass
- ## write the end of the file
- #f.write('
\n')
- #f.write(' \n')
- #f.write('\n')
- #f.close()
- ## remove the mail
- #p = Popen(["rm", new_base+"/"+new_mail], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
- #out, err = p.communicate()