mdecp2018 / finalproject-ag3 Goto Github PK
View Code? Open in Web Editor NEWfinalproject-ag3 created by GitHub Classroom
License: GNU Affero General Public License v3.0
finalproject-ag3 created by GitHub Classroom
License: GNU Affero General Public License v3.0
def set_css2()
<script src="tipuesearch_content.js"></script>
<script src="./../static/jquery.js"></script>
<link rel="stylesheet" href="./../static/tipuesearch/css/tipuesearch.css">
<script src="./../static/tipuesearch/tipuesearch_set.js"></script>
<script src="./../static/tipuesearch/tipuesearch.min.js"></script>
啟動 tipuesearch:
$(document).ready(function() {
$('#tipue_search_input').tipuesearch({
newWindow: true,
minimumLength: 2,
});
});
def render_menu2()
<div class="tipue_search_group">
<input style="width: 6vw;" type="text" name="q" id="tipue_search_input" pattern=".{3,}" title="Press enter key to search" required>
</div>
def generate_pages()
修改:
def get_page2(heading, head, edit)
為:
def get_page2(heading, head, edit, get_page_content = None)
擷取內容(page_content_list
):
if get_page_content is not None:
get_page_content.extend(page_content_list)
在 generate_pages
使用擷取的內容做為搜尋內容。寫成以下格式:
var tipuesearch = {"pages": [
{"title": "標題", "text": "文章內容", "tags": "標籤", "url": "跳轉位址"},
...
]};
文章內容轉純文字:
def visible(element):
if element.parent.name in ['style', 'script', '[document]', 'head', 'title']:
return False
elif re.match('<!--.*-->', str(element.encode('utf-8'))):
return False
return True
search_content = []
for i in range(len(newhead)):
...
soup = bs4.BeautifulSoup(" ".join(get_page_content), "lxml")
search_content.append({"title": newhead[i], "text": " ".join(filter(visible, soup.findAll(text=True))), "tags": "", "url": newhead[i] + ".html"})
...
存為 content/tipuesearch_content.js
。
with open(_curdir + "\\content\\tipuesearch_content.js", "w", encoding="utf-8") as f:
f.write("var tipuesearch = {\"pages\": " + str(search_content) + "};")
def get_page2()
將:
directory + "</nav><section>" + return_content + "</section></div></body></html>"
加上:
<div id="tipue_search_content">要覆蓋的文章內容</div>
所以改成:
directory + "</nav><section><div id=\"tipue_search_content\">" + return_content + "</div></section></div></body></html>"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.