-
Notifications
You must be signed in to change notification settings - Fork 2
/
htmlTemp.py
executable file
·147 lines (114 loc) · 4.45 KB
/
htmlTemp.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
import datetime
import jinja2
#!/usr/bin/python
# -*- coding: utf-8 -*-
# freeseer - vga/presentation capture software
#
# Copyright (C) 2013 Free and Open Source Software Learning Centre
# http://fosslc.org
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# For support, questions, suggestions or any other inquiries, visit:
# http://wiki.github.com/fosslc/freeseer/
# NOTE: in this template there is no data relating to specific posts.
# There are only references to data structures passed in from your main code
page_template = jinja2.Template('''
<div align="center">
{% block blog_posts %}
<!-- links/targets for the side menu to jump to a post -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WebUI HomePage</title>
<link rel="stylesheet" href="template.css" type="text/css" />
</head>
<body>
<h1>Welcome to Freeseer online portal</h1>
{% for post in posts1 %}
<li><a href="{{ post.url }}">{{post.title}}-{{post.content}}
</a></li>
<iframe src="{{post.url}}" width="500" height="200" style="float:left"></iframe>
{% endfor %}
{% for post in posts2 %}
<li><a href="{{ post.url }}">{{post.title}}-{{post.content}}
</a></li>
<iframe src="{{post.url}}" width="500" height="200" style="float:right"></iframe>
{% endfor %}
{% for post in posts3 %}
<li><a href="{{ post.url }}">{{post.title}}-{{post.content}}
</a></li>
<iframe src="{{post.url}}" width="500" height="200" style="float:center"></iframe>
{% endfor %}
{% endblock %}
</div>
{% block content %}
<div id="post">
<h1>{{ current.title }}</h1>
<h2>{{ current.date }}</h2>
<p>{{ current.content }}</p>
</div>
<div id="postB">
<h1>{{ current.title }}</h1>
<h2>{{ current.date }}</h2>
<p>{{ current.content }}</p>
</div>
<div id="postC">
<h1>{{ current.title }}</h1>
<h2>{{ current.date }}</h2>
<p>{{ current.content }}</p>
</div>
{% endblock %}
</body>
''')
# NOTE your main code would create a data structure such as this
# list of dictionaries ready to pass in to your template
now=datetime.date.today()
post_1 = [
{ 'url' : 'http://www.icecast.org/',
'title' : 'Icecast',
'date' : now,
'content' : 'This is the icecast streaming channel'}
]
post_2=[ { 'url' : 'http://www.irc.org/',
'title' : 'IRC channel',
'date' : now,
'content' : 'This is the IRC channel'}
]
post_3=[{'url': 'http://etherpad.org/',
'title':'Etherpad',
'date':now,
'content':'Etherpad is an online editor'}
]
# Pass in a full list of posts and a variable containing the last
# post in the list, assumed to be the most recent.
s=page_template.render(posts1 = post_1, post2=post_2, post3=post_3, current=post_2[0]
)
with open("httpTemplate.html","w") as html_file:
html_file.write(s)
f2=open("httpTemplate.html","r+")
m=f2.read()
#print m
# pass the event with url data and location to store the resulting html file
# apply html template and store it to file
#def createHTMLFile(event, fileLocation):
# eventPost = event.getHtmlFormat()
# s=page_template.render(posts = eventPost,
# current = eventPost[0])
# with open(fileLocation,"w") as html_file:
# html_file.write(s)
#
#
#
# f2=open("httpTemplate.html","r+")
# m=f2.read()
# print m