Browse Source

[fix] proper src/href url handling

Adam Tauber 11 years ago
parent
commit
a4f89a7981

+ 3 - 3
searx/templates/about.html

@@ -2,9 +2,9 @@
 {% block content %}
 {% include 'github_ribbon.html' %}
 <div class="row">
-    <h1>About <a href="/">searx</a></h1>
+    <h1>About <a href="{{ url_for('index') }}">searx</a></h1>
 
-    <p>Searx is a <a href="https://en.wikipedia.org/wiki/Metasearch_engine">metasearch engine</a>, aggregating the results of other <a href="/preferences">search engines</a> while not storing information about its users.
+    <p>Searx is a <a href="https://en.wikipedia.org/wiki/Metasearch_engine">metasearch engine</a>, aggregating the results of other <a href="{{ url_for('preferences') }}">search engines</a> while not storing information about its users.
     </p>
     <h2>Why use Searx?</h2>
     <ul>
@@ -60,7 +60,7 @@ Searx can be added to your browser's search bar; moreover, it can be set as the
 <p>See the <a href="https://github.com/asciimoo/searx/wiki/Installation">installation and setup</a> wiki page</p>
 
 <h3>How to debug engines?</h3>
-<p><a href="/stats">Stats page</a> contains some useful data about the engines used.</p>
+<p><a href="{{ url_for('stats') }}">Stats page</a> contains some useful data about the engines used.</p>
 
 </div>
 {% endblock %}

+ 3 - 3
searx/templates/base.html

@@ -6,19 +6,19 @@
     <meta name="keywords" content="searx, search, search engine, metasearch, meta search" />
     <meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=1" />
     <title>{% block title %}{% endblock %}searx</title>
-    <link rel="stylesheet" href="/static/css/style.css" type="text/css" media="screen" />
+    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" media="screen" />
     <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}?v=2" />
     {% block styles %}
     {% endblock %}
     {% block head %}
-    <link title="searx" type="application/opensearchdescription+xml" rel="search" href="/opensearch.xml"/>
+    <link title="searx" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/>
     {% endblock %}
 </head>
 <body>
 <div id="container">
 {% block content %}
 {% endblock %}
-<script src="/static/js/searx.js" ></script>
+<script src="{{ url_for('static', filename='js/searx.js') }}" ></script>
 </div>
 </body>
 </html>

+ 1 - 1
searx/templates/github_ribbon.html

@@ -1,3 +1,3 @@
 <a href="https://github.com/asciimoo/searx" class="github">
-    <img style="position: absolute; top: 0; right: 0; border: 0;" src="/static/img/github_ribbon.png" alt="Fork me on GitHub"  class="github"/>
+    <img style="position: absolute; top: 0; right: 0; border: 0;" src="{{ url_for('static', filename='img/github_ribbon.png') }}" alt="Fork me on GitHub"  class="github"/>
 </a>

+ 2 - 2
searx/templates/index.html

@@ -4,8 +4,8 @@
     <div class="title"><h1>searx</h1></div>
     {% include 'search.html' %}
     <p class="top_margin">
-        <a href="/about" class="hmarg">{{ _('about') }}</a>
-        <a href="/preferences" class="hmarg">{{ _('preferences') }}</a>
+        <a href="{{ url_for('about') }}" class="hmarg">{{ _('about') }}</a>
+        <a href="{{ url_for('preferences') }}" class="hmarg">{{ _('preferences') }}</a>
     </p>
 </div>
 {% endblock %}

+ 2 - 2
searx/templates/preferences.html

@@ -4,7 +4,7 @@
 <div class="row">
     <h2>{{ _('Preferences') }}</h2>
 
-    <form method="post" action="/preferences" id="search_form">
+    <form method="post" action="{{ url_for('preferences') }}" id="search_form">
     <fieldset>
         <legend>{{ _('Default categories') }}</legend>
         <p>
@@ -66,6 +66,6 @@
 
     <input type="submit" value="{{ _('save') }}" />
     </form>
-    <div class="right"><a href="/">{{ _('back') }}</a></div>
+    <div class="right"><a href="{{ url_for('index') }}">{{ _('back') }}</a></div>
 </div>
 {% endblock %}

+ 6 - 6
searx/templates/results.html

@@ -1,7 +1,7 @@
 {% extends "base.html" %}
 {% block title %}{{ q }} - {% endblock %}
 {% block content %}
-<div class="right"><a href="/preferences" id="preferences"><span>preferences</span></a></div>
+<div class="right"><a href="{{ url_for('preferences') }}" id="preferences"><span>preferences</span></a></div>
 <div class="small search">
     {% include 'search.html' %}
 </div>
@@ -10,8 +10,8 @@
         {% if suggestions %}
         <div id="suggestions"><span>{{ _('Suggestions') }}</span>
             {% for suggestion in suggestions %}
-            <form method="post" action="/">
-                <input type="hidden" name="q" value="{{suggestion}}">
+            <form method="post" action="{{ url_for('index') }}">
+                <input type="hidden" name="q" value="{{ suggestion }}">
                 <input type="submit" value="{{ suggestion }}" />
             </form>
             {% endfor %}
@@ -25,7 +25,7 @@
         <div id="apis">
         {{ _('Download results') }}
         {% for output_type in ('csv', 'json', 'rss') %}
-        <form method="post" action="/">
+        <form method="post" action="{{ url_for('index') }}">
             <div class="left">
             <input type="hidden" name="q" value="{{ q }}" />
             <input type="hidden" name="format" value="{{ output_type }}" />
@@ -52,7 +52,7 @@
     {% if paging %}
     <div id="pagination">
         {% if pageno > 1 %}
-            <form method="post" action="/">
+            <form method="post" action="{{ url_for('index') }}">
                 <div class="left">
                 <input type="hidden" name="q" value="{{ q }}" />
                 {% for category in selected_categories %}
@@ -63,7 +63,7 @@
                 </div>
             </form>
         {% endif %}
-        <form method="post" action="/">
+        <form method="post" action="{{ url_for('index') }}">
             <div class="left">
             {% for category in selected_categories %}
             <input type="hidden" name="category_{{ category }}" value="1"/>

+ 1 - 1
searx/templates/search.html

@@ -1,4 +1,4 @@
-<form method="post" action="/" id="search_form">
+<form method="post" action="{{ url_for('index') }}" id="search_form">
   <div id="search_wrapper">
     <input type="text" id="q" class="q" name="q" tabindex="1" autocomplete="off" {% if q %}value="{{ q }}"{% endif %}/>
     <input type="submit" value="search" id="search_submit" />