Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
[enh] archive.today option for results page (#3308)
Browse files Browse the repository at this point in the history
Adds an option to the oscar theme that puts an archive.today link next to the web.archive.org cache link. In preferences change 'Show archive.today links' to 'On'
  • Loading branch information
bencollerson committed Jul 31, 2022
1 parent 78a87ca commit 465bbd4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions searx/preferences.py
Expand Up @@ -354,6 +354,16 @@ def __init__(self, themes, categories, engines, plugins):
'True': True
}
),
'archive_today': MapSetting(
settings['ui'].get('archive_today', True),
is_locked('archive_today'),
map={
'0': False,
'1': True,
'False': False,
'True': True
}
),
'image_proxy': MapSetting(
settings['server'].get('image_proxy', False),
is_locked('image_proxy'),
Expand Down
1 change: 1 addition & 0 deletions searx/settings.yml
Expand Up @@ -38,6 +38,7 @@ server:

ui:
autofocus : True # Autofocus search input
archive_today : False # show archive.today links
static_path : "" # Custom static path - leave it blank if you didn't change
templates_path : "" # Custom templates path - leave it blank if you didn't change
default_theme : oscar # ui theme
Expand Down
6 changes: 6 additions & 0 deletions searx/templates/oscar/macros.html
Expand Up @@ -36,6 +36,9 @@ <h4 class="result_header" id="result-{{id}}">{% if result.engine~".png" in favic
<small>{{ result_link(result.cached_url, icon('link') + _('cached'), "text-info", id) }}</small>
{%- elif not result.is_onion -%}
<small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
{% if archive_today %}
<small>{{ result_link("https://archive.today/" + result.url, icon('link') + _('archive'), "text-info", id) }}</small>
{% endif %}
{%- endif -%}
{%- endif -%}
{%- if proxify -%}
Expand Down Expand Up @@ -72,6 +75,9 @@ <h4 class="result_header" id="result-{{id}}">{% if result.engine~".png" in favic
<small>{{ result_link(result.cached_url, icon('link') + _('cached'), "text-info", id) }}</small>
{%- elif not result.is_onion -%}
<small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
{% if archive_today %}
<small>{{ result_link("https://archive.today/" + result.url, icon('link') + _('archive'), "text-info", id) }}</small>
{% endif %}
{%- endif -%}
{%- endif -%}
{%- if proxify -%}
Expand Down
11 changes: 11 additions & 0 deletions searx/templates/oscar/preferences.html
Expand Up @@ -161,6 +161,17 @@ <h3>{{ _('General') }}</h3>
{{ preferences_item_footer(info, label, rtl) }}
{% endif %}

{% if 'archive_today' not in locked_preferences %}
{% set label = _('Show archive.today links') %}
{% set info = _('Alternative link cache service') %}
{{ preferences_item_header(info, label, rtl, 'archive_today') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="archive_today" id="archive_today">
<option value="1" {% if archive_today %}selected="selected"{% endif %}>{{ _('On') }}</option>
<option value="0" {% if not archive_today %}selected="selected"{% endif %}>{{ _('Off')}}</option>
</select>
{{ preferences_item_footer(info, label, rtl) }}
{% endif %}

{% set label = _('Show advanced settings') %}
{% set info = _('Show advanced settings panel in the home page by default') %}
{{ preferences_item_header(info, label, rtl, 'advanced_search') }}
Expand Down
2 changes: 2 additions & 0 deletions searx/webapp.py
Expand Up @@ -389,6 +389,8 @@ def render(template_name, override_theme=None, **kwargs):

kwargs['autofocus'] = request.preferences.get_value('autofocus')

kwargs['archive_today'] = request.preferences.get_value('archive_today')

kwargs['safesearch'] = str(request.preferences.get_value('safesearch'))

kwargs['language_codes'] = languages
Expand Down

0 comments on commit 465bbd4

Please sign in to comment.