branch develop updated (540789a -> 980ad7d)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository bow. See http://git.chorem.org/bow.git from 540789a fixes #233: Add support for login/password (change header jsp generation) (add minification css/js) new e73fa41 add shell script to compute password as same way that bookmarklet new 980ad7d - new BowAdd bookmarklet - add shell script to generate password as bookmarklet The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 980ad7d1853bf764a8eb820631980420d96ade70 Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Fri Jul 31 23:26:23 2015 +0200 - new BowAdd bookmarklet - add shell script to generate password as bookmarklet commit e73fa4105c785a395bd9bb3d170f27ac1948e388 Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Fri Jul 31 04:26:54 2015 +0200 add shell script to compute password as same way that bookmarklet Summary of changes: bow-ui/pom.xml | 20 +++++- bow-ui/src/main/java/org/chorem/bow/BowUtils.java | 75 +++++++++++++++++++--- bow-ui/src/main/resources/BowPwd.sh | 58 +++++++++++++++++ .../main/resources/i18n/bow-ui_en_GB.properties | 1 + .../main/resources/i18n/bow-ui_fr_FR.properties | 1 + bow-ui/src/main/webapp/WEB-INF/bowutils.tld | 12 ++++ bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp | 19 +++--- bow-ui/src/main/webapp/js/bowadd.js | 36 +++++++++++ bow-ui/src/main/webapp/js/bowpwd.js | 20 ++++++ 9 files changed, 224 insertions(+), 18 deletions(-) create mode 100755 bow-ui/src/main/resources/BowPwd.sh create mode 100644 bow-ui/src/main/webapp/js/bowadd.js -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository bow. See http://git.chorem.org/bow.git commit e73fa4105c785a395bd9bb3d170f27ac1948e388 Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Fri Jul 31 04:26:54 2015 +0200 add shell script to compute password as same way that bookmarklet --- bow-ui/src/main/java/org/chorem/bow/BowUtils.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/bow-ui/src/main/java/org/chorem/bow/BowUtils.java b/bow-ui/src/main/java/org/chorem/bow/BowUtils.java index 94b328e..d151d4a 100644 --- a/bow-ui/src/main/java/org/chorem/bow/BowUtils.java +++ b/bow-ui/src/main/java/org/chorem/bow/BowUtils.java @@ -22,10 +22,8 @@ package org.chorem.bow; import com.github.rjeschke.txtmark.Configuration; import com.github.rjeschke.txtmark.Processor; -import java.io.File; import java.net.URI; import java.net.URL; -import java.net.URLEncoder; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; @@ -39,7 +37,6 @@ import java.util.Set; import java.util.UUID; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository bow. See http://git.chorem.org/bow.git commit 980ad7d1853bf764a8eb820631980420d96ade70 Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Fri Jul 31 23:26:23 2015 +0200 - new BowAdd bookmarklet - add shell script to generate password as bookmarklet --- bow-ui/pom.xml | 20 +++++- bow-ui/src/main/java/org/chorem/bow/BowUtils.java | 72 ++++++++++++++++++++-- bow-ui/src/main/resources/BowPwd.sh | 58 +++++++++++++++++ .../main/resources/i18n/bow-ui_en_GB.properties | 1 + .../main/resources/i18n/bow-ui_fr_FR.properties | 1 + bow-ui/src/main/webapp/WEB-INF/bowutils.tld | 12 ++++ bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp | 19 +++--- bow-ui/src/main/webapp/js/bowadd.js | 36 +++++++++++ bow-ui/src/main/webapp/js/bowpwd.js | 20 ++++++ 9 files changed, 224 insertions(+), 15 deletions(-) diff --git a/bow-ui/pom.xml b/bow-ui/pom.xml index 7c83b49..724e8c2 100644 --- a/bow-ui/pom.xml +++ b/bow-ui/pom.xml @@ -353,7 +353,25 @@ </goals> </execution> <execution> - <id>scriptlet-minify</id> + <id>scriptlet-bowadd-minify</id> + <!--<phase>package</phase> When omitted defaults to 'process-resources' --> + <configuration> + <charset>UTF-8</charset> + <jsSourceDir>js</jsSourceDir> + <webappTargetDir>${project.build.directory}</webappTargetDir> + <jsTargetDir>classes</jsTargetDir> + <jsSourceFiles> + <jsSourceFile>bowadd.js</jsSourceFile> + </jsSourceFiles> + <jsFinalFile>bowadd.js</jsFinalFile> + <jsEngine>CLOSURE</jsEngine> + </configuration> + <goals> + <goal>minify</goal> + </goals> + </execution> + <execution> + <id>scriptlet-bowpwd-minify</id> <!--<phase>package</phase> When omitted defaults to 'process-resources' --> <configuration> <charset>UTF-8</charset> diff --git a/bow-ui/src/main/java/org/chorem/bow/BowUtils.java b/bow-ui/src/main/java/org/chorem/bow/BowUtils.java index d151d4a..835e8eb 100644 --- a/bow-ui/src/main/java/org/chorem/bow/BowUtils.java +++ b/bow-ui/src/main/java/org/chorem/bow/BowUtils.java @@ -22,7 +22,9 @@ package org.chorem.bow; import com.github.rjeschke.txtmark.Configuration; import com.github.rjeschke.txtmark.Processor; +import java.io.IOException; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; @@ -31,8 +33,10 @@ import org.nuiton.util.StringUtil; import java.util.Arrays; import java.util.Date; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.UUID; import org.apache.commons.codec.binary.Base64; @@ -67,23 +71,81 @@ public class BowUtils { return result; } + public static Map<String, String> resourceContent = new HashMap<String, String>(); + /** + * Get content of resource in classpath. First time read content from URL + * but next call with same resourceName use cache to speed performance + * + * @param resourceName + * @return + * @throws IOException + */ + public static String getResourceContent(String resourceName) throws IOException { + String result = resourceContent.get(resourceName); + if (result == null) { + URL resource = BowUtils.class.getResource("/" + resourceName); + result = IOUtils.toString(resource); + resourceContent.put(resourceName, result); + } + return result; + } + public static String scriptletPassword(BowAuthentication auth) { String result = ""; try { - URL script = BowUtils.class.getResource("/bowpwd-sha256.min.js"); - String js = IOUtils.toString(script) + - String.format(";window.bow.bowpwd('', '%s', '%s', '%s', '%s', '%s');", + String js = getResourceContent("bowpwd-sha256.min.js") + + String.format(";window.bow.bowpwd('','%s','%s','%s','%s','%s');", auth.getMaxLength(), auth.getPrefix(), auth.getInclude(), auth.getExclude(), auth.getSuffix()); - URI uri = new URI("javascript", js, null); - result = uri.toASCIIString(); + result = toScriptlet(js); } catch (Exception eee) { log.info("Can't create scriptlet password", eee); } return result; } + public static String scriptletAdd(String bowUrl, String token) { + String result = ""; + try { + String js = getResourceContent("bowadd.min.js") + + String.format(";window.bow.bowadd('%s','%s',true,true);", + bowUrl, token); + + result = toScriptlet(js); + } catch (Exception eee) { + log.info("Can't create scriptlet add", eee); + } + return result; + } + + public static String scriptPassword(BowAuthentication auth) { + String result = ""; + try { + String script = getResourceContent("bowpwd.sh") + + String.format("compute '%s' '%s' '%s' '%s' '%s' \"$DOMAIN\" \"$PASSWD\"", + auth.getMaxLength(), auth.getPrefix(), auth.getInclude(), + auth.getExclude(), auth.getSuffix()); + String b64 = Base64.encodeBase64URLSafeString(script.getBytes()); + result = "data:application/x-shellscript;base64," + b64; + } catch (Exception eee) { + log.info("Can't create scriptlet password", eee); + } + return result; + } + + /** + * Generate valide URL javascript:... + * @param js javascript code + * @return valide bookmarklet URL "javascript:..." + * @throws java.net.URISyntaxException + */ + public static String toScriptlet(String js) throws URISyntaxException { + URI uri = new URI("javascript", js, null); + String result = uri.toASCIIString(); + return result; + } + public static String toBase64(byte[] b) { return Base64.encodeBase64String(b); } diff --git a/bow-ui/src/main/resources/BowPwd.sh b/bow-ui/src/main/resources/BowPwd.sh new file mode 100755 index 0000000..0d38060 --- /dev/null +++ b/bow-ui/src/main/resources/BowPwd.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +# usage "bowpwd.sh [domain [password]]" +# you can install xclip to directly have you password in clipboard (just paste) + +CLIPBOARD=$(which xclip) + +compute() { + +LENGTH=$1 +PREFIX=$2 +INCLUDE=$3 +EXCLUDE=$4 +SUFFIX=$5 +DOMAIN=$6 +PASSWD=$7 + +result=$(echo -n "$DOMAIN" |hmac256 --binary "$PREFIX$PASSWD" |base64) + +if [ -n "$INCLUDE" ]; then + result=$(echo -n "$result" |sed -re "s/[^$INCLUDE]//g") +fi + +if [ -n "$EXCLUDE" ]; then + result=$(echo -n "$result" | sed -re "s/[$EXCLUDE]//g") +fi + +if [ -n "$LENGTH" ]; then + result=$(echo -n "$result" | cut -c-$LENGTH) +fi + +if [ -n "$SUFFIX" ]; then + result=$(echo -n "$result" |sed -re "s/(.*)/\1$SUFFIX/g") +fi + +if [ -n "$CLIPBOARD" ]; then + echo -n "$result" | xclip -selection clipboard + echo "your password is in your clipboard" +else + echo "$result" +fi + +} + +#compute $* + +DOMAIN=$1 +if [ -z "$DOMAIN" ]; then + read -p "Domain: " DOMAIN +fi +shift + +PASSWD=$1 +if [ -z "$PASSWD" ]; then + read -s -p "Password: " PASSWD +fi +shift + diff --git a/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties b/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties index 22696f4..0d3b163 100644 --- a/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties +++ b/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties @@ -95,6 +95,7 @@ bow.permanent.link.suggestionDescription=Permalink to use Bow as suggest engine bow.preference.authentication.exclude= bow.preference.authentication.include= bow.preference.authentication.login= +bow.preference.authentication.maxLength= bow.preference.authentication.maxlength= bow.preference.opensearch.prefix.separator=OpenSeach prefix separator bow.preferences.authentication= diff --git a/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties b/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties index f406c22..a93f8a5 100644 --- a/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties +++ b/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties @@ -95,6 +95,7 @@ bow.permanent.link.suggestionDescription=Lien permanent pour utiliser Bow comme bow.preference.authentication.exclude= bow.preference.authentication.include= bow.preference.authentication.login= +bow.preference.authentication.maxLength= bow.preference.authentication.maxlength= bow.preference.opensearch.prefix.separator=Separateur de préfix bow.preferences.authentication= diff --git a/bow-ui/src/main/webapp/WEB-INF/bowutils.tld b/bow-ui/src/main/webapp/WEB-INF/bowutils.tld index 68b88b2..3546f86 100644 --- a/bow-ui/src/main/webapp/WEB-INF/bowutils.tld +++ b/bow-ui/src/main/webapp/WEB-INF/bowutils.tld @@ -27,8 +27,20 @@ </function> <function> + <name>scriptletAdd</name> + <function-class>org.chorem.bow.BowUtils</function-class> + <function-signature>java.lang.String scriptletAdd(java.lang.String, java.lang.String)</function-signature> + </function> + + <function> <name>scriptletPassword</name> <function-class>org.chorem.bow.BowUtils</function-class> <function-signature>java.lang.String scriptletPassword(org.chorem.bow.BowAuthentication)</function-signature> </function> + + <function> + <name>scriptPassword</name> + <function-class>org.chorem.bow.BowUtils</function-class> + <function-signature>java.lang.String scriptPassword(org.chorem.bow.BowAuthentication)</function-signature> + </function> </taglib> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp index 3fd4041..75b4a87 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp @@ -34,6 +34,7 @@ <s:actionerror/> <div class="formFrame fond"> + <s:set var="bowUrl" value="config.bowUrl" /> <s:set var="permanentToken" value="bowSession.getPermanentToken()" /> <s:set var="temporaryToken" value="bowSession.getTemporaryToken()" /> <ul> @@ -62,16 +63,12 @@ </s:a> </li> <li> - <s:a title="%{getText('bow.rightMenu.bookmark.temporaryLinkDescription')}" - href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='%{config.bowUrl}addUrl.action?token=%{temporaryToken}&link='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(scr [...] - <s:text name="bow.rightMenu.bookmark.temporaryLink" /> - </s:a> + <s:text name="bow.rightMenu.bookmark.temporaryLink" /> + <a href="${u:scriptletAdd(bowUrl, temporaryToken)}">BowAddTemp</a> </li> <li> - <s:a title="%{getText('bow.rightMenu.bookmark.permanentLinkDescription')}" - href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='%{config.bowUrl}addUrl.action?token=%{permanentToken}&link='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(scr [...] - <s:text name="bow.rightMenu.bookmark.permanentLink" /> - </s:a> + <s:text name="bow.rightMenu.bookmark.permanentLink" /> + <a href="${u:scriptletAdd(bowUrl, permanentToken)}">BowAdd</a> </li> <li> <a href="extensions/bow4chromium.crx"> @@ -120,7 +117,11 @@ </div> <div class="formFrame fond"> - <h3><s:text name="bow.preferences.authentication"/> <a href="${u:scriptletPassword(bowAuth)}">BowPwd</a></h3> + <h3> + <s:text name="bow.preferences.authentication"/> + <a href="${u:scriptletPassword(bowAuth)}">BowPwd</a> + <a href="${u:scriptPassword(bowAuth)}" download="BowPwd.sh">BowPwd.sh</a> + </h3> <br/> <s:form action="updateAuthenticationPref" cssClass="pretty-form" method="post"> <s:textfield name="bowAuth.login" key="bow.preference.authentication.login" diff --git a/bow-ui/src/main/webapp/js/bowadd.js b/bow-ui/src/main/webapp/js/bowadd.js new file mode 100644 index 0000000..12d72c8 --- /dev/null +++ b/bow-ui/src/main/webapp/js/bowadd.js @@ -0,0 +1,36 @@ +/* + * #%L + * BOW UI + * %% + * Copyright (C) 2010 - 2015 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +window.bow = window.bow || {}; +window.bow.bowadd = window.bow.bowadd || function(bowUrl, token, forceEdit, redirectLink) { + var resume = document.title; + var description = ((window.getSelection && window.getSelection()) || (document.getSelection && document.getSelection()) || (document.selection && document.selection.createRange && document.selection.createRange().text)); + + if (description) { + resume = resume + "\n\n" + description; + } + location.href = bowUrl + '/addUrl.action?' + + 'token=' + token + + '&name=' + escape(resume) + + '&link=' + escape(location.href) + + '&forceEdit=' + !!forceEdit + + '&redirectLink=' + !!redirectLink; + ; +}; diff --git a/bow-ui/src/main/webapp/js/bowpwd.js b/bow-ui/src/main/webapp/js/bowpwd.js index 5d0651e..ef3ef58 100644 --- a/bow-ui/src/main/webapp/js/bowpwd.js +++ b/bow-ui/src/main/webapp/js/bowpwd.js @@ -1,3 +1,23 @@ +/* + * #%L + * BOW UI + * %% + * Copyright (C) 2010 - 2015 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ window.bow = window.bow || {}; window.bow.bowpwd = window.bow.bowpwd || function(hostname, maximum, prefix, include, exclude, suffix) { var e = document.activeElement; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm