From 630fa0015aa082fa0c7a03711b262be116f00428 Mon Sep 17 00:00:00 2001 From: luccioman Date: Fri, 15 Mar 2019 17:46:23 +0100 Subject: [PATCH] P2P/Privacy switch buttons support with JavaScript disabled --- htroot/env/base.css | 54 ++----------------------- htroot/yacysearchtrailer.html | 74 +++++++++++++++++++++-------------- htroot/yacysearchtrailer.java | 17 +++++--- locales/fr.lng | 7 ++-- locales/master.lng.xlf | 14 +++---- locales/ru.lng | 14 +++---- locales/zh.lng | 14 +++---- 7 files changed, 83 insertions(+), 111 deletions(-) diff --git a/htroot/env/base.css b/htroot/env/base.css index fd11056e1..3296eb049 100644 --- a/htroot/env/base.css +++ b/htroot/env/base.css @@ -1127,58 +1127,12 @@ div#tagcloud { } /******* yacysearch.html end ***********/ - -/******* yacysearchtrailer.html ********** - Styling for the resource switch button, to avoid overlapping at various screen sizes */ - -/* When screen size is too small, reduce font-size and padding as done in the bootstrap-switch-mini class */ -@media (max-width: 1449px) { -#resource-switch-form .bootstrap-switch-handle-on, -#resource-switch-form .bootstrap-switch-handle-off, -#resource-switch-form .bootstrap-switch-label { - padding: 1px 1px !important; - font-size: 12px !important; - line-height: 1.5 !important; - } -} -/* When screen size is large enough, us the same values as the bootstrap-switch-large class, - except padding wich is reduced to handle the quite long text */ -@media (min-width: 1450px) { -#resource-switch-form .bootstrap-switch-handle-on, -#resource-switch-form .bootstrap-switch-handle-off, -#resource-switch-form .bootstrap-switch-label { - padding: 6px 1px !important; - font-size: 18px !important; - line-height: 1.3333333 !important; - } +/******* yacysearchtrailer.html **********/ +#resource-switch-form .btn-lg { + /* Reduce bootstrap btn-lg padding to avoid text overlapping */ + padding: 6px 1px; } - -/* override bootstrap-switch wrapper to use 100% of the parent available size */ -#resource-switch-form, -.bootstrap-switch-large { - width: 100% !important; -} - -/* override bootstrap-switch-container to use 155% of the parent available size - (only 100% is displayed, hiding the switched off part) */ -#resource-switch-form .bootstrap-switch-container { - width: 155% !important; -} - -/* override bootstrap-switch-container to use a percent margin value - (when resource switch is "Privacy" position) */ -#resource-switch-form div[class~="bootstrap-switch-container"][style*="margin-left: -"] { - margin-left: -52% !important; -} - -/* override bootstrap-switch elements to use percent widths */ -#resource-switch-form .bootstrap-switch-handle-on, -#resource-switch-form .bootstrap-switch-handle-off, -#resource-switch-form .bootstrap-switch-label { - width: 33.333% !important; -} - /******* yacysearchtrailer.html end ***********/ /******* yacysearchitem.html **********/ diff --git a/htroot/yacysearchtrailer.html b/htroot/yacysearchtrailer.html index 4a2957698..397eb4a70 100644 --- a/htroot/yacysearchtrailer.html +++ b/htroot/yacysearchtrailer.html @@ -7,40 +7,54 @@ } -#(resource-select)#:: +#(resource-switches)#::
- + title="#(global)#Your search is done using only your own peer, locally.::Your search is done using peers in the YaCy P2P network.#(/global)#" + data-content="#(global)#You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network.::You can switch to 'Stealth Mode' which will switch off P2P, giving you full privacy. Expect less results then, because then only your own search index is used.#(/global)#" + onsubmit="document.getElementById('resourceSwitchFormQuery').value = document.getElementById('search').value;"> + + #(authSearch)#:: + + #(/authSearch)# + + + + + + + + + + + + + +
- -:: -
- -
- -#(/resource-select)# + +#(/resource-switches)#
diff --git a/htroot/yacysearchtrailer.java b/htroot/yacysearchtrailer.java index 9111e5e56..367ded421 100644 --- a/htroot/yacysearchtrailer.java +++ b/htroot/yacysearchtrailer.java @@ -89,12 +89,6 @@ public class yacysearchtrailer { return prop; } - final boolean clustersearch = sb.isRobinsonMode() && sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "").equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER); - final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true) || clustersearch; - boolean p2pmode = sb.peers != null && sb.peers.sizeConnected() > 0 && indexReceiveGranted; - boolean global = post == null || (!post.get("resource-switch", post.get("resource", "global")).equals("local") && p2pmode); - boolean stealthmode = p2pmode && !global; - prop.put("resource-select", !adminAuthenticated ? 0 : stealthmode ? 2 : global ? 1 : 0); // find search event final SearchEvent theSearch = SearchEventCache.getEvent(eventID); if (theSearch == null) { @@ -103,6 +97,13 @@ public class yacysearchtrailer { } final RequestHeader.FileType fileType = header.fileType(); + + final boolean clustersearch = sb.isRobinsonMode() && sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "").equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER); + final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true) || clustersearch; + boolean p2pmode = sb.peers != null && sb.peers.sizeConnected() > 0 && indexReceiveGranted; + boolean global = post == null || (!post.get("resource-switch", post.get("resource", "global")).equals("local") && p2pmode); + boolean stealthmode = p2pmode && !global; + /* Add information about the current navigators generation (number of updates since their initialization) */ prop.put("nav-generation", theSearch.getNavGeneration()); @@ -125,6 +126,10 @@ public class yacysearchtrailer { /* Maximum number of suggestions to display in the first results page */ final int meanMax = post.getInt("meanCount", 0); + prop.put("resource-switches", adminAuthenticated && (stealthmode || global)); + prop.put("resource-switches_global", adminAuthenticated && global); + appendSearchFormValues("resource-switches_", post, prop, global, theSearch, former, snippetFetchStrategyName, startRecord, meanMax); + appendSearchFormValues("", post, prop, global, theSearch, former, snippetFetchStrategyName, startRecord, meanMax); prop.put("contextRanking", !former.contains(" /date")); prop.put("contextRanking_formerWithoutDate", former.replace(" /date", "")); diff --git a/locales/fr.lng b/locales/fr.lng index b4e4ca12b..f6c4976f6 100644 --- a/locales/fr.lng +++ b/locales/fr.lng @@ -2611,12 +2611,11 @@ and contributors, CC-BY-SA==et ses contributeurs, CC-BY-SA #--------------------------- Your search is done using peers in the YaCy P2P network.==Recherche effectuée grâce aux noeuds du réseau P2P YaCy. You can switch to 'Stealth Mode' which will switch off P2P, giving you full privacy. Expect less results then, because then only your own search index is used.==Vous pouvez passer en 'Mode furtif' ce qui désactivera le réseau pair à pair et vous offrira une privatisation complète. Cependant vous obtiendrez probablement moins de résultats car la recherche sera alors basée uniquement sur votre propre index. -"Privacy"=="Privé" - Peer-to-Peer == Pair à pair  -Stealth Mode==Mode furtif +Privacy==Privé +>Peer-to-Peer<==>Pair à pair< +Stealth Mode==Mode furtif Your search is done using only your own peer, locally.==La recherche est réalisée uniquement sur les données locales de votre noeud. You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network.==Vous pouvez passer en mode 'Pair à pair' dans lequel votre recherche sera basée sur les autres noeuds du réseau YaCy. -"Peer-to-Peer"==Pair à pair Context Ranking==Classement contextuel Sort by Date==Trier par date Video==Vidéo diff --git a/locales/master.lng.xlf b/locales/master.lng.xlf index 5a7e1be7b..b055dee1e 100644 --- a/locales/master.lng.xlf +++ b/locales/master.lng.xlf @@ -11758,13 +11758,13 @@ >Language - &nbsp;&nbsp;&nbsp;Peer-to-Peer&nbsp;&nbsp;&nbsp;&nbsp; + >Peer-to-Peer< - &nbsp;&nbsp;&nbsp;&nbsp;Stealth&nbsp;Mode&nbsp;&nbsp;&nbsp; + Stealth Mode - "Privacy" + Privacy Context Ranking @@ -11779,16 +11779,16 @@ Images - "Your search is done using peers in the YaCy P2P network." + Your search is done using peers in the YaCy P2P network. - "You can switch to 'Stealth Mode' which will switch off P2P, giving you full privacy. Expect less results then, because then only your own search index is used." + You can switch to 'Stealth Mode' which will switch off P2P, giving you full privacy. Expect less results then, because then only your own search index is used. - "Your search is done using only your own peer, locally." + Your search is done using only your own peer, locally. - "You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network." + You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network. >Documents diff --git a/locales/ru.lng b/locales/ru.lng index c4cb8d055..a6a9758d7 100644 --- a/locales/ru.lng +++ b/locales/ru.lng @@ -4101,6 +4101,10 @@ Pictures==Изображения #File: yacysearchtrailer.html #--------------------------- show search results for "#[query]#" on map==Показать результат поиска "#[query]#" на карте +Your search is done using peers in the YaCy P2P network.==Ваш поиск выполняется с использованием узлов P2P-сети YaCy. +You can switch to 'Stealth Mode' which will switch off P2P, giving you full privacy. Expect less results then, because then only your own search index is used.==Вы можете перейти в режим Стелс, который отключит использование P2P, но обеспечит вашу полную анонимность. В этом случае результатов поиска будет меньше, потому что поиск будет осуществляться только в локальном индексе. +Your search is done using only your own peer, locally.==Поиск выполняется только в вашем локальном индексе. +You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network.==Вы можете перейти в режим P2P, который позволит производить поиск с использованием других узлов сети YaCy. >Provider==>Домен >Name Space==>Имя >Author==>Автор @@ -4108,17 +4112,13 @@ show search results for "#[query]#" on map==Показать результат >Filetype==>Тип файла >Language==>Язык >Please support YaCy!==>Пожалуйста, поддержите YaCy! -   Peer-to-Peer    ==   P2P     -    Stealth Mode   ==    Режим стелс    -"Privacy"=="Частный" +>Peer-to-Peer<==>P2P< +Stealth Mode==Режим стелс +Privacy==Частный Context Ranking==Фильтр по рейтингу Sort by Date==Фильтр по дате Documents==Документы Images==Изображения -"Your search is done using peers in the YaCy P2P network."=="Ваш поиск выполняется с использованием узлов P2P-сети YaCy." -"You can switch to 'Stealth Mode' which will switch off P2P, giving you full privacy. Expect less results then, because then only your own search index is used."=="Вы можете перейти в режим Стелс, который отключит использование P2P, но обеспечит вашу полную анонимность. В этом случае результатов поиска будет меньше, потому что поиск будет осуществляться только в локальном индексе." -"Your search is done using only your own peer, locally."=="Поиск выполняется только в вашем локальном индексе." -"You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network."=="Вы можете перейти в режим P2P, который позволит производить поиск с использованием других узлов сети YaCy." #----------------------------- ### Subdirectory api ### diff --git a/locales/zh.lng b/locales/zh.lng index 6b2fd9652..5c9144dfd 100644 --- a/locales/zh.lng +++ b/locales/zh.lng @@ -4529,22 +4529,22 @@ Pictures==图片 #File: yacysearchtrailer.html #--------------------------- show search results for "#[query]#" on map==在地图上显示 "#[query]#" 的搜索结果 +Your search is done using peers in the YaCy P2P network.==您的搜索是靠YaCy P2P网络中的节点完成的。 +You can switch to 'Stealth Mode' which will switch off P2P, giving you full privacy. Expect less results then, because then only your own search index is used.==您可以切换到'隐形模式',这将关闭P2P,给你完全的隐私。期待较少的结果,因为那时只有您自己的搜索索引被使用。 +Your search is done using only your own peer, locally.==你的搜索是靠在本地的YaCy节点完成的。 +You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network.==您可以切换到'P2P',这将让您的搜索使用YaCy网络中的YaCy节点。 >Provider==>提供者 >Name Space==>命名空间 >Author==>作者 >Filetype==>文件类型 >Language==>语言 -   Peer-to-Peer    ==   P2P     -    Stealth Mode   ==    隐身 模式    -"Privacy"=="隐私" +>Peer-to-Peer<==>P2P< +Stealth Mode==隐身 模式 +Privacy==隐私 Context Ranking==按内容排名 Sort by Date==按日期排序 Documents==文件 Images==图片 -"Your search is done using peers in the YaCy P2P network."=="您的搜索是靠YaCy P2P网络中的节点完成的。" -"You can switch to 'Stealth Mode' which will switch off P2P, giving you full privacy. Expect less results then, because then only your own search index is used."=="您可以切换到'隐形模式',这将关闭P2P,给你完全的隐私。期待较少的结果,因为那时只有您自己的搜索索引被使用。" -"Your search is done using only your own peer, locally."=="你的搜索是靠在本地的YaCy节点完成的。" -"You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network."=="您可以切换到'P2P',这将让您的搜索使用YaCy网络中的YaCy节点。" >Documents==>文件 >Images==>图片 #-----------------------------