1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 12:18:00 +01:00

fixed gu and gU

This commit is contained in:
Martin Stubenschrott
2007-05-01 00:19:18 +00:00
parent 635e4f5566
commit 7c16e5c969
3 changed files with 60 additions and 21 deletions

View File

@@ -97,7 +97,7 @@ release: ${XPI} ${RDF}
${RDF}: ${RDF_IN} Makefile ${RDF}: ${RDF_IN} Makefile
@echo "Preparing release..." @echo "Preparing release..."
${Q}${SED} -e "s,###VERSION###,${VERSION},g" \ ${Q}${SED} -e "s,###VERSION###,${VERSION},g" \
-e "s,###DATE###,${DATE},g" \ -e "s,###DATE###,${BUILD_DATE},g" \
< $< > $@ < $< > $@
@echo "SUCCESS: $@" @echo "SUCCESS: $@"
@@ -120,7 +120,7 @@ ${XPI}: ${BUILD_XPI_SUBDIRS} ${XPI_FILES}
done done
${Q}for f in ${XPI_TXT_FILES} ; do \ ${Q}for f in ${XPI_TXT_FILES} ; do \
${SED} -e "s,###VERSION###,${VERSION},g" \ ${SED} -e "s,###VERSION###,${VERSION},g" \
-e "s,###DATE###,${DATE},g" \ -e "s,###DATE###,${BUILD_DATE},g" \
< $$f > ${BUILD_XPI_DIR}/$$f ; \ < $$f > ${BUILD_XPI_DIR}/$$f ; \
( diff -q $$f ${BUILD_XPI_DIR}/$$f 1>/dev/null ) || \ ( diff -q $$f ${BUILD_XPI_DIR}/$$f 1>/dev/null ) || \
( echo "modified: $$f" ; \ ( echo "modified: $$f" ; \
@@ -138,7 +138,7 @@ ${JAR}: ${BUILD_JAR_SUBDIRS} ${JAR_FILES}
@echo "Building JAR..." @echo "Building JAR..."
${Q}for f in ${JAR_FILES} ; do \ ${Q}for f in ${JAR_FILES} ; do \
${SED} -e "s,###VERSION###,${VERSION},g" \ ${SED} -e "s,###VERSION###,${VERSION},g" \
-e "s,###DATE###,${DATE},g" \ -e "s,###DATE###,${BUILD_DATE},g" \
< $$f > ${BUILD_JAR_DIR}/$$f ; \ < $$f > ${BUILD_JAR_DIR}/$$f ; \
( diff -q $$f ${BUILD_JAR_DIR}/$$f 1>/dev/null ) || \ ( diff -q $$f ${BUILD_JAR_DIR}/$$f 1>/dev/null ) || \
( echo "modified: $$f" ; \ ( echo "modified: $$f" ; \

View File

@@ -81,14 +81,15 @@ var g_commands = [/*{{{*/
], ],
[ [
["bmadd"], ["bmadd"],
["bmadd [-tT] [url]"], ["bmadd [-tTk] [url]"],
"Add a bookmark", "Add a bookmark",
"If you don't add a custom title, either the title of the webpage or the URL will be taken as the title.<br/>" + "If you don't add a custom title, either the title of the webpage or the URL will be taken as the title.<br/>" +
"Tags WILL be some mechanism to classify bookmarks. Assume, you tag a url with the tags \"linux\" and \"computer\" you'll be able to search for bookmarks containing these tags.<br/>" + "Tags WILL be some mechanism to classify bookmarks. Assume, you tag a url with the tags \"linux\" and \"computer\" you'll be able to search for bookmarks containing these tags.<br/>" +
"You can omit the optional [url] field, so just do <code>:bmadd</code> to bookmark the currently loaded web page with a default title and without any tags.<br/>" + "You can omit the optional [url] field, so just do <code>:bmadd</code> to bookmark the currently loaded web page with a default title and without any tags.<br/>" +
"The following options WILL be interpretted in the future:<br/>" + " -t \"custom title\"<br/>" +
" -t 'custom title'<br/>" + "The following options will be interpreted in the future:<br/>" +
" -T comma,separated,tag,list <br/>", " -T comma,separated,tag,list <br/>"+
" -k keyword <br/>",
bmadd, bmadd,
null null
], ],
@@ -239,9 +240,9 @@ var g_commands = [/*{{{*/
"Multiple URLs can be separated with the | character.<br/>" + "Multiple URLs can be separated with the | character.<br/>" +
"Each |-separated token is analayzed and in this order:<br/>"+ "Each |-separated token is analayzed and in this order:<br/>"+
"<ol><li>Opened with the specified search engine if the token looks like a search string and the first word of the token is the name of a search engine (<code class=command>:open wiki linus torvalds</code> will open the wikipedia entry for linux torvalds).</li>"+ "<ol><li>Opened with the specified search engine if the token looks like a search string and the first word of the token is the name of a search engine (<code class=command>:open wiki linus torvalds</code> will open the wikipedia entry for linux torvalds).</li>"+
" <li>Transformed to a relative URL of the current location if it starts with . or .. or ...;<br/>... is special and goes to the moves up the directory hierarchy as far as possible.<br/>"+ " <li>Transformed to a relative URL of the current location if it starts with . or .. or ...;<br/>... is special and moves up the directory hierarchy as far as possible.<br/>"+
" <code class=command>:open ...</code> with current location <code>http://www.example.com/dir1/dir2/file.html</code> will open <code>http://www.example.com</code><br/>"+ "<ul><li><code class=command>:open ...</code> with current location <code>\"http://www.example.com/dir1/dir2/file.html\"</code> will open <code>\"http://www.example.com\"</code></li></li>"+
" <code class=command>:open ./foo.html</code> with current location <code>http://www.example.com/dir1/dir2/file.html</code> will open <code>http://www.example.com/dir1/dir2/foo.html</code></li>"+ "<li><code class=command>:open ./foo.html</code> with current location <code>\"http://www.example.com/dir1/dir2/file.html\"</code> will open <code>\"http://www.example.com/dir1/dir2/foo.html\"</code></li></ul></li>"+
" <li>Opened with the default search engine if the first word is no search engine (<code>:open linus torvalds</code> will open a google search for linux torvalds).</li>"+ " <li>Opened with the default search engine if the first word is no search engine (<code>:open linus torvalds</code> will open a google search for linux torvalds).</li>"+
" <li>Passed directly to Firefox in all other cases (<code class=command>:open www.osnews.com | www.slashdot.org</code> will open OSNews in the current, and Slashdot in a new background tab).</li></ol>"+ " <li>Passed directly to Firefox in all other cases (<code class=command>:open www.osnews.com | www.slashdot.org</code> will open OSNews in the current, and Slashdot in a new background tab).</li></ol>"+
"You WILL be able to use <code class=command>:open [-T \"linux\"] torvalds&lt;Tab&gt;</code> to complete bookmarks with tag \"linux\" and which contain \"torvalds\". Note that -T support is only available for tab completion, not for the actual command.<br/>"+ "You WILL be able to use <code class=command>:open [-T \"linux\"] torvalds&lt;Tab&gt;</code> to complete bookmarks with tag \"linux\" and which contain \"torvalds\". Note that -T support is only available for tab completion, not for the actual command.<br/>"+
@@ -1313,8 +1314,13 @@ function stringToURLs(str)
// first check if the first word is a search engine // first check if the first word is a search engine
var matches = urls[url].match(/^\s*(\w+)\s*(.*)/); var matches = urls[url].match(/^\s*(\w+)\s*(.*)/);
var alias = matches[1] || null; var alias = null;
var text = matches[2] || null; var text = null;
if (matches && matches[1])
alias = matches[1];
if (matches && matches[2])
text = matches[2];
if (alias) if (alias)
{ {
var engine = search_service.getEngineByAlias(alias); var engine = search_service.getEngineByAlias(alias);
@@ -1335,8 +1341,10 @@ function stringToURLs(str)
{ {
var default_engine = search_service.defaultEngine; var default_engine = search_service.defaultEngine;
if (default_engine) if (default_engine)
{
urls[url] = default_engine.getSubmission(urls[url], null).uri.spec; urls[url] = default_engine.getSubmission(urls[url], null).uri.spec;
continue; continue;
}
} }
@@ -1453,6 +1461,17 @@ function getCurrentLocation()
return content.document.location.href; return content.document.location.href;
} }
/* returns the current title or null */
function getCurrentTitle()
{
var titles = window.content.document.getElementsByTagName('title');
if (titles.length >= 1)
return titles[0];
else
return null;
}
function goUp(count) function goUp(count)
{ {
var gocmd = ""; var gocmd = "";
@@ -1502,12 +1521,18 @@ function bmadd(str)
if (parseBookmarkString(str, res)) if (parseBookmarkString(str, res))
{ {
if(res.url == null) if(res.url == null)
{
res.url = getCurrentLocation(); res.url = getCurrentLocation();
if(res.title == null) // XXX: maybe use current title of webpage // also guess title if the current url is :bmadded
if(res.title == null)
res.title = getCurrentTitle();
}
if(res.title == null) // title could still be null
res.title = res.url; res.title = res.url;
addBookmark(res.title, res.url); addBookmark(res.title, res.url);
echo("Bookmark `" + res.url + "' added"); echo("Bookmark `" + res.title + "' added with url `" + res.url + "'");
} }
else else
echo("Usage: :bmadd [-t \"My Title\"] [-T tag1,tag2] <url>"); echo("Usage: :bmadd [-t \"My Title\"] [-T tag1,tag2] <url>");

View File

@@ -228,14 +228,21 @@ function build_longest_common_substring(list, filter)/*{{{*/
var filtered = []; var filtered = [];
//var filter_length = filter.length; //var filter_length = filter.length;
//filter = filter.toLowerCase(); //filter = filter.toLowerCase();
var ignorecase = false;
if(filter == filter.toLowerCase())
ignorecase = true;
for (var i = 0; i < list.length; i++) for (var i = 0; i < list.length; i++)
{ {
for (var j = 0; j < list[i][0].length; j++) for (var j = 0; j < list[i][0].length; j++)
{ {
var item = list[i][0][j].toLowerCase(); var item = list[i][0][j];
if(ignorecase)
item = item.toLowerCase();
if (item.indexOf(filter) == -1) if (item.indexOf(filter) == -1)
continue; continue;
if (g_substrings.length == 0) if (g_substrings.length == 0)
{ {
//alert('if: ' + item); //alert('if: ' + item);
@@ -333,8 +340,10 @@ function filter_url_array(urls, filter)/*{{{*/
return [$_[0], $_[1]] return [$_[0], $_[1]]
}); });
var filter_length = filter.length; //var filter_length = filter.length;
filter = filter.toLowerCase(); var ignorecase = false;
if(filter == filter.toLowerCase())
ignorecase = true;
/* /*
* Longest Common Subsequence * Longest Common Subsequence
@@ -343,8 +352,13 @@ function filter_url_array(urls, filter)/*{{{*/
*/ */
for (var i = 0; i < urls.length; i++) for (var i = 0; i < urls.length; i++)
{ {
var url = urls[i][0].toLowerCase(); var url = urls[i][0];
var title = urls[i][1].toLowerCase(); var title = urls[i][1];
if(ignorecase)
{
url = url.toLowerCase();
title = title.toLowerCase();
}
if (url.indexOf(filter) == -1) if (url.indexOf(filter) == -1)
{ {
@@ -358,7 +372,7 @@ function filter_url_array(urls, filter)/*{{{*/
var url_length = url.length; var url_length = url.length;
for (var k = url.indexOf(filter); k != -1 && k <= last_index; k = url.indexOf(filter, k + 1)) for (var k = url.indexOf(filter); k != -1 && k <= last_index; k = url.indexOf(filter, k + 1))
{ {
for (var l = k + filter_length; l <= url_length; l++) for (var l = k + filter.length; l <= url_length; l++)
g_substrings.push(url.substring(k, l)); g_substrings.push(url.substring(k, l));
} }
} }