8000 feat(clean url): support clean URL for search page · Pelican-Elegant/elegant@088791e · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 088791e

Browse files
committed
feat(clean url): support clean URL for search page
1 parent a837c28 commit 088791e

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

documentation/content/Advanced Features/clean-url.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,11 @@ For pages, set
5151
PAGE_URL = "{slug}"
5252
PAGE_SAVE_AS = "{slug}.html"
5353
```
54+
55+
## Search
56+
57+
For search page, set
58+
59+
```python
60+
SEARCH_URL = "search"
61+
```

documentation/pelicanconf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
TAGS_URL = "tags"
5959
CATEGORIES_URL = "categories"
6060
ARCHIVES_URL = "archives"
61+
SEARCH_URL = "search"
6162

6263
# Feeds
6364
AUTHOR_FEED_ATOM = None

templates/404.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ <h1>That page doesn't exist!</h1>
2020
<p>Sorry, but the page you are looking for cannot be found. It seems that the page you were trying to reach doesn't exist, or may be it has just moved, or it no longer exists.</p>
2121
<p>The best thing to do is to use the search form or start again from the <a href="{{ SITEURL }}">home page</a>.</p>
2222
<div class="input-append">
23-
<form action="{{ SITEURL }}/search.html" onsubmit="return validateForm(this.elements['q'].value)">
23+
{% from '_includes/_defaults.html' import SEARCH_URL with context %}
24+
<form action="{{ SITEURL }}/{{ SEARCH_URL }}" onsubmit="return validateForm(this.elements['q'].value)">
2425
<input type="text" class="span12" placeholder="Search" name="q" id="tipue_search_input_404">
2526
<button class="btn" type="submit">Search</button>
2627
</form>

templates/_includes/_defaults.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,9 @@
194194
{% else %}
195195
{% set ARCHIVES_URL = ARCHIVES_URL %}
196196
{% endif %}
197+
198+
{%if not SEARCH_URL %}
199+
{% set SEARCH_URL = 'search.html' %}
200+
{% else %}
201+
{% set SEARCH_URL = SEARCH_URL %}
202+
{% endif %}

templates/base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@
7878
<li {% if p == page %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ p.url }}">{{ p.title }}</a></li>
7979
{% endfor %}
8080
{% endif %}
81-
{% from '_includes/_defaults.html' import TAGS_URL, CATEGORIES_URL, ARCHIVES_URL with context %}
81+
{% from '_includes/_defaults.html' import TAGS_URL, CATEGORIES_URL, ARCHIVES_URL, SEARCH_URL with context %}
8282
<li {% if page_name == 'categories' %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ CATEGORIES_URL }}">Categories</a></li>
8383
<li {% if page_name == 'tags' %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ TAGS_URL }}">Tags</a></li>
8484
<li {% if page_name == 'archives' %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ ARCHIVES_URL }}">Archives</a></li>
85-
<li><form class="navbar-search" action="{{ SITEURL }}/search.html" onsubmit="return validateForm(this.elements['q'].value);"> <input type="text" class="search-query" placeholder="Search" name="q" id="tipue_search_input"></form></li>
85+
<li><form class="navbar-search" action="{{ SITEURL }}/{{ SEARCH_URL }}" onsubmit="return validateForm(this.elements['q'].value);"> <input type="text" class="search-query" placeholder="Search" name="q" id="tipue_search_input"></form></li>
8686
</ul>
8787
</div>
8888
</div>

templates/search.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
{% block meta_tags_in_head %}
1212
{{ super() }}
13+
{% from '_includes/_defaults.html' import FEATURED_IMAGE, SEARCH_URL with context %}
1314
<meta property="og:title" content="Search · {{ SITENAME|striptags|e }}"/>
1415
<meta name="twitter:title" content="Search · {{ SITENAME|striptags|e }}">
15-
<meta property="og:url" content="{{ SITEURL }}/search.html" />
16+
<meta property="og:url" content="{{ SITEURL }}/{{ SEARCH_URL }}" />
1617
<meta property="og:description" content="Search results for {{ SITENAME|striptags|e }} blog" />
1718
<meta name="twitter:description" content="Search results for {{ SITENAME|striptags|e }} blog">
1819
<meta property="og:site_name" content="{{ SITENAME|striptags|e }}" />
1920
<meta property="og:article:author" content="{{ AUTHOR }}" />
20-
{% from '_includes/_defaults.html' import FEATURED_IMAGE with context %}
2121
{% if FEATURED_IMAGE %}
2222
<meta property="og:image" content="{{FEATURED_IMAGE}}" />
2323
<meta name="twitter:image" content="{{FEATURED_IMAGE}}" >

0 commit comments

Comments
 (0)
0