Browse Source

ascii

revision
Cailean Finn 1 month ago
parent
commit
06d8686eb8
  1. 32
      app.py
  2. 79
      static/assets/styles.css
  3. 8
      templates/index.html

32
app.py

@ -34,10 +34,10 @@ class WikiApp(Flask):
data = response.json() data = response.json()
# Extract page title and content # Extract page title and content
page_content = data['parse']['text']['*'] page_content = data['parse']['text']['*']
page_content = self.fix_html(page_content) page_content, table = self.fix_html(page_content)
homepage_content += page_content homepage_content += page_content
print(table)
return render_template('index.html', title=pages[0], cont=homepage_content) return render_template('index.html', title=pages[0], cont=homepage_content, table=table)
def data_int(self): def data_int(self):
return render_template('data.html') return render_template('data.html')
@ -313,8 +313,9 @@ class WikiApp(Flask):
# Extract page title and content # Extract page title and content
page_title = data['parse']['title'] page_title = data['parse']['title']
page_content = data['parse']['text']['*'] page_content = data['parse']['text']['*']
page_content = self.fix_html(page_content) page_content, table = self.fix_html(page_content)
return render_template('index.html', title=page_title, cont=page_content) print(table)
return render_template('index.html', title=page_title, cont=page_content, table=table)
def fetch_page(self, title): def fetch_page(self, title):
@ -364,7 +365,7 @@ class WikiApp(Flask):
for link in links: for link in links:
# Add _blank to href # Add _blank to href
link['target'] = '_blank' link['target'] = '_blank'
link.string = link.string.strip() + "" link.string = link.string.strip()
# Find all a tags with href containing 'index.php' # Find all a tags with href containing 'index.php'
links = soup.find_all('a', href=lambda href: href and 'index.php' in href) links = soup.find_all('a', href=lambda href: href and 'index.php' in href)
@ -409,13 +410,30 @@ class WikiApp(Flask):
table_html = str(table) if table else None # Store the table HTML table_html = str(table) if table else None # Store the table HTML
has_content = False
# Check if the table has meaningful rows
if table:
rows = table.find_all('tr')
has_content = False # Assume no meaningful content
for row in rows:
cells = row.find_all(['td', 'th'])
# Check if any cell has non-empty text
if any(cell.get_text(strip=True) for cell in cells):
has_content = True
break
if has_content is False:
table_html = None
# Remove the table from the main HTML # Remove the table from the main HTML
if table: if table:
table.decompose() table.decompose()
# Return the modified HTML # Return the modified HTML
return soup.prettify() return soup.prettify(), table_html
def remove_thumbnail_img(self, soup): def remove_thumbnail_img(self, soup):
thumbnail = soup.find_all(attrs={"typeof": "mw:File/Thumb"}) thumbnail = soup.find_all(attrs={"typeof": "mw:File/Thumb"})

79
static/assets/styles.css

@ -24,6 +24,19 @@ body {
overflow: hidden; overflow: hidden;
} }
* {
margin:0;
padding:0;
border:0;
font-family: "Inter", serif;
-webkit-text-size-adjust:none;
}
a {
text-decoration: none;
color:black;
}
#main-container { #main-container {
height: 100%; height: 100%;
width: 100%; width: 100%;
@ -88,6 +101,11 @@ body {
overflow-x: hidden; overflow-x: hidden;
} }
#content-container a{
text-decoration: underline;
color:blue;
}
#content-title { #content-title {
text-decoration: underline; text-decoration: underline;
} }
@ -98,12 +116,44 @@ body {
gap: 20px; gap: 20px;
} }
#content-body img{
width: 100%;
height: auto;
object-fit: contain;
-webkit-filter: grayscale(100%); /* Safari 6.0 - 9.0 */
filter: grayscale(100%) contrast(1.75);
}
#wiki-box {
border-style: dashed;
}
#line-divider { #line-divider {
width: 2px; /* Thickness of the divider */ width: 2px; /* Thickness of the divider */
background-color: black; /* Color of the line */ background-color: black; /* Color of the line */
} }
/*
table
*/
table {
display: table;
border-collapse: separate;
box-sizing: border-box;
text-indent: initial;
unicode-bidi: isolate;
border-spacing: 20px;
border-color: gray;
border-radius: 30px;
font-size: 16px;
}
th {
text-transform: uppercase;
}
/* /*
classes classes
*/ */
@ -155,3 +205,32 @@ p {
font-size: 12px; font-size: 12px;
font-weight: bold; font-weight: bold;
} }
/* headers */
h4 {
font-size: 24px;
margin: 0;
color: black;
}
h3 {
font-size: 26px;
margin: 0;
color: black;
}
h2 {
font-size: 28px;
margin: 0;
color: black;
}
h1 {
font-size: 30px;
margin: 0;
color: black;
}
hr {
border-top: 1px solid black;
}

8
templates/index.html

@ -5,7 +5,7 @@
{% block content %} {% block content %}
<div id="main-container"> <div id="main-container">
<div id="index-container" class="disable-scrollbar"> <div id="index-container" class="disable-scrollbar">
<div id="index-header"> <a href="/"><div id="index-header">
<div class="ascii"> <div class="ascii">
.g8"""bgd .g8""8q. `7MN. `7MF' .g8"""bgd `7MM"""YMM `7MM"""Mq. MMP""MM""YMM .g8"""bgd .g8""8q. `7MN. `7MF' .g8"""bgd `7MM"""YMM `7MM"""Mq. MMP""MM""YMM
.dP' `M .dP' `YM. MMN. M .dP' `M MM `7 MM `MM.P' MM `7 .dP' `M .dP' `YM. MMN. M .dP' `M MM `7 MM `MM.P' MM `7
@ -23,7 +23,7 @@ MM. MM. ,MP M `MM.M MM. MM Y , MM MM
M YMM YM. ,M MM ,M MM ,M M YMM YM. ,M MM ,M MM ,M
.JML. YM `bmmmmd"' .JMMmmmmMMM .JMMmmmmMMM </div> .JML. YM `bmmmmd"' .JMMmmmmMMM .JMMmmmmMMM </div>
<div class="astr-line">&#x2732; &#x2732; &#x2732;</div> <div class="astr-line">&#x2732; &#x2732; &#x2732;</div>
</div> </div></a>
<div id="index-content"> <div id="index-content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat dignissim justo, posuere imperdiet justo condimentum at. Sed eget odio vitae velit efficitur facilisis lacinia eget libero. Donec ex magna, laoreet id hendrerit at, varius et sem. Phasellus tempor ante in felis vehicula, vitae rhoncus tellus posuere. Ut nec sodales urna. Sed molestie lectus vel dolor maximus, sed cursus urna mattis. Cras eu mauris sit amet mauris lacinia accumsan vitae eu arcu. Duis quis mollis mauris. Maecenas condimentum ac tortor vel sodales. Fusce eget erat ut odio interdum porta. Donec placerat nisl id dui dapibus, finibus volutpat massa placerat. Donec commodo pellentesque ipsum eget ullamcorper. Praesent fermentum sit amet turpis sit amet sagittis. Aliquam tempus, sapien eget tincidunt luctus, urna felis molestie dolor, ac blandit arcu erat vitae eros. Morbi a lacus laoreet, varius eros ut, rutrum nibh.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat dignissim justo, posuere imperdiet justo condimentum at. Sed eget odio vitae velit efficitur facilisis lacinia eget libero. Donec ex magna, laoreet id hendrerit at, varius et sem. Phasellus tempor ante in felis vehicula, vitae rhoncus tellus posuere. Ut nec sodales urna. Sed molestie lectus vel dolor maximus, sed cursus urna mattis. Cras eu mauris sit amet mauris lacinia accumsan vitae eu arcu. Duis quis mollis mauris. Maecenas condimentum ac tortor vel sodales. Fusce eget erat ut odio interdum porta. Donec placerat nisl id dui dapibus, finibus volutpat massa placerat. Donec commodo pellentesque ipsum eget ullamcorper. Praesent fermentum sit amet turpis sit amet sagittis. Aliquam tempus, sapien eget tincidunt luctus, urna felis molestie dolor, ac blandit arcu erat vitae eros. Morbi a lacus laoreet, varius eros ut, rutrum nibh.</p>
@ -46,9 +46,11 @@ MM. MM. ,MP M `MM.M MM. MM Y , MM MM
</div> </div>
<div class="title astr-line">&#x2732; &#x2732; &#x2732;</div> <div class="title astr-line">&#x2732; &#x2732; &#x2732;</div>
<div id="content-metadata"> <div id="content-metadata">
{%if table != None %}
<div id="wiki-box"> <div id="wiki-box">
{{ table | safe }}
</div> </div>
{%endif%}
</div> </div>
</div> </div>

Loading…
Cancel
Save