Commit a7bed578 authored by Denis Salem's avatar Denis Salem
Browse files

done with linked list

parent 75ae2767
......@@ -120,7 +120,7 @@
DONE | add entry preview / full content.
DONE | Support for video.
DONE | Support for audio.
WIP | Optimise entries set with linked list.
DONE | Optimise entries access with linked list.
TODO | Fix: Import asset from external theme if necessary.
TODO | Allow disabling exportation of specific kind of thread.
TODO | Add more specific pattern to detect location (IfInCategories,IfInArchives,IfInFirstPage).
......
......@@ -65,7 +65,7 @@ class DataStore:
entry_index = 0
for filename in yield_entries_content():
if len(self.entries):
self.entries.append(Entry(filename, previous_entry=self.entries[-1]))
self.entries.append(Entry(filename, previous_entry = self.entries[-1]))
self.entries[-2].next_entry = self.entries[-1]
else:
......@@ -157,15 +157,6 @@ class DataStore:
self.requested_entry_index = entry
yield self.entries[entry]
def get_next_entry_id(self, entry_id):
index = [e.id for e in self.entries].index(entry_id) + 1
return self.entries[index].id
def get_previous_entry_id(self, entry_id):
index = [e.id for e in self.entries].index(entry_id) - 1
return self.entries[index].id
def get_entries(self, reverse=False):
self.requested_entry_index = 0 if not reverse else len(self.entries) - 1
......
......@@ -49,8 +49,8 @@ class Thread:
return string.format(**{
"destination_page":destination_page_number,
"destination_page_url":filename,
"entry_name" : self.entry_name,
"entry_id": self.entry_id
"entry_name" : self.current_entry.title,
"entry_id": self.current_entry.id
})
......@@ -76,7 +76,8 @@ class Thread:
def get_next_page(self,argv=list()):
if self.current_page < len(self.pages) - 1:
destination_page_number = str(self.current_page + 1)
filename = self.filename.format(**{"page_number":destination_page_number,"entry_id":self.datastore.get_next_entry_id(self.entry_id)})
next_entry_id = self.current_entry.next_entry.id
filename = self.filename.format(**{"page_number":destination_page_number,"entry_id":next_entry_id})
return self.return_page_around(argv[0], destination_page_number, filename)
else:
......@@ -86,11 +87,16 @@ class Thread:
def get_previous_page(self, argv=list()):
if self.current_page > 0:
destination_page_number = str(self.current_page - 1)
try:
previous_entry_id = self.current_entry.previous_entry.id
except:
previous_entry_id = -1
if self.current_page == 1:
filename = self.filename.format(**{"page_number":"","entry_id": self.datastore.get_previous_entry_id(self.entry_id)})
filename = self.filename.format(**{"page_number" : "", "entry_id" : previous_entry_id})
else:
filename = self.filename.format(**{"page_number":destination_page_number,"entry_id":self.datastore.get_previous_entry_id(self.entry_id)})
filename = self.filename.format(**{"page_number" : destination_page_number, "entry_id" : previous_entry_id})
return self.return_page_around(argv[0], destination_page_number, filename)
......@@ -155,8 +161,7 @@ class Thread:
columns_counter = 0
columns = [ '' for i in range(0, columns_number) ]
for entry in page:
self.entry_name = entry.title
self.entry_id = entry.id
self.current_entry = entry
columns[columns_counter] += ''.join(self.processor.batch_process(entry.html_wrapper.above, entry.filename).sub_strings)
if entry.html_wrapper.required_content_pattern == ".:GetEntryPreview:.":
columns[columns_counter] += ''.join(self.processor.batch_process(entry.preview, entry.filename,).sub_strings)
......
......@@ -27,7 +27,6 @@ class CategoriesThread(Thread):
super().__init__(prompt, datastore, theme, patterns)
self.filename = self.datastore.blog_configuration["path"]["index_file_name"]
self.entryname = str()
self.relative_origin = "../"
self.in_thread = True
self.export_path = "blog/"
......
......@@ -27,7 +27,6 @@ class DatesThread(Thread):
super().__init__(prompt, datastore, theme, patterns)
self.filename = self.datastore.blog_configuration["path"]["index_file_name"]
self.entry_name = str()
self.relative_origin = "../"
self.in_thread = True
......
......@@ -33,7 +33,6 @@ class EntriesThread(Thread):
])
self.filename = self.datastore.blog_configuration["path"]["entry_file_name"]
self.entry_name = str()
self.relative_origin = str()
self.export_path = "blog/"
self.in_thread = False
......
......@@ -30,7 +30,6 @@ class MainThread(Thread):
])
self.filename = self.datastore.blog_configuration["path"]["index_file_name"]
self.entry_name = str()
self.relative_origin = str()
self.export_path = "blog/"
self.in_thread = True
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment