-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLINKPAGE.py
178 lines (152 loc) · 4.16 KB
/
LINKPAGE.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#LINKPAGE
#Filip Rokita
#www.filiprokita.com
#writing/reading settings.py
while True:
print("\n")
print("CHOOSE")
print("1. Create new link page configuration")
print("2. Load configuration from settings.py")
choice = input("CHOICE: ")
if choice == "1":
#input site settings
author = input("AUTHOR: ")
description = input("DESCRIPTION: ")
fontcolor = input("FONT COLOR: ")
itembackgroundcolor = input("ITEM BACKGROUND COLOR: ")
backgroundcolor = input("BACKGROUND COLOR: ")
#write site settings
settings = open("settings.py", "w")
settingscontent = """author = """+'"'+author+'"'+"""
description = """+'"'+description+'"'+"""
fontcolor = """+'"'+fontcolor+'"'+"""
itembackgroundcolor = """+'"'+itembackgroundcolor+'"'+"""
backgroundcolor = """+'"'+backgroundcolor+'"'+""""""
settings.write(settingscontent)
settings.close()
break
elif choice == "2":
try:
from settings import *
break
except:
print("\n" * 100)
print("File settings.py does not exist! Try again.")
print("\n")
else:
print("\n" * 100)
print("This choice is not available! Try again.")
#writing/reading links.py
while True:
print("\n")
print("CHOOSE")
print("1. Create new links")
print("2. Load existing links from links.py")
choice = input("CHOICE: ")
if choice == "1":
while True:
numberoflinks = int(input("NUMBER OF LINKS: "))
if numberoflinks >= 1 and numberoflinks <=100:
linktitle = [None] * (numberoflinks + 1)
link = [None] * (numberoflinks + 1)
for i in range(1, numberoflinks + 1):
linktitle[i] = input("LINK TITLE "+str(i)+": ")
link[i] = input("LINK "+str(i)+": ")
int(i)
links = open("links.py", "w")
linkscontent = """linktitle = """+str(linktitle)+"""
link = """+str(link)+""""""
links.write(linkscontent)
links.close()
break
else:
print("\n" * 100)
print("Number of links must be between 1 and 100! Try again.")
print("\n")
break
elif choice == "2":
try:
from links import *
break
except:
print("\n" * 100)
print("File links.py does not exist! Try again.")
print("\n")
else:
print("\n" * 100)
print("This choice is not available! Try again.")
print("\n")
#formatting links for <div id="links">
divcontent = ""
for i in range(1, len(link)):
divcontent = divcontent + """
<div id="link">
<h2>"""+str(linktitle[i])+"""</h2>
<a href="""+'"'+str(link[i])+'"'+""" class="button"><b>CLICK</b></a>
</div>"""
divcontent = divcontent.strip()
#creating index.html
index = open("index.html", "w")
indexcontent = """<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>"""+author+" - LINKPAGE"+"""</title>
<meta name="description" content="""+'"'+description+'"'+"""/>
<meta name="keywords" content="""+'"'+author+", "+"linkpage"+", "+"links"+'"'+"""/>
<meta name="author" content="""+'"'+author+'"'+"""/>
<link rel="stylesheet" href="style.css"/>
<script src="script.js"></script>
</head>
<body>
<header>
<h1>"""+author+"""</h1>
<p>"""+description+"""</p>
</header>
<div id="content">
"""+divcontent+"""
</div>
</body>
</html>"""
index.write(indexcontent)
index.close()
#creating style.css
style=open("style.css", "w")
stylecontent = """body {
font-family: arial;
text-align: center;
background-color: """+backgroundcolor+""";
}
header {
margin: 50px;
padding: 30px;
font-size: 20px;
color: """+fontcolor+""";
background: """+itembackgroundcolor+""";
border-radius: 50px;
}
#link {
margin: 0px 100px 100px 100px;
}
h2 {
padding: 10px;
margin: 0px 20% 40px 20%;
color: """+fontcolor+""";
background-color: """+itembackgroundcolor+""";
border-radius: 50px;
}
.button {
padding: 10px 30px;
cursor: pointer;
color: """+fontcolor+""";
text-decoration: none;
background-color: """+itembackgroundcolor+""";
border-radius: 50px;
}"""
style.write(stylecontent)
style.close()
#creating script.js
script = open("script.js", "w")
scriptcontent = """"""
script.write(scriptcontent)
script.close()