浏览代码

adding random search function for 'active' page

main
Simon Bowie 2 年前
父节点
当前提交
3d8d92d1e1
共有 4 个文件被更改,包括 87 次插入2 次删除
  1. +16
    -1
      web/app/hidden.py
  2. +69
    -0
      web/app/templates/theme.html
  3. +1
    -1
      web/content/TOC.md
  4. +1
    -0
      web/content/section_3/active.md

+ 16
- 1
web/app/hidden.py 查看文件

@@ -6,6 +6,7 @@
# @acknowledgements:

from flask import Blueprint, render_template
from . import solr
import markdown

hidden = Blueprint('hidden', __name__)
@@ -18,4 +19,18 @@ def index():
# route for active theme page
@hidden.route('/hidden/active/')
def active():
return render_template('index.html')
with open('content/section_3/active.md', 'r') as f:
text = f.read()
text = markdown.markdown(text)

core = 'active'
results_list = []
i = 0
while i <= 9:
search_results = solr.random_search(core)
results = search_results[0]
for result in results:
results_list.append(result)
i += 1

return render_template('theme.html', text=text, results=results_list)

+ 69
- 0
web/app/templates/theme.html 查看文件

@@ -0,0 +1,69 @@
{% extends "base.html" %}

{% block content %}

{{ text|safe }}

<hr>

{% if results == 'no results found' %}

{{ results }}

{% else %}

{% for result in results %}

<p class="h1">

Year:

{{ result['year'] }}

</p>

{% if result['title'] is defined %}
<p class="mb-2 mt-5">
<span class="emphasis">Title:</span>
<span class="result-entry">
{{ result['title'] }}
</span>
</p>
{% endif %}

{% if result['country'] is defined %}
<p class="mb-2">
<span class="emphasis">Country:</span>
{% if result['country'].name is defined %}
{{ result['country'].name }} {{ result['country'].flag }}
{% else %}
{{ result['country'] }}
{% endif %}
</p>
{% endif %}

{% if result['abstract'] is defined %}
<p class="mb-2">
<span class="emphasis">Abstract:</span>
<span class="result-entry">
{{ result['abstract'] }}
</span>
</p>
{% endif %}

<div class="mt-2 mb-5 search-links">
<p>
<span class="emphasis">European Patent Office PDF:</span>
<a href="{{ url_for('search.id_search', id=result['id'], core='all') }}">
<span class="result-entry">
{{ result['application_id'] }}
</span>
</a>
</p>
</div>

{% endfor %}

{% endif %}

{% endblock %}

+ 1
- 1
web/content/TOC.md 查看文件

@@ -54,7 +54,7 @@
- [Expanding citizens](hidden/#expanding "links to hidden section expanding citizens")
- [Secret citizens](hidden/#secret "links to hidden section secret")
- [Pissing & leaking citizens](hidden/#pissing "links to hidden section pissing & leaking citizens")
- [Active citizens](hidden/#active "links to hidden section active citizens")
- [Active citizens](/hidden/active)
- [In/visible citizens](hidden/#visible "links to hidden section in/visible citizens")
- [Multispecies citizens](hidden/#multispecies "links to hidden section multispecies citizens")
- [Working citizens](hidden/#working "links to hidden section working citizens")

+ 1
- 0
web/content/section_3/active.md 查看文件

@@ -0,0 +1 @@
test text

正在加载...
取消
保存