Giter VIP home page Giter VIP logo

finalproject-ag3's People

Contributors

mdecourse avatar pyslvs avatar s40723120 avatar s40723145 avatar s40723147 avatar s40723150 avatar

Watchers

 avatar  avatar

finalproject-ag3's Issues

tipuesearch 重點

載入 javascript

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>"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.