Commit e8933105 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '449-einmalige-eigene-suche-ohne-ausgewahlte-suchmaschinen' into 'development'

Resolve "Einmalige eigene Suche ohne ausgewählte Suchmaschinen"

Closes #449

See merge request !806
parents 2c2f0d97 7a745b1d
......@@ -36,26 +36,23 @@ class StartpageController extends Controller
}
}
$maps = $request->input('param_maps', 'on');
$agent = new Agent();
$browser = $agent->browser();
return view('index')
->with('title', trans('titles.index'))
->with('homeIcon')
->with('focusPages', $focusPages)
->with('browser', (new Agent())->browser())
->with('navbarFocus', 'suche')
->with('theme', $theme)
->with('autocomplete', $request->input('param_autocomplete', 'on'))
->with('foki', $this->loadFoki())
->with('focus', $request->input('focus', 'web'))
->with('lang', $request->input('param_lang', 'all'))
->with('resultCount', $request->input('param_resultCount', '20'))
->with('time', $request->input('param_time', '1000'))
->with('sprueche', $request->input('param_sprueche', 'off'))
->with('newtab', $request->input('param_newtab', 'on'))
->with('focusPages', $focusPages)
->with('browser', $browser)
->with('navbarFocus', 'suche')
->with('theme', $theme)
->with('maps', $maps)
->with('autocomplete', $request->input('param_autocomplete', 'on'));
->with('maps', $maps = $request->input('param_maps', 'on'));
}
public function loadPage($subpage)
......@@ -124,6 +121,35 @@ class StartpageController extends Controller
}
public function loadSettings(Request $request)
{
$foki = $this->loadFoki();
return view('settings')
->with('foki', $foki)
->with('title', 'Einstellungen')
->with('js', ['settings.js'])
->with('navbarFocus', 'suche');
die(var_dump($foki));
return $xml->saveXML();
}
public function berlin(Request $request)
{
$link = "";
$password = "";
if ($request->has('eingabe')) {
$password = getenv('berlin');
$password = md5($request->input('eingabe') . " -host:userpage.fu-berlin.de" . $password);
$link = "/meta/meta.ger3?eingabe=" . $request->input('eingabe') . " -host:userpage.fu-berlin.de&focus=web&password=" . $password . "&encoding=utf8&lang=all&site=fu-berlin.de&quicktips=off&out=results-with-style";
}
return view('berlin')
->with('title', 'Testseite für die FU-Berlin')
->with('link', $link)
->with('password', $password);
}
private function loadFoki()
{
$sumaFile = "";
if (App::isLocale('en')) {
......@@ -153,28 +179,6 @@ class StartpageController extends Controller
}
}
return view('settings')
->with('foki', $foki)
->with('title', 'Einstellungen')
->with('js', ['settings.js'])
->with('navbarFocus', 'suche');
die(var_dump($foki));
return $xml->saveXML();
}
public function berlin(Request $request)
{
$link = "";
$password = "";
if ($request->has('eingabe')) {
$password = getenv('berlin');
$password = md5($request->input('eingabe') . " -host:userpage.fu-berlin.de" . $password);
$link = "/meta/meta.ger3?eingabe=" . $request->input('eingabe') . " -host:userpage.fu-berlin.de&focus=web&password=" . $password . "&encoding=utf8&lang=all&site=fu-berlin.de&quicktips=off&out=results-with-style";
}
return view('berlin')
->with('title', 'Testseite für die FU-Berlin')
->with('link', $link)
->with('password', $password);
return $foki;
}
}
......@@ -556,7 +556,8 @@ class MetaGer
$engine->startSearch($this);
}
$this->adjustFocus($sumas, $enabledSearchengines);
// Derzeit deaktiviert, da es die eigene Suche gibt
// $this->adjustFocus($sumas, $enabledSearchengines);
/* Wir warten auf die Antwort der Suchmaschinen
* Die Verbindung steht zu diesem Zeitpunkt und auch unsere Requests wurden schon gesendet.
......
......@@ -12,7 +12,18 @@ require('laravel-elixir-vue-2');
*/
elixir(function(mix) {
mix.less('default.less', 'public/css/themes/default.css');
mix.scripts(['lib/jquery.js', 'lib/bootstrap.js', 'widgets.js', 'editLanguage.js', 'kontakt.js', 'lib/lightslider.js', 'lib/masonry.js', 'lib/imagesloaded.js', 'lib/openpgp.min.js', 'scriptResultPage.js', 'scriptStartPage.js', 'settings.js', 'lib/iframeResizer.min.js' /*, 'lib/vue/app.js', 'lib/vue/bootstrap.js'*/ ]);
/*
| Not mixed (specific pages only)
|
| widgets.js
| editLanguage.js
| kontakt.js
| scriptResultPage.js
| scriptStartPage.js
| settings.js
*/
mix.scripts(['lib/jquery.js', 'lib/bootstrap.js', 'lib/lightslider.js', 'lib/masonry.js', 'lib/imagesloaded.js', 'lib/openpgp.min.js', 'lib/iframeResizer.min.js'], 'public/js/lib.js');
mix.scripts(['lib/jquery.js', 'lib/iframeResizer.contentWindow.min.js'], 'public/js/quicktips.js');
mix.version(['css/themes/default.css', 'js/all.js', 'js/quicktips.js']);
mix.version(['css/themes/default.css', 'js/lib.js', 'js/quicktips.js']);
mix.version(['js/widgets.js', 'js/editLanguage.js', 'js/kontakt.js', 'js/scriptResultPage.js', 'js/scriptStartPage.js', 'js/settings.js']);
});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
$(document).ready(function() {
switch (getLanguage()) {
case "de":
$(".encrypt-btn").html("Verschlüsseln und senden");
break;
case "en":
$(".encrypt-btn").html("encrypt and send");
break;
case "es":
// $(".encrypt-btn").html(""); TODO
break;
}
$(".contact").submit(function() {
return encrypt(this);
});
});
//based on https://github.com/encrypt-to/secure.contactform.php
/* The MIT License (MIT)
Copyright (c) 2013 Jan Wiegelmann
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
function encrypt() {
if (window.crypto && window.crypto.getRandomValues) {
var message = document.getElementById("message");
if (message.value.indexOf("-----BEGIN PGP MESSAGE-----") !== -1 && message.value.indexOf("-----END PGP MESSAGE-----") !== -1) {
// encryption done
} else {
var pub_key = openpgp.key.readArmored(document.getElementById("pubkey").innerHTML).keys[0];
var plaintext = message.value;
var ciphertext = openpgp.encryptMessage([pub_key], plaintext);
message.value = ciphertext;
return true;
}
} else {
switch (getLanguage()) {
case "de":
alert("Fehler: Ihr Browser wird nicht unterstützt. Bitte installieren Sie einen aktuellen Browser wie z.B. Mozilla Firefox.");
break;
case "en":
alert("Error: Your browser is not supported. Please install an up to date browser like Mozilla Firefox.");
break;
case "es":
// alert(""); TODO
break;
}
return false;
}
}
function getLanguage() {
var metaData = document.getElementsByTagName('meta');
for (var m in metaData) {
if (metaData[m]["httpEquiv"] == "language") {
return metaData[m]["content"];
}
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
$(document).ready(function() {
getDocumentReadyForUse($("#foki > li.active > a").attr("aria-controls"));
$('iframe').iFrameResize();
botProtection();
createCustomFocuses();
var focus = $("#foki > li.active > a").attr("aria-controls");
var custom = $("#foki > li.active").hasClass("custom-focus-tab-selector");
getDocumentReadyForUse(focus, custom);
});
function tabs() {
//return;
$("#foki > li.tab-selector > a").each(function() {
if($(this).attr("target") != "_blank") {
if ($(this).attr("target") != "_blank") {
$(this).attr("href", "#" + $(this).attr("aria-controls"));
$(this).attr("role", "tab");
$(this).attr("data-toggle", "tab");
......@@ -30,16 +30,19 @@ function tabs() {
});
}
function getDocumentReadyForUse(fokus) {
function getDocumentReadyForUse(fokus, custom = false) {
clickLog();
popovers();
if (fokus === "bilder") imageLoader();
if (custom) initialLoadContent(fokus);
//pagination();
tabs();
theme();
fokiChanger();
pluginInfo();
productWidget();
$('iframe:not(.resized)').iFrameResize();
$('iframe').addClass("resized");
}
function pluginInfo() {
......@@ -214,14 +217,6 @@ function fokiChanger() {
});
})(jQuery);
function botProtection() {
if ($("meta[name=pqr]").length > 0) {
var link = atob($("meta[name=pqr]").attr("content"));
var hash = $("meta[name=pq]").attr("content");
document.location.href = link + "&bot=" + hash;
}
}
function productWidget() {
var isMobile = false; //initiate as false
// device detection
......@@ -314,4 +309,172 @@ function productWidget() {
});
}
$(".lightSliderContainer").removeClass("hidden");
}
function createCustomFocuses() {
for (var key in localStorage) {
if (key.startsWith("focus_")) {
var focus = loadFocusById(key);
var active = false;
if (getActiveFocusId() === getIdFromName(focus.name)) {
active = true;
}
addFocus(focus, active);
addTab(focus, active);
}
}
}
/*
@if( $metager->getFokus() === "produktsuche" )
<li id="produktsucheTabSelector" class="active tab-selector" role="presentation" data-loaded="1">
<a aria-controls="produktsuche" data-href="#produktsuche" href="#produktsuche">
<span class='glyphicon glyphicon-shopping-cart'></span>
<span class="hidden-xs">{{ trans('index.foki.produkte') }}</span>
</a>
</li>
@else
<li id="produktsucheTabSelector" class="tab-selector" role="presentation" data-loaded="0">
<a aria-controls="produktsuche" data-href="{!! $metager->generateSearchLink('produktsuche') !!}" href="{!! $metager->generateSearchLink('produktsuche', false) !!}">
<span class='glyphicon glyphicon-shopping-cart'></span>
<span class="hidden-xs">{{ trans('index.foki.produkte') }}</span>
</a>
</li>
@endif
*/
function addFocus(focus, active = false) {
var id = getIdFromName(focus.name);
var foki = document.getElementById("foki");
// create <input>
var focusElement = document.createElement("li");
focusElement.id = id + "TabSelector";
focusElement.classList.add("tab-selector");
focusElement.classList.add("custom-focus-tab-selector");
if (active) {
focusElement.classList.add("active");
focusElement.setAttribute("data-loaded", "1");
} else {
focusElement.setAttribute("data-loaded", "0");
}
focusElement.setAttribute("role", "presentation");
// create <a>
var focusElementLink = document.createElement("a");
focusElementLink.setAttribute("aria-controls", id);
var searchLink = generateSearchLinkForFocus(focus)
focusElementLink.setAttribute("data-href", searchLink);
focusElementLink.setAttribute("href", searchLink);
// create <span> glyphicon
var focusElementIcon = document.createElement("span");
focusElementIcon.classList.add("glyphicon");
focusElementIcon.classList.add("glyphicon-cog");
// create <span> focusname
var focusElementName = document.createElement("span");
focusElementName.classList.add("hidden-xs");
focusElementName.innerHTML = focus.name;
// add new elements
var mapsTabSelector = document.getElementById("mapsTabSelector");
foki.insertBefore(focusElement, mapsTabSelector);
focusElement.appendChild(focusElementLink);
focusElementLink.appendChild(focusElementIcon);
focusElementLink.appendChild(focusElementName);
}
/*
@if( $metager->getFokus() === "produktsuche" )
<div role="tabpanel" class="tab-pane active" id="produktsuche">
<div class="row">
@yield('results')
</div>
</div>
@else
<div role="tabpanel" class="tab-pane" id="produktsuche">
<div class="loader">
<img src="/img/ajax-loader.gif" alt="" />
</div>
</div>
@endif
*/
function addTab(focus, active = false) {
var id = getIdFromName(focus.name);
// create tab div
var tabPane = document.createElement("div");
tabPane.id = id;
tabPane.classList.add("tab-pane");
if (active) {
tabPane.classList.add("active");
}
tabPane.setAttribute("role", "tabpanel");
// create row div
var row = document.createElement("div");
row.classList.add("loader");
// create loader image
var img = document.createElement("img");
img.setAttribute("src", "/img/ajax-loader.gif");
img.setAttribute("alt", "");
row.appendChild(img);
// add new elements
var tabs = document.getElementById("main-content-tabs");
tabs.appendChild(tabPane)
tabPane.appendChild(row);
}
function getIdFromName(name) {
return "focus_" + name.split(" ").join("_").toLowerCase();
}
function loadFocusById(id) {
return JSON.parse(localStorage.getItem(id));
}
function getActiveFocusId() {
var search = window.location.search;
var from = search.indexOf("focus=") + "focus=".length;
var to = search.substring(from).indexOf("&") + from;
if (to <= 0) {
to = search.substring(from).length;
}
id = search.substring(from, to);
return id;
}
// TODO catch error if link is http://localhost:8000/meta/meta.ger3?
function generateSearchLinkForFocus(focus) {
var link = document.location.href;
// remove old engine settings
// not yet tested
/*
while (link.indexOf("engine_") !== -1) {
var from = search.indexOf("engine_");
var to = search.substring(from).indexOf("&") + from;
if (to === 0) {
to = search.substring(from).length;
}
link = link.substring(0, from) + link.substring(to);
}
*/
// add new engine settings
for (var key in focus) {
if (key.startsWith("engine_")) {
var focusName = key.substring("engine_".length);
link += "&" + focusName + "=" + focus[key];
}
}
link += "&out=results";
link = replaceFocusInUrl(link);
return link;
}
function replaceFocusInUrl(url) {
var from = url.indexOf("focus=");
var to = url.substring(from).indexOf("&") + from;
if (to === 0) {
to = url.substring(from).length;
}
url = url.substring(0, from) + url.substring(to);
return url + "&focus=angepasst";
}
function initialLoadContent(fokus) {
var link = $("#" + fokus + "TabSelector a").attr("data-href");
$.get(link, function(data) {
$("#" + fokus).html(data);
getDocumentReadyForUse(fokus);
});
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ $(document).ready(function() {
if (location.href.indexOf("#plugin-modal") > -1) {
$("#plugin-modal").modal("show");
}
$('#addFocusBtn').removeClass('hide');
$("button").popover();
if (localStorage) {
var theme = localStorage.getItem("theme");
......@@ -18,6 +19,11 @@ $(document).ready(function() {
setSettings();
}
}
setActionListeners();
loadInitialCustomFocuses()
});
function setActionListeners() {
$("button").on("shown.bs.popover", function() {
$("#color-chooser a").click(function() {
var theme = $(this).attr("data-rgba");
......@@ -28,19 +34,24 @@ $(document).ready(function() {
});
});
$("#mobileFoki").change(function() {
var fokus = $("#mobileFoki > option:selected").val();
if (fokus == "angepasst") window.location = "./settings/";
else window.location = "./?focus=" + fokus; //$("#mobileFoki > option:selected").val());
var focus = $("#mobileFoki > option:selected").val();
if (focus == "angepasst") {
window.location = "./settings/";
} else {
window.location = "./?focus=" + focus;
}
});
if ($("fieldset#foki.mobile").length) {
$("fieldset#foki.mobile label#anpassen-label").click(function() {
window.location = "./settings/";
});
}
$("#anpassen-label").click(function() {
window.location = "./settings/";
$("#addFocusBtn").click(function() {
showFocusCreateDialog("");
});
});
$("#save-focus-btn").click(saveFocus);
$("#delete-focus-btn").click(deleteFocus);
}
function setSettings() {
for (var i = 0; i < localStorage.length; i++) {
......@@ -52,19 +63,16 @@ function setSettings() {
}
$("#foki input[type=radio]#angepasst").attr("checked", true);
}
if( localStorage.getItem("param_lang") !== null ) {
if (localStorage.getItem("param_lang") !== null) {
var value = localStorage.getItem("param_lang");
// Change the value of the lang input field to the given parameter
$("input[name=lang]").val(value);
}
if( localStorage.getItem("param_autocomplete") !== null ) {
if (localStorage.getItem("param_autocomplete") !== null) {
var value = localStorage.getItem("param_autocomplete");
// Change the value of the lang input field to the given parameter
$("input[name=eingabe]").attr("autocomplete", value);
}
if ($("fieldset#foki.mobile").length) {
$("fieldset.mobile input#bilder").val("angepasst");
$("fieldset.mobile input#bilder").prop("checked", true);
......@@ -160,6 +168,205 @@ var isBlink = (isChrome || isOpera) && !!window.CSS;
function isUseOnce() {
var url = document.location.search;
var pos = url.indexOf("usage=");
if (pos >= 0 && url.substring(pos + 6, pos + 11) == "once") return true;
return false;
if (pos >= 0 && url.substring(pos + 6, pos + 11) == "once") {
return true;
} else {
return false;
}
}
function loadInitialCustomFocuses() {
for (var key in localStorage) {
if (key.startsWith("focus_")) {
var focus = loadFocusById(key);
addFocus(focus.name);
}
}
}
function showFocusCreateDialog(id = "") {
document.getElementById("original-id").value = id;
$("#create-focus-modal").modal("show");
var storedFocus = loadFocusById(id);
var focus = {};
// Try to load a focus for the given id
$("#focus-name").val("");
uncheckAll()
if (storedFocus !== null) {
try {
focus = JSON.parse(localStorage.getItem(id));
$("#focus-name").val(focus.name);
for (var key in focus) {
if (key.startsWith("engine_")) {
$(".focusCheckbox[name=" + key + "]").prop('checked', true);
}
}
} catch (ex) {
console.error(ex);
}
}
}
function showFocusEditDialog(id) {
showFocusCreateDialog(id);
}
function saveFocus() {
var name = document.getElementById("focus-name").value;
if (isValidName(name) && atLeastOneChecked()) {
var id = getIdFromName(name);
var overwrite = true;
if (alreadyInUse(name)) {
overwrite = confirm("Name bereits genutzt\nüberschreiben?");
if (overwrite) {
localStorage.removeItem(id);
removeFocusById(id);
}
}
if (overwrite) {
var oldId = document.getElementById("original-id").value;
var focus = {};
$("input[type=checkbox]:checked").each(function(el) {
focus[$(this).attr("name")] = $(this).val();
});
focus["name"] = name;
if (oldId !== "") {