diff options
-rwxr-xr-x | pyblog | 185 |
1 files changed, 0 insertions, 185 deletions
@@ -326,128 +326,6 @@ def generate_menu(): os.remove(tmppath) -def generate_submenu(): - """Generate submenu.""" - - sys.stderr.write("generating submenu\n") - - fd, tmppath = tempfile.mkstemp() - os.close(fd) - - # Put in a list the pages where the menu will be written - documents_fileList = [] - documents_fileList.append("/website/bts-sio.html") - for root, dirs, files in os.walk(BUILDDIR+"/website/Documents"): - for name in files: - if name.endswith(".html"): - try: - documents_fileList.append(os.path.join(root.split('build')[1], name)) - except IndexError: - documents_fileList.append(name) - - # Generate the string who contain the links of the menu - htmly_website_page = "<ul>" - htmly_website_page += "<a href='/website/bts-sio.html' class='sublia'><li><span class='subleft-lia'></span><span class='subcenter-lia'>bts-sio</span><span class='subright-lia'></span></li></a>" - for name in sorted(os.listdir(os.path.join(BUILDDIR, "website/Documents"))): - if name != "Situation1" and name != "Situation2": - htmly_website_page += "<a href='/website/Documents/"+name+"' class='sublia'><li><span class='subleft-lia'></span><span class='subcenter-lia'>"+name.split('.html')[0]+"</span><span class='subright-lia'></span></li></a>" - htmly_website_page += "</ul>" - - # Writing the menu in all pages contained in the variable in place of the -- generate submenu here -- - for document_file in documents_fileList: - with open(tmppath, 'w', encoding='utf-8') as tmpfile: - if os.path.exists("build"+document_file): - with open("build"+document_file, 'r', encoding='utf-8') as indexmd: - lines = indexmd.readlines() - with open("build"+document_file, 'w', encoding='utf-8') as indexmd: - for line in lines: - indexmd.write(re.sub(r'-- generate submenu here --', htmly_website_page, line)) - - os.remove(tmppath) - -def generate_situation1menu(): - """Generate situation1menu.""" - - sys.stderr.write("generating situation1menu\n") - - documents_fileList = [] - documents_fileList.append("/website/Documents/PPE4.html") - - fd, tmppath = tempfile.mkstemp() - os.close(fd) - - htmly_website_page = "" - - if os.path.exists(BUILDDIR+"/website/Documents/Situation1"): - - # Put in a list the pages where the menu will be written - for root, dirs, files in os.walk(BUILDDIR+"/website/Documents/Situation1"): - for name in files: - if name.endswith(".html"): - try: - documents_fileList.append(os.path.join(root.split('build')[1], name)) - except IndexError: - documents_fileList.append(name) - - # Generate the string who contain the links of the menu - htmly_website_page = "<ul>" - for name in os.listdir(os.path.join(BUILDDIR, "website/Documents/Situation1")): - htmly_website_page += "<a href='/website/Documents/Situation1/"+name+"' class='situation1lia'><li><span class='situation1left-lia'></span><span class='situation1center-lia'>"+name.split('.html')[0]+"</span><span class='situation1right-lia'></span></li></a>" - htmly_website_page += "</ul>" - - # Writing the menu in all pages contained in the variable in place of the -- generate submenu here -- - for document_file in documents_fileList: - with open(tmppath, 'w', encoding='utf-8') as tmpfile: - if os.path.exists("build"+document_file): - with open("build"+document_file, 'r', encoding='utf-8') as indexmd: - lines = indexmd.readlines() - with open("build"+document_file, 'w', encoding='utf-8') as indexmd: - for line in lines: - indexmd.write(re.sub(r'-- generate situation1menu here --', htmly_website_page, line)) - - os.remove(tmppath) - -def generate_situation2menu(): - """Generate situation2menu.""" - - documents_fileList = [] - documents_fileList.append("/website/Documents/stage2.html") - - fd, tmppath = tempfile.mkstemp() - os.close(fd) - - htmly_website_page = "" - - if os.path.exists(BUILDDIR+"/website/Documents/Situation2"): - sys.stderr.write("generating situation2menu\n") - - # Put in a list the pages where the menu will be written - for root, dirs, files in os.walk(BUILDDIR+"/website/Documents/Situation2"): - for name in files: - if name.endswith(".html"): - try: - documents_fileList.append(os.path.join(root.split('build')[1], name)) - except IndexError: - documents_fileList.append(name) - - # Generate the string who contain the links of the menu - htmly_website_page = "<ul>" - for name in os.listdir(os.path.join(BUILDDIR, "website/Documents/Situation2")): - htmly_website_page += "<a href='/website/Documents/Situation2/"+name+"' class='situation2lia'><li><span class='situation2left-lia'></span><span class='situation2center-lia'>"+name.split('.html')[0]+"</span><span class='situation2right-lia'></span></li></a>" - htmly_website_page += "</ul>" - - # Writing the menu in all pages contained in the variable in place of the -- generate submenu here -- - for document_file in documents_fileList: - with open(tmppath, 'w', encoding='utf-8') as tmpfile: - if os.path.exists("build"+document_file): - with open("build"+document_file, 'r', encoding='utf-8') as indexmd: - lines = indexmd.readlines() - with open("build"+document_file, 'w', encoding='utf-8') as indexmd: - for line in lines: - indexmd.write(re.sub(r'-- generate situation2menu here --', htmly_website_page, line)) - - os.remove(tmppath) - def generate_table(): """Generate table.""" @@ -540,65 +418,6 @@ def generate_table(): os.remove(tmppath) -def generate_tagcloud(): - """Generate tagcloud.""" - - first_comp = 1 - first_pr = 1 - tr_class = "odd" - - documents_fileList = [] - documents_fileList.append("/website/Documents/veille_techno.html") - - fd, tmppath = tempfile.mkstemp() - os.close(fd) - - try: - r = requests.get("https://shaarli.neodarz.net/?do=tagcloud") - data = r.text - soup = bs4.BeautifulSoup(data, 'lxml') - - htmly_website_page = "" - - if os.path.exists(BUILDDIR+"/website/Documents/veille_techno.html"): - sys.stderr.write("generating tagcloud\n") - - # Put in a list the pages where the menu will be written - #for root, dirs, files in os.walk(BUILDDIR+"/website/Documents/Situation2"): - # for name in files: - # if name.endswith(".html"): - # try: - # documents_fileList.append(os.path.join(root.split('build')[1], name)) - # except IndexError: - # documents_fileList.append(name) - - # Generate the string who contain the links of the menu - #htmly_website_page = "<ul>" - #for name in os.listdir(os.path.join(BUILDDIR, "website/Documents/Situation2")): - # htmly_website_page += "<a href='/website/Documents/Situation2/"+name+"' class='situation2lia'><li><span class='situation2left-lia'></span><span class='situation2center-lia'>"+name.split('.html')[0]+"</span><span class='situation2right-lia'></span></li></a>" - #htmly_website_page += "</ul>" - - #Writing the menu in all pages contained in the variable in place of the -- generate submenu here -- - for document_file in documents_fileList: - with open(tmppath, 'w', encoding='utf-8') as tmpfile: - if os.path.exists("build"+document_file): - with open("build"+document_file, 'r', encoding='utf-8') as indexmd: - lines = indexmd.readlines() - with open("build"+document_file, 'w', encoding='utf-8') as indexmd: - for line in lines: - indexmd.write(re.sub(r'-- generate tagcloud --', str(soup.find('div', {'id': 'cloudtag'})), line)) - #https://shaarli.neodarz.net/ - with open("build"+document_file, 'r', encoding='utf-8') as indexmd: - lines = indexmd.readlines() - with open("build"+document_file, 'w', encoding='utf-8') as indexmd: - for line in lines: - indexmd.write(re.sub(r'\?searchtags=', 'https://shaarli.neodarz.net/?searchtags=', line)) - - except Exception: - print("generating tagcloud... /!\ No internet connection ! => tagcloud not generated !") - - os.remove(tmppath) - def generate_blog_list(feed): """"Generate blog list """ @@ -1163,11 +982,7 @@ def generate_index_and_feed(): generate_index(feed) generate_menu() - #generate_submenu() - generate_situation1menu() - generate_situation2menu() generate_table() - generate_tagcloud() generate_blog_list(feed) generate_notes_list() rewrite_title() |