squash merge gallery-tweak
This commit is contained in:
parent
c8d8673037
commit
c787cf3ac8
31
microblog.py
31
microblog.py
@ -35,13 +35,21 @@ def make_gallery(i, w):
|
||||
|
||||
# apply basic HTML formatting - only div class here is gallery
|
||||
from html import escape
|
||||
def markup(msg):
|
||||
# iterate through posts and get information about them
|
||||
def get_posts(filename, email):
|
||||
class Post:
|
||||
def __init__(self, ts, msg):
|
||||
self.timestamp = ts # string
|
||||
self.message = msg # list
|
||||
def markup(self):
|
||||
result = 0
|
||||
tagged = ""
|
||||
words = msg.split()
|
||||
# support multiple images (gallery style)
|
||||
images = [] # list of integers
|
||||
tags = [] # list of strings
|
||||
output = []
|
||||
for line in self.message:
|
||||
images = [] # list of integers
|
||||
words = line.split()
|
||||
for i in range(len(words)):
|
||||
word = words[i]
|
||||
# don't help people click http
|
||||
@ -63,18 +71,11 @@ def markup(msg):
|
||||
words[i] = new_word
|
||||
elif word.find(".jpg") != -1 or word.find(".png") != -1:
|
||||
images.append(i)
|
||||
# are .gifs and other media files too much bloat?
|
||||
if len(images) > 0:
|
||||
gallery = make_gallery(images, words)
|
||||
words += gallery
|
||||
return " ".join(words), tags
|
||||
|
||||
# iterate through posts and get information about them
|
||||
def get_posts(filename, email):
|
||||
class Post:
|
||||
def __init__(self, ts, msg):
|
||||
self.timestamp = ts # string
|
||||
self.message = msg # list
|
||||
pass
|
||||
output.append(" ".join(words))
|
||||
return "<br>".join(output), tags
|
||||
|
||||
def parse_txt(filename):
|
||||
content = []
|
||||
@ -98,7 +99,7 @@ def get_posts(filename, email):
|
||||
if len(line) > 1:
|
||||
message.append(line)
|
||||
else:
|
||||
p = Post(timestamp, "<br>".join(message))
|
||||
p = Post(timestamp, message)
|
||||
posts.append(p)
|
||||
# reset
|
||||
message = []
|
||||
@ -114,7 +115,7 @@ def get_posts(filename, email):
|
||||
index = count # - 1
|
||||
timeline = []
|
||||
for post in posts:
|
||||
markedup, tags = markup(post.message)
|
||||
markedup, tags = post.markup()
|
||||
count -= 1
|
||||
index -= 1
|
||||
timeline.append(
|
||||
|
Loading…
x
Reference in New Issue
Block a user