blob: cdff3b30d16c99223fc5b20e9c02b47d8332665c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/usr/bin/env python
#script creates searchable website for different operation manuals
import os
folder = "manuals"
header = """
<head>
<title>collection of different operation manuals and data sheets</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="static/style.css">
</head>"""
middlepart = """"""
footer = """
<script src="static/list.js"></script>
<script src="static/script.js"></script>"""
middlepart += """
<div id="the-list">
<div class='header'>
<h1 class='head'>Operation manuals and data sheets</h1>
<h4>managed by <a href='http://joak.nospace.at'>JoaK</a> and others! If you have an old/new operation manual or a rare/unusual data sheet, please send it to me(joak(((((a)))))nospace.at)!</h4>
<input class="search" placeholder="Search" />
</div>
<ul class="list">"""
for file in os.listdir(folder):
if file.endswith(".txt"):
filename = file
text = open(folder+"/"+filename, 'r')
title = ""
filename = ""
tags = []
description = ""
for line in text:
line = line.replace('\n','')
if "Title:" in line:
title = line.replace("Title: ", "")
if "File:" in line:
filename = line.replace("File: ", "")
if "Tags:" in line:
tags = line.replace("Tags: ", "")
if "Description:" in line:
description = line.replace("Description: ", "")
if not os.path.isfile(folder+"/"+filename.replace("pdf", "jpg")):
os.system("convert -density 144 -background white -alpha remove "+folder+"/"+filename+"[0] -resize x300 "+folder+"/"+filename.replace("pdf","")+"jpg")
middlepart +="""
<li id='"""+title+"""'>
<h3 class="title">"""+title+"""</h3>
<a href='"""+folder+"""/"""+filename+"""'><img src='"""+folder+"""/"""+filename.replace("pdf","jpg")+"""'></a>
<span><a href='"""+folder+"""/"""+filename+"""'>pdf-link</a></span><span class="anchorlink"><a href='#"""+title+"""'>anchor-link</a></span>
<p class="description">"""+description+"""</p>
<div class="tags"><span>Tags: </span><marquee behavior="scroll" direction="left">"""+tags+"""</marquee></div>
</li>"""
middlepart += """
</ul>
</div>"""
f = open('index.html', 'w')
f.write(header+middlepart+footer)
f.close()
|