repo
string
commit
string
message
string
diff
string
swganh/mmoserverdb
d583198c24bbb1a08a00f857ebb3849ff919aa29
fixed an issue with houses missing the maintenance attributes, thus houses could not be redeeded
diff --git a/Server Scripts/structure_attribute_defaults.sql b/Server Scripts/structure_attribute_defaults.sql index a5ccb43..c635a21 100644 --- a/Server Scripts/structure_attribute_defaults.sql +++ b/Server Scripts/structure_attribute_defaults.sql @@ -1,156 +1,170 @@ -/* ---------------------------------------------------------------------------------------- -This source file is part of SWG:ANH (Star Wars Galaxies - A New Hope - Server Emulator) - -For more information, visit http://www.swganh.com - -Copyright (c) 2006 - 2010 The SWG:ANH Team ---------------------------------------------------------------------------------------- -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library 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 -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ---------------------------------------------------------------------------------------- -*/ - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; - -USE swganh; - --- --- Definition of table `structure_attribute_defaults` --- - -DROP TABLE IF EXISTS `structure_attribute_defaults`; -CREATE TABLE `structure_attribute_defaults` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `structure_type` int(10) unsigned NOT NULL, - `attribute_id` int(10) unsigned NOT NULL, - `attribute_value` varchar(128) NOT NULL, - `attribute_order` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8; - --- --- Dumping data for table `structure_attribute_defaults` --- - -/*!40000 ALTER TABLE `structure_attribute_defaults` DISABLE KEYS */; -INSERT INTO `structure_attribute_defaults` (`id`,`structure_type`,`attribute_id`,`attribute_value`,`attribute_order`) VALUES - (2,51,362,'1',4), - (3,51,383,'10',1), - (4,51,382,'0',2), - (5,51,381,'1000',3), - (8,41,382,'0',2), - (9,41,381,'3000',3), - (12,42,382,'0',2), - (13,42,381,'2000',3), - (16,43,382,'0',2), - (17,43,381,'2000',3), - (18,48,362,'1',4), - (19,48,383,'10',1), - (20,48,382,'0',2), - (21,48,381,'1000',3), - (22,49,362,'3',4), - (23,49,383,'30',1), - (24,49,382,'0',2), - (25,49,381,'3000',3), - (26,50,362,'2',4), - (27,50,383,'20',1), - (28,50,382,'0',2), - (29,50,381,'2000',3), - (30,52,362,'2',4), - (31,52,383,'20',1), - (32,52,382,'0',2), - (33,52,381,'2000',3), - (34,53,362,'3',4), - (35,53,383,'30',1), - (36,53,382,'0',2), - (37,53,381,'3000',3), - (38,54,362,'1',4), - (39,54,383,'10',1), - (40,54,382,'0',2), - (41,54,381,'1000',3), - (42,55,362,'2',4), - (43,55,383,'20',1), - (44,55,382,'0',2), - (45,55,381,'2000',3), - (46,56,362,'3',4), - (47,56,383,'30',1), - (48,56,382,'0',2), - (49,56,381,'3000',3), - (50,57,362,'1',4), - (51,57,383,'10',1), - (52,57,382,'0',2), - (53,57,381,'1000',3), - (54,58,362,'3',4), - (55,58,383,'30',1), - (56,58,382,'0',2), - (57,58,381,'3000',3), - (58,59,362,'2',4), - (59,59,383,'20',2), - (60,59,382,'0',2), - (61,59,381,'3000',2), - (62,60,362,'3',4), - (63,60,383,'30',1), - (64,60,382,'0',2), - (65,60,381,'1000',3), - (66,61,362,'1',4), - (67,61,383,'10',1), - (68,61,382,'0',2), - (69,61,381,'1000',3), - (70,62,362,'2',4), - (71,62,383,'20',1), - (72,62,382,'0',2), - (73,62,381,'2000',3), - (77,48,384,'2000',5), - (78,49,384,'2000',5), - (79,50,384,'2000',5), - (80,51,384,'2000',5), - (81,52,384,'2000',5), - (82,53,384,'2000',5), - (83,54,384,'2000',5), - (84,55,384,'2000',5), - (85,56,384,'2000',5), - (86,57,384,'2000',5), - (87,58,384,'2000',5), - (88,59,384,'2000',5), - (89,60,384,'2000',5), - (90,62,384,'2000',5), - (91,61,384,'2000',5), - (92,38,384,'2000',5), - (93,37,384,'2000',5), - (94,39,384,'2000',5), - (95,40,384,'2000',5), - (96,37,382,'0',2), - (97,38,382,'0',2), - (98,39,382,'0',2), - (99,40,382,'0',2); -/*!40000 ALTER TABLE `structure_attribute_defaults` ENABLE KEYS */; - - - - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +-- MySQL Administrator dump 1.4 +-- +-- ------------------------------------------------------ +-- Server version 5.1.36-community + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; + + +-- +-- Create schema swganh +-- + +CREATE DATABASE IF NOT EXISTS swganh; +USE swganh; + +-- +-- Definition of table `structure_attribute_defaults` +-- + +DROP TABLE IF EXISTS `structure_attribute_defaults`; +CREATE TABLE `structure_attribute_defaults` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `structure_type` int(10) unsigned NOT NULL, + `attribute_id` int(10) unsigned NOT NULL, + `attribute_value` varchar(128) NOT NULL, + `attribute_order` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=126 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `structure_attribute_defaults` +-- + +/*!40000 ALTER TABLE `structure_attribute_defaults` DISABLE KEYS */; +INSERT INTO `structure_attribute_defaults` (`id`,`structure_type`,`attribute_id`,`attribute_value`,`attribute_order`) VALUES + (2,51,362,'1',4), + (3,51,383,'10',1), + (4,51,382,'0',2), + (5,51,381,'1000',3), + (8,41,382,'0',2), + (9,41,381,'3000',3), + (12,42,382,'0',2), + (13,42,381,'2000',3), + (16,43,382,'0',2), + (17,43,381,'2000',3), + (18,48,362,'1',4), + (19,48,383,'10',1), + (20,48,382,'0',2), + (21,48,381,'1000',3), + (22,49,362,'3',4), + (23,49,383,'30',1), + (24,49,382,'0',2), + (25,49,381,'3000',3), + (26,50,362,'2',4), + (27,50,383,'20',1), + (28,50,382,'0',2), + (29,50,381,'2000',3), + (30,52,362,'2',4), + (31,52,383,'20',1), + (32,52,382,'0',2), + (33,52,381,'2000',3), + (34,53,362,'3',4), + (35,53,383,'30',1), + (36,53,382,'0',2), + (37,53,381,'3000',3), + (38,54,362,'1',4), + (39,54,383,'10',1), + (40,54,382,'0',2), + (41,54,381,'1000',3), + (42,55,362,'2',4), + (43,55,383,'20',1), + (44,55,382,'0',2), + (45,55,381,'2000',3), + (46,56,362,'3',4), + (47,56,383,'30',1), + (48,56,382,'0',2), + (49,56,381,'3000',3), + (50,57,362,'1',4), + (51,57,383,'10',1), + (52,57,382,'0',2), + (53,57,381,'1000',3), + (54,58,362,'3',4), + (55,58,383,'30',1), + (56,58,382,'0',2), + (57,58,381,'3000',3), + (58,59,362,'2',4), + (59,59,383,'20',2), + (60,59,382,'0',2), + (61,59,381,'3000',2), + (62,60,362,'3',4), + (63,60,383,'30',1), + (64,60,382,'0',2), + (65,60,381,'1000',3), + (66,61,362,'1',4), + (67,61,383,'10',1), + (68,61,382,'0',2), + (69,61,381,'1000',3), + (70,62,362,'2',4), + (71,62,383,'20',1), + (72,62,382,'0',2), + (73,62,381,'2000',3), + (77,48,384,'2000',5), + (78,49,384,'2000',5), + (79,50,384,'2000',5), + (80,51,384,'2000',5), + (81,52,384,'2000',5), + (82,53,384,'2000',5), + (83,54,384,'2000',5), + (84,55,384,'2000',5), + (85,56,384,'2000',5), + (86,57,384,'2000',5), + (87,58,384,'2000',5), + (88,59,384,'2000',5), + (89,60,384,'2000',5), + (90,62,384,'2000',5), + (91,61,384,'2000',5), + (92,38,384,'2000',5), + (93,37,384,'2000',5), + (94,39,384,'2000',5), + (95,40,384,'2000',5), + (96,37,382,'0',2), + (97,38,382,'0',2), + (98,39,382,'0',2), + (99,40,382,'0',2), + (100,63,382,'0',1), + (101,64,382,'0',1), + (102,65,382,'0',1), + (103,66,382,'0',1), + (104,67,382,'0',1), + (105,68,382,'0',1), + (106,69,382,'0',1), + (107,70,382,'0',1), + (108,71,382,'0',1), + (109,72,382,'0',1), + (110,73,382,'0',1), + (111,74,382,'0',1), + (112,75,382,'0',1), + (113,76,382,'0',1), + (114,77,382,'0',1), + (115,78,382,'0',1), + (116,79,382,'0',1), + (117,80,382,'0',1), + (118,81,382,'0',1), + (119,82,382,'0',1), + (120,83,382,'0',1), + (121,84,382,'0',1), + (122,85,382,'0',1), + (123,86,382,'0',1), + (124,87,382,'0',1), + (125,88,382,'0',1); +/*!40000 ALTER TABLE `structure_attribute_defaults` ENABLE KEYS */; + + + + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
swganh/mmoserverdb
c29161201f3e315ea4a9a851ebe07a19ffed2bd2
factories radials now are rebuild so changes to the factories status apply when a player cancels an ID session (ie the group is destroyed) the customer / Imagedesigner will no longer be flagged as still being in a valid session
diff --git a/Server Scripts/structure_terminal_link.sql b/Server Scripts/structure_terminal_link.sql index 0747aa6..3c03cdd 100644 --- a/Server Scripts/structure_terminal_link.sql +++ b/Server Scripts/structure_terminal_link.sql @@ -1,98 +1,98 @@ /* --------------------------------------------------------------------------------------- This source file is part of SWG:ANH (Star Wars Galaxies - A New Hope - Server Emulator) For more information, visit http://www.swganh.com Copyright (c) 2006 - 2010 The SWG:ANH Team --------------------------------------------------------------------------------------- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA --------------------------------------------------------------------------------------- */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; use swganh; -- -- Definition of table `structure_terminal_link` -- DROP TABLE IF EXISTS `structure_terminal_link`; CREATE TABLE `structure_terminal_link` ( `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `terminal_type` int(10) unsigned NOT NULL, `structure_type` int(10) unsigned NOT NULL, `cellId` int(10) unsigned NOT NULL, `x` float NOT NULL, `y` float NOT NULL, `z` float NOT NULL, `qx` float NOT NULL, `qy` float NOT NULL, `qz` float NOT NULL, `qw` float NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; -- -- Dumping data for table `structure_terminal_link` -- /*!40000 ALTER TABLE `structure_terminal_link` DISABLE KEYS */; INSERT INTO `structure_terminal_link` (`ID`,`terminal_type`,`structure_type`,`cellId`,`x`,`y`,`z`,`qx`,`qy`,`qz`,`qw`) VALUES - (1,29,83,1,0.6,0.6,6.15,0,1,0,0), - (2,29,86,0,3.7,0.6,6.15,0,1,0,0), - (3,29,87,0,0.6,0.6,6.15,0,1,0,0), - (4,29,63,0,0.6,0.6,6.15,0,1,0,0), - (5,29,64,0,0.6,0.6,8.7,0,0,0,1), - (6,29,65,3,0.6,0.6,6.15,0,1,0,0), - (7,29,66,3,0.6,0.6,6.15,0,1,0,0), - (8,29,67,3,0.6,0.6,6.15,0,1,0,0), - (9,29,68,3,0.6,0.6,6.15,0,1,0,0), - (10,29,69,3,0.6,0.6,6.15,0,1,0,0), - (11,29,70,3,0.6,0.6,6.15,0,1,0,0), - (12,29,71,3,0.6,0.6,6.15,0,1,0,0), - (13,29,72,3,0.6,0.6,6.15,0,1,0,0), - (14,29,73,3,0.6,0.6,6.15,0,1,0,0), - (15,29,74,3,0.6,0.6,6.15,0,1,0,0), - (16,29,75,3,0.6,0.6,6.15,0,1,0,0), - (17,29,76,3,0.6,0.6,6.15,0,1,0,0), - (18,29,77,3,0.6,0.6,6.15,0,1,0,0), - (19,29,78,3,0.6,0.6,6.15,0,1,0,0), - (20,29,79,3,0.6,0.6,6.15,0,1,0,0), - (21,29,80,3,0.6,0.6,6.15,0,1,0,0), - (22,29,81,3,0.6,0.6,6.15,0,1,0,0), - (23,29,82,3,0.6,0.6,6.15,0,1,0,0), - (24,29,84,1,8.0,0.6,11.0,0,1,0,0), - (25,29,85,3,0.6,0.6,6.15,0,1,0,0); + (1,29,83,1,0.6,0.5,6.15,0,1,0,0), + (2,29,86,0,3.7,0.5,6.15,0,1,0,0), + (3,29,87,0,0.6,0.5,6.15,0,1,0,0), + (4,29,63,0,0.6,0.5,6.15,0,1,0,0), + (5,29,64,0,0.6,0.5,8.7,0,0,0,1), + (6,29,65,3,0.6,0.5,6.15,0,1,0,0), + (7,29,66,3,0.6,0.5,6.15,0,1,0,0), + (8,29,67,3,0.6,0.5,6.15,0,1,0,0), + (9,29,68,3,0.6,0.5,6.15,0,1,0,0), + (10,29,69,3,0.6,0.5,6.15,0,1,0,0), + (11,29,70,3,0.6,0.5,6.15,0,1,0,0), + (12,29,71,3,0.6,0.5,6.15,0,1,0,0), + (13,29,72,3,0.6,0.5,6.15,0,1,0,0), + (14,29,73,3,0.6,0.5,6.15,0,1,0,0), + (15,29,74,3,0.6,0.5,6.15,0,1,0,0), + (16,29,75,3,0.6,0.5,6.15,0,1,0,0), + (17,29,76,3,0.6,0.5,6.15,0,1,0,0), + (18,29,77,3,0.6,0.5,6.15,0,1,0,0), + (19,29,78,3,0.6,0.5,6.15,0,1,0,0), + (20,29,79,3,0.6,0.5,6.15,0,1,0,0), + (21,29,80,3,0.6,0.5,6.15,0,1,0,0), + (22,29,81,3,0.6,0.5,6.15,0,1,0,0), + (23,29,82,3,0.6,0.5,6.15,0,1,0,0), + (24,29,84,1,8.0,0.5,12.0,0,1,0,0), + (25,29,85,3,0.6,0.5,6.15,0,1,0,0); /*!40000 ALTER TABLE `structure_terminal_link` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
swganh/mmoserverdb
7158999f170b36ef52b5a31838c3a8337064b71c
[MySQL] - Update - fix for the Mantis bug submission stored function
diff --git a/Server Scripts/Functions/sf_GetCSRTicketValues.sql b/Server Scripts/Functions/sf_GetCSRTicketValues.sql new file mode 100644 index 0000000..d764460 --- /dev/null +++ b/Server Scripts/Functions/sf_GetCSRTicketValues.sql @@ -0,0 +1,75 @@ +/* +--------------------------------------------------------------------------------------- +This source file is part of SWG:ANH (Star Wars Galaxies - A New Hope - Server Emulator) + +For more information, visit http://www.swganh.com + +Copyright (c) 2006 - 2010 The SWG:ANH Team +--------------------------------------------------------------------------------------- +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +--------------------------------------------------------------------------------------- +*/ + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; + +use swganh; +-- +-- Definition of function `sf_GetCSRTicketValues` +-- + +DROP FUNCTION IF EXISTS `sf_GetCSRTicketValues`; + +DELIMITER $$ + +/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER' */ $$ +CREATE DEFINER=`root`@`%` FUNCTION `sf_GetCSRTicketValues`(mSearchIn TEXT, mSearchFor TEXT) RETURNS char(32) CHARSET utf8 +BEGIN + + DECLARE mStart INT; + DECLARE mEnd INT; + DECLARE mLength INT; + DECLARE result CHAR(32); + + SELECT LENGTH(mSearchFor) INTO mLength; + SELECT LOCATE(mSearchFor, mSearchIn) INTO mStart; + + SET mStart = mStart + mLength; + + SELECT LOCATE('\n', mSearchIn, mStart) INTO mEnd; + + SELECT SUBSTR(mSearchIn, mStart, mEnd - mStart) INTO result; + + RETURN result; + +END $$ + +/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$ + +DELIMITER ; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; \ No newline at end of file diff --git a/Server Scripts/Functions/sf_NewTicketMantis.sql b/Server Scripts/Functions/sf_NewTicketMantis.sql index beb2469..66bb6d4 100644 --- a/Server Scripts/Functions/sf_NewTicketMantis.sql +++ b/Server Scripts/Functions/sf_NewTicketMantis.sql @@ -1,109 +1,109 @@ /* --------------------------------------------------------------------------------------- This source file is part of SWG:ANH (Star Wars Galaxies - A New Hope - Server Emulator) For more information, visit http://www.swganh.com Copyright (c) 2006 - 2010 The SWG:ANH Team --------------------------------------------------------------------------------------- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA --------------------------------------------------------------------------------------- */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; use swganh; -- -- Definition of function `sf_NewTicketMantis` -- -- Only for use on swganh.org TC since it requires Mantis to be present and installed -- DROP FUNCTION IF EXISTS `sf_NewTicketMantis`; DELIMITER $$ /*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='' */ $$ CREATE FUNCTION `sf_NewTicketMantis`(playerName TEXT, category INT, subCategory INT, ticketcomment TEXT, info TEXT, harrassing TEXT, lang CHAR(2), bugreport TINYINT(1)) RETURNS int(11) BEGIN DECLARE character_id BIGINT(20); DECLARE subcategory_id INT; DECLARE inserted INT; DECLARE mSeverity CHAR(32); DECLARE mRepeatable CHAR(32); DECLARE mLastMantisTextID INT; DECLARE mMantisCategory TEXT; DECLARE mMantisSeverity INT(2); DECLARE mMantisReproducability INT(2); SELECT id FROM characters WHERE characters.firstname = SUBSTRING_INDEX(playerName, ' ', 1) INTO character_id; SELECT csr_subcategories.subcategory_index FROM csr_subcategories WHERE (csr_subcategories.subcategory_id = subCategory) AND (csr_subcategories.category_id = category) INTO subcategory_id; INSERT INTO csr_tickets VALUES (NULL, subcategory_id, ticketcomment, info, harrassing, lang, bugreport, character_id, 0, 0, UNIX_TIMESTAMP()); ## ## Insert ticket into Mantis ## ## Get Ticket Severity SELECT sf_GetCSRTicketValues(ticketcomment, 'Severity: ') INTO mSeverity; IF mSeverity LIKE '%Crash%' THEN SET mMantisSeverity = 70; ELSEIF mSeverity LIKE '%Cannot%' THEN SET mMantisSeverity = 60; ELSEIF mSeverity LIKE '%Can be%' THEN SET mMantisSeverity = 50; ELSE SET mMantisSeverity = 50; END IF; ## Get Ticket Reproducability SELECT sf_GetCSRTicketValues(ticketcomment, 'Repeatable: ') INTO mRepeatable; IF mRepeatable LIKE '%No%' THEN SET mMantisReproducability = 90; ELSE SET mMantisReproducability = 10; END IF; ## Get Ticket Author INSERT INTO swganh_bugtracker2.mantis_bug_text_table VALUES (NULL, ticketcomment, '', ''); SELECT LAST_INSERT_ID() INTO mLastMantisTextID; SELECT name FROM swganh.csr_categories WHERE category_id = category INTO mMantisCategory; - INSERT INTO swganh_bugtracker2.mantis_bug_table VALUES (NULL, 17, character_id, 0, 0, 30, mMantisSeverity, mMantisReproducability, 10, 10, 10, mMantisCategory, NOW(), NOW(), 10, mLastMantisTextID, '', '', '', '', '', '', 0, 10, 'SWGANH - Game Submitted Bug', 0, 0, ''); + INSERT INTO swganh_bugtracker2.mantis_bug_table VALUES (NULL, 1, character_id, 0, 0, 30, mMantisSeverity, mMantisReproducability, 10, 10, 10, mMantisCategory, NOW(), NOW(), 10, mLastMantisTextID, '', '', '', '', '', '', 0, 10, 'SWGANH - Game Submitted Bug', 0, 0, ''); SELECT MAX(ticket_id) FROM csr_tickets INTO inserted; RETURN (inserted); END $$ /*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$ DELIMITER ; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; \ No newline at end of file
swganh/mmoserverdb
0a8760e37961323427becd0db2b37ee922e1fb2c
[MySQL] - Update - adding note about the mantis function for future reference
diff --git a/Mantis_README.txt b/Mantis_README.txt new file mode 100644 index 0000000..25bd86e --- /dev/null +++ b/Mantis_README.txt @@ -0,0 +1,9 @@ +In order to have the game directly submit bugs to mantis replace the contents of + +sf_NewTicket.sql + +with + +sf_NewTicketMantis.sql + +-- \ No newline at end of file
swganh/mmoserverdb
5e44f545b2302c256c731798d57b9bf75839517d
fixed an issue with incell- radials for tangible Objects the structure terminal for large tatooine houses now displays at the proper spot
diff --git a/Server Scripts/structure_terminal_link.sql b/Server Scripts/structure_terminal_link.sql index 465134f..0747aa6 100644 --- a/Server Scripts/structure_terminal_link.sql +++ b/Server Scripts/structure_terminal_link.sql @@ -1,98 +1,98 @@ -/* ---------------------------------------------------------------------------------------- -This source file is part of SWG:ANH (Star Wars Galaxies - A New Hope - Server Emulator) - -For more information, visit http://www.swganh.com - -Copyright (c) 2006 - 2010 The SWG:ANH Team ---------------------------------------------------------------------------------------- -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library 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 -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ---------------------------------------------------------------------------------------- -*/ - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; - -use swganh; - --- --- Definition of table `structure_terminal_link` --- - -DROP TABLE IF EXISTS `structure_terminal_link`; -CREATE TABLE `structure_terminal_link` ( - `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `terminal_type` int(10) unsigned NOT NULL, - `structure_type` int(10) unsigned NOT NULL, - `cellId` int(10) unsigned NOT NULL, - `x` float NOT NULL, - `y` float NOT NULL, - `z` float NOT NULL, - `qx` float NOT NULL, - `qy` float NOT NULL, - `qz` float NOT NULL, - `qw` float NOT NULL, - PRIMARY KEY (`ID`) -) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; - --- --- Dumping data for table `structure_terminal_link` --- - -/*!40000 ALTER TABLE `structure_terminal_link` DISABLE KEYS */; -INSERT INTO `structure_terminal_link` (`ID`,`terminal_type`,`structure_type`,`cellId`,`x`,`y`,`z`,`qx`,`qy`,`qz`,`qw`) VALUES - (1,29,83,1,0.6,0.7,6.15,0,1,0,0), - (2,29,86,0,3.7,0.7,6.15,0,1,0,0), - (3,29,87,0,0.6,0.7,6.15,0,1,0,0), - (4,29,63,0,0.6,0.7,6.15,0,1,0,0), - (5,29,64,0,0.6,0.7,8.7,0,0,0,1), - (6,29,65,3,0.6,0.7,6.15,0,1,0,0), - (7,29,66,3,0.6,0.7,6.15,0,1,0,0), - (8,29,67,3,0.6,0.7,6.15,0,1,0,0), - (9,29,68,3,0.6,0.7,6.15,0,1,0,0), - (10,29,69,3,0.6,0.7,6.15,0,1,0,0), - (11,29,70,3,0.6,0.7,6.15,0,1,0,0), - (12,29,71,3,0.6,0.7,6.15,0,1,0,0), - (13,29,72,3,0.6,0.7,6.15,0,1,0,0), - (14,29,73,3,0.6,0.7,6.15,0,1,0,0), - (15,29,74,3,0.6,0.7,6.15,0,1,0,0), - (16,29,75,3,0.6,0.7,6.15,0,1,0,0), - (17,29,76,3,0.6,0.7,6.15,0,1,0,0), - (18,29,77,3,0.6,0.7,6.15,0,1,0,0), - (19,29,78,3,0.6,0.7,6.15,0,1,0,0), - (20,29,79,3,0.6,0.7,6.15,0,1,0,0), - (21,29,80,3,0.6,0.7,6.15,0,1,0,0), - (22,29,81,3,0.6,0.7,6.15,0,1,0,0), - (23,29,82,3,0.6,0.7,6.15,0,1,0,0), - (24,29,84,3,0.6,0.7,6.15,0,1,0,0), - (25,29,85,3,0.6,0.7,6.15,0,1,0,0); -/*!40000 ALTER TABLE `structure_terminal_link` ENABLE KEYS */; - - - - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/* +--------------------------------------------------------------------------------------- +This source file is part of SWG:ANH (Star Wars Galaxies - A New Hope - Server Emulator) + +For more information, visit http://www.swganh.com + +Copyright (c) 2006 - 2010 The SWG:ANH Team +--------------------------------------------------------------------------------------- +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +--------------------------------------------------------------------------------------- +*/ + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; + +use swganh; + +-- +-- Definition of table `structure_terminal_link` +-- + +DROP TABLE IF EXISTS `structure_terminal_link`; +CREATE TABLE `structure_terminal_link` ( + `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `terminal_type` int(10) unsigned NOT NULL, + `structure_type` int(10) unsigned NOT NULL, + `cellId` int(10) unsigned NOT NULL, + `x` float NOT NULL, + `y` float NOT NULL, + `z` float NOT NULL, + `qx` float NOT NULL, + `qy` float NOT NULL, + `qz` float NOT NULL, + `qw` float NOT NULL, + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `structure_terminal_link` +-- + +/*!40000 ALTER TABLE `structure_terminal_link` DISABLE KEYS */; +INSERT INTO `structure_terminal_link` (`ID`,`terminal_type`,`structure_type`,`cellId`,`x`,`y`,`z`,`qx`,`qy`,`qz`,`qw`) VALUES + (1,29,83,1,0.6,0.6,6.15,0,1,0,0), + (2,29,86,0,3.7,0.6,6.15,0,1,0,0), + (3,29,87,0,0.6,0.6,6.15,0,1,0,0), + (4,29,63,0,0.6,0.6,6.15,0,1,0,0), + (5,29,64,0,0.6,0.6,8.7,0,0,0,1), + (6,29,65,3,0.6,0.6,6.15,0,1,0,0), + (7,29,66,3,0.6,0.6,6.15,0,1,0,0), + (8,29,67,3,0.6,0.6,6.15,0,1,0,0), + (9,29,68,3,0.6,0.6,6.15,0,1,0,0), + (10,29,69,3,0.6,0.6,6.15,0,1,0,0), + (11,29,70,3,0.6,0.6,6.15,0,1,0,0), + (12,29,71,3,0.6,0.6,6.15,0,1,0,0), + (13,29,72,3,0.6,0.6,6.15,0,1,0,0), + (14,29,73,3,0.6,0.6,6.15,0,1,0,0), + (15,29,74,3,0.6,0.6,6.15,0,1,0,0), + (16,29,75,3,0.6,0.6,6.15,0,1,0,0), + (17,29,76,3,0.6,0.6,6.15,0,1,0,0), + (18,29,77,3,0.6,0.6,6.15,0,1,0,0), + (19,29,78,3,0.6,0.6,6.15,0,1,0,0), + (20,29,79,3,0.6,0.6,6.15,0,1,0,0), + (21,29,80,3,0.6,0.6,6.15,0,1,0,0), + (22,29,81,3,0.6,0.6,6.15,0,1,0,0), + (23,29,82,3,0.6,0.6,6.15,0,1,0,0), + (24,29,84,1,8.0,0.6,11.0,0,1,0,0), + (25,29,85,3,0.6,0.6,6.15,0,1,0,0); +/*!40000 ALTER TABLE `structure_terminal_link` ENABLE KEYS */; + + + + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
swganh/mmoserverdb
0203d61cb5b1ce2335a62693e53bdfe1b52d1756
table name in houses.sql should be private to better reflect the bools use as a true will set the building to private Radials of creatureObjects (Players, Vehicles) are now reset after every useage the housefactories handleObjectready should not check for a valid client, as the query will never display a valid client - especially on startup fixed an issue with querying terminals, especially ticketterminals, were the nearest terminal was set in a faulty way and the distance check was not performed properly
diff --git a/Server Scripts/houses.sql b/Server Scripts/houses.sql index d4b1af9..a4c0cc5 100644 --- a/Server Scripts/houses.sql +++ b/Server Scripts/houses.sql @@ -1,63 +1,63 @@ /* --------------------------------------------------------------------------------------- This source file is part of SWG:ANH (Star Wars Galaxies - A New Hope - Server Emulator) For more information, visit http://www.swganh.com Copyright (c) 2006 - 2010 The SWG:ANH Team --------------------------------------------------------------------------------------- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA --------------------------------------------------------------------------------------- */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; use swganh; -- -- Definition of table `houses` -- DROP TABLE IF EXISTS `houses`; CREATE TABLE `houses` ( `id` bigint(22) unsigned NOT NULL AUTO_INCREMENT, - `public` int(10) unsigned NOT NULL, + `private` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `houses` -- /*!40000 ALTER TABLE `houses` DISABLE KEYS */; /*!40000 ALTER TABLE `houses` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
swganh/mmoserverdb
a0ec50a2c6955d3791152159f2e47cbe6d03534d
[MySQL] - Update - accounts added + hoonius + crazymiller + axler + johnshandy
diff --git a/Server Scripts/account.sql b/Server Scripts/account.sql index 4797e39..9d17cf4 100644 --- a/Server Scripts/account.sql +++ b/Server Scripts/account.sql @@ -1,271 +1,275 @@ /* --------------------------------------------------------------------------------------- This source file is part of SWG:ANH (Star Wars Galaxies - A New Hope - Server Emulator) For more information, visit http://www.swganh.com Copyright (c) 2006 - 2010 The SWG:ANH Team --------------------------------------------------------------------------------------- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA --------------------------------------------------------------------------------------- */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; use swganh; -- -- Definition of table `account` -- DROP TABLE IF EXISTS `account`; CREATE TABLE `account` ( `account_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Account ID', `username` char(32) NOT NULL default '' COMMENT 'Account username', `password` char(64) NOT NULL COMMENT 'Account password', `station_id` bigint(20) unsigned NOT NULL default '0' COMMENT 'Account STATION_ID', `csr` tinyint(1) NOT NULL default '0' COMMENT 'Account - CSR Flag', `banned` tinyint(1) NOT NULL default '0' COMMENT 'Account - Banned Status', `email` char(64) NOT NULL default '' COMMENT 'Account - User email', `joindate` datetime NOT NULL default '0000-00-00 00:00:00' COMMENT 'Account - Join Date', `lastlogin` timestamp NULL default NULL COMMENT 'Account - Last Login Timestamp', `active` tinyint(1) default NULL COMMENT 'Account - Active Flag', `loggedin` int(1) NOT NULL default '0' COMMENT 'Account - Cluster id account is logged into', `authenticated` tinyint(1) NOT NULL default '0' COMMENT 'Account - Authenticated Status', `characters_allowed` tinyint(3) unsigned NOT NULL default '2', `session_key` varchar(32) default NULL, PRIMARY KEY (`account_id`), UNIQUE KEY `username` (`username`) ) ENGINE=InnoDB AUTO_INCREMENT=145 DEFAULT CHARSET=utf8; -- -- Dumping data for table `account` -- /*!40000 ALTER TABLE `account` DISABLE KEYS */; INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (1,'rouse','24d08e080faa85645fd81fb664d04c04d2c8fb50',100000001,2,0,'[email protected]','2007-01-19 00:00:00','2009-09-17 23:03:28',1,0,0,2,'8e77b76fe4fdb6e694b114ded06c75e6'), (2,'spety','dedf80b32567e17671925e514a8c5d7e26c75a99',100000002,2,0,'[email protected]','2007-01-19 00:00:00','2008-02-12 02:27:29',1,0,0,2,NULL), (3,'ketusringa','4cd6be19b0c56fccf3f35d4ba2677f94751f9b06',100000003,2,0,'[email protected]','2007-01-19 00:00:00','2008-05-29 18:00:51',1,0,0,2,'4c6c7c3ca367f5fe492c614524f7ca3a'), (4,'schmunzel','5c74bd74fe1d5ef454282415040c16df3f2306e9',100000004,2,0,'[email protected]','2007-01-19 00:00:00','2009-10-19 18:44:25',1,0,0,2,NULL), (5,'ready','75c0533730caf1f78561c0883fb87bc8d98ef04b',100000005,2,0,'[email protected]','2007-01-19 00:00:00','2009-09-19 08:38:57',1,0,0,2,'7d3373140687c27bd7a4f9f4aa6c63a5'), (6,'xeno','bcb4e151133f13fff6edd64dfacfe1a84dd59aa0',100000006,2,0,'[email protected]','2007-01-19 00:00:00','2007-03-09 00:43:39',1,0,0,2,NULL); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (7,'htx','3906524c2e109c44dd6daa1ad3cad6d708cd5be3',100000007,2,0,'[email protected]','2007-01-19 00:00:00','2008-10-10 19:02:45',1,0,0,2,NULL), (8,'narook','3cbbd500c1701e804fd73534a737e595e647dce7',100000008,2,0,'[email protected]','2007-01-19 00:00:00','2009-07-12 04:35:07',1,0,0,2,NULL), (9,'jack','596727c8a0ea4db3ba2ceceedccbacd3d7b371b8',100000009,2,0,'[email protected]','2007-01-19 00:00:00','2008-10-10 15:45:12',1,0,0,2,NULL), (10,'xunil','15e479d3dffb3674f5848c8349439612bd9cb11c',100000010,0,0,'[email protected]','2007-01-19 00:00:00','2007-02-19 00:00:00',1,0,0,2,NULL), (11,'jay','8bfd13cad0bc4b2ac41d9e235951e72c9b62c2aa',100000011,2,0,'[email protected]','2007-01-19 00:00:00','2009-10-14 02:24:26',1,0,0,2,NULL), (12,'tmr','b5b369bdc5e23bce7d241a763857b16bdff61cdb',100000012,2,0,'[email protected]','2007-01-19 00:00:00','2009-10-15 11:09:30',1,0,0,2,'0e5a9987f8d72b7a5ee1416933e14ff1'), (13,'snow','b94e9f3d7e001981b2dd49f2a70822a8ac8f3e68',100000013,2,0,'[email protected]','2007-01-19 00:00:00','2009-10-19 20:34:09',1,0,0,2,'4fa657c25722ae72c0c2e90334c76b7c'); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (14,'yosh','1443bccc73f4a523b6dc65d81743d030e55316b0',100000014,2,0,'[email protected]','2007-01-03 00:00:00','2008-04-17 10:02:40',1,0,0,2,NULL), (15,'exca','5fbec650f6eb9280c4d5b892a5cf82afc35419d5',100000015,2,0,'[email protected]','2007-01-09 00:00:00','2008-05-29 21:48:55',1,0,0,2,NULL), (16,'mugly','f195b0bd72bc95b960e58204abaefdbd2012b950',100000016,2,0,'[email protected]','2007-01-28 00:00:00','2009-10-19 15:05:15',1,0,0,2,NULL), (17,'meanmon','8989ba27cadd33f8a6721da50d916f5803910d17',100000017,2,0,'[email protected]','2007-01-28 00:00:00','2009-08-28 18:01:14',1,0,0,2,'cc634bdebc510a3d6cebe2cb8d835419'), (18,'natakiya','4324456319ffd1b7b1a243512ae111efbbec50fa',100000018,2,0,'[email protected]','2007-01-28 00:00:00','2007-03-09 04:40:07',1,0,0,2,NULL), (19,'wyz','35b44e03b3991ffd063b439d5518adb5bf86b2cc',100000019,2,0,'[email protected]','2007-06-04 20:00:11','2009-03-08 22:00:20',1,0,0,2,NULL), (20,'pope','b29488f0e58b98c8f1d82f8a5bf714f99ed0ca57',100000020,2,0,'[email protected]','0000-00-00 00:00:00','2009-06-30 20:17:18',1,0,0,2,NULL); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (21,'Ramakin','092e2ed0645918fafd448496de03af3745785095',100000021,2,0,'[email protected]','0000-00-00 00:00:00','2008-05-28 01:38:15',1,0,0,2,'d42ce54e315fe68353fbcbd8c5e9e344'), (22,'Nelk','e4eea39cdb5f8a57cd1a4e93ab31cba1d5edc3f3',100000022,2,0,'[email protected]','0000-00-00 00:00:00','0000-00-00 00:00:00',1,0,0,2,''), (23,'Vidi','48432aaa6de6d34764e6036fedc1d56f8303db85',100000023,2,0,'[email protected]','0000-00-00 00:00:00','2009-03-30 19:46:16',1,0,0,2,NULL), (24,'sostrata','42472a47c436170601e2a5cb249fc2c83c6f4fc5',100000024,2,0,'[email protected]','0000-00-00 00:00:00','2009-10-19 17:20:15',1,0,0,2,NULL), (25,'cieto','ac9553b16639c9097d61e9b5b533c42a312fe297',100000025,2,0,'[email protected]','2007-06-07 17:02:43','2008-02-19 18:14:10',1,0,0,2,NULL), (26,'starko','67e29e1fd6e5b48e6e4b0de0831d978f7c854a16',100000026,2,0,'[email protected]','2007-06-07 17:02:42','2008-02-13 02:17:10',1,0,0,2,NULL), (27,'lloydyboy','42d80cba231ea3120ee36b8843b111a22dad8cff',100000027,2,0,'[email protected]','2007-06-07 17:02:43','2009-01-26 14:52:01',1,0,0,2,NULL); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (28,'eruptor','732ca0f9f8987163f8b0b9400241cfb77d21a65a',100000028,2,0,'[email protected]','2007-06-07 17:02:43','2009-09-23 11:28:53',1,0,0,2,NULL), (29,'dante','3e56e6a43d0de25d89f59e6ee90b13c57e01da64',100000029,2,0,'[email protected]','2007-06-07 17:02:43','2007-07-12 02:48:09',1,0,0,2,NULL), (30,'ravenlock','e6554293277946225f682186d9d1fa5b857f5f1f',100000030,2,0,'[email protected]','2007-06-07 17:02:43','2007-07-12 02:48:09',1,0,0,2,NULL), (31,'ferrin','e6451e36b32f9a5102ffcf69e3107667db3d529f',100000031,0,0,'[email protected]','0000-00-00 00:00:00','2008-06-03 02:46:51',1,0,0,2,'d640b1ce99a4938cde71fa32a97cc2c9'), (32,'hal','094022e39fb0c633090647448c9c2d3014d34274',100000032,0,0,'[email protected]','2007-08-22 00:00:00','2008-05-14 06:59:15',1,0,0,2,NULL), (33,'owen','d9a42a1e92a151c31de33f20009594d036ab3615',100000033,2,0,' [email protected]','2009-08-20 21:28:48','2009-09-03 12:55:47',1,0,0,2,''), (34,'vostromus','25c947262b916d206cf623ff878dded9c8da60b0',100000034,2,0,'[email protected]','2009-10-11 14:44:52','2009-10-14 22:51:29',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (35, 'Machine1020','82ccc6b45a69f7de9f833996894734ab2064e0c2',100000035,2,0,'[email protected]','2009-10-12 10:47:02','2009-10-15 17:25:19',1,0,0,2,''), (36, 'apathy', '2bc4e9268958e0078398a912710e04d26f7cd419', 100000036, 2, 0, '[email protected]', '2009-10-19 22:11:41', '2009-10-29 07:27:32', 1, 0, 0, 2, ''), (37, 'Valkyra', 'c1f4de4cf474e1e6d22cadaa1f68daba7e0cd2dc', 100000037, 2, 0, '[email protected]', '2010-02-15 17:02:46', '2010-02-15 17:02:46', 1, 0, 0, 2, ''), (38, 'firewarrior','e04e3ef576e5c581de0671a0970c283a6cda035e',999990502,1,0,'[email protected]','2010-02-13 15:41:29','2010-02-16 18:35:52',1,0,0,1,NULL), (39, 'powerking', '8b58ed1ed75e6f134f27ae7e9b43bb9fc96d93c9', 999990503, 2, 0, '[email protected]', '2010-02-20 14:07:06', '2010-02-20 14:07:06', 1, 0, 0, 1, ''), (100,'Ackob','85f51c18b746b1034fc4642f592fa882362feb9c',111111100,0,0,'[email protected]','2008-05-12 00:00:00','2008-11-09 12:52:20',1,0,0,2,'0c5368341bdd90606449f42b1a755c36'), (101,'agestee','812b29aad1bad88767d781f1e7e55f898dab8ed3',111111101,0,0,'[email protected]','2007-05-20 03:24:20','2008-06-04 12:13:44',1,0,0,2,NULL), (104,'diezen','ec38f3fe6dd0850fef8c01ab6dd95021f3e58072',111111104,0,0,'[email protected]','2007-06-07 17:02:43','2009-10-14 09:56:56',1,0,0,2,NULL), (105,'ernie','65b1d89c9efba00fcc5d74bb84e61f59d6bbf961',111111105,0,0,'[email protected]','2007-06-07 17:02:43','2009-04-05 13:51:16',1,0,0,2,NULL), (106,'FEDS91','2d46473c3cf6f929e7830b8251f0dc6a3f6d0e47',111111106,0,0,'[email protected]','2007-06-25 18:52:34','2008-05-28 10:50:48',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (107,'gohma','75d90b9e9258743f6f3fa0cbc5e9c138e0309f8d',111111107,0,0,'[email protected]','2007-06-07 17:02:43','2008-09-24 07:56:04',1,0,0,2,'2520d81daabb75110adcf601105692f8'), (108,'joekiffer','0595385394dd0f29abb9550aa81b2ce4a5f89be6',111111108,0,0,'[email protected]','2007-05-20 03:24:20','2008-06-01 13:26:07',1,0,0,2,'1ff39b8751e99b2e81515611148f5939'), (109,'ka-wiz','14523c7c1717361c4bcfce5cc902630c23899433',111111109,0,0,'[email protected]','2007-06-25 18:52:34','2008-10-10 21:38:51',1,0,0,2,'83e7c93cb3840aec8d739b4e9039be70'), (110,'karyfars','537ed22f5969568ad6b7c651d4766fe6e708ae32',111111110,0,0,'[email protected]','2007-05-20 03:24:20','2009-08-03 14:54:28',1,0,0,2,'324198b0ac06047bcdba4cb8bfd0eed8'), (111,'kiithwarrior','71a0aeb998b2131169826d8d60c44b82d5432601',111111111,0,0,'[email protected]','2007-06-07 17:02:43','2007-08-16 16:21:13',1,0,0,2,NULL), (112,'mirasa','763aee563496b994063237a7b4d610f68da92e0b',111111112,0,0,'[email protected]','2007-08-22 00:00:00','2008-05-31 22:04:24',1,0,0,2,'ecb2c322b62a8a9929834c27fa1411a0'); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (114,'netrex','d93e06f145c48753f1d154c8600083d4efbc0e93',111111114,0,0,'[email protected]','2007-01-05 00:00:00','2009-10-12 13:55:59',1,0,0,2,'32b19c03948307a7eb48c1c8cc908c87'), (115,'praxi','00735fc07b190eb9ec2f00892ee3f5b5c5aae6c0',111111115,0,0,'[email protected]','0000-00-00 00:00:00','2008-02-29 18:12:33',1,0,0,2,''), (116,'riverins','2cebe3e4c8274256ae7338876787966f37b2e957',111111116,0,0,'[email protected]','0000-00-00 00:00:00','2008-09-01 00:07:25',1,0,0,2,'75e2ad3f58812cca4a01c3395308d50d'), (117,'scinis','d8b0c429239dc957c875c01e54bd3a87ecdbd0fa',111111117,0,0,'[email protected]','2007-01-19 00:00:00','2009-08-02 20:06:22',1,0,0,0,NULL), (118,'Silent-X','3995a361f62f0ea85f93d1d589b213d1a0f543d1',111111118,0,0,'[email protected]','0000-00-00 00:00:00','2008-10-06 15:37:09',1,0,0,2,NULL), (119,'stevewitt76','264fbeb92f8dfb13441d446a151bbc5fbd9d8683',111111119,0,0,'[email protected]','0000-00-00 00:00:00','2008-05-14 19:59:35',1,0,0,2,NULL); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (120,'taswavo','d7d0e56ca0116cd462e336add9550658d8fc5979',111111120,0,0,'[email protected]','2007-06-04 20:02:09','2008-11-20 15:00:55',1,0,0,2,'44bb28b731aa93cb56a1cce299743d44'), (121,'teko','8d1772e4731155086e82a555468b45fc2c350d1f',111111121,0,0,'[email protected]','2008-05-12 00:00:00','2008-05-26 20:41:26',1,0,0,2,'40559490d0ca1c7e43b0a4a05ba4ec77'), (122,'tomcat','8b480686e529e1edda5475859b65f50b398e90f8',111111122,0,0,'[email protected]','0000-00-00 00:00:00','2009-10-18 12:29:27',1,0,0,2,'c824575c346d122b3dc6138ec48e05ff'), (124,'zorkhea','ec38f3fe6dd0850fef8c01ab6dd95021f3e58072',111111124,0,0,'[email protected]','2007-06-07 17:02:43','2008-10-03 14:28:11',1,0,0,2,'2f2f67540c32add4f0621ba0883b74ba'), (125,'SaderBiscut','7b9944da2d19c787acd5b5d00ea5ec0a4df9a6b0',111111125,0,0,'[email protected]','2008-09-24 18:29:18','2008-09-30 22:25:34',1,0,0,2,NULL), (126,'nebula','5403662684fd509c23208b88e1cba41330411d73',111111126,0,0,'[email protected]','2008-09-28 16:11:31','2009-04-04 13:29:24',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (127,'MasterBlaster','5bc0125afb713d3665cc529d1bb8d7df8c354dc9',111111127,0,0,'[email protected]','2008-09-28 16:11:31','2008-09-28 16:11:31',1,0,0,2,''), (128,'MandaloreVerdo','f71b47e5f8be4c6e31dad9f5bb646b0d544b5a90',111111128,0,0,'[email protected]','2008-09-28 16:11:31','2008-09-28 16:11:31',1,0,0,2,''), (129,'Rigphoria','af8d3998cda32310afc2b0f0cca843356004ce1f',111111129,0,0,'[email protected]','2008-09-28 16:11:31','2009-03-08 20:26:31',1,0,0,2,''), (130,'Raeche','1a6d32f09b14f7fbef817c26970450a2d24baae1',111111130,0,0,'[email protected]','2008-09-28 16:11:31','2009-04-06 08:31:08',1,0,0,2,''), (131,'Vanderbilt','7eef6873b826371e29fd8b06775904528d987f7d',111111131,0,0,'[email protected]','2008-10-02 23:33:32','2009-01-20 14:30:34',1,0,0,2,''), (132,'ironsight','e38a5cde6da526c0621d154b2a6518369d76d511',111111132,0,0,'[email protected]','2008-10-02 23:33:32','2008-10-24 16:41:03',1,0,0,2,''), (133,'Slyyke','b68296e3391c8b2aa87041a6295d20e239036f45',111111133,0,0,'[email protected]','2008-10-02 23:33:32','2008-10-02 23:33:32',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (134,'CrazyCarlton','07fad9b8cabe0f47927c90b11909bd5fc77a7f06',111111134,0,0,'[email protected]','2008-10-04 19:31:43','2008-10-05 15:22:32',1,0,0,2,''), (135,'Calael','3253fa0caf041bdba22c2e4919682ecf4c61e2e8',111111135,0,0,'[email protected]','2008-10-04 19:31:43','2008-10-10 23:42:43',1,0,0,2,''), (136,'Uberman','94879c6fc041e706f29b6a20ab64072a98b66393',111111136,0,0,'[email protected]','2008-10-04 19:31:43','2008-10-05 13:04:03',1,0,0,2,''), (137,'Lunchbox','7e9cb31c6bca8ad037cdc882a15efd999ef3316a',111111137,0,0,'[email protected]','2008-10-04 19:31:43','2008-10-21 20:51:21',1,0,0,2,''), (138,'Amen','c24e9df697f908c683546c2c8a27a66a7592dcb2',111111138,0,0,'[email protected]','2008-10-04 23:50:25','2008-10-25 11:14:12',1,0,0,2,''), (139,'Sahara','c24e9df697f908c683546c2c8a27a66a7592dcb2',111111139,0,0,'[email protected]','2008-10-04 23:50:25','2008-10-22 11:38:15',1,0,0,2,''), (140,'Iasrokaf','642cefddf45e7407dd470c1a90d5d35d23a7bcc3',111111140,0,0,'[email protected]','2008-10-09 21:54:11','2008-10-10 22:51:44',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (141,'Kaeyll','5208f4e39a446da09dc88e4fbaff71985b773a22',111111141,0,0,'[email protected]','2008-10-09 21:54:11','2008-10-10 10:52:06',1,0,0,2,''), (142,'facehead360','8eff8967e51da8c02e5adaff6e59219f55964cc3',111111142,0,0,'[email protected]','2008-10-10 22:55:17','2008-10-10 22:55:39',1,0,0,2,''), (143,'biohazard','bcc50443316b83988742c4cc7127f8712829a255',111111143,0,0,'[email protected]','2008-10-11 21:51:14','2008-10-13 15:26:26',1,0,0,2,''), (144,'aeludor','844ca232460f6798468af3cc5816fdef19004544',111111144,0,0,'[email protected]','2008-10-12 20:46:40','2008-10-13 09:20:46',1,0,0,2,''), (145,'ousely','cd575264346679ea545a73c364a01cfa3c20d98f',111111145,0,0,'[email protected]','2008-10-24 19:24:54','2009-07-24 18:34:28',1,0,0,2,''), (146,'nicventura','0ee8343bca2245d4783de55217955e787207d934',111111146,0,0,'[email protected]','2008-10-24 18:50:54','2008-10-24 18:50:54',1,0,0,2,''), (147,'gumbybacca','3ddf904ea656c6446c5c4e0fb624119abf287421',111111147,0,0,'[email protected]','2008-10-24 18:50:54','2008-11-06 15:13:56',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (148,'ruzan','05010c45bcc0589244e056044134874c2f5f0572',111111148,0,0,'[email protected]','2008-10-24 18:50:54','2008-10-24 18:50:54',1,0,0,2,''), (149,'temploiter','5f423624bcee2ea22495b8a2b1602628259e57ec',111111149,0,0,'[email protected]','2008-10-24 18:50:54','2009-04-10 15:10:57',1,0,0,2,''), (150,'ernie247','ba0ec1f9b8c715d7e6644b5bf766cd8243d7dd4d',111111150,0,0,'[email protected]','2008-10-25 11:40:03','2008-10-25 11:40:03',1,0,0,2,''), (151,'Tiri','24d08e080faa85645fd81fb664d04c04d2c8fb50',111111151,0,0,'[email protected]','2008-11-07 04:43:00','2008-11-25 18:37:39',1,0,0,2,NULL), (152,'experiment13','cd4ef128d6396477cdeb1f17a8b042d2fb2beea6',111111152,0,0,'[email protected]','2008-11-18 22:06:28','2009-01-15 20:32:10',1,0,0,2,''), (153,'richie','f901c7dd326d29361df7a854ec0a2ad2f5e221d8',111111153,0,0,'[email protected]','2008-11-18 22:06:28','2008-11-18 22:06:28',1,0,0,2,''), (154,'chewpekka','ee17b55d63f2c31019d6f0b101e1ef324e2b9f7a',111111154,0,0,'[email protected]','2008-11-18 22:06:28','2008-11-24 19:02:49',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (155,'suran37','21e5c307280557707a0358406da525f32b66b73f',111111155,0,0,'[email protected]','2008-11-18 22:06:28','2008-11-18 22:06:28',1,0,0,2,''), (156,'craven938','c6657332956494fd9548f546722a515c98dc142c',111111156,0,0,'[email protected]','2008-11-18 22:06:28','2008-11-18 22:06:28',1,0,0,2,''), (157,'arrius','4cf4b0fc05c7bf964919c0b24630c39091d286f1',111111157,0,0,'[email protected]','2008-11-18 22:06:28','2008-11-18 22:06:28',1,0,0,2,''), (158,'obi-two','172f7c3cb3dfdda62c5076e7f231da7fc3bde3b8',111111158,0,0,'[email protected]','2008-11-18 22:06:28','2009-10-03 07:15:59',1,0,0,2,''), (159,'kingsinner','36d40257794a418053aa1bcf3edbb724db8c6396',111111159,0,0,'[email protected]','2008-12-13 12:06:20','2008-12-17 16:24:04',1,0,0,2,''), (160,'revan','f2f7d2a4e7c1d1fcc4ef7e7968586c99aade8b5b',111111160,0,0,'[email protected]','2008-12-13 12:06:23','2009-07-07 21:44:34',1,0,0,2,''), (161,'rynnn','c05d8f448e25d8039e914aaeea38c8c426c722dd',111111161,0,0,'[email protected]','2008-12-13 12:06:24','2008-12-15 12:06:06',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (162,'sostrata2','42472a47c436170601e2a5cb249fc2c83c6f4fc5',111111162,2,0,'[email protected]','0000-00-00 00:00:00','2009-08-30 09:34:23',1,0,0,2,''), (163,'Tiri2','24d08e080faa85645fd81fb664d04c04d2c8fb50',111111163,0,0,'[email protected]','2008-11-07 04:43:00','2008-12-12 21:20:33',1,0,0,2,''), (164,'tomcat2','8b480686e529e1edda5475859b65f50b398e90f8',111111164,0,0,'[email protected]','0000-00-00 00:00:00','2008-12-13 11:52:01',1,0,0,2,''), (165,'obi-two2','172f7c3cb3dfdda62c5076e7f231da7fc3bde3b8',111111165,0,0,'[email protected]','2008-11-18 22:06:28','2009-01-18 13:18:05',1,0,0,2,''), (166,'hinch','58782add558f76d0e53f70872851eeacc41ddc4e',111111166,2,0,'[email protected]','2009-01-02 14:24:46','2009-03-09 15:17:00',1,0,0,2,''), (167,'ootini','bde555f28e962d7e4e1231eca033e390e0863b57',100000167,0,0,'[email protected]','2009-01-09 14:45:36','2009-01-16 22:55:13',1,0,0,2,''), (168,'boab','497f02302834c19a02c8e62cc996ae41790baa13',100000168,0,0,'[email protected]','2009-01-09 14:45:39','2009-01-14 19:25:47',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (169,'slidey','fd85b509f55d055071c3fd98d6c46284a70b7268',100000169,2,0,'[email protected]','2009-01-09 14:45:41','2009-01-09 14:45:41',1,0,0,2,''), (170,'flas','832569abf7e3355aabdfd86c4299437d2654a31d',111111170,0,0,'[email protected]','2008-12-22 14:31:36','2009-09-22 19:43:17',1,0,0,2,''), (171,'oica','ce9d7ff65e51caeaf13f0d755002ad60b77cb384',111111171,0,0,'[email protected]','2008-12-22 14:31:53','2008-12-22 14:31:53',1,0,0,2,''), (172,'arokh','eb0da3ad5ec9bf1eeacfa4ab434c0d405c99657c',111111172,0,0,'[email protected]','2008-12-22 14:32:09','2008-12-22 14:32:09',1,0,0,2,''), (173,'swganh','41d14978522cc50b70e73f6f0007e82a000a95d5',111111173,0,0,'swganh','2009-01-02 11:07:22','2009-01-02 11:07:22',1,0,0,2,''), (174,'audune','2ecd5c0896ab646f5b01fcb44eafb67a9d568e1b',111111174,0,0,'[email protected]','2009-01-28 19:33:03','2009-01-28 22:34:41',1,0,0,2,''), (175,'Eikokai','f58c9eccfbe9a18a24eba27fbef70f6084f44a52',111111175,0,0,'[email protected]','2009-02-04 17:39:19','2009-02-21 20:20:16',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (176,'argivo','3e2573a75821576a00dae928f8a77e35ef60e176',111111176,0,0,'[email protected]','2009-02-05 18:33:18','2009-09-22 19:27:13',1,0,0,2,''), (177,'wombatula','3b2b153ee277efaa333bcba4a096d4f2bd0e7379',111111177,0,0,'[email protected]','2009-02-05 19:13:52','2009-02-05 19:13:52',1,0,0,2,''), (178,'arrev','4303f59222a783cd96605d3765b3979454773e5d',111111178,0,0,'[email protected]','2009-02-11 18:06:41','2009-02-12 18:02:28',1,0,0,2,''), (179,'hrvoje','ac542190acb9581f0d0ccfc57b016154c73add90',111111179,0,0,'[email protected]','2009-02-12 17:10:24','2009-02-18 11:30:07',1,0,0,2,''), (180,'hakry','9ff3e04a14876beec13f6b49aecad0bc2505f4e5',111111180,0,0,'[email protected]','2009-02-15 04:56:08','2009-09-16 01:26:09',1,0,0,2,''), (181,'electricnexus','e6b6afbd6d76bb5d2041542d7d2e3fac5bb05593',111111181,0,0,'[email protected]','2009-02-15 04:56:08','2009-02-22 06:40:59',1,0,0,2,''), (182,'samuel','d3f5e5fb1152e4cdd518a75f018bf87d00b00c98',111111182,0,0,'[email protected]','2009-02-18 02:31:36','2009-03-12 12:11:39',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (183,'argivo2','3e2573a75821576a00dae928f8a77e35ef60e176',111111183,0,0,'[email protected]','2009-02-18 02:31:41','2009-09-22 19:27:34',1,0,0,2,''), (184,'jacku','f9da6cf84f279f992462706b15b21f8c38d8d702',111111184,0,0,'[email protected]','2009-02-22 00:02:35','2009-08-18 22:19:49',1,0,0,2,''), (185,'yosie','b26cd3905e2e5418996e77a312a4fcd17fa5dfc5',111111185,0,0,'[email protected]','2009-03-11 18:54:21','2009-07-20 10:41:02',1,0,0,2,''), (186,'washproof','c033e563ac341c2420484652180f256d0de4bd26',111111186,0,0,'[email protected]','2009-03-19 14:18:44','2009-03-19 14:18:44',1,0,0,2,''), (187,'renagade','82a25775c47ed3cf2b9fad67f92ff3088da2ba19',111111187,0,0,'[email protected]','2009-03-31 19:10:00','2009-04-10 00:25:01',1,0,0,2,''), (188,'nahich','3604d72de47c0e2d211f0fd2f5f7a7c799a3abc9',111111188,0,0,'[email protected]','2009-03-31 19:10:00','2009-07-28 09:19:50',1,0,0,2,''), (189,'dressari','fa2999a3fd05be4db1e33a5f63201f565d30fb3a',111111189,0,0,'[email protected]','2009-03-31 19:10:00','2009-04-10 15:17:39',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (190,'sliff','1d3bdae40e6c9524259c62a23b684874af930569',111111190,0,0,'[email protected]','2009-03-31 19:10:00','2009-04-04 11:18:20',1,0,0,2,''), (191,'malakitin','aa2b276d9f72125ecd1e09e8eeba0a02bde723ed',111111191,0,0,'[email protected]','2009-03-31 19:10:00','2009-04-10 15:08:55',1,0,0,2,''), (192,'linkman214','d4bf812cd0e5cf576c011afdc1e69445e7e7a760',111111192,0,0,'[email protected]','2009-04-12 16:03:49','2009-09-14 13:12:08',1,0,0,2,''), (193,'Exitwounds','a4a85b080d09b941d2228f84a92f0710a69c4955',111111193,0,0,'[email protected]','2009-04-12 16:03:49','2009-04-14 15:13:04',1,0,0,2,''), (194,'peej','b3ef4625b8cc9de5305028ca5749c256e733083a',111111194,0,0,'[email protected]','2009-07-17 13:43:22','2009-10-09 22:22:13',1,0,0,2,''), (195,'rozus','4d4e9b2001b28f7ede8928f52389b39717c7ebd4',111111195,0,0,'[email protected]','2009-06-28 02:18:03','2009-08-27 18:20:54',1,0,0,2,''), (196,'juspar','b22bdde83614961dcba83b86a87312333abc0c81',111111196,0,0,'[email protected]','2009-07-17 13:43:49','2009-08-28 09:43:14',1,0,0,2,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (206,'madylyn','0f676e03868ab5dd2a0910e07d8a6073bd400efc',111111206,0,0,'[email protected]','2009-07-19 19:15:05','2009-08-07 00:23:24',1,0,0,1,''), (207,'isk','fe239ce16ed8e851783222ac1f110e1000e10caf',111111207,0,0,'[email protected]','2009-07-18 15:01:57','2009-07-24 11:33:09',1,0,0,1,''), (208,'lucilla','d954de26261db878e18f91771937f00c77d67538',111111208,0,0,'[email protected]','2009-07-18 15:01:59','2009-10-17 13:18:37',1,0,0,1,''), (209,'wmbook','12b13a37731061fc59b3cdbc792b84198f2d4638',111111209,0,0,'[email protected]','2009-07-18 15:02:03','2009-08-13 15:07:05',1,0,0,1,''), (210,'tsiya','6f8f3d39f89b90d8d4f39da09a3da5afdf58a381',111111210,0,0,'[email protected]','2009-07-18 18:31:51','2009-07-21 13:25:48',1,0,0,1,''), (211,'cloudstrifese','c973ee705d24d2092f6a10b084a8be620460fa09',111111211,0,0,'[email protected]','2009-07-21 19:05:23','2009-09-12 12:36:34',1,0,0,1,''), (212,'count','51b7eda98b0927441c433b60d9d55427f65e9dd0',111111212,0,0,'[email protected]','2009-08-05 23:17:26','2009-08-07 14:18:20',1,0,0,1,''); INSERT INTO `account` (`account_id`,`username`,`password`,`station_id`,`csr`,`banned`,`email`,`joindate`,`lastlogin`,`active`,`loggedin`,`authenticated`,`characters_allowed`,`session_key`) VALUES (213,'kinsar','9c0eb5ae7c33a258c01d1378a55b4e0d1712740f',111111213,0,0,'[email protected]','2009-08-20 11:27:41','2009-08-20 11:27:41',1,0,0,1,''), (214,'phantommenace','cce4a8f258be93e5d66fce33ac7d9a2df99b9e65',111111214,0,0,'[email protected]','2009-08-19 11:08:20','2009-09-18 20:38:54',1,0,0,1,''), (215,'cisno','e7af8e932411677cdca3b2aa8f2f2f8e6bd0d3d3',111111215,0,0,'[email protected]','2009-08-30 15:12:01','2009-10-08 11:46:27',1,0,0,1,''), (216,'peej2','b3ef4625b8cc9de5305028ca5749c256e733083a',111111216,0,0,'[email protected]','2009-09-14 20:46:06','2009-09-14 20:46:06',1,0,0,1,''), (225,'adrikthorsen','57b9bce36613c31ef1832fc448a659040c0f5b59',111111225,0,0,'[email protected]','2009-10-15 17:32:23','2009-10-15 17:32:23',1,0,0,1,''), (226,'wulf','1e72916b92b291c8785c07109c490db2a84a704f',111111226,0,0,'[email protected]','2009-10-15 17:34:08','2009-10-16 15:45:03',1,0,1,1,''), (227, 'danglejangles', '4e95fa85a06fd2a24ec9ea46e2deb75d0a27f595', 111111227, 0, 0, '[email protected]', '2009-10-15 17:32:23','2009-10-15 17:32:23',1,0,0,1,''), (228, 'vasilli', 'f1e93fd2be119e3876c6a2f57c27c86ef000dc16', 111111228, 0, 0, '[email protected]', '2009-10-15 17:32:23','2009-10-15 17:32:23',1,0,0,1,''), (229, 'blade', '71abba49ae296f03522de104ae01615ae2c6b36b', 111111229, 0, 0, '[email protected]', '2009-10-15 17:32:23','2009-10-15 17:32:23',1,0,0,1,''), - (231, 'sojiro', '26daa966ac6659475ae98db2720f9a6243249ab3', 111111231, 0, 0, '[email protected]', '2010-03-06 11:36:15', '2010-03-06 11:36:15', 1, 0, 0, 1, ''); + (231, 'sojiro', '26daa966ac6659475ae98db2720f9a6243249ab3', 111111231, 0, 0, '[email protected]', '2010-03-06 11:36:15', '2010-03-06 11:36:15', 1, 0, 0, 1, ''), + (232, 'hoonius', '9d1aacc5d91ae12c89b90749b9f0ebe46ea71d9b', 111111232, 0, 0, '[email protected]', '2010-03-16 17:06:48', '2010-03-16 17:06:48', 1, 0, 0, 1, ''), + (233, 'crazymiller', '605dbf0f65d002aa1c4f0a182a9fe52049aa198a', 111111233, 0, 0, '[email protected]', '2010-03-16 17:06:51', '2010-03-16 17:06:51', 1, 0, 0, 1, ''), + (234, 'axler', 'fb7869ee49504b23815500b684f0520c777d8302', 111111234, 0, 0, '[email protected]', '2010-03-16 17:06:54', '2010-03-16 17:06:54', 1, 0, 0, 1, ''), + (235, 'johnshandy', '6794d21b82ccbc26c3c80f0d4976a76ab0446ad7', 111111235, 0, 0, '[email protected]', '2010-03-16 17:06:56', '2010-03-16 17:06:56', 1, 0, 0, 1, ''); /*!40000 ALTER TABLE `account` ENABLE KEYS */; -- -- Definition of trigger `tr_LoggerAccountInsert` -- DROP TRIGGER /*!50030 IF EXISTS */ `tr_LoggerAccountInsert`; DELIMITER $$ CREATE DEFINER = `root`@`%` TRIGGER `tr_LoggerAccountInsert` AFTER INSERT ON `account` FOR EACH ROW BEGIN DECLARE sqlcommand TEXT; SET sqlcommand = CONCAT('INSERT INTO swganh.account VALUES(',new.account_id,', \'',new.username,'\', \'',new.password,'\', ',new.station_id,', ',new.csr,', ',new.banned,', \'',new.email,'\', \'',new.joindate,'\', \'',new.lastlogin,'\', ',new.active,', ',new.loggedin,', ',new.authenticated,', ',new.characters_allowed,');'); INSERT INTO swganh_logs.account_logs SET affected_record_id = new.account_id, account_name = new.username, account_email = new.email, event_type = 'INSERT', event_date = NOW(), event_command = sqlcommand; END $$ DELIMITER ; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; \ No newline at end of file
swganh/mmoserverdb
c8f50fd9814aac48e2a29f7f2b057d1f723c0b77
Moved the Character Creation / Planet Map handling to the ChatServer. Fixed issue with traveling.
diff --git a/Server Scripts/config_message_routes.sql b/Server Scripts/config_message_routes.sql index 35063f2..8b9aa6e 100644 --- a/Server Scripts/config_message_routes.sql +++ b/Server Scripts/config_message_routes.sql @@ -1,108 +1,108 @@ /* --------------------------------------------------------------------------------------- This source file is part of SWG:ANH (Star Wars Galaxies - A New Hope - Server Emulator) For more information, visit http://www.swganh.com Copyright (c) 2006 - 2010 The SWG:ANH Team --------------------------------------------------------------------------------------- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA --------------------------------------------------------------------------------------- */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; use swganh; -- -- Definition of table `config_message_routes` -- DROP TABLE IF EXISTS `config_message_routes`; CREATE TABLE `config_message_routes` ( `messageId` int(32) NOT NULL default '0', `processId` int(32) unsigned NOT NULL default '0', `description` char(255) NOT NULL, PRIMARY KEY (`messageId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `config_message_routes` -- /*!40000 ALTER TABLE `config_message_routes` DISABLE KEYS */; INSERT INTO `config_message_routes` (`messageId`,`processId`,`description`) VALUES (-2068110857,6,'0x84BB21F7 - ChatInstantMessageToCharacter'), (-1975546364,6,'0x8A3F8E04 - ChatRemoveModeratorFromRoom'), (-1893394879,6,'0x8F251641 - ChatDeletePersistantMessage'), (-1866602641,6,'0x90BDE76F - ChatAddModeratorToRoom'), (-1861069741,6,'0x91125453 - BidAuctionInstant'), (-1775334501,6,'0x962E8B9B - SearchKnowledgeBaseMessage'), (-1661816430,6,'0x9CF2b192 - ChatQueryRoom'), - (-1632613473,1,'0x9EB04B9F - check_char_name - Checks a new characters name to make sure it is unique. First name only.'), + (-1632613473,6,'0x9EB04B9F - check_char_name - Checks a new characters name to make sure it is unique. First name only.'), (-1257665162,1,'0xB5098D76 - SelectCharacter'), (-1198567066,1,'0xB88F5166 - ClusterZoneRegisterName'), - (-1182846860,1,'0xB97F3074 - ClientChreateCharacter'), + (-1182846860,6,'0xB97F3074 - ClientChreateCharacter'), (-1133781518,6,'0xBC6BDDF2 - ChatEnterRoomById'), (-911869555,6,'0xC9A5F98D - GetTicketsMessage'), (-747701532,6,'0xD36EFAE4 - GetAuctionsDetails'), (-712404442,1,'0xD5899226 - ClientIdMsg'), - (-690899247,1,'0xD6D1B6D1 - verify_character_name'), + (-690899247,6,'0xD6D1B6D1 - verify_character_name'), (-637927020,6,'0xD9FA0194 - ChatBanAvatarFromRoom'), (-124198305,6,'0xF898E25F - RequestCategoriesMessage'), (-57867791,6,'0xFC8D01F1 - ChatUninviteFromRoom'), (-32611253,6,'0xFE0E644B - GetAuctionsDetailsResponse'), (132339103,6,'0x07E3559F - ChatRequestPersistantMessage'), (180655684,6,'0x0AC49644 - AppendCommentMessage'), (313578569,6,'0x12B0D449 - RetrieveAuctionItemMessage'), (395986942,6,'0x179A47FE - ChatAvatarId'), - (444250169,1,'0x1A7AB839 - GetMapLocationsMessage'), + (444250169,6,'0x1A7AB839 - GetMapLocationsMessage'), (551869411,6,'0x20E4DBE3 - ChatSendToRoom'), (565533243,6,'0x21B55A3B - IsVendorMessage'), (631414694,6,'0x25A29FA6 - ChatPersistantMessageToServer'), (655007429,6,'0x270A9EC5 - GetCommentsMessage'), (659508856,6,'0x274F4E78 - NewTicketActivityMessage'), (775311896,6,'0x2E365218 - ConnectPlayerMessage'), - (830496480,1,'0x31805EE0 -'), + (830496480,6,'0x31805EE0 -'), (892759021,6,'0x35366BED - ChatCreateRoom'), (155921015,6,'0x94B2A77 - ChatDestroyRoom, noted as revered in wiki'), (914859218,6,'0x3687A4D2 - CancelLiveAuctionMessage'), (1088834988,6,'0x40E64DAC - CreateTicketMessage'), (1223988165,6,'0xD4E937FC - CommoditiesTypeList'), (1228816378,6,'0x493E3FFA - ChatRemoveAvatarFromRoom'), (1279077626,6,'0x4C3D2CFA - ChatRequestRoomList'), (1284478121,6,'0x4C8F94A9 - ChatUnbanAvatarFromRoom'), (1585137734,6,'0x5E7B4846 - GetArticleMessage'), (1670313009,6,'0x638EF431 - CancelTicketMessage'), (1738411264,6,'0x679E0D00 - AuctionQueryHeadersMessage'), (1811950867,6,'0x6C002D13 - ChatAddFriend'), (1825766616,6,'0x6CD2FCD8 - ChatFriendlistUpdate'), (1920199891,6,'0x7273ECD3 - ChatInviteAvatarToRoom'); /*!40000 ALTER TABLE `config_message_routes` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; \ No newline at end of file
akosma/PracticalCommonLisp_ePub
b8c2f67816f1bbcfd1d6be0faf6a51b84c108afe
fix readme title
diff --git a/README.md b/README.md index 3a66c4a..6e28b1f 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,43 @@ -Common List Book in ePub Format -=============================== +Practical Common Lisp Book in ePub Format +========================================= This is an unofficial ePub version of the Practical Common Lisp book [available online](http://www.gigamonkeys.com/book/). Build ----- The `Makefile` depends on [Pandoc](http://johnmacfarlane.net/pandoc/) to create the eBooks. If you have [Kindlegen](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211) you can generate an eBook that is readable on the Kindle. To build the ePub just run any of the following commands at the command line: - `make` will generate the PDF, ePub and Kindle files. - `make pdf`, `make epub` and `make kindle` will only generate the requested format. The files will be available in the `_build` folder after the operation completes. Troubleshooting --------------- If you reuse this Makefile to create your own eBooks, make sure that the input files are saved with the UTF-8 encoding, which is the one that Pandoc expects. Download -------- The source code of the book can be downloaded in [tar.gz](http://www.gigamonkeys.com/book/practicals-1.0.3.tar.gz) and [zip](http://www.gigamonkeys.com/book/practicals-1.0.3.zip) formats from the original website. Copyright --------- Copyright © 2003-2009, Peter Seibel.
akosma/PracticalCommonLisp_ePub
e78e05db2ad92c1e5f0364e60b1006123407216c
Title, author and date fixed
diff --git a/Makefile b/Makefile index af78fb3..218f478 100644 --- a/Makefile +++ b/Makefile @@ -1,64 +1,73 @@ # This makefile generates the eBooks from the HTML files using Pandoc +# This is the version of the build system, just to tell apart different renderings +# Build 1 is everything came before the numbering scheme =) +BUILD = 2 + +#Set the correct shell +#Under Ubuntu, for example, /bin/sh point to /bin/dash +#which does not support "[[" and other bash things +SHELL = /bin/bash + # Constants DIR = _build -OUTPUT = book -KINDLEGEN = /Applications/KindleGen_Mac_i386_v2_7/kindlegen -PDFOPTS = --chapters --smart --standalone --table-of-contents -EPUBOPTS = --smart --standalone --table-of-contents +OUTPUT = Practical_Common_Lisp +KINDLEGEN = $(which kindlegen) +GENERALOPTS = --smart --standalone --table-of-contents -V title:"Practical Common Lisp" -V author:"Peter Seibel" -V date:"June 29, 2012 - Build ${BUILD}" +PDFOPTS = --chapters ${GENERALOPTS} +EPUBOPTS = ${GENERALOPTS} HTML_FILES = index.html blurbs.html letter-to-reader.html introduction-why-lisp.html lather-rinse-repeat-a-tour-of-the-repl.html practical-a-simple-database.html syntax-and-semantics.html functions.html variables.html macros-standard-control-constructs.html macros-defining-your-own.html practical-building-a-unit-test-framework.html numbers-characters-and-strings.html collections.html they-called-it-lisp-for-a-reason-list-processing.html beyond-lists-other-uses-for-cons-cells.html files-and-file-io.html practical-a-portable-pathname-library.html object-reorientation-generic-functions.html object-reorientation-classes.html a-few-format-recipes.html beyond-exception-handling-conditions-and-restarts.html the-special-operators.html programming-in-the-large-packages-and-symbols.html loop-for-black-belts.html practical-a-spam-filter.html practical-parsing-binary-files.html practical-an-id3-parser.html practical-web-programming-with-allegroserve.html practical-an-mp3-database.html practical-a-shoutcast-server.html practical-an-mp3-browser.html practical-an-html-generation-library-the-interpreter.html practical-an-html-generation-library-the-compiler.html conclusion-whats-next.html - # --------------------------------- # Public targets all: clean create_pdf create_epub create_kindle remove_files pdf: clean create_pdf remove_files epub: clean create_epub remove_files kindle: clean create_kindle remove_files clean: if [ -d "${DIR}" ]; \ then rm -r ${DIR}; \ fi # --------------------------------- # Private targets # If the build directory does not exist, create it create_folder: if [ ! -d "${DIR}" ]; then \ mkdir ${DIR}; \ mkdir ${DIR}/figures; \ mkdir ${DIR}/screenshots; \ cp html/* ${DIR}; \ cp html/figures/* ${DIR}/figures; \ cp html/screenshots/* ${DIR}/screenshots; \ fi # Generate PDF create_pdf: create_folder cd ${DIR}; \ pandoc ${PDFOPTS} -o ${OUTPUT}.pdf ${HTML_FILES} # Generate EPUB create_epub: create_folder cd ${DIR}; \ pandoc ${EPUBOPTS} -o ${OUTPUT}.epub ${HTML_FILES} # Create Kindle version (ignoring the error that it outputs) -create_kindle: create_epub - -${KINDLEGEN} ${DIR}/${OUTPUT}.epub +create_kindle: create_epub + @if [[ ! -z "${KINDLEGEN}" ]]; then ${KINDLEGEN} ${DIR}/${OUTPUT}.epub; else echo "KindleGen cannot be found - unable to create Kindle format"; fi # Clean up, so that only the product files remain remove_files: create_folder cd ${DIR}; \ rm -f *.png; \ rm -f *.jpg; \ rm -f *.css; \ rm -rf figures/; \ rm -rf screenshots/; \ rm -f *.html
akosma/PracticalCommonLisp_ePub
b9b9f427fc6be488217eb65f22ca07851a4eb673
Removed sentence from README
diff --git a/README.md b/README.md index 2e23567..3a66c4a 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,43 @@ Common List Book in ePub Format =============================== This is an unofficial ePub version of the Practical Common Lisp book -[available online](http://www.gigamonkeys.com/book/). The HTML of the -website has been downloaded adapted to be processed with Calibre into an -ePub file, which can be read with [iBooks on the -iPad](http://www.apple.com/ipad/features/ibooks.html). +[available online](http://www.gigamonkeys.com/book/). Build ----- The `Makefile` depends on [Pandoc](http://johnmacfarlane.net/pandoc/) to create the eBooks. If you have [Kindlegen](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211) you can generate an eBook that is readable on the Kindle. To build the ePub just run any of the following commands at the command line: - `make` will generate the PDF, ePub and Kindle files. - `make pdf`, `make epub` and `make kindle` will only generate the requested format. The files will be available in the `_build` folder after the operation completes. Troubleshooting --------------- If you reuse this Makefile to create your own eBooks, make sure that the input files are saved with the UTF-8 encoding, which is the one that Pandoc expects. Download -------- The source code of the book can be downloaded in [tar.gz](http://www.gigamonkeys.com/book/practicals-1.0.3.tar.gz) and [zip](http://www.gigamonkeys.com/book/practicals-1.0.3.zip) formats from the original website. Copyright --------- Copyright © 2003-2009, Peter Seibel.
akosma/PracticalCommonLisp_ePub
11782067532add1fc93362c72b75b1f019e5a409
Added a Makefile to simplify the creation of the eBooks
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e35d885 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +_build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..af78fb3 --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +# This makefile generates the eBooks from the HTML files using Pandoc + +# Constants +DIR = _build +OUTPUT = book +KINDLEGEN = /Applications/KindleGen_Mac_i386_v2_7/kindlegen +PDFOPTS = --chapters --smart --standalone --table-of-contents +EPUBOPTS = --smart --standalone --table-of-contents +HTML_FILES = index.html blurbs.html letter-to-reader.html introduction-why-lisp.html lather-rinse-repeat-a-tour-of-the-repl.html practical-a-simple-database.html syntax-and-semantics.html functions.html variables.html macros-standard-control-constructs.html macros-defining-your-own.html practical-building-a-unit-test-framework.html numbers-characters-and-strings.html collections.html they-called-it-lisp-for-a-reason-list-processing.html beyond-lists-other-uses-for-cons-cells.html files-and-file-io.html practical-a-portable-pathname-library.html object-reorientation-generic-functions.html object-reorientation-classes.html a-few-format-recipes.html beyond-exception-handling-conditions-and-restarts.html the-special-operators.html programming-in-the-large-packages-and-symbols.html loop-for-black-belts.html practical-a-spam-filter.html practical-parsing-binary-files.html practical-an-id3-parser.html practical-web-programming-with-allegroserve.html practical-an-mp3-database.html practical-a-shoutcast-server.html practical-an-mp3-browser.html practical-an-html-generation-library-the-interpreter.html practical-an-html-generation-library-the-compiler.html conclusion-whats-next.html + + + +# --------------------------------- +# Public targets +all: clean create_pdf create_epub create_kindle remove_files + +pdf: clean create_pdf remove_files + +epub: clean create_epub remove_files + +kindle: clean create_kindle remove_files + +clean: + if [ -d "${DIR}" ]; \ + then rm -r ${DIR}; \ + fi + +# --------------------------------- +# Private targets +# If the build directory does not exist, create it +create_folder: + if [ ! -d "${DIR}" ]; then \ + mkdir ${DIR}; \ + mkdir ${DIR}/figures; \ + mkdir ${DIR}/screenshots; \ + cp html/* ${DIR}; \ + cp html/figures/* ${DIR}/figures; \ + cp html/screenshots/* ${DIR}/screenshots; \ + fi + +# Generate PDF +create_pdf: create_folder + cd ${DIR}; \ + pandoc ${PDFOPTS} -o ${OUTPUT}.pdf ${HTML_FILES} + +# Generate EPUB +create_epub: create_folder + cd ${DIR}; \ + pandoc ${EPUBOPTS} -o ${OUTPUT}.epub ${HTML_FILES} + +# Create Kindle version (ignoring the error that it outputs) +create_kindle: create_epub + -${KINDLEGEN} ${DIR}/${OUTPUT}.epub + +# Clean up, so that only the product files remain +remove_files: create_folder + cd ${DIR}; \ + rm -f *.png; \ + rm -f *.jpg; \ + rm -f *.css; \ + rm -rf figures/; \ + rm -rf screenshots/; \ + rm -f *.html + diff --git a/README.md b/README.md index 4ce280f..2e23567 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,46 @@ Common List Book in ePub Format =============================== This is an unofficial ePub version of the Practical Common Lisp book [available online](http://www.gigamonkeys.com/book/). The HTML of the website has been downloaded adapted to be processed with Calibre into an ePub file, which can be read with [iBooks on the iPad](http://www.apple.com/ipad/features/ibooks.html). Build ----- -To build the ePub just run `make` at the command line. The `Makefile` -depends on [Pandoc](http://johnmacfarlane.net/pandoc/) to create the -file. +The `Makefile` depends on [Pandoc](http://johnmacfarlane.net/pandoc/) to +create the eBooks. If you have +[Kindlegen](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211) +you can generate an eBook that is readable on the Kindle. + +To build the ePub just run any of the following commands at the command line: + +- `make` will generate the PDF, ePub and Kindle files. +- `make pdf`, `make epub` and `make kindle` will only generate the + requested format. + +The files will be available in the `_build` folder after the operation +completes. + +Troubleshooting +--------------- + +If you reuse this Makefile to create your own eBooks, make sure that the +input files are saved with the UTF-8 encoding, which is the one that +Pandoc expects. Download -------- The source code of the book can be downloaded in [tar.gz](http://www.gigamonkeys.com/book/practicals-1.0.3.tar.gz) and [zip](http://www.gigamonkeys.com/book/practicals-1.0.3.zip) formats from the original website. Copyright --------- Copyright © 2003-2009, Peter Seibel.
akosma/PracticalCommonLisp_ePub
a55f3b3a383896bfed1b6885164fa1718cf27e04
Changed encoding of files to UTF-8
diff --git a/html/a-few-format-recipes.html b/html/a-few-format-recipes.html index c006f37..acaa7c1 100644 --- a/html/a-few-format-recipes.html +++ b/html/a-few-format-recipes.html @@ -1,548 +1,548 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title> A Few FORMAT Recipes </title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1> 18. A Few FORMAT Recipes </h1> <p> Common Lisp's <code><b>FORMAT</b></code> function is--along with the extended <code><b>LOOP</b></code> macro--one of the two Common Lisp features that inspires a strong emotional response in a lot of Common Lisp users. Some love it; others hate it.<sup>1</sup> </p> <p> <code><b>FORMAT</b></code>'s fans love it for its great power and concision, while its detractors hate it because of the potential for misuse and its opacity. Complex <code><b>FORMAT</b></code> control strings sometimes bear a suspicious resemblance to line noise, but <code><b>FORMAT</b></code> remains popular with Common Lispers who like to be able to generate little bits of human-readable output without having to clutter their code with lots of output-generating code. While <code><b>FORMAT</b></code>'s control strings can be cryptic, at least a single <code><b>FORMAT</b></code> expression doesn't clutter things up too badly. For instance, suppose you want to print the values in a list delimited with commas. You could write this: </p> <pre> (loop for cons on list do (format t "~a" (car cons)) when (cdr cons) do (format t ", ")) </pre> <p> That's not too bad, but anyone reading this code has to mentally parse it just to figure out that all it's doing is printing the contents of <code>list</code> to standard output. On the other hand, you can tell at a glance that the following expression is printing <code>list</code>, in some form, to standard output: </p> <pre> (format t "~{~a~^, ~}" list) </pre> <p> If you care exactly what form the output will take, then you'll have to examine the control string, but if all you want is a first-order approximation of what this line of code is doing, that's immediately available. </p> <p> At any rate, you should have at least a reading knowledge of <code><b>FORMAT</b></code>, and it's worth getting a sense of what it can do before you affiliate yourself with the pro- or anti-<code><b>FORMAT</b></code> camp. It's also important to understand at least the basics of <code><b>FORMAT</b></code> because other standard functions, such as the condition-signaling functions discussed in the next chapter, use <code><b>FORMAT</b></code>-style control strings to generate output. </p> <p> - To further complicate matters, <code><b>FORMAT</b></code> supports three quite different kinds of formatting: printing tables of data, <i>pretty-printing</i> s-expressions, and generating human-readable messages with interpolated values. Printing tables of data as text is a bit passé these days; it's one of those reminders that Lisp is nearly as old as FORTRAN. In fact, several of the directives you can use to print floating-point values in fixed-width fields were based quite directly on FORTRAN <i>edit descriptors</i>, which are used in FORTRAN to read and print columns of data arranged in fixed-width fields. However, using Common Lisp as a FORTRAN replacement is beyond the scope of this book, so I won't discuss those aspects of <code><b>FORMAT</b></code>. + To further complicate matters, <code><b>FORMAT</b></code> supports three quite different kinds of formatting: printing tables of data, <i>pretty-printing</i> s-expressions, and generating human-readable messages with interpolated values. Printing tables of data as text is a bit passé these days; it's one of those reminders that Lisp is nearly as old as FORTRAN. In fact, several of the directives you can use to print floating-point values in fixed-width fields were based quite directly on FORTRAN <i>edit descriptors</i>, which are used in FORTRAN to read and print columns of data arranged in fixed-width fields. However, using Common Lisp as a FORTRAN replacement is beyond the scope of this book, so I won't discuss those aspects of <code><b>FORMAT</b></code>. </p> <p> - Pretty-printing is likewise beyond the scope of this book--not because it's passé but just because it's too big a topic. Briefly, the Common Lisp pretty printer is a customizable system for printing block-structured data such as--but not limited to--s-expressions while varying indentation and dynamically adding line breaks as needed. It's a great thing when you need it, but it's not often needed in day-to-day programming.<sup>2</sup> + Pretty-printing is likewise beyond the scope of this book--not because it's passé but just because it's too big a topic. Briefly, the Common Lisp pretty printer is a customizable system for printing block-structured data such as--but not limited to--s-expressions while varying indentation and dynamically adding line breaks as needed. It's a great thing when you need it, but it's not often needed in day-to-day programming.<sup>2</sup> </p> <p> Instead, I'll focus on the parts of <code><b>FORMAT</b></code> you can use to generate human-readable strings with interpolated values. Even limiting the scope in that way, there's still a fair bit to cover. You shouldn't feel obliged to remember every detail described in this chapter. You can get quite far with just a few <code><b>FORMAT</b></code> idioms. I'll describe the most important features of <code><b>FORMAT</b></code> first; it's up to you how much of a <code><b>FORMAT</b></code> wizard you want to become. </p> <h2> <a name="the-format-function" id="the-format-function">The FORMAT Function</a> </h2> <p> As you've seen in previous chapters, the <code><b>FORMAT</b></code> function takes two required arguments: a destination for its output and a control string that contains literal text and embedded <i>directives</i>. Any additional arguments provide the values used by the directives in the control string that interpolate values into the output. I'll refer to these arguments as <i>format arguments</i>. </p> <p> The first argument to <code><b>FORMAT</b></code>, the destination for the output, can be <code><b>T</b></code>, <code><b>NIL</b></code>, a stream, or a string with a fill pointer. <code><b>T</b></code> is shorthand for the stream <code><b>*STANDARD-OUTPUT*</b></code>, while <code><b>NIL</b></code> causes <code><b>FORMAT</b></code> to generate its output to a string, which it then returns.<sup>3</sup> If the destination is a stream, the output is written to the stream. And if the destination is a string with a fill pointer, the formatted output is added to the end of the string and the fill pointer is adjusted appropriately. Except when the destination is <code><b>NIL</b></code> and it returns a string, <code><b>FORMAT</b></code> returns <code><b>NIL</b></code>. </p> <p> The second argument, the control string, is, in essence, a program in the <code><b>FORMAT</b></code> language. The <code><b>FORMAT</b></code> language isn't Lispy at all--its basic syntax is based on characters, not s-expressions, and it's optimized for compactness rather than easy comprehension. This is why a complex <code><b>FORMAT</b></code> control string can end up looking like line noise. </p> <p> Most of <code><b>FORMAT</b></code>'s directives simply interpolate an argument into the output in one form or another. Some directives, such as <code>~%</code>, which causes <code><b>FORMAT</b></code> to emit a newline, don't consume any arguments. And others, as you'll see, can consume more than one argument. One directive even allows you to jump around in the list of arguments in order to process the same argument more than once or to skip certain arguments in certain situations. But before I discuss specific directives, let's look at the general syntax of a directive. </p> <h2> <a name="format-directives" id="format-directives">FORMAT Directives</a> </h2> <p> All directives start with a tilde (<code>~</code>) and end with a single character that identifies the directive. You can write the character in either upper- or lowercase. Some directives take <i>prefix parameters</i>, which are written immediately following the tilde, separated by commas, and used to control things such as how many digits to print after the decimal point when printing a floating-point number. For example, the <code>~$</code> directive, one of the directives used to print floating-point values, by default prints two digits following the decimal point. </p> <pre> CL-USER&gt; (format t "~$" pi) 3.14 NIL </pre> <p> However, with a prefix parameter, you can specify that it should print its argument to, say, five decimal places like this: </p> <pre> CL-USER&gt; (format t "~5$" pi) 3.14159 NIL </pre> <p> The values of prefix parameters are either numbers, written in decimal, or characters, written as a single quote followed by the desired character. The value of a prefix parameter can also be derived from the format arguments in two ways: A prefix parameter of <code>v</code> causes <code><b>FORMAT</b></code> to consume one format argument and use its value for the prefix parameter. And a prefix parameter of <code>#</code> will be evaluated as the number of remaining format arguments. For example: </p> <pre> CL-USER&gt; (format t "~v$" 3 pi) 3.142 NIL CL-USER&gt; (format t "~#$" pi) 3.1 NIL </pre> <p> I'll give some more realistic examples of how you can use the <code>#</code> argument in the section "Conditional Formatting." </p> <p> You can also omit prefix parameters altogether. However, if you want to specify one parameter but not the ones before it, you must include a comma for each unspecified parameter. For instance, the <code>~F</code> directive, another directive for printing floating-point values, also takes a parameter to control the number of decimal places to print, but it's the second parameter rather than the first. If you want to use <code>~F</code> to print a number to five decimal places, you can write this: </p> <pre> CL-USER&gt; (format t "~,5f" pi) 3.14159 NIL </pre> <p> You can also modify the behavior of some directives with colon and at-sign <i>modifiers</i>, which are placed after any prefix parameters and before the directive's identifying character. These modifiers change the behavior of the directive in small ways. For instance, with a colon modifier, the <code>~D</code> directive used to output integers in decimal emits the number with commas separating every three digits, while the at-sign modifier causes <code>~D</code> to include a plus sign when the number is positive. </p> <pre> CL-USER&gt; (format t "~d" 1000000) 1000000 NIL CL-USER&gt; (format t "~:d" 1000000) 1,000,000 NIL CL-USER&gt; (format t "~@d" 1000000) +1000000 NIL </pre> <p> When it makes sense, you can combine the colon and at-sign modifiers to get both modifications. </p> <pre> CL-USER&gt; (format t "~:@d" 1000000) +1,000,000 NIL </pre> <p> In directives where the two modified behaviors can't be meaningfully combined, using both modifiers is either undefined or given a third meaning. </p> <h2> <a name="basic-formatting" id="basic-formatting">Basic Formatting</a> </h2> <p> Now you're ready to look at specific directives. I'll start with several of the most commonly used directives, including some you've seen in previous chapters. </p> <p> The most general-purpose directive is <code>~A</code>, which consumes one format argument of any type and outputs it in <i>aesthetic</i> (human-readable) form. For example, strings are output without quotation marks or escape characters, and numbers are output in a natural way for the type of number. If you just want to emit a value for human consumption, this directive is your best bet. </p> <pre> (format nil "The value is: ~a" 10) ==&gt; "The value is: 10" (format nil "The value is: ~a" "foo") ==&gt; "The value is: foo" (format nil "The value is: ~a" (list 1 2 3)) ==&gt; "The value is: (1 2 3)" </pre> <p> A closely related directive, <code>~S</code>, likewise consumes one format argument of any type and outputs it. However, <code>~S</code> tries to generate output that can be read back in with <code><b>READ</b></code>. Thus, strings will be enclosed in quotation marks, symbols will be package-qualified when necessary, and so on. Objects that don't have a <code><b>READ</b></code>able representation are printed with the unreadable object syntax, <code>#&lt;&gt;</code>. With a colon modifier, both the <code>~A</code> and <code>~S</code> directives emit <code><b>NIL</b></code> as <code>()</code> rather than <code><b>NIL</b></code>. Both the <code>~A</code> and <code>~S</code> directives also take up to four prefix parameters, which can be used to control whether padding is added after (or before with the at-sign modifier) the value, but those parameters are only really useful for generating tabular data. </p> <p> The other two most frequently used directives are <code>~%</code>, which emits a newline, and <code>~&amp;</code>, which emits a <i>fresh line</i>. The difference between the two is that <code>~%</code> always emits a newline, while <code>~&amp;</code> emits one only if it's not already at the beginning of a line. This is handy when writing loosely coupled functions that each generate a piece of output and that need to be combined in different ways. For instance, if one function generates output that ends with a newline (<code>~%</code>) and another function generates some output that starts with a fresh line (<code>~&amp;</code>), you don't have to worry about getting an extra blank line if you call them one after the other. Both of these directives can take a single prefix parameter that specifies the number of newlines to emit. The <code>~%</code> directive will simply emit that many newline characters, while the <code>~&amp;</code> directive will emit either <i>n</i> - 1 or <i>n</i> newlines, depending on whether it starts at the beginning of a line. </p> <p> Less frequently used is the related <code>~~</code> directive, which causes <code><b>FORMAT</b></code> to emit a literal tilde. Like the <code>~%</code> and <code>~&amp;</code> directives, it can be parameterized with a number that controls how many tildes to emit. </p> <h2> <a name="character-and-integer-directives" id="character-and-integer-directives">Character and Integer Directives</a> </h2> <p> In addition to the general-purpose directives, <code>~A</code> and <code>~S</code>, <code><b>FORMAT</b></code> supports several directives that can be used to emit values of specific types in particular ways. One of the simplest of these is the <code>~C</code> directive, which is used to emit characters. It takes no prefix arguments but can be modified with the colon and at-sign modifiers. Unmodified, its behavior is no different from <code>~A</code> except that it works only with characters. The modified versions are more useful. With a colon modifier, <code>~:C</code> outputs <i>nonprinting</i> characters such as space, tab, and newline by name. This is useful if you want to emit a message to the user about some character. For instance, the following: </p> <pre> (format t "Syntax error. Unexpected character: ~:c" char) </pre> <p> can emit messages like this: </p> <pre> Syntax error. Unexpected character: a </pre> <p> but also like the following: </p> <pre> Syntax error. Unexpected character: Space </pre> <p> With the at-sign modifier, <code>~@C</code> will emit the character in Lisp's literal character syntax. </p> <pre> CL-USER&gt; (format t "~@c~%" #\a) #\a NIL </pre> <p> With both the colon and at-sign modifiers, the <code>~C</code> directive can print extra information about how to enter the character at the keyboard if it requires special key combinations. For instance, on the Macintosh, in certain applications you can enter a null character (character code 0 in ASCII or in any ASCII superset such as ISO-8859-1 or Unicode) by pressing the Control key and typing @. In OpenMCL, if you print the null character with the <code>~:C</code> directive, it tells you this: </p> <pre> (format nil "~:@c" (code-char 0)) ==&gt; "^@ (Control @)" </pre> <p> However, not all Lisps implement this aspect of the <code>~C</code> directive. And even if they do, it may or may not be accurate--for instance, if you're running OpenMCL in SLIME, the <code>C-@</code> key chord is intercepted by Emacs, invoking <code>set-mark-command</code>.<sup>4</sup> </p> <p> Format directives dedicated to emitting numbers are another important category. While you can use the <code>~A</code> and <code>~S</code> directives to emit numbers, if you want fine control over how they're printed, you need to use one of the number-specific directives. The numeric directives can be divided into two subcategories: directives for formatting integer values and directives for formatting floating-point values. </p> <p> Five closely related directives format integer values: <code>~D</code>, <code>~X</code>, <code>~O</code>, <code>~B</code>, and <code>~R</code>. The most frequently used is the <code>~D</code> directive, which outputs integers in base 10. </p> <pre> (format nil "~d" 1000000) ==&gt; "1000000" </pre> <p> As I mentioned previously, with a colon modifier it adds commas. </p> <pre> (format nil "~:d" 1000000) ==&gt; "1,000,000" </pre> <p> And with an at-sign modifier, it always prints a sign. </p> <pre> (format nil "~@d" 1000000) ==&gt; "+1000000" </pre> <p> And the two modifiers can be combined. </p> <pre> (format nil "~:@d" 1000000) ==&gt; "+1,000,000" </pre> <p> The first prefix parameter can specify a minimum width for the output, and the second parameter can specify a padding character to use. The default padding character is space, and padding is always inserted before the number itself. </p> <pre> (format nil "~12d" 1000000) ==&gt; " 1000000" (format nil "~12,'0d" 1000000) ==&gt; "000001000000" </pre> <p> These parameters are handy for formatting things such as dates in a fixed-width format. </p> <pre> (format nil "~4,'0d-~2,'0d-~2,'0d" 2005 6 10) ==&gt; "2005-06-10" </pre> <p> The third and fourth parameters are used in conjunction with the colon modifier: the third parameter specifies the character to use as the separator between groups and digits, and the fourth parameter specifies the number of digits per group. These parameters default to a comma and the number 3. Thus, you can use the directive <code>~:D</code> without parameters to output large integers in standard format for the United States but can change the comma to a period and the grouping from 3 to 4 with <code>~,,'.,4D</code>. </p> <pre> (format nil "~:d" 100000000) ==&gt; "100,000,000" (format nil "~,,'.,4:d" 100000000) ==&gt; "1.0000.0000" </pre> <p> Note that you must use commas to hold the places of the unspecified width and padding character parameters, allowing them to keep their default values. </p> <p> The <code>~X</code>, <code>~O</code>, and <code>~B</code> directives work just like the <code>~D</code> directive except they emit numbers in hexadecimal (base 16), octal (base 8), and binary (base 2). </p> <pre> (format nil "~x" 1000000) ==&gt; "f4240" (format nil "~o" 1000000) ==&gt; "3641100" (format nil "~b" 1000000) ==&gt; "11110100001001000000" </pre> <p> Finally, the <code>~R</code> directive is the general <i>radix</i> directive. Its first parameter is a number between 2 and 36 (inclusive) that indicates what base to use. The remaining parameters are the same as the four parameters accepted by the <code>~D</code>, <code>~X</code>, <code>~O</code>, and <code>~B</code> directives, and the colon and at-sign modifiers modify its behavior in the same way. The <code>~R</code> directive also has some special behavior when used with no prefix parameters, which I'll discuss in the section "English-Language Directives." </p> <h2> <a name="floating-point-directives" id="floating-point-directives">Floating-Point Directives</a> </h2> <p> Four directives format floating-point values: <code>~F</code>, <code>~E</code>, <code>~G</code>, and <code>~$</code>. The first three of these are the directives based on FORTRAN's edit descriptors. I'll skip most of the details of those directives since they mostly have to do with formatting floating-point values for use in tabular form. However, you can use the <code>~F</code>, <code>~E</code>, and <code>~$</code> directives to interpolate floating-point values into text. The <code>~G</code>, or <i>general,</i> floating-point directive, on the other hand, combines aspects of the <code>~F</code> and <code>~E</code> directives in a way that only really makes sense for generating tabular output. </p> <p> The <code>~F</code> directive emits its argument, which should be a number,<sup>5</sup> in decimal format, possibly controlling the number of digits after the decimal point. The <code>~F</code> directive is, however, allowed to use computerized scientific notation if the number is sufficiently large or small. The <code>~E</code> directive, on the other hand, always emits numbers in computerized scientific notation. Both of these directives take a number of prefix parameters, but you need to worry only about the second, which controls the number of digits to print after the decimal point. </p> <pre> (format nil "~f" pi) ==&gt; "3.141592653589793d0" (format nil "~,4f" pi) ==&gt; "3.1416" (format nil "~e" pi) ==&gt; "3.141592653589793d+0" (format nil "~,4e" pi) ==&gt; "3.1416d+0" </pre> <p> The <code>~$</code>, or monetary, directive is similar to <code>~F</code> but a bit simpler. As its name suggests, it's intended for emitting monetary units. With no parameters, it's basically equivalent to <code>~,2F</code>. To modify the number of digits printed after the decimal point, you use the <i>first</i> parameter, while the second parameter controls the minimum number of digits to print before the decimal point. </p> <pre> (format nil "~$" pi) ==&gt; "3.14" (format nil "~2,4$" pi) ==&gt; "0003.14" </pre> <p> All three directives, <code>~F</code>, <code>~E</code>, and <code>~$</code>, can be made to always print a sign, plus or minus, with the at-sign modifier.<sup>6</sup> </p> <h2> <a name="english-language-directives" id="english-language-directives">English-Language Directives</a> </h2> <p> Some of the handiest <code><b>FORMAT</b></code> directives for generating human-readable messages are the ones for emitting English text. These directives allow you to emit numbers as English words, to emit plural markers based on the value of a format argument, and to apply case conversions to sections of <code><b>FORMAT</b></code>'s output. </p> <p> The <code>~R</code> directive, which I discussed in "Character and Integer Directives," when used with no base specified, prints numbers as English words or Roman numerals. When used with no prefix parameter and no modifiers, it emits the number in words as a cardinal number. </p> <pre> (format nil "~r" 1234) ==&gt; "one thousand two hundred thirty-four" </pre> <p> With the colon modifier, it emits the number as an ordinal. </p> <pre> (format nil "~:r" 1234) ==&gt; "one thousand two hundred thirty-fourth" </pre> <p> And with an at-sign modifier, it emits the number as a Roman numeral; with both an at-sign and a colon, it emits "old-style" Roman numerals in which fours and nines are written as IIII and VIIII instead of IV and IX. </p> <pre> (format nil "~@r" 1234) ==&gt; "MCCXXXIV" (format nil "~:@r" 1234) ==&gt; "MCCXXXIIII" </pre> <p> For numbers too large to be represented in the given form, <code>~R</code> behaves like <code>~D</code>. </p> <p> To help you generate messages with words properly pluralized, <code><b>FORMAT</b></code> provides the <code>~P</code> directive, which simply emits an <i>s</i> unless the corresponding argument is <code>1</code>. </p> <pre> (format nil "file~p" 1) ==&gt; "file" (format nil "file~p" 10) ==&gt; "files" (format nil "file~p" 0) ==&gt; "files" </pre> <p> Typically, however, you'll use <code>~P</code> with the colon modifier, which causes it to reprocess the previous format argument. </p> <pre> (format nil "~r file~:p" 1) ==&gt; "one file" (format nil "~r file~:p" 10) ==&gt; "ten files" (format nil "~r file~:p" 0) ==&gt; "zero files" </pre> <p> With the at-sign modifier, which can be combined with the colon modifier, <code>~P</code> emits either <i>y</i> or <i>ies</i>. </p> <pre> (format nil "~r famil~:@p" 1) ==&gt; "one family" (format nil "~r famil~:@p" 10) ==&gt; "ten families" (format nil "~r famil~:@p" 0) ==&gt; "zero families" </pre> <p> Obviously, <code>~P</code> can't solve all pluralization problems and is no help for generating messages in other languages, but it's handy for the cases it does handle. And the <code>~[</code> directive, which I'll discuss in a moment, gives you a more flexible way to conditionalize parts of <code><b>FORMAT</b></code>'s output. </p> <p> The last directive for dealing with emitting English text is <code>~(</code>, which allows you to control the case of text in the output. Each <code>~(</code> is paired with a <code>~)</code>, and all the output generated by the portion of the control string between the two markers will be converted to all lowercase. </p> <pre> (format nil "~(~a~)" "FOO") ==&gt; "foo" (format nil "~(~@r~)" 124) ==&gt; "cxxiv" </pre> <p> You can modify <code>~(</code> with an at sign to make it capitalize the first word in a section of text, with a colon to make it to capitalize all words, and with both modifiers to convert all text to uppercase. (A <i>word</i> for the purpose of this directive is a sequence of alphanumeric characters delimited by nonalphanumeric characters or the ends of the text.) </p> <pre> (format nil "~(~a~)" "tHe Quick BROWN foX") ==&gt; "the quick brown fox" (format nil "~@(~a~)" "tHe Quick BROWN foX") ==&gt; "The quick brown fox" (format nil "~:(~a~)" "tHe Quick BROWN foX") ==&gt; "The Quick Brown Fox" (format nil "~:@(~a~)" "tHe Quick BROWN foX") ==&gt; "THE QUICK BROWN FOX" </pre> <h2> <a name="conditional-formatting" id="conditional-formatting">Conditional Formatting</a> </h2> <p> In addition to directives that interpolate arguments and modify other output, <code><b>FORMAT</b></code> provides several directives that implement simple control constructs within the control string. One of these, which you used in Chapter 9, is the <i>conditional</i> directive <code>~[.</code> This directive is closed by a corresponding <code>~]</code>, and in between are a number of clauses separated by <code>~;</code>. The job of the <code>~[</code> directive is to pick one of the clauses, which is then processed by <code><b>FORMAT</b></code>. With no modifiers or parameters, the clause is selected by numeric index; the <code>~[</code> directive consumes a format argument, which should be a number, and takes the <i>nth</i> (zero-based) clause where <i>N</i> is the value of the argument. </p> <pre> (format nil "~[cero~;uno~;dos~]" 0) ==&gt; "cero" (format nil "~[cero~;uno~;dos~]" 1) ==&gt; "uno" (format nil "~[cero~;uno~;dos~]" 2) ==&gt; "dos" </pre> <p> If the value of the argument is greater than the number of clauses, nothing is printed. </p> <pre> (format nil "~[cero~;uno~;dos~]" 3) ==&gt; "" </pre> <p> However, if the last clause separator is <code>~:;</code> instead of <code>~;</code>, then the last clause serves as a default clause. </p> <pre> (format nil "~[cero~;uno~;dos~:;mucho~]" 3) ==&gt; "mucho" (format nil "~[cero~;uno~;dos~:;mucho~]" 100) ==&gt; "mucho" </pre> <p> It's also possible to specify the clause to be selected using a prefix parameter. While it'd be silly to use a literal value in the control string, recall that <code>#</code> used as a prefix parameter means the number of arguments remaining to be processed. Thus, you can define a format string such as the following: </p> <pre> (defparameter *list-etc* "~#[NONE~;~a~;~a and ~a~:;~a, ~a~]~#[~; and ~a~:;, ~a, etc~].") </pre> <p> and then use it like this: </p> <pre> (format nil *list-etc*) ==&gt; "NONE." (format nil *list-etc* 'a) ==&gt; "A." (format nil *list-etc* 'a 'b) ==&gt; "A and B." (format nil *list-etc* 'a 'b 'c) ==&gt; "A, B and C." (format nil *list-etc* 'a 'b 'c 'd) ==&gt; "A, B, C, etc." (format nil *list-etc* 'a 'b 'c 'd 'e) ==&gt; "A, B, C, etc." </pre> <p> Note that the control string actually contains two <code>~[~]</code> directives--both of which use <code>#</code> to select the clause to use. The first consumes between zero and two arguments, while the second consumes one more, if available. <code><b>FORMAT</b></code> will silently ignore any arguments not consumed while processing the control string. </p> <p> With a colon modifier, the <code>~[</code> can contain only two clauses; the directive consumes a single argument and processes the first clause if the argument is <code><b>NIL</b></code> and the second clause is otherwise. You used this variant of <code>~[</code> in Chapter 9 to generate pass/fail messages, like this: </p> <pre> (format t "~:[FAIL~;pass~]" test-result) </pre> <p> Note that either clause can be empty, but the directive must contain a <code>~;</code>. </p> <p> Finally, with an at-sign modifier, the <code>~[</code> directive can have only one clause. The directive consumes one argument and, if it's non-<code><b>NIL</b></code>, processes the clause after backing up to make the argument available to be consumed again. </p> <pre> (format nil "~@[x = ~a ~]~@[y = ~a~]" 10 20) ==&gt; "x = 10 y = 20" (format nil "~@[x = ~a ~]~@[y = ~a~]" 10 nil) ==&gt; "x = 10 " (format nil "~@[x = ~a ~]~@[y = ~a~]" nil 20) ==&gt; "y = 20" (format nil "~@[x = ~a ~]~@[y = ~a~]" nil nil) ==&gt; "" </pre> <h2> <a name="iteration" id="iteration">Iteration</a> </h2> <p> Another <code><b>FORMAT</b></code> directive that you've seen already, in passing, is the iteration directive <code>~{</code>. This directive tells <code><b>FORMAT</b></code> to iterate over the elements of a list or over the implicit list of the format arguments. </p> <p> With no modifiers, <code>~{</code> consumes one format argument, which must be a list. Like the <code>~[</code> directive, which is always paired with a <code>~]</code> directive, the <code>~{</code> directive is always paired with a closing <code>~</code>}. The text between the two markers is processed as a control string, which draws its arguments from the list consumed by the <code>~{</code> directive. <code><b>FORMAT</b></code> will repeatedly process this control string for as long as the list being iterated over has elements left. In the following example, the <code>~{</code> consumes the single format argument, the list <code>(1 2 3)</code>, and then processes the control string <code>"~a, "</code>, repeating until all the elements of the list have been consumed. </p> <pre> (format nil "~{~a, ~}" (list 1 2 3)) ==&gt; "1, 2, 3, " </pre> <p> However, it's annoying that in the output the last element of the list is followed by a comma and a space. You can fix that with the <code>~^</code> directive; within the body of a <code>~{</code> directive, the <code>~^</code> causes the iteration to stop immediately, without processing the rest of the control string, when no elements remain in the list. Thus, to avoid printing the comma and space after the last element of a list, you can precede them with a <code>~^</code>. </p> <pre> (format nil "~{~a~^, ~}" (list 1 2 3)) ==&gt; "1, 2, 3" </pre> <p> The first two times through the iteration, there are still unprocessed elements in the list when the <code>~^</code> is processed. The third time through, however, after the <code>~a</code> directive consumes the <code>3</code>, the <code>~^</code> will cause <code><b>FORMAT</b></code> to break out of the iteration without printing the comma and space. </p> <p> With an at-sign modifier, <code>~{</code> processes the remaining format arguments as a list. </p> <pre> (format nil "~@{~a~^, ~}" 1 2 3) ==&gt; "1, 2, 3" </pre> <p> Within the body of a <code>~{...~</code>}, the special prefix parameter <code>#</code> refers to the number of items remaining to be processed in the list rather than the number of remaining format arguments. You can use that, along with the <code>~[</code> directive, to print a comma-separated list with an "and" before the last item like this: </p> <pre> (format nil "~{~a~#[~;, and ~:;, ~]~}" (list 1 2 3)) ==&gt; "1, 2, and 3" </pre> <p> However, that doesn't really work right if the list is two items long because it adds an extra comma. </p> <pre> (format nil "~{~a~#[~;, and ~:;, ~]~}" (list 1 2)) ==&gt; "1, and 2" </pre> <p> You could fix that in a bunch of ways. The following takes advantage of the behavior of <code>~@{</code> when nested inside another <code>~{</code> or <code>~@{</code> directive--it iterates over whatever items remain in the list being iterated over by the outer <code>~{</code>. You can combine that with a <code>~#[</code> directive to make the following control string for formatting lists according to English grammar: </p> <pre> (defparameter *english-list* "~{~#[~;~a~;~a and ~a~:;~@{~a~#[~;, and ~:;, ~]~}~]~}") (format nil *english-list* '()) ==&gt; "" (format nil *english-list* '(1)) ==&gt; "1" (format nil *english-list* '(1 2)) ==&gt; "1 and 2" (format nil *english-list* '(1 2 3)) ==&gt; "1, 2, and 3" (format nil *english-list* '(1 2 3 4)) ==&gt; "1, 2, 3, and 4" </pre> <p> While that control string verges on being "write-only" code, it's not too hard to understand if you take it a bit at a time. The outer <code>~{...~</code>} will consume and iterate over a list. The whole body of the iteration then consists of a <code>~#[...~]</code>; the output generated each time through the iteration will thus depend on the number of items left to be processed from the list. Splitting apart the <code>~#[...~]</code> directive on the <code>~;</code> clause separators, you can see that it's made up of four clauses, the last of which is a default clause because it's preceded by a <code>~:;</code> rather than a plain <code>~;</code>. The first clause, for when there are zero elements to be processed, is empty, which makes sense--if there are no more elements to be processed, the iteration would've stopped already. The second clause handles the case of one element with a simple <code>~a</code> directive. Two elements are handled with <code>"~a and ~a"</code>. And the default clause, which handles three or more elements, consists of another iteration directive, this time using <code>~@{</code> to iterate over the remaining elements of the list being processed by the outer <code>~{</code>. And the body of that iteration is the control string that can handle a list of three or more elements correctly, which is fine in this context. Because the <code>~@{</code> loop consumes all the remaining list items, the outer loop iterates only once. </p> <p> If you wanted to print something special such as "&lt;empty&gt;" when the list was empty, you have a couple ways to do it. Perhaps the easiest is to put the text you want into the first (zeroth) clause of the outer <code>~#[</code> and then add a colon modifier to the closing <code>~</code>} of the outer iteration--the colon forces the iteration to be run at least once, even if the list is empty, at which point <code><b>FORMAT</b></code> processes the zeroth clause of the conditional directive. </p> <pre> (defparameter *english-list* "~{~#[&lt;empty&gt;~;~a~;~a and ~a~:;~@{~a~#[~;, and ~:;, ~]~}~]~:}") (format nil *english-list* '()) ==&gt; "&lt;empty&gt;" </pre> <p> Amazingly, the <code>~{</code> directive provides even more variations with different combinations of prefix parameters and modifiers. I won't discuss them other than to say you can use an integer prefix parameter to limit the maximum number of iterations and that, with a colon modifier, each element of the list (either an actual list or the list constructed by the <code>~@{</code> directive) must itself be a list whose elements will then be used as arguments to the control string in the <code>~:{...~</code>} directive. </p> <h2> <a name="hop-skip-jump" id="hop-skip-jump">Hop, Skip, Jump</a> </h2> <p> A much simpler directive is the <code>~*</code> directive, which allows you to jump around in the list of format arguments. In its basic form, without modifiers, it simply skips the next argument, consuming it without emitting anything. More often, however, it's used with a colon modifier, which causes it to move backward, allowing the same argument to be used a second time. For instance, you can use <code>~:*</code> to print a numeric argument once as a word and once in numerals like this: </p> <pre> (format nil "~r ~:*(~d)" 1) ==&gt; "one (1)" </pre> <p> Or you could implement a directive similar to <code>~:P</code> for an irregular plural by combing <code>~:*</code> with <code>~[</code>. </p> <pre> (format nil "I saw ~r el~:*~[ves~;f~:;ves~]." 0) ==&gt; "I saw zero elves." (format nil "I saw ~r el~:*~[ves~;f~:;ves~]." 1) ==&gt; "I saw one elf." (format nil "I saw ~r el~:*~[ves~;f~:;ves~]." 2) ==&gt; "I saw two elves." </pre> <p> In this control string, the <code>~R</code> prints the format argument as a cardinal number. Then the <code>~:*</code> directive backs up so the number is also used as the argument to the <code>~[</code> directive, selecting between the clauses for when the number is zero, one, or anything else.<sup>7</sup> </p> <p> Within an <code>~{</code> directive, <code>~*</code> skips or backs up over the items in the list. For instance, you could print only the keys of a plist like this: </p> <pre> (format nil "~{~s~*~^ ~}" '(:a 10 :b 20)) ==&gt; ":A :B" </pre> <p> The <code>~*</code> directive can also be given a prefix parameter. With no modifiers or with the colon modifier, this parameter specifies the number of arguments to move forward or backward and defaults to one. With an at-sign modifier, the prefix parameter specifies an absolute, zero-based index of the argument to jump to, defaulting to zero. The at-sign variant of <code>~*</code> can be useful if you want to use different control strings to generate different messages for the same arguments and if different messages need to use the arguments in different orders.<sup>8</sup> </p> <h2> <a name="and-more---" id="and-more---">And More . . .</a> </h2> <p> And there's more--I haven't mentioned the <code>~?</code> directive, which can take snippets of control strings from the format arguments or the <code>~/</code> directive, which allows you to call an arbitrary function to handle the next format argument. And then there are all the directives for generating tabular and pretty-printed output. But the directives discussed in this chapter should be plenty for the time being. </p> <p> In the next chapter, you'll move onto Common Lisp's condition system, the Common Lisp analog to other languages' exception and error handling systems. </p> <hr> <div class="notes"> <p> <sup>1</sup>Of course, most folks realize it's not worth getting that worked up over <i>anything</i> in a programming language and use it or not without a lot of angst. On the other hand, it's interesting that these two features are the two features in Common Lisp that implement what are essentially domain-specific languages using a syntax not based on s-expressions. The syntax of <code><b>FORMAT</b></code>'s control strings is character based, while the extended <code><b>LOOP</b></code> macro can be understood only in terms of the grammar of the <code><b>LOOP</b></code> keywords. That one of the common knocks on both <code><b>FORMAT</b></code> and <code><b>LOOP</b></code> is that they "aren't Lispy enough" is evidence that Lispers really do like the s-expression syntax. </p> <p> <sup>2</sup>Readers interested in the pretty printer may want to read the paper "XP: A Common Lisp Pretty Printing System" by Richard Waters. It's a description of the pretty printer that was eventually incorporated into Common Lisp. You can download it from <code>ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-1102a.pdf</code>. </p> <p> <sup>3</sup>To slightly confuse matters, most other I/O functions also accept <code><b>T</b></code> and <code><b>NIL</b></code> as <i>stream designators</i> but with a different meaning: as a stream designator, <code><b>T</b></code> designates the bidirectional stream <code><b>*TERMINAL-IO*</b></code>, while <code><b>NIL</b></code> designates <code><b>*STANDARD-OUTPUT*</b></code> as an output stream and <code><b>*STANDARD-INPUT*</b></code> as an input stream. </p> <p> <sup>4</sup>This variant on the <code>~C</code> directive makes more sense on platforms like the Lisp Machines where key press events were represented by Lisp characters. </p> <p> <sup>5</sup>Technically, if the argument isn't a real number, <code>~F</code> is supposed to format it as if by the <code>~D</code> directive, which in turn behaves like the <code>~A</code> directive if the argument isn't a number, but not all implementations get this right. </p> <p> <sup>6</sup>Well, that's what the language standard says. For some reason, perhaps rooted in a common ancestral code base, several Common Lisp implementations don't implement this aspect of the <code>~F</code> directive correctly. </p> <p> <sup>7</sup>If you find "I saw zero elves" to be a bit clunky, you could use a slightly more elaborate format string that makes another use of <code>~:*</code> like this: </p> <pre> (format nil "I saw ~[no~:;~:*~r~] el~:*~[ves~;f~:;ves~]." 0) ==&gt; "I saw no elves." (format nil "I saw ~[no~:;~:*~r~] el~:*~[ves~;f~:;ves~]." 1) ==&gt; "I saw one elf." (format nil "I saw ~[no~:;~:*~r~] el~:*~[ves~;f~:;ves~]." 2) ==&gt; "I saw two elves." </pre> <p> <sup>8</sup>This kind of problem can arise when trying to localize an application and translate human-readable messages into different languages. <code><b>FORMAT</b></code> can help with some of these problems but is by no means a full-blown localization system. </p> </div> <div class="copyright"> - Copyright © 2003-2005, Peter Seibel + Copyright © 2003-2005, Peter Seibel </div> </body> </html> diff --git a/html/conclusion-whats-next.html b/html/conclusion-whats-next.html index c9f320d..94dabde 100644 --- a/html/conclusion-whats-next.html +++ b/html/conclusion-whats-next.html @@ -1,506 +1,506 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title> Conclusion: What's Next? </title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1> 32. Conclusion: What's Next? </h1> <p> I hope by now you're convinced that the title of this book isn't an oxymoron. However, it's quite likely there's some area of programming that's of great practical importance to you that I haven't discussed at all. For instance, I haven't said anything about how to develop graphical user interfaces (GUIs), how to connect to relational databases, how to parse XML, or how to write programs that act as clients for various network protocols. Similarly, I haven't discussed two topics that will become important when you write real applications in Common Lisp: optimizing your Lisp code and packaging your application for delivery. </p> <p> I'm obviously not going to cover all these topics in depth in this final chapter. Instead, I'll give you a few pointers you can use to pursue whichever aspect of Lisp programming interests you most. </p> <h2> <a name="finding-lisp-libraries" id="finding-lisp-libraries">Finding Lisp Libraries</a> </h2> <p> While the standard library of functions, data types, and macros that comes with Common Lisp is quite large, it provides only general-purpose programming constructs. Specialized tasks such as writing GUIs, talking to databases, and parsing XML require libraries beyond what are provided by the ANSI standardized language. </p> <p> The easiest way to obtain a library to do something you need may be simply to check out your Lisp implementation. Most implementations provide at least some facilities not specified in the language standard. The commercial Common Lisp vendors tend to work especially hard at providing additional libraries for their implementation in order to justify their prices. Franz's Allegro Common Lisp, Enterprise Edition, for instance, comes with libraries for parsing XML, speaking SOAP, generating HTML, connecting to relational databases, and building graphical interfaces in various ways, among others. LispWorks, another prominent commercial Lisp, provides several similar libraries, including a well-regarded portable GUI toolkit, CAPI, which can be used to develop GUI applications that will run on any operating system LispWorks runs on. </p> <p> The free and open-source Common Lisp implementations typically don't include quite so many bundled libraries, relying instead on portable free and open-source libraries. But even those implementations usually fill in some of the more important areas not addressed by the language standard such as networking and multithreading. </p> <p> The only disadvantage of using implementation-specific libraries is that they tie you to the implementation that provides them. If you're delivering end-user apps or are deploying a server-based application on a server that you control, that may not matter a lot. But if you want to write code to share with other Lispers or if you simply don't want to be tied to a particular implementation, it's a little more annoying. </p> <p> For portable libraries--portable either because they're written entirely in standard Common Lisp or because they contain appropriate read-time conditionalization to work on multiple implementations<sup>1</sup>--your best bet is to go to the Web. With the usual caveats about URLs going stale as soon as they're printed on paper, these are three of the best current starting points: </p> <ul> <li>Common-Lisp.net (<code>http://www.common-lisp.net/</code>) is a site that hosts free and open-source Common Lisp projects, providing version control, mailing lists, and Web hosting of project pages. In the first year and a half after the site went live, nearly a hundred projects were registered. </li> <li>The Common Lisp Open Code Collection (CLOCC) (<code>http://clocc.sourceforge.net/</code>) is a slightly older collection of free software libraries, which are intended to be portable between Common Lisp implementations and self-contained, not relying on any libraries not included in CLOCC itself. </li> <li>Cliki (<code>http://www.cliki.net/</code>) is a wiki devoted to free software in Common Lisp. While, like any wiki, it may change at any time, typically it has quite a few links to libraries as well to various open-source Common Lisp implementations. The eponymous software it runs on is also written in Common Lisp. </li> </ul> <p> Linux users running the Debian or Gentoo distributions can also easily install an ever-growing number of Lisp libraries that have been packaged with those distributions' packing tools, <code>apt-get</code> on Debian and <code>emerge</code> on Gentoo. </p> <p> I won't recommend any specific libraries here since the library situation is changing every day--after years of envying the library collections of Perl, Python, and Java, Common Lispers have, in the past couple of years, begun to take up the challenge of giving Common Lisp the set of libraries--both open source and commercial--that it deserves. </p> <p> One area where there has been a lot of activity recently is on the GUI front. Unlike Java and C# but like Perl, Python, and C, there's no single way to develop GUIs in Common Lisp. Instead, it depends both on what Common Lisp implementation you're using and what operating system or systems you want to support. </p> <p> The commercial Common Lisp implementations usually provide some way to build GUIs for the platforms they run on. Additionally, LispWorks provides CAPI, the previously mentioned, portable GUI API. </p> <p> On the open-source side, you have a number of options. On Unix, you can write low-level X Windows GUIs using CLX, a pure-Common Lisp implementation of the X Windows protocol, roughly akin to xlib in C. Or you can use various bindings to higher-level APIs and toolkits such as GTK and Tk, much the way you might in Perl or Python. </p> <p> Or, if you're looking for something completely different, you can check out Common Lisp Interface Manager (CLIM). A descendant of the Symbolics Lisp Machines GUI framework, CLIM is powerful but complex. Although many commercial Common Lisp implementations actually support it, it doesn't seem to have seen a lot of use. But in the past couple years, an open-source implementation of CLIM, McCLIM--now hosted at Common-Lisp.net--has been picking up steam lately, so we may be on the verge of a CLIM renaissance. </p> <h2> <a name="interfacing-with-other-languages" id="interfacing-with-other-languages">Interfacing with Other Languages</a> </h2> <p> While many useful libraries can be written in "pure" Common Lisp using only the features specified in the language standard, and many more can be written in Lisp using nonstandard facilities provided by a given implementation, occasionally it's more straightforward to use an existing library written in another language, such as C. </p> <p> The language standard doesn't specify a mechanism for Lisp code to call code written in another language or even require that implementations provide such a mechanism. But these days, almost all Common Lisp implementations support what's called a <i>Foreign Function Interface</i>, or FFI for short.<sup>2</sup> The basic job of an FFI is to allow you to give Lisp enough information to be able to link in the foreign code. Thus, if you're going to call a function from a C library, you need to tell Lisp about how to translate the Lisp objects passed to the function into C types and the value returned by the function back into a Lisp object. However, each implementation provides its own FFI, each with slightly varying capabilities and syntax. Some FFIs allow callbacks from C to Lisp, and others don't. The Universal Foreign Function Interface (UFFI) project provides a portability layer over the FFIs of more than a half dozen different Common Lisp implementations. It works by defining its own macros that expand into appropriate FFI code for the implementation it's running in. The UFFI takes a lowest common denominator approach, which means it can't take advantage of all the features of different implementations' FFIs, but it does provide a good way to build a simple Lisp wrapper around a basic C API.<sup>3</sup> </p> <h2> <a name="make-it-work-make-it-right-make-it-fast" id="make-it-work-make-it-right-make-it-fast">Make It Work, Make It Right, Make It Fast</a> </h2> <p> As has been said many times, and variously attributed to Donald Knuth, C.A.R. Hoare, and Edsger Dijkstra, premature optimization is the root of all evil.<sup>4</sup> Common Lisp is an excellent language to program in if you want to heed this wisdom yet still need high performance. This may come as a surprise if you've heard the conventional wisdom that Lisp is slow. In Lisp's earliest days, when computers were programmed with punch cards, Lisp's high-level features may have doomed it to be slower than the competition, namely, assembly and FORTRAN. But that was a long time ago. In the meantime, Lisp has been used for everything from creating complex AI systems to writing operating systems, and a lot of work has gone into figuring out how to compile Lisp into efficient code. In this section I'll talk about some of the reasons why Common Lisp is an excellent language for writing high-performance code and some of the techniques for doing so. </p> <p> The first reason that Lisp is an excellent language for writing high-performance code is, ironically enough, the dynamic nature of Lisp programming--the very thing that originally made it hard to bring Lisp's performance up to the levels achieved by FORTRAN compilers. The reason Common Lisp's dynamic features make it easier to write high-performance code is that the first step to writing efficient code is to find the right algorithms and data structures. </p> <p> Common Lisp's dynamic features keep code flexible, which makes it easier to try different approaches. Given a finite amount of time to write a program, you're much more likely to end up with a high-performance version if you don't spend a lot of time getting into and out of dead ends. In Common Lisp, you can try an idea, see it's going nowhere, and move on without having spent a ton of time convincing the compiler your code is worthy of being run and then waiting for it to finish compiling. You can write a straightforward but inefficient version of a function--a <i>code sketch</i>--to determine whether your basic approach is sound and then replace that function with a more complex but more efficient implementation if you determine that it is. And if the overall approach turns out to be flawed, then you haven't wasted a bunch of time tuning a function that's no longer needed, which means you have more time to find a better approach. </p> <p> The next reason Common Lisp is a good language for developing high-performance software is that most Common Lisp implementations come with mature compilers that generate quite efficient machine code. I'll talk in a moment about how to help these compilers generate code that will be competitive with code generated by C compilers, but these implementations already are quite a bit faster than those of languages whose implementations are less mature and use simpler compilers or interpreters. Also, since the Lisp compiler is available at runtime, the Lisp programmer has some possibilities that would be hard to emulate in other languages--your programs can generate Lisp code at runtime that's then compiled into machine code and run. If the generated code is going to run enough times, this can be a big win. Or, even without using the compiler at runtime, closures give you another way to meld machine code with runtime data. For instance, the CL-PPCRE regular expression library, running in CMUCL, is faster than Perl's regular expression engine on some benchmarks, even though Perl's engine is written in highly tuned C. This is presumably because in Perl a regular expression is translated into what are essentially bytecodes that are then interpreted by the regex engine, while CL-PPCRE translates a regular expression into a tree of compiled closures that invoke each other via the normal function-calling machinery.<sup>5</sup> </p> <p> However, even with the right algorithm and a high-quality compiler, you may not get the raw speed you need. Then it's time to think about profiling and tuning. The key, in Lisp as in any language, is to profile first to find the spots where your program is actually spending its time and then worry about speeding up those parts.<sup>6</sup> </p> <p> You have a number of different ways to approach profiling. The language standard provides a few rudimentary tools for measuring how long certain forms take to execute. In particular, the <code><b>TIME</b></code> macro can be wrapped around any form and will return whatever values the form returns after printing a message to <code><b>*TRACE-OUTPUT*</b></code> about how long it took to run and how much memory it used. The exact form of the message is implementation defined. </p> <p> You can use <code><b>TIME</b></code> for a bit of quick-and-dirty profiling to narrow your search for bottlenecks. For instance, suppose you have a function that's taking a long time to run and that calls two other functions--something like this: </p> <pre> (defun foo () (bar) (baz)) </pre> <p> If you want to see whether <code>bar</code> or <code>baz</code> is taking more time, you can change the definition of <code>foo</code> to this: </p> <pre> (defun foo () (time (bar)) (time (baz))) </pre> <p> Now you can call <code>foo</code>, and Lisp will print two reports, one for <code>bar</code> and one for <code>baz</code>. The form is implementation dependent; here's what it looks like in Allegro Common Lisp: </p> <pre> CL-USER&gt; (foo) ; cpu time (non-gc) 60 msec user, 0 msec system ; cpu time (gc) 0 msec user, 0 msec system ; cpu time (total) 60 msec user, 0 msec system ; real time 105 msec ; space allocation: ; 24,172 cons cells, 1,696 other bytes, 0 static bytes ; cpu time (non-gc) 540 msec user, 10 msec system ; cpu time (gc) 170 msec user, 0 msec system ; cpu time (total) 710 msec user, 10 msec system ; real time 1,046 msec ; space allocation: ; 270,172 cons cells, 1,696 other bytes, 0 static bytes </pre> <p> Of course, that'd be a bit easier to read if the output included a label. If you use this technique a lot, it might be worth defining your own macro like this: </p> <pre> (defmacro labeled-time (form) `(progn (format *trace-output* "~2&amp;~a" ',form) (time ,form))) </pre> <p> If you replace <code><b>TIME</b></code> with <code>labeled-time</code> in <code>foo</code>, you'll get this output: </p> <pre> CL-USER&gt; (foo) (BAR) ; cpu time (non-gc) 60 msec user, 0 msec system ; cpu time (gc) 0 msec user, 0 msec system ; cpu time (total) 60 msec user, 0 msec system ; real time 131 msec ; space allocation: ; 24,172 cons cells, 1,696 other bytes, 0 static bytes (BAZ) ; cpu time (non-gc) 490 msec user, 0 msec system ; cpu time (gc) 190 msec user, 10 msec system ; cpu time (total) 680 msec user, 10 msec system ; real time 1,088 msec ; space allocation: ; 270,172 cons cells, 1,696 other bytes, 0 static bytes </pre> <p> From this output, it's clear that most of the time in <code>foo</code> is spent in <code>baz</code>. </p> <p> Of course, the output from <code><b>TIME</b></code> gets a bit unwieldy if the form you want to profile is called repeatedly. You can build your own measurement tools using the functions <code><b>GET-INTERNAL-REAL-TIME</b></code> and <code><b>GET-INTERNAL-RUN-TIME</b></code>, which return a number that increases by the value of the constant <code><b>INTERNAL-TIME-UNITS-PER-SECOND</b></code> each second. <code><b>GET-INTERNAL-REAL-TIME</b></code> measures <i>wall time</i>, the actual amount of time elapsed, while <code><b>GET-INTERNAL-RUN-TIME</b></code> measures some implementation-defined value such as the amount of time Lisp was actually executing or the time Lisp was executing user code and not internal bookkeeping such as the garbage collector. Here's a trivial but useful profiling tool built with a few macros and <code><b>GET-INTERNAL-RUN-TIME</b></code>: </p> <pre> (defparameter *timing-data* ()) (defmacro with-timing (label &amp;body body) (with-gensyms (start) `(let ((,start (get-internal-run-time))) (unwind-protect (progn ,@body) (push (list ',label ,start (get-internal-run-time)) *timing-data*))))) (defun clear-timing-data () (setf *timing-data* ())) (defun show-timing-data () (loop for (label time count time-per %-of-total) in (compile-timing-data) do (format t "~3d% ~a: ~d ticks over ~d calls for ~d per.~%" %-of-total label time count time-per))) (defun compile-timing-data () (loop with timing-table = (make-hash-table) with count-table = (make-hash-table) for (label start end) in *timing-data* for time = (- end start) summing time into total do (incf (gethash label timing-table 0) time) (incf (gethash label count-table 0)) finally (return (sort (loop for label being the hash-keys in timing-table collect (let ((time (gethash label timing-table)) (count (gethash label count-table))) (list label time count (round (/ time count)) (round (* 100 (/ time total)))))) #'&gt; :key #'fifth)))) </pre> <p> This profiler lets you wrap a <code>with-timing</code> around any form; each time the form is executed, the time it starts and the time it ends are recorded, associating with a label you provide. The function <code>show-timing-data</code> dumps out a table showing how much time was spent in different labeled sections of code like this: </p> <pre> CL-USER&gt; (show-timing-data) 84% BAR: 650 ticks over 2 calls for 325 per. 16% FOO: 120 ticks over 5 calls for 24 per. NIL </pre> <p> You could obviously make this profiling code more sophisticated in many ways. Alternatively, your Lisp implementation most likely provides its own profiling tools, which, since they have access to the internals of the implementation, can get at information not necessarily available to user-level code. </p> <p> Once you've found the bottleneck in your code, you can start tuning. The first thing you should try, of course, is to find a more efficient basic algorithm--that's where the big gains are to be had. But assuming you're already using an appropriate algorithm, then it's down to <i>code bumming</i>--locally optimizing the code so it does absolutely no more work than necessary. </p> <p> The main tools for code bumming in Common Lisp are its optional declarations. The basic idea behind declarations in Common Lisp is that they're used to give the compiler information it can use in a variety of ways to generate better code. </p> <p> For a simple example, consider this Common Lisp function: </p> <pre> (defun add (x y) (+ x y)) </pre> <p> I mentioned in Chapter 10 that if you compare the performance of this function Lisp to the seemingly equivalent C function: </p> <pre> int add (int x, int y) { return x + y; } </pre> <p> you'll likely find the Common Lisp version to be quite a bit slower, even if your Common Lisp implementation features a high-quality native compiler. </p> <p> That's because the Common Lisp version is doing a lot more--the Common Lisp compiler doesn't even know that the values of <code>a</code> and <code>b</code> are numbers and so has to generate code to check at runtime. And once it determines they <i>are</i> numbers, it has to determine what types of numbers--integers, rationals, floating point, or complex--and dispatch to the appropriate addition routine for the actual types. And even if <code>a</code> and <code>b</code> are integers--the case you care about--then the addition routine has to account for the possibility that the result may be too large to represent as a <i>fixnum</i>, a number that can be represented in a single machine word, and thus it may have to allocate a <i>bignum</i> object. </p> <p> In C, on the other hand, because the type of all variables are declared, the compiler knows exactly what kind of values <code>a</code> and <code>b</code> will hold. And because C's arithmetic simply overflows when the result of an addition is too large to represent in whatever type is being returned, there's no checking for overflow and no allocation of a bignum object to represent the result when the mathematical sum is too large to fit in a machine word. </p> <p> Thus, while the behavior of the Common Lisp code is much more likely to be mathematically correct, the C version can probably be compiled down to one or two machine instructions. But if you're willing to give the Common Lisp compiler the same information the C compiler has about the types of arguments and return values and to accept certain C-like compromises in terms of generality and error checking, the Common Lisp function can also be compiled down to an instruction or two. </p> <p> That's what declarations are for. The main use of declarations is to tell the compiler about the types of variables and other expressions. For instance, you could tell the compiler that the arguments to <code>add</code> are both fixnums by writing the function like this: </p> <pre> (defun add (x y) (declare (fixnum x y)) (+ x y)) </pre> <p> The <code><b>DECLARE</b></code> expression isn't a Lisp form; rather, it's part of the syntax of the <code><b>DEFUN</b></code> and must appear before any other code in the function body.<sup>7</sup> This declaration declares that the arguments passed for the parameters <code>x</code> and <code>y</code> will always be fixnums. In other words, it's a promise to the compiler, and the compiler is allowed to generate code on the assumption that whatever you tell it is true. </p> <p> To declare the type of the value returned, you can wrap the form <code>(+ x y)</code> in the <code><b>THE</b></code> special operator. This operator takes a type specifier, such as <code><b>FIXNUM</b></code>, and a form and tells the compiler the form will evaluate to the given type. Thus, to give the Common Lisp compiler all the information about <code>add</code> that the C compiler gets, you can write it like this: </p> <pre> (defun add (x y) (declare (fixnum x y)) (the fixnum (+ x y))) </pre> <p> However, even this version needs one more declaration to give the Common Lisp compiler the same license as the C compiler to generate fast but dangerous code. The <code><b>OPTIMIZE</b></code> declaration is used to tell the compiler how to balance five qualities: the speed of the code generated; the amount of runtime error checking; the memory usage of the code, both in terms of code size and runtime memory usage; the amount of debugging information kept with the code; and the speed of the compilation process. An <code><b>OPTIMIZE</b></code> declaration consists of one or more lists, each containing one of the symbols <code><b>SPEED</b></code>, <code><b>SAFETY</b></code>, <code><b>SPACE</b></code>, <code><b>DEBUG</b></code>, and <code><b>COMPILATION-SPEED</b></code>, and a number from zero to three, inclusive. The number specifies the relative weighting the compiler should give to the corresponding quality, with <code>3</code> being the most important and <code>0</code> meaning not important at all. Thus, to make Common Lisp compile <code>add</code> more or less like a C compiler would, you can write it like this: </p> <pre> (defun add (x y) (declare (optimize (speed 3) (safety 0))) (declare (fixnum x y)) (the fixnum (+ x y))) </pre> <p> Of course, now the Lisp version suffers from many of the same liabilities as the C version--if the arguments passed aren't fixnums or if the addition overflows, the result will be mathematically incorrect or worse. Also, if someone calls <code>add</code> with a wrong number of arguments, it may not be pretty. Thus, you should use these kinds of declarations only after your program is working correctly. And you should add them only where profiling shows they'll make a difference. If you're getting reasonable performance without them, leave them out. But when profiling shows you a real hot spot in your code and you need to tune it up, go ahead. Because you can use declarations this way, it's rarely necessary to rewrite code in C just for performance reasons; FFIs are used to access existing C code, but declarations are used when C-like performance is needed. Of course, how close you can get the performance of a given piece of Common Lisp code to C and C++ depends mostly on how much like C you're willing to make it. </p> <p> Another code-tuning tool built into Lisp is the function <code><b>DISASSEMBLE</b></code>. The exact behavior of this function is implementation dependent because it depends on how the implementation compiles code--whether to machine code, bytecodes, or some other form. But the basic idea is that it shows you the code generated by the compiler when it compiled a specific function. </p> <p> Thus, you can use <code><b>DISASSEMBLE</b></code> to see whether your declarations are having any effect on the code generated. And if your Lisp implementation uses a native compiler and you know your platform's assembly language, you can get a pretty good sense of what's actually going on when you call one of your functions. For instance, you could use <code><b>DISASSEMBLE</b></code> to get a sense of the difference between the first version of <code>add</code>, with no declarations, and the final version. First, define and compile the original version. </p> <pre> (defun add (x y) (+ x y)) </pre> <p> Then, at the REPL, call <code><b>DISASSEMBLE</b></code> with the name of the function. In Allegro, it shows the following assembly-language-like dump of the code generated by the compiler: </p> <pre> CL-USER&gt; (disassemble 'add) ;; disassembly of #&lt;Function ADD&gt; ;; formals: X Y ;; code start: #x737496f4: 0: 55 pushl ebp 1: 8b ec movl ebp,esp 3: 56 pushl esi 4: 83 ec 24 subl esp,$36 7: 83 f9 02 cmpl ecx,$2 10: 74 02 jz 14 12: cd 61 int $97 ; SYS::TRAP-ARGERR 14: 80 7f cb 00 cmpb [edi-53],$0 ; SYS::C_INTERRUPT-PENDING 18: 74 02 jz 22 20: cd 64 int $100 ; SYS::TRAP-SIGNAL-HIT 22: 8b d8 movl ebx,eax 24: 0b da orl ebx,edx 26: f6 c3 03 testb bl,$3 29: 75 0e jnz 45 31: 8b d8 movl ebx,eax 33: 03 da addl ebx,edx 35: 70 08 jo 45 37: 8b c3 movl eax,ebx 39: f8 clc 40: c9 leave 41: 8b 75 fc movl esi,[ebp-4] 44: c3 ret 45: 8b 5f 8f movl ebx,[edi-113] ; EXCL::+_2OP 48: ff 57 27 call *[edi+39] ; SYS::TRAMP-TWO 51: eb f3 jmp 40 53: 90 nop ; No value </pre> <p> Clearly, there's a bunch of stuff going on here. If you're familiar with x86 assembly language, you can probably tell what. Now compile this version of <code>add</code> with all the declarations. </p> <pre> (defun add (x y) (declare (optimize (speed 3) (safety 0))) (declare (fixnum x y)) (the fixnum (+ x y))) </pre> <p> Now disassemble <code>add</code> again, and see if the declarations had any effect. </p> <pre> CL-USER&gt; (disassemble 'add) ;; disassembly of #&lt;Function ADD&gt; ;; formals: X Y ;; code start: #x7374dc34: 0: 03 c2 addl eax,edx 2: f8 clc 3: 8b 75 fc movl esi,[ebp-4] 6: c3 ret 7: 90 nop ; No value </pre> <p> Looks like they did. </p> <h2> <a name="delivering-applications" id="delivering-applications">Delivering Applications</a> </h2> <p> Another topic of practical importance, which I didn't talk about elsewhere in the book, is how to deliver software written in Lisp. The main reason I neglected this topic is because there are many different ways to do it, and which one is best for you depends on what kind of software you need to deliver to what kind of user with what Common Lisp implementation. In this section I'll give an overview of some of the different options. </p> <p> If you've written code you want to share with fellow Lisp programmers, the most straightforward way to distribute it is as source code.<sup>8</sup> You can distribute a simple library as a single source file, which programmers can <code><b>LOAD</b></code> into their Lisp image, possibly after compiling it with <code><b>COMPILE-FILE</b></code>. </p> <p> More complex libraries or applications, broken up across multiple source files, pose an additional challenge--in order to load and compile the code, the files need to be loaded and compiled in the correct order. For instance, a file containing macro definitions must be loaded before you can compile files that use those macros. And a file containing <code><b>DEFPACKAGE</b></code> forms must be loaded before any files that use those packages can even be <code><b>READ</b></code>. Lispers call this the <i>system definition</i> problem and typically handle it with tools called <i>system definition facilities</i> or <i>system definition utilities</i>, which are somewhat analogous to build tools such as <code>make</code> or <code>ant</code>. As with <code>make</code> and <code>ant</code>, system definition tools allow you to specify the dependencies between different files and then take care of loading and compiling the files in the correct order while trying to do only work that's necessary--recompiling only files that have changed, for example. </p> <p> These days the most widely used system definition tool is ASDF, which stands for <i>Another System Definition Facility</i>.<sup>9</sup> The basic idea behind ASDF is that you define systems in ASD files, and ASDF provides a number of operations on systems such as loading them or compiling them. A system can also be defined to depend on other systems, which will be loaded as necessary. For instance, the following shows the contents of <code>html.asd</code>, the ASD file for the FOO library from Chapters 31 and 32: </p> <pre> (defpackage :com.gigamonkeys.html-system (:use :asdf :cl)) (in-package :com.gigamonkeys.html-system) (defsystem html :name "html" :author "Peter Seibel &lt;[email protected]&gt;" :version "0.1" :maintainer "Peter Seibel &lt;[email protected]&gt;" :license "BSD" :description "HTML and CSS generation from sexps." :long-description "" :components ((:file "packages") (:file "html" :depends-on ("packages")) (:file "css" :depends-on ("packages" "html"))) :depends-on (:macro-utilities)) </pre> <p> If you add a symbolic link to this file from a directory listed in <code>asdf:*central-registry*</code>,<sup>10</sup> then you can type this: </p> <pre> (asdf:operate 'asdf:load-op :html) </pre> <p> to compile and load the files <code>packages.lisp</code>, <code>html.lisp</code>, and <code>html-macros.lisp</code> in the correct order after first making sure the <code>:macro-utilities</code> system has been compiled and loaded. For other examples of ASD files, you can look at this book's source code--the code from each practical chapter is defined as a system with appropriate intersystem dependencies expressed in the ASD files. </p> <p> Most free and open-source Common Lisp libraries you'll find will come with an ASD file. Some will use other system definition tools such as the slightly older MK:DEFSYSTEM or even utilities devised by the library's author, but the tide seems to be turning in the direction of ASDF.<sup>11</sup> </p> <p> Of course, while ASDF makes it easy for Lispers to install Lisp libraries, it's not much help if you want to package an application for an end user who doesn't know or care about Lisp. If you're delivering a pure end-user application, presumably you want to provide something the user can download, install, and run without having to know anything about Lisp. You can't expect them to separately download and install a Lisp implementation. And you want them to be able to run your application just like any other application--by double-clicking an icon on Windows or OS X or by typing the name of the program at the command line on Unix. </p> <p> However, unlike C programs, which can typically rely on certain shared libraries (DLLs on Windows) that make up the C "runtime" being present as part of the operating system, Lisp programs must include a Lisp runtime, that is, the same program you run when you start Lisp though perhaps with certain functionality not needed to run the application excised. </p> <p> To further complicate matters, <i>program</i> isn't really well defined in Lisp. As you've seen throughout this book, the process of developing software in Lisp is an incremental process that involves making changes to the set of definitions and data living in your Lisp image. The "program" is just a particular state of the image arrived at by loading the <code>.lisp</code> or <code>.fasl</code> files that contain code that creates the appropriate definitions and data. You could, then, distribute a Lisp application as a Lisp runtime plus a bunch of FASL files and an executable that starts the runtime, loads the FASLs, and somehow invokes the appropriate starting function. However, since actually loading the FASLs can take some time, especially if they have to do any computation to set up the state of the world, most Common Lisp implementations provide a way to <i>dump an image</i>--to save the state of a running Lisp to a file called an <i>image file</i> or sometimes a <i>core</i>. When a Lisp runtime starts, the first thing it does is load an image file, which it can do in much less time than it'd take to re-create the state by loading FASL files. </p> <p> Normally the image file is a default image containing only the standard packages defined by the language and any extras provided by the implementation. But with most implementations, you have a way to specify a different image file. Thus, instead of packaging an app as a Lisp runtime plus a bunch of FASLs, you can package it as a Lisp runtime plus a single image file containing all the definitions and data that make up your application. Then all you need is a program that launches the Lisp runtime with the appropriate image file and invokes whatever function serves as the entry point to the application. </p> <p> This is where things get implementation and operating-system dependent. Some Common Lisp implementations, in particular the commercial ones such as Allegro and LispWorks, provide tools for building such an executable. For instance, Allegro's Enterprise Edition provides a function <code>excl:generate-application</code> that creates a directory containing the Lisp runtime as a shared library, an image file, and an executable that starts the runtime with the given image. Similarly, the LispWorks Professional Edition "delivery" mechanism allows you to build single-file executables of your programs. On Unix, with the various free and open-source implementations, you can do essentially the same thing except it's probably easier to use a shell script to start everything. </p> <p> And on OS X things are even better--since all applications on OS X are packaged as <code>.app</code> bundles, which are essentially directories with a certain structure, it's not all that difficult to package all the parts of a Lisp application as a double-clickable <code>.app</code> bundle. Mikel Evins's Bosco tool makes it easy to create <code>.app</code> bundles for applications running on OpenMCL. </p> <p> Of course, another popular way to deliver applications these days is as server-side applications. This is a niche where Common Lisp can really excel--you can pick a combination of operating system and Common Lisp implementation that works well for you, and you don't have to worry about packaging the application to be installed by an end user. And Common Lisp's interactive debugging and development features make it possible to debug and upgrade a live server in ways that either just aren't possible in a less dynamic language or would require you to build a lot of specific infrastructure. </p> <h2> <a name="where-to-go-next" id="where-to-go-next">Where to Go Next</a> </h2> <p> So, that's it. Welcome to the wonderful world of Lisp. The best thing you can do now--if you haven't already--is to start writing your own Lisp code. Pick a project that interests you, and do it in Common Lisp. Then do another. Lather, rinse, repeat. </p> <p> However, if you need some further pointers, this section offers some places to go. For starters, check out the <i>Practical Common Lisp</i> Web site at <code>http://www.gigamonkeys.com/book/</code>, where you can find the source code from the practical chapters, errata, and links to other Lisp resources on the Web. </p> <p> In addition to the sites I mentioned in the "Finding Lisp Libraries" section, you may also want explore the Common Lisp HyperSpec (a.k.a. the HyperSpec or CLHS), an HTML version of the ANSI language standard prepared by Kent Pitman and made available by LispWorks at <code>http://www.lispworks.com/documentation/HyperSpec/index.html</code>. The HyperSpec is by no means a tutorial, but it's as authoritative a guide to the language as you can get without buying a printed copy of the standard from ANSI and much more convenient for day-to-day use.<sup>12</sup> </p> <p> If you want to get in touch with other Lispers, <code>comp.lang.lisp</code> on Usenet and the <code>#lisp</code> IRC channel or the Freenode network (<code>http://www.freenode.net</code>) are two of the main online hang- outs. There are also a number of Lisp-related blogs, most of which are aggregated on Planet Lisp at <code>http://planet.lisp.org/</code>. </p> <p> And keep your eyes peeled in all those forums for announcements of local Lisp users get-togethers in your area--in the past few years, Lispnik gatherings have popped up in cities around the world, from New York to Oakland, from Cologne to Munich, and from Geneva to Helsinki. </p> <p> If you want to stick to books, here are a few suggestions. For a nice thick reference book to stick on your desk, grab <i>The ANSI Common Lisp Reference Book</i> edited by David Margolies (Apress, 2005).<sup>13</sup> </p> <p> - For more on Common Lisp's object system, you can start with <i>Object-Oriented Programming in Common Lisp: A Programmer's Guide to CLOS</i> by Sonya E. Keene (Addison-Wesley, 1989). Then if you really want to become an object wizard or just to stretch your mind in interesting ways, read <i>The Art of the Metaobject Protocol</i> by Gregor Kiczales, Jim des Riviéres, and Daniel G. Bobrow (MIT Press, 1991). This book, also known as AMOP, is both an explanation of what a metaobject protocol is and why you want one and the de facto standard for the metaobject protocol supported by many Common Lisp implementations. + For more on Common Lisp's object system, you can start with <i>Object-Oriented Programming in Common Lisp: A Programmer's Guide to CLOS</i> by Sonya E. Keene (Addison-Wesley, 1989). Then if you really want to become an object wizard or just to stretch your mind in interesting ways, read <i>The Art of the Metaobject Protocol</i> by Gregor Kiczales, Jim des Riviéres, and Daniel G. Bobrow (MIT Press, 1991). This book, also known as AMOP, is both an explanation of what a metaobject protocol is and why you want one and the de facto standard for the metaobject protocol supported by many Common Lisp implementations. </p> <p> Two books that cover general Common Lisp technique are <i>Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp</i> by Peter Norvig (Morgan Kaufmann, 1992) and <i>On Lisp: Advanced Techniques for Common Lisp</i> by Paul Graham (Prentice Hall, 1994). The former provides a solid introduction to artificial intelligence techniques while teaching quite a bit about how to write good Common Lisp code, and the latter is especially good in its treatment of macros. </p> <p> If you're the kind of person who likes to know how things work down to the bits, <i>Lisp in Small Pieces</i> by Christian Queinnec (Cambridge University Press, 1996) provides a nice blend of programming language theory and practical Lisp implementation techniques. While it's primarily focused on Scheme rather than Common Lisp, the same principles apply. </p> <p> For folks who want a little more theoretical look at things--or who just want to know what it's like to be a freshman comp sci student at M.I.T.--<i>Structure and Interpretation of Computer Programs</i>, Second Edition, by Harold Abelson, Gerald Jay Sussman, and Julie Sussman (M.I.T. <i>Press, 1996) is a classic computer science text that uses Scheme to teach important programming c</i>oncepts. Any programmer can learn a lot from this book--just remember that there are important differences between Scheme and Common Lisp. </p> <p> Once you've wrapped your mind around Lisp, you may want to place it in a bit of context. Since no one can claim to really understand object orientation who doesn't know something about Smalltalk, you might want to start with <i>Smalltalk-80: The Language</i> by Adele Goldberg and David Robson (Addison Wesley, 1989), the standard introduction to the core of Smalltalk. After that, <i>Smalltalk Best Practice Patterns</i> by Kent Beck (Prentice Hall, 1997) is full of good advice aimed at Smalltalkers, much of which is applicable to any object-oriented language. </p> <p> And at the other end of the spectrum, <i>Object-Oriented Software Construction</i> by Bertrand Meyer (Prentice Hall, 1997) is an excellent exposition of the static language mind-set from the inventor of Eiffel, an oft-overlooked descendant of Simula and Algol. It contains much food for thought, even for programmers working with dynamic languages such as Common Lisp. In particular, Meyer's ideas about Design By Contract can shed a lot of light on how one ought to use Common Lisp's condition system. </p> <p> Though not about computers per se, <i>The Wisdom of Crowds: Why the Many Are Smarter Than the Few and How Collective Wisdom Shapes Business, Economies, Societies, and Nations</i> by James Surowiecki (Doubleday, 2004) contains an excellent answer to the question, "If Lisp's so great how come everybody isn't using it?" See the section on "Plank-Road Fever" starting on page 53. </p> <p> And finally, for some fun, and to learn about the influence Lisp and Lispers have had on hacker culture, dip into (or read from cover to cover) <i>The New Hacker's Dictionary</i>, Third Edition, compiled by Eric S. Raymond (MIT Press, 1996) and based on the original <i>The Hacker's Dictionary</i> edited by Guy Steele (Harper &amp; Row, 1983). </p> <p> But don't let all these suggestions interfere with your programming--the only way to really learn a language is to use it. If you've made it this far, you're certainly ready to do that. Happy hacking! </p> <hr> <div class="notes"> <p> <sup>1</sup>The combination of Common Lisp's read-time conditionalization and macros makes it quite feasible to develop portability libraries that do nothing but provide a common API layered over whatever API different implementations provide for facilities not specified in the language standard. The portable pathname library from Chapter 15 is an example of this kind of library, albeit to smooth over differences in interpretation of the standard rather than implementation-dependent APIs. </p> <p> <sup>2</sup>A Foreign Function Interface is basically equivalent to JNI in Java, XS in Perl, or the extension module API in Python. </p> <p> <sup>3</sup>As of this writing, the two main drawbacks of UFFI are the lack of support for callbacks from C into Lisp, which many but not all implementations' FFIs support, and the lack of support for CLISP, whose FFI is quite good but different enough from the others as to not fit easily into the UFFI model. </p> <p> <sup>4</sup>Knuth has used the saying several times in publications, including in his 1974 ACM Turing Award paper, "Computer Programming as an Art," and in his paper "Structured Programs with goto Statements." In his paper "The Errors of TeX," he attributes the saying to C.A.R. Hoare. And Hoare, in an 2004 e-mail to Hans Genwitz of phobia.com, said he didn't remember the origin of the saying but that he might have attributed it to Dijkstra. </p> <p> <sup>5</sup>CL-PPCRE also takes advantage of another Common Lisp feature I haven't discussed, <i>compiler macros</i>. A compiler macro is a special kind of macro that's given a chance to optimize calls to a specific function by transforming calls to that function into more efficient code. CL-PPCRE defines compiler macros for its functions that take regular expression arguments. The compiler macros optimize calls to those functions in which the regular expression is a constant value by parsing the regular expression at compile time rather than leaving it to be done at runtime. Look up <code><b>DEFINE-COMPILER-MACRO</b></code> in your favorite Common Lisp reference for more information about compiler macros. </p> <p> <sup>6</sup>The word <i>premature</i> in "premature optimization" can pretty much be defined as "before profiling." Remember that even if you can speed up a piece of code to the point where it takes literally no time to run, you'll still speed up your program only by whatever percentage of time it spent in that piece of code. </p> <p> <sup>7</sup>Declarations can appear in most forms that introduce new variables, such as <code><b>LET</b></code>, <code><b>LET*</b></code>, and the <code><b>DO</b></code> family of looping macros. <code><b>LOOP</b></code> has its own syntax for declaring the types of loop variables. The special operator <code><b>LOCALLY</b></code>, mentioned in Chapter 20, does nothing but create a scope in which you can make declarations. </p> <p> <sup>8</sup>The FASL files produced by <code><b>COMPILE-FILE</b></code> are implementation dependent and may or may not be compatible between different versions of the same Common Lisp implementation. Thus, they're not a very good way to distribute Lisp code. The one time they can be handy is as a way of providing patches to be applied to an application running in a known version of a particular implementation. Applying the patch simply entails <code><b>LOAD</b></code>ing the FASL, and because a FASL can contain arbitrary code, it can be used to upgrade existing data as well as to provide new code definitions. </p> <p> <sup>9</sup>ASDF was originally written by Daniel Barlow, one of the SBCL developers, and has been included as part of SBCL for a long time and also distributed as a stand-alone library. It has recently been adopted and included in other implementations such as OpenMCL and Allegro. </p> <p> <sup>10</sup>On Windows, where there are no symbolic links, it works a little bit differently but roughly the same. </p> <p> <sup>11</sup>Another tool, ASDF-INSTALL, builds on top of ASDF and MK:DEFSYSTEM, providing an easy way to automatically download and install libraries from the network. The best starting point for learning about ASDF-INSTALL is Edi Weitz's "A tutorial for ASDF-INSTALL" (<code>http:// www.weitz.de/asdf-install/</code>). </p> <p> <sup>12</sup>SLIME incorporates an Elisp library that allows you to automatically jump to the HyperSpec entry for any name defined in the standard. You can also download a complete copy of the HyperSpec to keep locally for offline browsing. </p> <p> <sup>13</sup>Another classic reference is <i>Common Lisp: The Language</i> by Guy Steele (Digital Press, 1984 and 1990). The first edition, a.k.a. CLtL1, was the de facto standard for the language for a number of years. While waiting for the official ANSI standard to be finished, Guy Steele--who was on the ANSI committee--decided to release a second edition to bridge the gap between CLtL1 and the eventual standard. The second edition, now known as CLtL2, is essentially a snapshot of the work of the standardization committee taken at a particular moment in time near to, but not quite at, the end of the standardization process. Consequently, CLtL2 differs from the standard in ways that make it not a very good day-to-day reference. It is, however, a useful historical document, particularly because it includes documentation of some features that were dropped from the standard before it was finished as well as commentary that isn't part of the standard about why certain features are the way they are. </p> </div> <div class="copyright"> - Copyright © 2003-2005, Peter Seibel + Copyright © 2003-2005, Peter Seibel </div> </body> </html> diff --git a/html/index.html b/html/index.html index 200b184..3865d91 100644 --- a/html/index.html +++ b/html/index.html @@ -1,187 +1,185 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title> Practical Common Lisp </title> <link rel='stylesheet' type='text/css' href='style.css'><!-- <script language="JavaScript" src="http://www.gvisit.com/record.php?sid=f8af8124c8b07e7f044291fa5b28611b" type="text/javascript"></script> --> <style type='text/css'> <!-- BODY { font-family: sans-serif; margin: .5in; } .INTRO { font-size: 11pt; } TD.NEWS { vertical-align: top; width: 22em; } P.BOX-HEADER { font-weight: bold; margin-bottom: -1ex; } DIV.NEWS { float: right; width: 20em; text-align: center; background-color: #ffc426; margin: 1em; padding: 1em; border-style: solid; border-width: thin; } LI { padding: 0pt 2pt; } H1 { text-align: center; margin-bottom: 0pt; } P.BLURB { text-align: center; font-size: 12pt; font-style: italic; } P.MORE-BLURBS { margin-top: -12pt; text-align: center; font-size: 10pt; font-family: sans-serif; } #jolt-logo { float: right; border: none; } --> </style> </head> <body> <h1> - <img border="0" class='floater' src="small-cover.png"><img src="http://www.assoc-amazon.com/e/ir?t=gigamonkeys-20&amp;l=as2&amp;o=1&amp;a=1590592395" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;">Practical Common Lisp<img id='jolt-logo' src="jolt_logo16_sm.png" name="jolt-logo"> + Practical Common Lisp </h1> <p class='blurb'> that book is dead sexy —Xach on #lisp </p> <p class='more-blurbs'> (<a href='blurbs.html'>more blurbs</a>) </p> <p class='intro'> This page, and the pages it links to, contain text of the Common Lisp book <i>Practical Common Lisp</i> published by Apress These pages now contain the final text as it appears in the book. If you find errors in these pages, please send email to <a href='mailto:[email protected]'>[email protected]</a>. These pages will remain online in perpetuity—I hope they will serve as a useful introduction to Common Lisp for folks who are curious about Lisp but maybe not yet curious enough to shell out big bucks for a dead-tree book and a good Common Lisp tutorial for folks who want to get down to real coding right away. However, don't let that stop you from buying the printed version available from Apress at your favorite local or online bookseller. For the complete bookstore browsing experience, you can read the <a href='letter-to-reader.html'>letter to the reader</a> that appears on the back cover of the treeware edition of the book. </p> <ol> <li> <a href='introduction-why-lisp.html'>Introduction: Why Lisp?</a> </li> <li> <a href='lather-rinse-repeat-a-tour-of-the-repl.html'>Lather, Rinse, Repeat: A Tour of the REPL</a> </li> <li> <a href='practical-a-simple-database.html'>Practical: A Simple Database</a> </li> <li> <a href='syntax-and-semantics.html'>Syntax and Semantics</a> </li> <li> <a href='functions.html'>Functions</a> </li> <li> <a href='variables.html'>Variables</a> </li> <li> <a href='macros-standard-control-constructs.html'>Macros: Standard Control Constructs</a> </li> <li> <a href='macros-defining-your-own.html'>Macros: Defining Your Own</a> </li> <li> <a href='practical-building-a-unit-test-framework.html'>Practical: Building a Unit Test Framework</a> </li> <li> <a href='numbers-characters-and-strings.html'>Numbers, Characters, and Strings</a> </li> <li> <a href='collections.html'>Collections</a> </li> <li> <a href='they-called-it-lisp-for-a-reason-list-processing.html'>They Called It LISP for a Reason: List Processing</a> </li> <li> <a href='beyond-lists-other-uses-for-cons-cells.html'>Beyond Lists: Other Uses for Cons Cells</a> </li> <li> <a href='files-and-file-io.html'>Files and File I/O</a> </li> <li> <a href='practical-a-portable-pathname-library.html'>Practical: A Portable Pathname Library</a> </li> <li> <a href='object-reorientation-generic-functions.html'>Object Reorientation: Generic Functions</a> </li> <li> <a href='object-reorientation-classes.html'>Object Reorientation: Classes</a> </li> <li> <a href='a-few-format-recipes.html'>A Few FORMAT Recipes</a> </li> <li> <a href='beyond-exception-handling-conditions-and-restarts.html'>Beyond Exception Handling: Conditions and Restarts</a> </li> <li> <a href='the-special-operators.html'>The Special Operators</a> </li> <li> <a href='programming-in-the-large-packages-and-symbols.html'>Programming in the Large: Packages and Symbols</a> </li> <li> <a href='loop-for-black-belts.html'>LOOP for Black Belts</a> </li> <li> <a href='practical-a-spam-filter.html'>Practical: A Spam Filter</a> </li> <li> <a href='practical-parsing-binary-files.html'>Practical: Parsing Binary Files</a> </li> <li> <a href='practical-an-id3-parser.html'>Practical: An ID3 Parser</a> </li> <li> <a href='practical-web-programming-with-allegroserve.html'>Practical: Web Programming with AllegroServe</a> </li> <li> <a href='practical-an-mp3-database.html'>Practical: An MP3 Database</a> </li> <li> <a href='practical-a-shoutcast-server.html'>Practical: A Shoutcast Server</a> </li> <li> <a href='practical-an-mp3-browser.html'>Practical: An MP3 Browser</a> </li> <li> <a href='practical-an-html-generation-library-the-interpreter.html'>Practical: An HTML Generation Library, the Interpreter</a> </li> <li> <a href='practical-an-html-generation-library-the-compiler.html'>Practical: An HTML Generation Library, the Compiler</a> </li> <li> <a href='conclusion-whats-next.html'>Conclusion: What's Next?</a> </li> </ol> <div class='copyright'> Copyright © 2003-2009, Peter Seibel - </div><!-- amazon link enhancer foo --> - <script type="text/javascript" src="http://www.assoc-amazon.com/s/link-enhancer?tag=gigamonkeys-20"> -</script><noscript><img src="http://www.assoc-amazon.com/s/noscript?tag=gigamonkeys-20" alt=""></noscript><!-- end amazon link enhancer foo --> + </div> </body> </html> diff --git a/html/lather-rinse-repeat-a-tour-of-the-repl.html b/html/lather-rinse-repeat-a-tour-of-the-repl.html index 39aa8e6..7fc6f9b 100644 --- a/html/lather-rinse-repeat-a-tour-of-the-repl.html +++ b/html/lather-rinse-repeat-a-tour-of-the-repl.html @@ -1,325 +1,325 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title> Lather, Rinse, Repeat: A Tour of the REPL </title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1> 2. Lather, Rinse, Repeat: A Tour of the REPL </h1> <p> In this chapter you'll set up your programming environment and write your first Common Lisp programs. We'll use the easy-to-install Lisp in a Box developed by Matthew Danish and Mikel Evins, which packages a Common Lisp implementation with Emacs, a powerful Lisp-aware text editor, and SLIME,<sup>1</sup> a Common Lisp development environment built on top of Emacs. </p> <p> This combo provides a state-of-the-art Common Lisp development environment that supports the incremental, interactive development style that characterizes Lisp programming. The SLIME environment has the added advantage of providing a fairly uniform user interface regardless of the operating system and Common Lisp implementation you choose. I'll use the Lisp in a Box environment in order to have a specific development environment to talk about; folks who want to explore other development environments such as the graphical integrated development environments (IDEs) provided by some of the commercial Lisp vendors or environments based on other editors shouldn't have too much trouble translating the basics.<sup>2</sup> </p> <h2> <a name="choosing-a-lisp-implementation" id="choosing-a-lisp-implementation">Choosing a Lisp Implementation</a> </h2> <p> The first thing you have to do is to choose a Lisp implementation. This may seem like a strange thing to have to do for folks used to languages such as Perl, Python, Visual Basic (VB), C#, and Java. The difference between Common Lisp and these languages is that Common Lisp is defined by its standard--there is neither a single implementation controlled by a benevolent dictator, as with Perl and Python, nor a canonical implementation controlled by a single company, as with VB, C#, and Java. Anyone who wants to read the standard and implement the language is free to do so. Furthermore, changes to the standard have to be made in accordance with a process controlled by the standards body American National Standards Institute (ANSI). That process is designed to keep any one entity, such as a single vendor, from being able to arbitrarily change the standard.<sup>3</sup> Thus, the Common Lisp standard is a contract between any Common Lisp vendor and Common Lisp programmers. The contract tells you that if you write a program that uses the features of the language the way they're described in the standard, you can count on your program behaving the same in any conforming implementation. </p> <p> On the other hand, the standard may not cover everything you may want to do in your programs--some things were intentionally left unspecified in order to allow continuing experimentation by implementers in areas where there wasn't consensus about the best way for the language to support certain features. So every implementation offers some features above and beyond what's specified in the standard. Depending on what kind of programming you're going to be doing, it may make sense to just pick one implementation that has the extra features you need and use that. On the other hand, if we're delivering Lisp source to be used by others, such as libraries, you'll want--as far as possible--to write portable Common Lisp. For writing code that should be mostly portable but that needs facilities not defined by the standard, Common Lisp provides a flexible way to write code "conditionalized" on the features available in a particular implementation. You'll see an example of this kind of code in Chapter 15 when we develop a simple library that smoothes over some differences between how different Lisp implementations deal with filenames. </p> <p> For the moment, however, the most important characteristic of an implementation is whether it runs on our favorite operating system. The folks at Franz, makers of Allegro Common Lisp, are making available a trial version of their product for use with this book that runs on Linux, Windows, and OS X. Folks looking for an open-source implementation have several options. SBCL<sup>4</sup> is a high-quality open-source implementation that compiles to native code and runs on a wide variety of Unixes, including Linux and OS X. SBCL is derived from CMUCL,<sup>5</sup> which is a Common Lisp developed at Carnegie Mellon University, and, like CMUCL, is largely in the public domain, except a few sections licensed under Berkeley Software Distribution (BSD) style licenses. CMUCL itself is another fine choice, though SBCL tends to be easier to install and now supports 21-bit Unicode.<sup>6</sup> For OS X users, OpenMCL is an excellent choice--it compiles to machine code, supports threads, and has quite good integration with OS X's Carbon and Cocoa toolkits. Other open-source and commercial implementations are available. See Chapter 32 for resources from which you can get more information. </p> <p> All the Lisp code in this book should work in any conforming Common Lisp implementation unless otherwise noted, and SLIME will smooth out some of the differences between implementations by providing us with a common interface for interacting with Lisp. The output shown in this book is from Allegro running on GNU/Linux; in some cases, other Lisp's may generate slightly different error messages or debugger output. </p> <h2> <a name="getting-up-and-running-with-lisp-in-a-box" id="getting-up-and-running-with-lisp-in-a-box">Getting Up and Running with Lisp in a Box</a> </h2> <p> Since the Lisp in a Box packaging is designed to get new Lispers up and running in a first-rate Lisp development environment with minimum hassle, all you need to do to get it running is to grab the appropriate package for your operating system and the preferred Lisp from the Lisp in a Box Web site listed in Chapter 32 and then follow the installation instructions. </p> <p> Since Lisp in a Box uses Emacs as its editor, you'll need to know at least a bit about how to use it. Perhaps the best way to get started with Emacs is to work through its built-in tutorial. To start the tutorial, select the first item of the Help menu, Emacs tutorial. Or press the Ctrl key, type <code>h</code>, release the Ctrl key, and then press <code>t</code>. Most Emacs commands are accessible via such key combinations; because key combinations are so common, Emacs users have a notation for describing key combinations that avoids having to constantly write out combinations such as "Press the Ctrl key, type <code>h</code>, release the Ctrl key, and then press <code>t</code>." Keys to be pressed together--a so-called key chord--are written together and separated by a hyphen. Keys, or key chords, to be pressed in sequence are separated by spaces. In a key chord, <code>C</code> represents the Ctrl key and <code>M</code> represents the Meta key (also known as Alt). Thus, we could write the key combination we just described that starts the tutorial like so: <code>C-h t</code>. </p> <p> The tutorial describes other useful commands and the key combinations that invoke them. Emacs also comes with extensive online documentation using its own built-in hypertext documentation browser, Info. To read the manual, type <code>C-h i</code>. The Info system comes with its own tutorial, accessible simply by pressing <code>h</code> while reading the manual. Finally, Emacs provides quite a few ways to get help, all bound to key combos starting with <code>C-h</code>. Typing <code>C-h ?</code> brings up a complete list. Two of the most useful, besides the tutorial, are <code>C-h k</code>, which lets us type any key combo and tells us what command it invokes, and <code>C-h w</code>, which lets us enter the name of a command and tells us what key combination invokes it. </p> <p> The other crucial bit of Emacs terminology, for folks who refuse to work through the tutorial, is the notion of a <i>buffer</i>. While working in Emacs, each file you edit will be represented by a different buffer, only one of which is "current" at any given time. The current buffer receives all input--whatever you type and any commands you invoke. Buffers are also used to represent interactions with programs such as Common Lisp. Thus, one common action you'll take is to "switch buffers," which means to make a different buffer the current buffer so you can edit a particular file or interact with a particular program. The command <code>switch-to-buffer</code>, bound to the key combination <code>C-x b</code>, prompts for the name of a buffer in the area at the bottom of the Emacs frame. When entering a buffer name, hitting Tab will complete the name based on the characters typed so far or will show a list of possible completions. The prompt also suggests a default buffer, which you can accept just by hitting Return. You can also switch buffers by selecting a buffer from the Buffers menu. </p> <p> In certain contexts, other key combinations may be available for switching to certain buffers. For instance, when editing Lisp source files, the key combo <code>C-c C-z</code> switches to the buffer where you interact with Lisp. </p> <h2> <a name="free-your-mind-interactive-programming" id="free-your-mind-interactive-programming">Free Your Mind: Interactive Programming</a> </h2> <p> When you start Lisp in a Box, you should see a buffer containing a prompt that looks like this: </p> <pre> CL-USER&gt; </pre> <p> This is the Lisp prompt. Like a Unix or DOS shell prompt, the Lisp prompt is a place where you can type expressions that will cause things to happen. However, instead of reading and interpreting a line of shell commands, Lisp reads Lisp expressions, evaluates them according to the rules of Lisp, and prints the result. Then it does it again with the next expression you type. That endless cycle of reading, evaluating, and printing is why it's called the <i>read-eval-print loop</i>, or REPL for short. It's also referred to as the <i>top-level</i>, the <i>top-level listener</i>, or the <i>Lisp listener</i>. </p> <p> From within the environment provided by the REPL, you can define and redefine program elements such as variables, functions, classes, and methods; evaluate any Lisp expression; load files containing Lisp source code or compiled code; compile whole files or individual functions; enter the debugger; step through code; and inspect the state of individual Lisp objects. </p> <p> All those facilities are built into the language, accessible via functions defined in the language standard. If you had to, you could build a pretty reasonable programming environment out of just the REPL and any text editor that knows how to properly indent Lisp code. But for the true Lisp programming experience, you need an environment, such as SLIME, that lets you interact with Lisp both via the REPL and while editing source files. For instance, you don't want to have to cut and paste a function definition from a source file to the REPL or have to load a whole file just because you changed one function; your Lisp environment should let us evaluate or compile both individual expressions and whole files directly from your editor. </p> <h2> <a name="experimenting-in-the-repl" id="experimenting-in-the-repl">Experimenting in the REPL</a> </h2> <p> To try the REPL, you need a Lisp expression that can be read, evaluated, and printed. One of the simplest kinds of Lisp expressions is a number. At the Lisp prompt, you can type <code>10</code> followed by Return and should see something like this: </p> <pre> CL-USER&gt; 10 10 </pre> <p> The first <code>10</code> is the one you typed. The Lisp reader, the <i>R</i> in REPL, reads the text "10" and creates a Lisp object representing the number 10. This object is a <i>self-evaluating</i> object, which means that when given to the evaluator, the <i>E</i> in REPL, it evaluates to itself. This value is then given to the printer, which prints the <code>10</code> on the line by itself. While that may seem like a lot of work just to get back to where you started, things get a bit more interesting when you give Lisp something meatier to chew on. For instance, you can type <code>(+ 2 3)</code> at the Lisp prompt. </p> <pre> CL-USER&gt; (+ 2 3) 5 </pre> <p> Anything in parentheses is a list, in this case a list of three elements, the symbol <code>+</code>, and the numbers 2 and 3. Lisp, in general, evaluates lists by treating the first element as the name of a function and the rest of the elements as expressions to be evaluated to yield the arguments to the function. In this case, the symbol <code>+</code> names a function that performs addition. 2 and 3 evaluate to themselves and are then passed to the addition function, which returns 5. The value 5 is passed to the printer, which prints it. Lisp can evaluate a list expression in other ways, but we needn't get into them right away. First we have to write. . . </p> <h2> <a name="hello-world-lisp-style" id="hello-world-lisp-style">"Hello, World," Lisp Style</a> </h2> <p> No programming book is complete without a "hello, world"<sup>7</sup> program. As it turns out, it's trivially easy to get the REPL to print "hello, world." </p> <pre> CL-USER&gt; "hello, world" "hello, world" </pre> <p> This works because strings, like numbers, have a literal syntax that's understood by the Lisp reader and are self-evaluating objects: Lisp reads the double-quoted string and instantiates a string object in memory that, when evaluated, evaluates to itself and is then printed in the same literal syntax. The quotation marks aren't part of the string object in memory--they're just the syntax that tells the reader to read a string. The printer puts them back on when it prints the string because it tries to print objects in the same syntax the reader understands. </p> <p> However, this may not really qualify as a "hello, world" <i>program</i>. It's more like the "hello, world" <i>value</i>. </p> <p> - You can take a step toward a real program by writing some code that as a side effect prints the string "hello, world" to standard output. Common Lisp provides a couple ways to emit output, but the most flexible is the <code><b>FORMAT</b></code> function. <code><b>FORMAT</b></code> takes a variable number of arguments, but the only two required arguments are the place to send the output and a string. You'll see in the next chapter how the string can contain embedded directives that allow you to interpolate subsequent arguments into the string, à la <code>printf</code> or Python's string-<code>%</code>. As long as the string doesn't contain an <code>~</code>, it will be emitted as-is. If you pass <code>t</code> as its first argument, it sends its output to standard output. So a <code><b>FORMAT</b></code> expression that will print "hello, world" looks like this:<sup>8</sup> + You can take a step toward a real program by writing some code that as a side effect prints the string "hello, world" to standard output. Common Lisp provides a couple ways to emit output, but the most flexible is the <code><b>FORMAT</b></code> function. <code><b>FORMAT</b></code> takes a variable number of arguments, but the only two required arguments are the place to send the output and a string. You'll see in the next chapter how the string can contain embedded directives that allow you to interpolate subsequent arguments into the string, à la <code>printf</code> or Python's string-<code>%</code>. As long as the string doesn't contain an <code>~</code>, it will be emitted as-is. If you pass <code>t</code> as its first argument, it sends its output to standard output. So a <code><b>FORMAT</b></code> expression that will print "hello, world" looks like this:<sup>8</sup> </p> <pre> CL-USER&gt; (format t "hello, world") hello, world NIL </pre> <p> One thing to note about the result of the <code><b>FORMAT</b></code> expression is the <code><b>NIL</b></code> on the line after the "hello, world" output. That <code><b>NIL</b></code> is the result of evaluating the <code><b>FORMAT</b></code> expression, printed by the REPL. (<code><b>NIL</b></code> is Lisp's version of false and/or null. More on that in Chapter 4.) Unlike the other expressions we've seen so far, a <code><b>FORMAT</b></code> expression is more interesting for its side effect--printing to standard output in this case--than for its return value. But every expression in Lisp evaluates to some result.<sup>9</sup> </p> <p> However, it's still arguable whether you've yet written a true "program." But you're getting there. And you're seeing the bottom-up style of programming supported by the REPL: you can experiment with different approaches and build a solution from parts you've already tested. Now that you have a simple expression that does what you want, you just need to package it in a function. Functions are one of the basic program building blocks in Lisp and can be defined with a <code><b>DEFUN</b></code> expression such as this: </p> <pre> CL-USER&gt; (defun hello-world () (format t "hello, world")) HELLO-WORLD </pre> <p> The <code>hello-world</code> after the <code><b>DEFUN</b></code> is the name of the function. In Chapter 4 we'll look at exactly what characters can be used in a name, but for now suffice it to say that lots of characters, such as <code>-</code>, that are illegal in names in other languages are legal in Common Lisp. It's standard Lisp style--not to mention more in line with normal English typography--to form compound names with hyphens, such as <code>hello-world</code>, rather than with underscores, as in <code>hello_world</code>, or with inner caps such as <code>helloWorld</code>. The <code>()</code>s after the name delimit the parameter list, which is empty in this case because the function takes no arguments. The rest is the body of the function. </p> <p> At one level, this expression, like all the others you've seen, is just another expression to be read, evaluated, and printed by the REPL. The return value in this case is the name of the function you just defined.<sup>10</sup> But like the <code><b>FORMAT</b></code> expression, this expression is more interesting for the side effects it has than for its return value. Unlike the <code><b>FORMAT</b></code> expression, however, the side effects are invisible: when this expression is evaluated, a new function that takes no arguments and with the body <code>(format t "hello, world")</code> is created and given the name <code>HELLO-WORLD</code>. </p> <p> Once you've defined the function, you can call it like this: </p> <pre> CL-USER&gt; (hello-world) hello, world NIL </pre> <p> You can see that the output is just the same as when you evaluated the <code><b>FORMAT</b></code> expression directly, including the <code><b>NIL</b></code> value printed by the REPL. Functions in Common Lisp automatically return the value of the last expression evaluated. </p> <h2> <a name="saving-your-work" id="saving-your-work">Saving Your Work</a> </h2> <p> You could argue that this is a complete "hello, world" program of sorts. However, it still has a problem. If you exit Lisp and restart, the function definition will be gone. Having written such a fine function, you'll want to save your work. </p> <p> Easy enough. You just need to create a file in which to save the definition. In Emacs you can create a new file by typing <code>C-x C-f</code> and then, when Emacs prompts you, entering the name of the file you want to create. It doesn't matter particularly where you put the file. It's customary to name Common Lisp source files with a <code>.lisp</code> extension, though some folks use <code>.cl</code> instead. </p> <p> Once you've created the file, you can type the definition you previously entered at the REPL. Some things to note are that after you type the opening parenthesis and the word <code><b>DEFUN</b></code>, at the bottom of the Emacs window, SLIME will tell you the arguments expected. The exact form will depend somewhat on what Common Lisp implementation you're using, but it'll probably look something like this: </p> <pre> (defun name varlist &amp;rest body) </pre> <p> The message will disappear as you start to type each new element but will reappear each time you enter a space. When you're entering the definition in the file, you might choose to break the definition across two lines after the parameter list. If you hit Return and then Tab, SLIME will automatically indent the second line appropriately, like this:<sup>11</sup> </p> <pre> (defun hello-world () (format t "hello, world")) </pre> <p> SLIME will also help match up the parentheses--as you type a closing parenthesis, it will flash the corresponding opening parenthesis. Or you can just type <code>C-c C-q</code> to invoke the command <code>slime-close-parens-at-point</code>, which will insert as many closing parentheses as necessary to match all the currently open parentheses. </p> <p> Now you can get this definition into your Lisp environment in several ways. The easiest is to type <code>C-c C-c</code> with the cursor anywhere in or immediately after the <code><b>DEFUN</b></code> form, which runs the command <code>slime-compile-defun</code>, which in turn sends the definition to Lisp to be evaluated and compiled. To make sure this is working, you can make some change to <code>hello-world</code>, recompile it, and then go back to the REPL, using <code>C-c C-z</code> or <code>C-x b</code>, and call it again. For instance, you could make it a bit more grammatical. </p> <pre> (defun hello-world () (format t "Hello, world!")) </pre> <p> Next, recompile with <code>C-c C-c</code> and then type <code>C-c C-z</code> to switch to the REPL to try the new version. </p> <pre> CL-USER&gt; (hello-world) Hello, world! NIL </pre> <p> You'll also probably want to save the file you've been working on; in the <code>hello.lisp</code> buffer, type <code>C-x C-s</code> to invoke the Emacs command <code>save-buffer</code>. </p> <p> Now to try reloading this function from the source file, you'll need to quit Lisp and restart. To quit you can use a SLIME shortcut: at the REPL, type a comma. At the bottom of the Emacs window, you will be prompted for a command. Type <code>quit</code> (or <code>sayoonara</code>), and then hit Enter. This will quit Lisp and close all the buffers created by SLIME such as the REPL buffer.<sup>12</sup> Now restart SLIME by typing <code>M-x slime</code>. </p> <p> Just for grins, you can try to invoke <code>hello-world</code>. </p> <pre> CL-USER&gt; (hello-world) </pre> <p> At that point SLIME will pop up a new buffer that starts with something that looks like this: </p> <pre> attempt to call `HELLO-WORLD' which is an undefined function. [Condition of type UNDEFINED-FUNCTION] Restarts: 0: [TRY-AGAIN] Try calling HELLO-WORLD again. 1: [RETURN-VALUE] Return a value instead of calling HELLO-WORLD. 2: [USE-VALUE] Try calling a function other than HELLO-WORLD. 3: [STORE-VALUE] Setf the symbol-function of HELLO-WORLD and call it again. 4: [ABORT] Abort handling SLIME request. 5: [ABORT] Abort entirely from this process. Backtrace: 0: (SWANK::DEBUG-IN-EMACS #&lt;UNDEFINED-FUNCTION @ #x716b082a&gt;) 1: ((FLET SWANK:SWANK-DEBUGGER-HOOK SWANK::DEBUG-IT)) 2: (SWANK:SWANK-DEBUGGER-HOOK #&lt;UNDEFINED-FUNCTION @ #x716b082a&gt; #&lt;Function SWANK-DEBUGGER-HOOK&gt;) 3: (ERROR #&lt;UNDEFINED-FUNCTION @ #x716b082a&gt;) 4: (EVAL (HELLO-WORLD)) 5: (SWANK::EVAL-REGION "(hello-world) " T) </pre> <p> Blammo! What happened? Well, you tried to invoke a function that doesn't exist. But despite the burst of output, Lisp is actually handling this situation gracefully. Unlike Java or Python, Common Lisp doesn't just bail--throwing an exception and unwinding the stack. And it definitely doesn't dump core just because you tried to invoke a missing function. Instead Lisp drops you into the debugger. </p> <p> While you're in the debugger you still have full access to Lisp, so you can evaluate expressions to examine the state of our program and maybe even fix things. For now don't worry about that; just type <code>q</code> to exit the debugger and get back to the REPL. The debugger buffer will go away, and the REPL will show this: </p> <pre> CL-USER&gt; (hello-world) ; Evaluation aborted CL-USER&gt; </pre> <p> There's obviously more that can be done from within the debugger than just abort--we'll see, for instance, in Chapter 19 how the debugger integrates with the error handling system. For now, however, the important thing to know is that you can always get out of it, and back to the REPL, by typing <code>q</code>. </p> <p> Back at the REPL you can try again. Things blew up because Lisp didn't know the definition of <code>hello-world</code>. So you need to let Lisp know about the definition we saved in the file <code>hello.lisp</code>. You have several ways you could do this. You could switch back to the buffer containing the file (type <code>C-x b</code> and then enter <code>hello.lisp</code> when prompted) and recompile the definition as you did before with <code>C-c C-c</code>. Or you can load the whole file, which would be a more convenient approach if the file contained a bunch of definitions, using the <code>LOAD</code> function at the REPL like this: </p> <pre> CL-USER&gt; (load "hello.lisp") ; Loading /home/peter/my-lisp-programs/hello.lisp T </pre> <p> The <code><b>T</b></code> means everything loaded correctly.<sup>13</sup> Loading a file with <code>LOAD</code> is essentially equivalent to typing each of the expressions in the file at the REPL in the order they appear in the file, so after the call to <code><b>LOAD</b></code>, <code>hello-world</code> should be defined: </p> <pre> CL-USER&gt; (hello-world) Hello, world! NIL </pre> <p> Another way to load a file's worth of definitions is to compile the file first with <code><b>COMPILE-FILE</b></code> and then <code><b>LOAD</b></code> the resulting compiled file, called a <i>FASL file</i>, which is short for <i>fast-load file</i>. <code><b>COMPILE-FILE</b></code> returns the name of the FASL file, so we can compile and load from the REPL like this: </p> <pre> CL-USER&gt; (load (compile-file "hello.lisp")) ;;; Compiling file hello.lisp ;;; Writing fasl file hello.fasl ;;; Fasl write complete ; Fast loading /home/peter/my-lisp-programs/hello.fasl T </pre> <p> SLIME also provides support for loading and compiling files without using the REPL. When you're in a source code buffer, you can use <code>C-c C-l</code> to load the file with <code>slime-load-file</code>. Emacs will prompt for the name of a file to load with the name of the current file already filled in; you can just hit Enter. Or you can type <code>C-c C-k</code> to compile and load the file represented by the current buffer. In some Common Lisp implementations, compiling code this way will make it quite a bit faster; in others, it won't, typically because they always compile everything. </p> <p> This should be enough to give you a flavor of how Lisp programming works. Of course I haven't covered all the tricks and techniques yet, but you've seen the essential elements--interacting with the REPL trying things out, loading and testing new code, tweaking and debugging. Serious Lisp hackers often keep a Lisp image running for days on end, adding, redefining, and testing bits of their program incrementally. </p> <p> Also, even when the Lisp app is deployed, there's often still a way to get to a REPL. You'll see in Chapter 26 how you can use the REPL and SLIME to interact with the Lisp that's running a Web server at the same time as it's serving up Web pages. It's even possible to use SLIME to connect to a Lisp running on a different machine, allowing you--for instance--to debug a remote server just like a local one. </p> <p> An even more impressive instance of remote debugging occurred on NASA's 1998 Deep Space 1 mission. A half year after the space craft launched, a bit of Lisp code was going to control the spacecraft for two days while conducting a sequence of experiments. Unfortunately, a subtle race condition in the code had escaped detection during ground testing and was already in space. When the bug manifested in the wild--100 million miles away from Earth--the team was able to diagnose and fix the running code, allowing the experiments to complete.<sup>14</sup> One of the programmers described it as follows: </p> <blockquote> Debugging a program running on a $100M piece of hardware that is 100 million miles away is an interesting experience. Having a read-eval-print loop running on the spacecraft proved invaluable in finding and fixing the problem. </blockquote> <p> You're not quite ready to send any Lisp code into deep space, but in the next chapter you'll take a crack at writing a program a bit more interesting than "hello, world." </p> <hr> <div class="notes"> <p> <sup>1</sup>Superior Lisp Interaction Mode for Emacs </p> <p> <sup>2</sup>If you've had a bad experience with Emacs previously, you should treat Lisp in a Box as an IDE that happens to use an Emacs-like editor as its text editor; there will be no need to become an Emacs guru to program Lisp. It is, however, orders of magnitude more enjoyable to program Lisp with an editor that has some basic Lisp awareness. At a minimum, you'll want an editor that can automatically match <code>()</code>s for you and knows how to automatically indent Lisp code. Because Emacs is itself largely written in a Lisp dialect, Elisp, it has quite a bit of support for editing Lisp code. Emacs is also deeply embedded into the history of Lisp and the culture of Lisp hackers: the original Emacs and its immediate predecessors, TECMACS and TMACS, were written by Lispers at the Massachusetts Institute of Technology (MIT). The editors on the Lisp Machines were versions of Emacs written entirely in Lisp. The first two Lisp Machine Emacs, following the hacker tradition of recursive acronyms, were EINE and ZWEI, which stood for EINE Is Not Emacs and ZWEI Was EINE Initially. Later ones used a descendant of ZWEI, named, more prosaically, ZMACS. </p> <p> <sup>3</sup>Practically speaking, there's very little likelihood of the language standard itself being revised--while there are a small handful of warts that folks might like to clean up, the ANSI process isn't amenable to opening an existing standard for minor tweaks, and none of the warts that might be cleaned up actually cause anyone any serious difficulty. The future of Common Lisp standardization is likely to proceed via de facto standards, much like the "standardization" of Perl and Python--as different implementers experiment with application programming interfaces (APIs) and libraries for doing things not specified in the language standard, other implementers may adopt them or people will develop portability libraries to smooth over the differences between implementations for features not specified in the language standard. </p> <p> <sup>4</sup>Steel Bank Common Lisp </p> <p> <sup>5</sup>CMU Common Lisp </p> <p> <sup>6</sup>SBCL forked from CMUCL in order to focus on cleaning up the internals and making it easier to maintain. But the fork has been amiable; bug fixes tend to propagate between the two projects, and there's talk that someday they will merge back together. </p> <p> <sup>7</sup>The venerable "hello, world" predates even the classic Kernighan and Ritchie C book that played a big role in its popularization. The original "hello, world" seems to have come from Brian Kernighan's "A Tutorial Introduction to the Language B" that was part of the <i>Bell Laboratories Computing Science Technical Report #8: The Programming Language B</i> published in January 1973. (It's available online at <code>http://cm.bell-labs.com/cm/cs/who/dmr/bintro.html</code>.) </p> <p> <sup>8</sup>These are some other expressions that also print the string "hello, world": </p> <p> <sup>9</sup>Well, as you'll see when I discuss returning multiple values, it's technically possible to write expressions that evaluate to no value, but even such expressions are treated as returning <code>NIL</code> when evaluated in a context that expects a value. </p> <p> <sup>10</sup>I'll discuss in Chapter 4 why the name has been converted to all uppercase. </p> <p> <sup>11</sup>You could also have entered the definition as two lines at the REPL, as the REPL reads whole expressions, not lines. </p> <p> <sup>12</sup>SLIME shortcuts aren't part of Common Lisp--they're commands to SLIME. </p> <p> <sup>13</sup>If for some reason the <code><b>LOAD</b></code> doesn't go cleanly, you'll get another error and drop back into the debugger. If this happens, the most likely reason is that Lisp can't find the file, probably because its idea of the current working directory isn't the same as where the file is located. In that case, you can quit the debugger by typing <code>q</code> and then use the SLIME shortcut <code>cd</code> to change Lisp's idea of the current directory--type a comma and then <code>cd</code> when prompted for a command and then the name of the directory where <code>hello.lisp</code> was saved. </p> <p> <sup>14</sup><code>http://www.flownet.com/gat/jpl-lisp.html</code> </p> </div> <div class="copyright"> - Copyright © 2003-2005, Peter Seibel + Copyright © 2003-2005, Peter Seibel </div> </body> </html> diff --git a/html/macros-standard-control-constructs.html b/html/macros-standard-control-constructs.html index e043880..0094e78 100644 --- a/html/macros-standard-control-constructs.html +++ b/html/macros-standard-control-constructs.html @@ -1,415 +1,415 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title> Macros: Standard Control Constructs </title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1> 7. Macros: Standard Control Constructs </h1> <p> While many of the ideas that originated in Lisp, from the conditional expression to garbage collection, have been incorporated into other languages, the one language feature that continues to set Common Lisp apart is its macro system. Unfortunately, the word <i>macro</i> describes a lot of things in computing to which Common Lisp's macros bear only a vague and metaphorical similarity. This causes no end of misunderstanding when Lispers try to explain to non-Lispers what a great feature macros are.<sup>1</sup> To understand Lisp's macros, you really need to come at them fresh, without preconceptions based on other things that also happen to be called macros. So let's start our discussion of Lisp's macros by taking a step back and looking at various ways languages support extensibility. </p> <p> All programmers should be used to the idea that the definition of a language can include a standard library of functionality that's implemented in terms of the "core" language--functionality that could have been implemented by any programmer on top of the language if it hadn't been defined as part of the standard library. C's standard library, for instance, can be implemented almost entirely in portable C. Similarly, most of the ever-growing set of classes and interfaces that ship with Java's standard Java Development Kit (JDK) are written in "pure" Java. </p> <p> One advantage of defining languages in terms of a core plus a standard library is it makes them easier to understand and implement. But the real benefit is in terms of expressiveness--since much of what you think of as "the language" is really just a library--the language is easy to extend. If C doesn't have a function to do some thing or another that you need, you can write that function, and now you have a slightly richer version of C. Similarly, in a language such as Java or Smalltalk where almost all the interesting parts of the "language" are defined in terms of classes, by defining new classes you extend the language, making it more suited for writing programs to do whatever it is you're trying to do. </p> <p> While Common Lisp supports both these methods of extending the language, macros give Common Lisp yet another way. As I discussed briefly in Chapter 4, each macro defines its own syntax, determining how the s-expressions it's passed are turned into Lisp forms. With macros as part of the core language it's possible to build new syntax--control constructs such as <code><b>WHEN</b></code>, <code><b>DOLIST</b></code>, and <code><b>LOOP</b></code> as well as definitional forms such as <code><b>DEFUN</b></code> and <code><b>DEFPARAMETER</b></code>--as part of the "standard library" rather than having to hardwire them into the core. This has implications for how the language itself is implemented, but as a Lisp programmer you'll care more that it gives you another way to extend the language, making it a better language for expressing solutions to your particular programming problems. </p> <p> Now, it may seem that the benefits of having another way to extend the language would be easy to recognize. But for some reason a lot of folks who haven't actually used Lisp macros--folks who think nothing of spending their days creating new functional abstractions or defining hierarchies of classes to solve their programming problems--get spooked by the idea of being able to define new syntactic abstractions. The most common cause of macrophobia seems to be bad experiences with other "macro" systems. Simple fear of the unknown no doubt plays a role, too. To avoid triggering any macrophobic reactions, I'll ease into the subject by discussing several of the standard control-construct macros defined by Common Lisp. These are some of the things that, if Lisp didn't have macros, would have to be built into the language core. When you use them, you don't have to care that they're implemented as macros, but they provide a good example of some of the things you can do with macros.<sup>2</sup> In the next chapter, I'll show you how you can define your own macros. </p> <h2> <a name="when-and-unless" id="when-and-unless">WHEN and UNLESS</a> </h2> <p> As you've already seen, the most basic form of conditional execution--if <i>x</i>, do <i>y</i>; otherwise do <i>z</i>--is provided by the <code><b>IF</b></code> special operator, which has this basic form: </p> <pre> (if <i>condition</i> <i>then-form</i> [<i>else-form</i>]) </pre> <p> The <i>condition</i> is evaluated and, if its value is non-<code><b>NIL</b></code>, the <i>then-form</i> is evaluated and the resulting value returned. Otherwise, the <i>else-form</i>, if any, is evaluated and its value returned. If <i>condition</i> is <code><b>NIL</b></code> and there's no <i>else-form</i>, then the <code><b>IF</b></code> returns <code><b>NIL</b></code>. </p> <pre> (if (&gt; 2 3) "Yup" "Nope") ==&gt; "Nope" (if (&gt; 2 3) "Yup") ==&gt; NIL (if (&gt; 3 2) "Yup" "Nope") ==&gt; "Yup" </pre> <p> However, <code><b>IF</b></code> isn't actually such a great syntactic construct because the <i>then-form</i> and <i>else-form</i> are each restricted to being a single Lisp form. This means if you want to perform a sequence of actions in either clause, you need to wrap them in some other syntax. For instance, suppose in the middle of a spam-filtering program you wanted to both file a message as spam and update the spam database when a message is spam. You can't write this: </p> <pre> (if (spam-p current-message) (file-in-spam-folder current-message) (update-spam-database current-message)) </pre> <p> because the call to <code>update-spam-database</code> will be treated as the else clause, not as part of the then clause. Another special operator, <code><b>PROGN</b></code>, executes any number of forms in order and returns the value of the last form. So you could get the desired behavior by writing the following: </p> <pre> (if (spam-p current-message) (progn (file-in-spam-folder current-message) (update-spam-database current-message))) </pre> <p> That's not too horrible. But given the number of times you'll likely have to use this idiom, it's not hard to imagine that you'd get tired of it after a while. "Why," you might ask yourself, "doesn't Lisp provide a way to say what I really want, namely, 'When <i>x</i> is true, do this, that, and the other thing'?" In other words, after a while you'd notice the pattern of an <code><b>IF</b></code> plus a <code><b>PROGN</b></code> and wish for a way to abstract away the details rather than writing them out every time. </p> <p> This is exactly what macros provide. In this case, Common Lisp comes with a standard macro, <code><b>WHEN</b></code>, which lets you write this: </p> <pre> (when (spam-p current-message) (file-in-spam-folder current-message) (update-spam-database current-message)) </pre> <p> But if it wasn't built into the standard library, you could define <code><b>WHEN</b></code> yourself with a macro such as this, using the backquote notation I discussed in Chapter 3:<sup>3</sup> </p> <pre> (defmacro when (condition &amp;rest body) `(if ,condition (progn ,@body))) </pre> <p> A counterpart to the <code><b>WHEN</b></code> macro is <code><b>UNLESS</b></code>, which reverses the condition, evaluating its body forms only if the condition is false. In other words: </p> <pre> (defmacro unless (condition &amp;rest body) `(if (not ,condition) (progn ,@body))) </pre> <p> Admittedly, these are pretty trivial macros. There's no deep black magic here; they just abstract away a few language-level bookkeeping details, allowing you to express your true intent a bit more clearly. But their very triviality makes an important point: because the macro system is built right into the language, you can write trivial macros like <code><b>WHEN</b></code> and <code><b>UNLESS</b></code> that give you small but real gains in clarity that are then multiplied by the thousands of times you use them. In Chapters 24, 26, and 31 you'll see how macros can also be used on a larger scale, creating whole domain-specific embedded languages. But first let's finish our discussion of the standard control-construct macros. </p> <h2> <a name="cond" id="cond">COND</a> </h2> <p> Another time raw <code><b>IF</b></code> expressions can get ugly is when you have a multibranch conditional: if <i>a</i> do <i>x</i>, else if <i>b</i> do <i>y</i>; else do <i>z</i>. There's no logical problem writing such a chain of conditional expressions with just <code><b>IF</b></code>, but it's not pretty. </p> <pre> (if a (do-x) (if b (do-y) (do-z))) </pre> <p> And it would be even worse if you needed to include multiple forms in the then clauses, requiring <code><b>PROGN</b></code>s. So, not surprisingly, Common Lisp provides a macro for expressing multibranch conditionals: <code><b>COND</b></code>. This is the basic skeleton: </p> <pre> (cond (<i>test-1</i> <i>form</i>*) . . . (<i>test-N</i> <i>form</i>*)) </pre> <p> Each element of the body represents one branch of the conditional and consists of a list containing a condition form and zero or more forms to be evaluated if that branch is chosen. The conditions are evaluated in the order the branches appear in the body until one of them evaluates to true. At that point, the remaining forms in that branch are evaluated, and the value of the last form in the branch is returned as the value of the <code><b>COND</b></code> as a whole. If the branch contains no forms after the condition, the value of the condition is returned instead. By convention, the branch representing the final else clause in an if/else-if chain is written with a condition of <code><b>T</b></code>. Any non-<code><b>NIL</b></code> value will work, but a <code><b>T</b></code> serves as a useful landmark when reading the code. Thus, you can write the previous nested <code><b>IF</b></code> expression using <code><b>COND</b></code> like this: </p> <pre> (cond (a (do-x)) (b (do-y)) (t (do-z))) </pre> <h2> <a name="and-or-and-not" id="and-or-and-not">AND, OR, and NOT</a> </h2> <p> When writing the conditions in <code><b>IF</b></code>, <code><b>WHEN</b></code>, <code><b>UNLESS</b></code>, and <code><b>COND</b></code> forms, three operators that will come in handy are the boolean logic operators, <code><b>AND</b></code>, <code><b>OR</b></code>, and <code><b>NOT</b></code>. </p> <p> <code><b>NOT</b></code> is a function so strictly speaking doesn't belong in this chapter, but it's closely tied to <code><b>AND</b></code> and <code><b>OR</b></code>. It takes a single argument and inverts its truth value, returning <code><b>T</b></code> if the argument is <code><b>NIL</b></code> and <code><b>NIL</b></code> otherwise. </p> <p> <code><b>AND</b></code> and <code><b>OR</b></code>, however, are macros. They implement logical conjunction and disjunction of any number of subforms and are defined as macros so they can <i>short-circuit</i>. That is, they evaluate only as many of their subforms--in left-to-right order--as necessary to determine the overall truth value. Thus, <code><b>AND</b></code> stops and returns <code><b>NIL</b></code> as soon as one of its subforms evaluates to <code><b>NIL</b></code>. If all the subforms evaluate to non-<code><b>NIL</b></code>, it returns the value of the last subform. <code><b>OR</b></code>, on the other hand, stops as soon as one of its subforms evaluates to non-<code><b>NIL</b></code> and returns the resulting value. If none of the subforms evaluate to true, <code><b>OR</b></code> returns <code><b>NIL</b></code>. Here are some examples: </p> <pre> (not nil) ==&gt; T (not (= 1 1)) ==&gt; NIL (and (= 1 2) (= 3 3)) ==&gt; NIL (or (= 1 2) (= 3 3)) ==&gt; T </pre> <h2> <a name="looping" id="looping">Looping</a> </h2> <p> Control constructs are the other main kind of looping constructs. Common Lisp's looping facilities are--in addition to being quite powerful and flexible--an interesting lesson in the have-your-cake-and-eat-it-too style of programming that macros provide. </p> <p> As it turns out, none of Lisp's 25 special operators directly support structured looping. All of Lisp's looping control constructs are macros built on top of a pair of special operators that provide a primitive goto facility.<sup>4</sup> Like many good abstractions, syntactic or otherwise, Lisp's looping macros are built as a set of layered abstractions starting from the base provided by those two special operators. </p> <p> At the bottom (leaving aside the special operators) is a very general looping construct, <code><b>DO</b></code>. While very powerful, <code><b>DO</b></code> suffers, as do many general-purpose abstractions, from being overkill for simple situations. So Lisp also provides two other macros, <code><b>DOLIST</b></code> and <code><b>DOTIMES</b></code>, that are less flexible than <code><b>DO</b></code> but provide convenient support for the common cases of looping over the elements of a list and counting loops. While an implementation can implement these macros however it wants, they're typically implemented as macros that expand into an equivalent <code><b>DO</b></code> loop. Thus, <code><b>DO</b></code> provides a basic structured looping construct on top of the underlying primitives provided by Common Lisp's special operators, and <code><b>DOLIST</b></code> and <code><b>DOTIMES</b></code> provide two easier-to-use, if less general, constructs. And, as you'll see in the next chapter, you can build your own looping constructs on top of <code><b>DO</b></code> for situations where <code><b>DOLIST</b></code> and <code><b>DOTIMES</b></code> don't meet your needs. </p> <p> Finally, the <code><b>LOOP</b></code> macro provides a full-blown mini-language for expressing looping constructs in a non-Lispy, English-like (or at least Algol-like) language. Some Lisp hackers love <code><b>LOOP</b></code>; others hate it. <code><b>LOOP</b></code>'s fans like it because it provides a concise way to express certain commonly needed looping constructs. Its detractors dislike it because it's not Lispy enough. But whichever side one comes down on, it's a remarkable example of the power of macros to add new constructs to the language. </p> <h2> <a name="dolist-and-dotimes" id="dolist-and-dotimes">DOLIST and DOTIMES</a> </h2> <p> I'll start with the easy-to-use <code><b>DOLIST</b></code> and <code><b>DOTIMES</b></code> macros. </p> <p> <code><b>DOLIST</b></code> loops across the items of a list, executing the loop body with a variable holding the successive items of the list.<sup>5</sup> This is the basic skeleton (leaving out some of the more esoteric options): </p> <pre> (dolist (<i>var</i> <i>list-form</i>) <i>body-form</i>*) </pre> <p> When the loop starts, the <i>list-form</i> is evaluated once to produce a list. Then the body of the loop is evaluated once for each item in the list with the variable <i>var</i> holding the value of the item. For instance: </p> <pre> CL-USER&gt; (dolist (x '(1 2 3)) (print x)) 1 2 3 NIL </pre> <p> Used this way, the <code><b>DOLIST</b></code> form as a whole evaluates to <code><b>NIL</b></code>. </p> <p> If you want to break out of a <code><b>DOLIST</b></code> loop before the end of the list, you can use <code><b>RETURN</b></code>. </p> <pre> CL-USER&gt; (dolist (x '(1 2 3)) (print x) (if (evenp x) (return))) 1 2 NIL </pre> <p> <code><b>DOTIMES</b></code> is the high-level looping construct for counting loops. The basic template is much the same as <code><b>DOLIST</b></code>'s. </p> <pre> (dotimes (<i>var</i> <i>count-form</i>) <i>body-form</i>*) </pre> <p> The <i>count-form</i> must evaluate to an integer. Each time through the loop <i>var</i> holds successive integers from 0 to one less than that number. For instance: </p> <pre> CL-USER&gt; (dotimes (i 4) (print i)) 0 1 2 3 NIL </pre> <p> As with <code><b>DOLIST</b></code>, you can use <code><b>RETURN</b></code> to break out of the loop early. </p> <p> - Because the body of both <code><b>DOLIST</b></code> and <code><b>DOTIMES</b></code> loops can contain any kind of expressions, you can also nest loops. For example, to print out the times tables from <code>1 × 1 = 1</code> to <code>20 × 20 = 400</code>, you can write this pair of nested <code><b>DOTIMES</b></code> loops: + Because the body of both <code><b>DOLIST</b></code> and <code><b>DOTIMES</b></code> loops can contain any kind of expressions, you can also nest loops. For example, to print out the times tables from <code>1 × 1 = 1</code> to <code>20 × 20 = 400</code>, you can write this pair of nested <code><b>DOTIMES</b></code> loops: </p> <pre> (dotimes (x 20) (dotimes (y 20) (format t "~3d " (* (1+ x) (1+ y)))) (format t "~%")) </pre> <h2> <a name="do" id="do">DO</a> </h2> <p> While <code><b>DOLIST</b></code> and <code><b>DOTIMES</b></code> are convenient and easy to use, they aren't flexible enough to use for all loops. For instance, what if you want to step multiple variables in parallel? Or use an arbitrary expression to test for the end of the loop? If neither <code><b>DOLIST</b></code> nor <code><b>DOTIMES</b></code> meet your needs, you still have access to the more general <code><b>DO</b></code> loop. </p> <p> Where <code><b>DOLIST</b></code> and <code><b>DOTIMES</b></code> provide only one loop variable, <code><b>DO</b></code> lets you bind any number of variables and gives you complete control over how they change on each step through the loop. You also get to define the test that determines when to end the loop and can provide a form to evaluate at the end of the loop to generate a return value for the <code><b>DO</b></code> expression as a whole. The basic template looks like this: </p> <pre> (do (<i>variable-definition</i>*) (<i>end-test-form</i> <i>result-form</i>*) <i>statement</i>*) </pre> <p> Each <i>variable-definition</i> introduces a variable that will be in scope in the body of the loop. The full form of a single variable definition is a list containing three elements. </p> <pre> (<i>var</i> <i>init-form</i> <i>step-form</i>) </pre> <p> The <i>init-form</i> will be evaluated at the beginning of the loop and the resulting values bound to the variable <i>var</i>. Before each subsequent iteration of the loop, the <i>step-form</i> will be evaluated and the new value assigned to <i>var</i>. The <i>step-form</i> is optional; if it's left out, the variable will keep its value from iteration to iteration unless you explicitly assign it a new value in the loop body. As with the variable definitions in a <code><b>LET</b></code>, if the <i>init-form</i> is left out, the variable is bound to <code><b>NIL</b></code>. Also as with <code><b>LET</b></code>, you can use a plain variable name as shorthand for a list containing just the name. </p> <p> At the beginning of each iteration, after all the loop variables have been given their new values, the <i>end-test-form</i> is evaluated. As long as it evaluates to <code><b>NIL</b></code>, the iteration proceeds, evaluating the <i>statements</i> in order. </p> <p> When the <i>end-test-form</i> evaluates to true, the <i>result-forms</i> are evaluated, and the value of the last result form is returned as the value of the <code><b>DO</b></code> expression. </p> <p> At each step of the iteration the step forms for all the variables are evaluated before assigning any of the values to the variables. This means you can refer to any of the other loop variables in the step forms.<sup>6</sup> That is, in a loop like this: </p> <pre> (do ((n 0 (1+ n)) (cur 0 next) (next 1 (+ cur next))) ((= 10 n) cur)) </pre> <p> the step forms <code>(1+ n)</code>, <code>next</code>, and <code>(+ cur next)</code> are all evaluated using the old values of <code>n</code>, <code>cur</code>, and <code>next</code>. Only after all the step forms have been evaluated are the variables given their new values. (Mathematically inclined readers may notice that this is a particularly efficient way of computing the eleventh Fibonacci number.) </p> <p> This example also illustrates another characteristic of <code><b>DO</b></code>--because you can step multiple variables, you often don't need a body at all. Other times, you may leave out the result form, particularly if you're just using the loop as a control construct. This flexibility, however, is the reason that <code><b>DO</b></code> expressions can be a bit cryptic. Where exactly do all the parentheses go? The best way to understand a <code><b>DO</b></code> expression is to keep in mind the basic template. </p> <pre> <b>(</b>do <b>(</b><i>variable-definition</i>*<b>)</b> <b>(</b><i>end-test-form</i> <i>result-form</i>*<b>)</b> <i>statement</i>*<b>)</b> </pre> <p> The six parentheses in that template are the only ones required by the <code><b>DO</b></code> itself. You need one pair to enclose the variable declarations, one pair to enclose the end test and result forms, and one pair to enclose the whole expression. Other forms within the <code><b>DO</b></code> may require their own parentheses--variable definitions are usually lists, for instance. And the test form is often a function call. But the skeleton of a <code><b>DO</b></code> loop will always be the same. Here are some example <code><b>DO</b></code> loops with the skeleton in bold: </p> <pre> <b>(</b>do <b>(</b>(i 0 (1+ i))<b>)</b> <b>(</b>(&gt;= i 4)<b>)</b> (print i)<b>)</b> </pre> <p> Notice that the result form has been omitted. This is, however, not a particularly idiomatic use of <code><b>DO</b></code>, as this loop is much more simply written using <code><b>DOTIMES</b></code>.<sup>7</sup> </p> <pre> (dotimes (i 4) (print i)) </pre> <p> As another example, here's the bodiless Fibonacci-computing loop: </p> <pre> <b>(</b>do <b>(</b>(n 0 (1+ n)) (cur 0 next) (next 1 (+ cur next))<b>)</b> <b>(</b>(= 10 n) cur<b>))</b> </pre> <p> Finally, the next loop demonstrates a <code><b>DO</b></code> loop that binds no variables. It loops while the current time is less than the value of a global variable, printing "Waiting" once a minute. Note that even with no loop variables, you still need the empty variables list. </p> <pre> <b>(</b>do <b>()</b> <b>(</b>(&gt; (get-universal-time) *some-future-date*)<b>)</b> (format t "Waiting~%") (sleep 60)<b>)</b> </pre> <h2> <a name="the-mighty-loop" id="the-mighty-loop">The Mighty LOOP</a> </h2> <p> For the simple cases you have <code><b>DOLIST</b></code> and <code><b>DOTIMES</b></code>. And if they don't suit your needs, you can fall back on the completely general <code><b>DO</b></code>. What more could you want? </p> <p> Well, it turns out a handful of looping idioms come up over and over again, such as looping over various data structures: lists, vectors, hash tables, and packages. Or accumulating values in various ways while looping: collecting, counting, summing, minimizing, or maximizing. If you need a loop to do one of these things (or several at the same time), the <code><b>LOOP</b></code> macro may give you an easier way to express it. </p> <p> The <code><b>LOOP</b></code> macro actually comes in two flavors--<i>simple</i> and <i>extended</i>. The simple version is as simple as can be--an infinite loop that doesn't bind any variables. The skeleton looks like this: </p> <pre> (loop <i>body-form</i>*) </pre> <p> The forms in body are evaluated each time through the loop, which will iterate forever unless you use <code><b>RETURN</b></code> to break out. For example, you could write the previous <code><b>DO</b></code> loop with a simple <code><b>LOOP</b></code>. </p> <pre> (loop (when (&gt; (get-universal-time) *some-future-date*) (return)) (format t "Waiting~%") (sleep 60)) </pre> <p> The extended <code><b>LOOP</b></code> is quite a different beast. It's distinguished by the use of certain <i>loop keywords</i> that implement a special-purpose language for expressing looping idioms. It's worth noting that not all Lispers love the extended <code><b>LOOP</b></code> language. At least one of Common Lisp's original designers hated it. <code><b>LOOP</b></code>'s detractors complain that its syntax is totally un-Lispy (in other words, not enough parentheses). <code><b>LOOP</b></code>'s fans counter that that's the point: complicated looping constructs are hard enough to understand without wrapping them up in <code><b>DO</b></code>'s cryptic syntax. It's better, they say, to have a slightly more verbose syntax that gives you some clues what the heck is going on. </p> <p> For instance, here's an idiomatic <code><b>DO</b></code> loop that collects the numbers from 1 to 10 into a list: </p> <pre> (do ((nums nil) (i 1 (1+ i))) ((&gt; i 10) (nreverse nums)) (push i nums)) ==&gt; (1 2 3 4 5 6 7 8 9 10) </pre> <p> A seasoned Lisper won't have any trouble understanding that code--it's just a matter of understanding the basic form of a <code><b>DO</b></code> loop and recognizing the <code><b>PUSH</b></code>/<code><b>NREVERSE</b></code> idiom for building up a list. But it's not exactly transparent. The <code><b>LOOP</b></code> version, on the other hand, is almost understandable as an English sentence. </p> <pre> (loop for i from 1 to 10 collecting i) ==&gt; (1 2 3 4 5 6 7 8 9 10) </pre> <p> The following are some more examples of simple uses of <code><b>LOOP</b></code>. This sums the first ten squares: </p> <pre> (loop for x from 1 to 10 summing (expt x 2)) ==&gt; 385 </pre> <p> This counts the number of vowels in a string: </p> <pre> (loop for x across "the quick brown fox jumps over the lazy dog" counting (find x "aeiou")) ==&gt; 11 </pre> <p> This computes the eleventh Fibonacci number, similar to the <code><b>DO</b></code> loop used earlier: </p> <pre> (loop for i below 10 and a = 0 then b and b = 1 then (+ b a) finally (return a)) </pre> <p> The symbols <code>across</code>, <code>and</code>, <code>below</code>, <code>collecting</code>, <code>counting</code>, <code>finally</code>, <code>for</code>, <code>from</code>, <code>summing</code>, <code>then</code>, and <code>to</code> are some of the loop keywords whose presence identifies these as instances of the extended <code><b>LOOP</b></code>. <sup>8</sup> </p> <p> I'll save the details of <code><b>LOOP</b></code> for Chapter 22, but it's worth noting here as another example of the way macros can be used to extend the base language. While <code><b>LOOP</b></code> provides its own language for expressing looping constructs, it doesn't cut you off from the rest of Lisp. The loop keywords are parsed according to loop's grammar, but the rest of the code in a <code><b>LOOP</b></code> is regular Lisp code. </p> <p> And it's worth pointing out one more time that while the <code><b>LOOP</b></code> macro is quite a bit more complicated than macros such as <code><b>WHEN</b></code> or <code><b>UNLESS</b></code>, it <i>is</i> just another macro. If it hadn't been included in the standard library, you could implement it yourself or get a third-party library that does. </p> <p> With that I'll conclude our tour of the basic control-construct macros. Now you're ready to take a closer look at how to define your own macros. </p> <hr> <div class="notes"> <p> <sup>1</sup>To see what this misunderstanding looks like, find any longish Usenet thread cross-posted between comp.lang.lisp and any other comp.lang.* group with <i>macro</i> in the subject. A rough paraphrase goes like this: </p> <p> Lispnik: "Lisp is the best because of its macros!"; </p> <p> Othernik: "You think Lisp is good <i>because of</i> macros?! But macros are horrible and evil; Lisp must be horrible and evil." </p> <p> <sup>2</sup>Another important class of language constructs that are defined using macros are all the definitional constructs such as <code><b>DEFUN</b></code>, <code><b>DEFPARAMETER</b></code>, <code><b>DEFVAR</b></code>, and others. In Chapter 24 you'll define your own definitional macros that will allow you to concisely write code for reading and writing binary data. </p> <p> <sup>3</sup>You can't actually feed this definition to Lisp because it's illegal to redefine names in the <code>COMMON-LISP</code> package where <code><b>WHEN</b></code> comes from. If you really want to try writing such a macro, you'd need to change the name to something else, such as <code>my-when</code>. </p> <p> <sup>4</sup>The special operators, if you must know, are <code><b>TAGBODY</b></code> and <code><b>GO</b></code>. There's no need to discuss them now, but I'll cover them in Chapter 20. </p> <p> <sup>5</sup><code><b>DOLIST</b></code> is similar to Perl's <code>foreach</code> or Python's <code>for</code>. Java added a similar kind of loop construct with the "enhanced" <code>for</code> loop in Java 1.5, as part of JSR-201. Notice what a difference macros make. A Lisp programmer who notices a common pattern in their code can write a macro to give themselves a source-level abstraction of that pattern. A Java programmer who notices the same pattern has to convince Sun that this particular abstraction is worth adding to the language. Then Sun has to publish a JSR and convene an industry-wide "expert group" to hash everything out. That process--according to Sun--takes an average of 18 months. After that, the compiler writers all have to go upgrade their compilers to support the new feature. And even once the Java programmer's favorite compiler supports the new version of Java, they probably <i>still</i> can't use the new feature until they're allowed to break source compatibility with older versions of Java. So an annoyance that Common Lisp programmers can resolve for themselves within five minutes plagues Java programmers for years. </p> <p> <sup>6</sup>A variant of <code><b>DO</b></code>, <code><b>DO*</b></code>, assigns each variable its value before evaluating the step form for subsequent variables. For more details, consult your favorite Common Lisp reference. </p> <p> <sup>7</sup>The <code><b>DOTIMES</b></code> is also preferred because the macro expansion will likely include declarations that allow the compiler to generate more efficient code. </p> <p> <sup>8</sup><i>Loop keywords</i> is a bit of a misnomer since they aren't keyword symbols. In fact, <code><b>LOOP</b></code> doesn't care what package the symbols are from. When the <code><b>LOOP</b></code> macro parses its body, it considers any appropriately named symbols equivalent. You could even use true keywords if you wanted--<code>:for</code>, <code>:across</code>, and so on--because they also have the correct name. But most folks just use plain symbols. Because the loop keywords are used only as syntactic markers, it doesn't matter if they're used for other purposes--as function or variable names. </p> </div> <div class="copyright"> - Copyright © 2003-2005, Peter Seibel + Copyright © 2003-2005, Peter Seibel </div> </body> </html> diff --git a/html/practical-an-id3-parser.html b/html/practical-an-id3-parser.html index 23299b0..8aa51e1 100644 --- a/html/practical-an-id3-parser.html +++ b/html/practical-an-id3-parser.html @@ -617,550 +617,550 @@ NIL </pre> <p> The <code>id3v2.3-frame</code>, on the other hand, requires more changes. The frame identifier and size fields were extended in version 2.3 from three to four bytes each, and two bytes worth of flags were added. Additionally, the frame, like the version 2.3 tag, can contain optional fields, controlled by the values of three of the frame's flags.<sup>8</sup> With those changes in mind, you can define the version 2.3 frame base class, along with some helper functions, like this: </p> <pre> (define-tagged-binary-class id3v2.3-frame () ((id (frame-id :length 4)) (size u4) (flags u2) (decompressed-size (optional :type 'u4 :if (frame-compressed-p flags))) (encryption-scheme (optional :type 'u1 :if (frame-encrypted-p flags))) (grouping-identity (optional :type 'u1 :if (frame-grouped-p flags)))) (:dispatch (find-frame-class id))) (defun frame-compressed-p (flags) (logbitp 7 flags)) (defun frame-encrypted-p (flags) (logbitp 6 flags)) (defun frame-grouped-p (flags) (logbitp 5 flags)) </pre> <p> With these two classes defined, you can now implement the methods on the generic function <code>frame-header-size</code>. </p> <pre> (defmethod frame-header-size ((frame id3v2.2-frame)) 6) (defmethod frame-header-size ((frame id3v2.3-frame)) 10) </pre> <p> The optional fields in a version 2.3 frame aren't counted as part of the header for this computation since they're already included in the value of the frame's <code>size</code>. </p> <h2> <a name="versioned-concrete-frame-classes" id="versioned-concrete-frame-classes">Versioned Concrete Frame Classes</a> </h2> <p> In the original definition, <code>generic-frame</code> subclassed <code>id3-frame</code>. But now <code>id3-frame</code> has been replaced with the two version-specific base classes, <code>id3v2.2-frame</code> and <code>id3v2.3-frame</code>. So, you need to define two new versions of <code>generic-frame</code>, one for each base class. One way to define this classes would be like this: </p> <pre> (define-binary-class generic-frame-v2.2 (id3v2.2-frame) ((data (raw-bytes :size size)))) (define-binary-class generic-frame-v2.3 (id3v2.3-frame) ((data (raw-bytes :size size)))) </pre> <p> However, it's a bit annoying that these two classes are the same except for their superclass. It's not too bad in this case since there's only one additional field. But if you take this approach for other concrete frame classes, ones that have a more complex internal structure that's identical between the two ID3 versions, the duplication will be more irksome. </p> <p> Another approach, and the one you should actually use, is to define a class <code>generic-frame</code> as a <i>mixin</i>: a class intended to be used as a superclass along with one of the version-specific base classes to produce a concrete, version-specific frame class. The only tricky bit about this approach is that if <code>generic-frame</code> doesn't extend either of the frame base classes, then you can't refer to the <code>size</code> slot in its definition. Instead, you must use the <code>current-binary-object</code> function I discussed at the end of the previous chapter to access the object you're in the midst of reading or writing and pass it to <code>size</code>. And you need to account for the difference in the number of bytes of the total frame size that will be left over, in the case of a version 2.3 frame, if any of the optional fields are included in the frame. So, you should define a generic function <code>data-bytes</code> with methods that do the right thing for both version 2.2 and version 2.3 frames. </p> <pre> (define-binary-class generic-frame () ((data (raw-bytes :size (data-bytes (current-binary-object)))))) (defgeneric data-bytes (frame)) (defmethod data-bytes ((frame id3v2.2-frame)) (size frame)) (defmethod data-bytes ((frame id3v2.3-frame)) (let ((flags (flags frame))) (- (size frame) (if (frame-compressed-p flags) 4 0) (if (frame-encrypted-p flags) 1 0) (if (frame-grouped-p flags) 1 0)))) </pre> <p> Then you can define concrete classes that extend one of the version-specific base classes and <code>generic-frame</code> to define version-specific generic frame classes. </p> <pre> (define-binary-class generic-frame-v2.2 (id3v2.2-frame generic-frame) ()) (define-binary-class generic-frame-v2.3 (id3v2.3-frame generic-frame) ()) </pre> <p> With these classes defined, you can redefine the <code>find-frame-class</code> function to return the right versioned class based on the length of the identifier. </p> <pre> (defun find-frame-class (id) (ecase (length id) (3 'generic-frame-v2.2) (4 'generic-frame-v2.3))) </pre> <h2> <a name="what-frames-do-you-actually-need" id="what-frames-do-you-actually-need">What Frames Do You Actually Need?</a> </h2> <p> With the ability to read both version 2.2 and version 2.3 tags using generic frames, you're ready to start implementing classes to represent the specific frames you care about. However, before you dive in, you should take a breather and figure out what frames you actually care about since, as I mentioned earlier, the ID3 spec specifies many frames that are almost never used. Of course, what frames you care about depends on what kinds of applications you're interested in writing. If you're mostly interested in extracting information from existing ID3 tags, then you need implement only the classes representing the frames containing the information you care about. On the other hand, if you want to write an ID3 tag editor, you may need to support all the frames. </p> <p> Rather than guessing which frames will be most useful, you can use the code you've already written to poke around a bit at the REPL and see what frames are actually used in your own MP3s. To start, you need an instance of <code>id3-tag</code>, which you can get with the <code>read-id3</code> function. </p> <pre> ID3V2&gt; (read-id3 "/usr2/mp3/Kitka/Wintersongs/02 Byla Cesta.mp3") #&lt;ID3V2.2-TAG @ #x727b2912&gt; </pre> <p> Since you'll want to play with this object a bit, you should save it in a variable. </p> <pre> ID3V2&gt; (defparameter *id3* (read-id3 "/usr2/mp3/Kitka/Wintersongs/02 Byla Cesta.mp3")) *ID3* </pre> <p> Now you can see, for example, how many frames it has. </p> <pre> ID3V2&gt; (length (frames *id3*)) 11 </pre> <p> Not too many--let's take a look at what they are. </p> <pre> ID3V2&gt; (frames *id3*) (#&lt;GENERIC-FRAME-V2.2 @ #x72dabdda&gt; #&lt;GENERIC-FRAME-V2.2 @ #x72dabec2&gt; #&lt;GENERIC-FRAME-V2.2 @ #x72dabfa2&gt; #&lt;GENERIC-FRAME-V2.2 @ #x72dac08a&gt; #&lt;GENERIC-FRAME-V2.2 @ #x72dac16a&gt; #&lt;GENERIC-FRAME-V2.2 @ #x72dac24a&gt; #&lt;GENERIC-FRAME-V2.2 @ #x72dac32a&gt; #&lt;GENERIC-FRAME-V2.2 @ #x72dac40a&gt; #&lt;GENERIC-FRAME-V2.2 @ #x72dac4f2&gt; #&lt;GENERIC-FRAME-V2.2 @ #x72dac632&gt; #&lt;GENERIC-FRAME-V2.2 @ #x72dac7b2&gt;) </pre> <p> Okay, that's not too informative. What you really want to know are what kinds of frames are in there. In other words, you want to know the <code>id</code>s of those frames, which you can get with a simple <code><b>MAPCAR</b></code> like this: </p> <pre> ID3V2&gt; (mapcar #'id (frames *id3*)) ("TT2" "TP1" "TAL" "TRK" "TPA" "TYE" "TCO" "TEN" "COM" "COM" "COM") </pre> <p> If you look up these identifiers in the ID3v2.2 spec, you'll discover that all the frames with identifiers starting with <i>T</i> are text information frames and have a similar structure. And <i>COM</i> is the identifier for comment frames, which have a structure similar to that of text information frames. The particular text information frames identified here turn out to be the frames for representing the song title, artist, album, track, part of set, year, genre, and encoding program. </p> <p> Of course, this is just one MP3 file. Maybe other frames are used in other files. It's easy enough to discover. First define a function that combines the previous <code><b>MAPCAR</b></code> expression with a call to <code>read-id3</code> and wraps the whole thing in a <code><b>DELETE-DUPLICATES</b></code> to keep things tidy. You'll have to use a <code>:test</code> argument of <code>#'string=</code> to <code><b>DELETE-DUPLICATES</b></code> to specify that you want two elements considered the same if they're the same string. </p> <pre> (defun frame-types (file) (delete-duplicates (mapcar #'id (frames (read-id3 file))) :test #'string=)) </pre> <p> This should give the same answer except with only one of each identifier when passed the same filename. </p> <pre> ID3V2&gt; (frame-types "/usr2/mp3/Kitka/Wintersongs/02 Byla Cesta.mp3") ("TT2" "TP1" "TAL" "TRK" "TPA" "TYE" "TCO" "TEN" "COM") </pre> <p> Then you can use Chapter 15's <code>walk-directory</code> function along with <code>mp3-p</code> to find every MP3 file under a directory and combine the results of calling <code>frame-types</code> on each file. Recall that <code><b>NUNION</b></code> is the recycling version of the <code><b>UNION</b></code> function; since <code>frame-types</code> makes a new list for each file, this is safe. </p> <pre> (defun frame-types-in-dir (dir) (let ((ids ())) (flet ((collect (file) (setf ids (nunion ids (frame-types file) :test #'string=)))) (walk-directory dir #'collect :test #'mp3-p)) ids)) </pre> <p> Now pass it the name of a directory, and it'll tell you the set of identifiers used in all the MP3 files under that directory. It may take a few seconds depending how many MP3 files you have, but you'll probably get something similar to this: </p> <pre> ID3V2&gt; (frame-types-in-dir "/usr2/mp3/") ("TCON" "COMM" "TRCK" "TIT2" "TPE1" "TALB" "TCP" "TT2" "TP1" "TCM" "TAL" "TRK" "TPA" "TYE" "TCO" "TEN" "COM") </pre> <p> The four-letter identifiers are the version 2.3 equivalents of the version 2.2 identifiers I discussed previously. Since the information stored in those frames is exactly the information you'll need in Chapter 27, it makes sense to implement classes only for the frames actually used, namely, text information and comment frames, which you'll do in the next two sections. If you decide later that you want to support other frame types, it's mostly a matter of translating the ID3 specifications into the appropriate binary class definitions. </p> <h2> <a name="text-information-frames" id="text-information-frames">Text Information Frames</a> </h2> <p> All text information frames consist of two fields: a single byte indicating which string encoding is used in the frame and a string encoded in the remaining bytes of the frame. If the encoding byte is zero, the string is encoded in ISO 8859-1; if the encoding is one, the string is a UCS-2 string. </p> <p> You've already defined binary types representing the four different kinds of strings--two different encodings each with two different methods of delimiting the string. However, <code>define-binary-class</code> provides no direct facility for determining the type of value to read based on other values in the object. Instead, you can define a binary type that you pass the value of the encoding byte and that then reads or writes the appropriate kind of string. </p> <p> As long as you're defining such a type, you can also define it to take two parameters, <code>:length</code> and <code>:terminator</code>, and pick the right type of string based on which argument is supplied. To implement this new type, you must first define some helper functions. The first two return the name of the appropriate string type based on the encoding byte. </p> <pre> (defun non-terminated-type (encoding) (ecase encoding (0 'iso-8859-1-string) (1 'ucs-2-string))) (defun terminated-type (encoding) (ecase encoding (0 'iso-8859-1-terminated-string) (1 'ucs-2-terminated-string))) </pre> <p> Then <code>string-args</code> uses the encoding byte, the length, and the terminator to determine several of the arguments to be passed to <code>read-value</code> and <code>write-value</code> by the <code>:reader</code> and <code>:writer</code> of <code>id3-encoded-string</code>. One of the length and terminator arguments to <code>string-args</code> should always be <code><b>NIL</b></code>. </p> <pre> (defun string-args (encoding length terminator) (cond (length (values (non-terminated-type encoding) :length length)) (terminator (values (terminated-type encoding) :terminator terminator)))) </pre> <p> With those helpers, the definition of <code>id3-encoded-string</code> is simple. One detail to note is that the keyword--either <code>:length</code> or <code>:terminator</code>--used in the call to <code>read-value</code> and <code>write-value</code> is just another piece of data returned by <code>string-args</code>. Although keywords in arguments lists are almost always literal keywords, they don't have to be. </p> <pre> (define-binary-type id3-encoded-string (encoding length terminator) (:reader (in) (multiple-value-bind (type keyword arg) (string-args encoding length terminator) (read-value type in keyword arg))) (:writer (out string) (multiple-value-bind (type keyword arg) (string-args encoding length terminator) (write-value type out string keyword arg)))) </pre> <p> Now you can define a <code>text-info</code> mixin class, much the way you defined <code>generic-frame</code> earlier. </p> <pre> (define-binary-class text-info-frame () ((encoding u1) (information (id3-encoded-string :encoding encoding :length (bytes-left 1))))) </pre> <p> As when you defined <code>generic-frame</code>, you need access to the size of the frame, in this case to compute the <code>:length</code> argument to pass to <code>id3-encoded-string</code>. Because you'll need to do a similar computation in the next class you define, you can go ahead and define a helper function, <code>bytes-left</code>, that uses <code>current-binary-object</code> to get at the size of the frame. </p> <pre> (defun bytes-left (bytes-read) (- (size (current-binary-object)) bytes-read)) </pre> <p> Now, as you did with the <code>generic-frame</code> mixin, you can define two version-specific concrete classes with a minimum of duplicated code. </p> <pre> (define-binary-class text-info-frame-v2.2 (id3v2.2-frame text-info-frame) ()) (define-binary-class text-info-frame-v2.3 (id3v2.3-frame text-info-frame) ()) </pre> <p> To wire these classes in, you need to modify <code>find-frame-class</code> to return the appropriate class name when the ID indicates the frame is a text information frame, namely, whenever the ID starts with <i>T</i> and isn't <i>TXX</i> or <i>TXXX</i>. </p> <pre> (defun find-frame-class (name) (cond ((and (char= (char name 0) #\T) (not (member name '("TXX" "TXXX") :test #'string=))) (ecase (length name) (3 'text-info-frame-v2.2) (4 'text-info-frame-v2.3))) (t (ecase (length name) (3 'generic-frame-v2.2) (4 'generic-frame-v2.3))))) </pre> <h2> <a name="comment-frames" id="comment-frames">Comment Frames</a> </h2> <p> Another commonly used frame type is the comment frame, which is like a text information frame with a few extra fields. Like a text information frame, it starts with a single byte indicating the string encoding used in the frame. That byte is followed by a three-character ISO 8859-1 string (regardless of the value of the string encoding byte), which indicates what language the comment is in using an ISO-639-2 code, for example, "eng" for English or "jpn" for Japanese. That field is followed by two strings encoded as indicated by the first byte. The first is a null-terminated string containing a description of the comment. The second, which takes up the remainder of the frame, is the comment text itself. </p> <pre> (define-binary-class comment-frame () ((encoding u1) (language (iso-8859-1-string :length 3)) (description (id3-encoded-string :encoding encoding :terminator +null+)) (text (id3-encoded-string :encoding encoding :length (bytes-left (+ 1 ; encoding 3 ; language (encoded-string-length description encoding t))))))) </pre> <p> As in the definition of the <code>text-info</code> mixin, you can use <code>bytes-left</code> to compute the size of the final string. However, since the <code>description</code> field is a variable-length string, the number of bytes read prior to the start of <code>text</code> isn't a constant. To make matters worse, the number of bytes used to encode <code>description</code> is dependent on the encoding. So, you should define a helper function that returns the number of bytes used to encode a string given the string, the encoding code, and a boolean indicating whether the string is terminated with an extra character. </p> <pre> (defun encoded-string-length (string encoding terminated) (let ((characters (+ (length string) (if terminated 1 0)))) (* characters (ecase encoding (0 1) (1 2))))) </pre> <p> And, as before, you can define the concrete version-specific comment frame classes and wire them into <code>find-frame-class</code>. </p> <pre> (define-binary-class comment-frame-v2.2 (id3v2.2-frame comment-frame) ()) (define-binary-class comment-frame-v2.3 (id3v2.3-frame comment-frame) ()) (defun find-frame-class (name) (cond ((and (char= (char name 0) #\T) (not (member name '("TXX" "TXXX") :test #'string=))) (ecase (length name) (3 'text-info-frame-v2.2) (4 'text-info-frame-v2.3))) ((string= name "COM") 'comment-frame-v2.2) ((string= name "COMM") 'comment-frame-v2.3) (t (ecase (length name) (3 'generic-frame-v2.2) (4 'generic-frame-v2.3))))) </pre> <h2> <a name="extracting-information-from-an-id3-tag" id="extracting-information-from-an-id3-tag">Extracting Information from an ID3 Tag</a> </h2> <p> Now that you have the basic ability to read and write ID3 tags, you have a lot of directions you could take this code. If you want to develop a complete ID3 tag editor, you'll need to implement specific classes for all the frame types. You'd also need to define methods for manipulating the tag and frame objects in a consistent way (for instance, if you change the value of a string in a <code>text-info-frame</code>, you'll likely need to adjust the size); as the code stands, there's nothing to make sure that happens.<sup>9</sup> </p> <p> Or, if you just need to extract certain pieces of information about an MP3 file from its ID3 tag--as you will when you develop a streaming MP3 server in Chapters 27, 28, and 29--you'll need to write functions that find the appropriate frames and extract the information you want. </p> <p> Finally, to make this production-quality code, you'd have to pore over the ID3 specs and deal with the details I skipped over in the interest of space. In particular, some of the flags in both the tag and the frame can affect the way the contents of the tag or frame is read; unless you write some code that does the right thing when those flags are set, there may be ID3 tags that this code won't be able to parse correctly. But the code from this chapter should be capable of parsing nearly all the MP3s you actually encounter. </p> <p> For now you can finish with a few functions to extract individual pieces of information from an <code>id3-tag</code>. You'll need these functions in Chapter 27 and probably in other code that uses this library. They belong in this library because they depend on details of the ID3 format that the users of this library shouldn't have to worry about. </p> <p> To get, say, the name of the song of the MP3 from which an <code>id3-tag</code> was extracted, you need to find the ID3 frame with a specific identifier and then extract the information field. And some pieces of information, such as the genre, can require further decoding. Luckily, all the frames that contain the information you'll care about are text information frames, so extracting a particular piece of information mostly boils down to using the right identifier to look up the appropriate frame. Of course, the ID3 authors decided to change all the identifiers between ID3v2.2 and ID3v2.3, so you'll have to account for that. </p> <p> Nothing too complex--you just need to figure out the right path to get to the various pieces of information. This is a perfect bit of code to develop interactively, much the way you figured out what frame classes you needed to implement. To start, you need an <code>id3-tag</code> object to play with. Assuming you have an MP3 laying around, you can use <code>read-id3</code> like this: </p> <pre> ID3V2&gt; (defparameter *id3* (read-id3 "Kitka/Wintersongs/02 Byla Cesta.mp3")) *ID3* ID3V2&gt; *id3* #&lt;ID3V2.2-TAG @ #x73d04c1a&gt; </pre> <p> replacing <code>Kitka/Wintersongs/02 Byla Cesta.mp3</code> with the filename of your MP3. Once you have your <code>id3-tag</code> object, you can start poking around. For instance, you can check out the list of frame objects with the <code>frames</code> function. </p> <pre> ID3V2&gt; (frames *id3*) (#&lt;TEXT-INFO-FRAME-V2.2 @ #x73d04cca&gt; #&lt;TEXT-INFO-FRAME-V2.2 @ #x73d04dba&gt; #&lt;TEXT-INFO-FRAME-V2.2 @ #x73d04ea2&gt; #&lt;TEXT-INFO-FRAME-V2.2 @ #x73d04f9a&gt; #&lt;TEXT-INFO-FRAME-V2.2 @ #x73d05082&gt; #&lt;TEXT-INFO-FRAME-V2.2 @ #x73d0516a&gt; #&lt;TEXT-INFO-FRAME-V2.2 @ #x73d05252&gt; #&lt;TEXT-INFO-FRAME-V2.2 @ #x73d0533a&gt; #&lt;COMMENT-FRAME-V2.2 @ #x73d0543a&gt; #&lt;COMMENT-FRAME-V2.2 @ #x73d05612&gt; #&lt;COMMENT-FRAME-V2.2 @ #x73d0586a&gt;) </pre> <p> Now suppose you want to extract the song title. It's probably in one of those frames, but to find it, you need to find the frame with the "TT2" identifier. Well, you can check easily enough to see if the tag contains such a frame by extracting all the identifiers like this: </p> <pre> ID3V2&gt; (mapcar #'id (frames *id3*)) ("TT2" "TP1" "TAL" "TRK" "TPA" "TYE" "TCO" "TEN" "COM" "COM" "COM") </pre> <p> There it is, the first frame. However, there's no guarantee it'll always be the first frame, so you should probably look it up by identifier rather than position. That's also straightforward using the <code><b>FIND</b></code> function. </p> <pre> ID3V2&gt; (find "TT2" (frames *id3*) :test #'string= :key #'id) #&lt;TEXT-INFO-FRAME-V2.2 @ #x73d04cca&gt; </pre> <p> Now, to get at the actual information in the frame, do this: </p> <pre> ID3V2&gt; (information (find "TT2" (frames *id3*) :test #'string= :key #'id)) "Byla Cesta^@" </pre> <p> Whoops. That <code>^@</code> is how Emacs prints a null character. In a maneuver reminiscent of the kludge that turned ID3v1 into ID3v1.1, the <code>information</code> slot of a text information frame, though not officially a null-terminated string, can contain a null, and ID3 readers are supposed to ignore any characters after the null. So, you need a function that takes a string and returns the contents up to the first null character, if any. That's easy enough using the <code>+null+</code> constant from the binary data library. </p> <pre> (defun upto-null (string) (subseq string 0 (position +null+ string))) </pre> <p> Now you can get just the title. </p> <pre> ID3V2&gt; (upto-null (information (find "TT2" (frames *id3*) :test #'string= :key #'id))) "Byla Cesta" </pre> <p> You could just wrap that code in a function named <code>song</code> that takes an <code>id3-tag</code> as an argument, and you'd be done. However, the only difference between this code and the code you'll use to extract the other pieces of information you'll need (such as the album name, the artist, and the genre) is the identifier. So, it's better to split up the code a bit. For starters, you can write a function that just finds a frame given an <code>id3-tag</code> and an identifier like this: </p> <pre> (defun find-frame (id3 id) (find id (frames id3) :test #'string= :key #'id)) ID3V2&gt; (find-frame *id3* "TT2") #&lt;TEXT-INFO-FRAME-V2.2 @ #x73d04cca&gt; </pre> <p> Then the other bit of code, the part that extracts the information from a <code>text-info-frame</code>, can go in another function. </p> <pre> (defun get-text-info (id3 id) (let ((frame (find-frame id3 id))) (when frame (upto-null (information frame))))) ID3V2&gt; (get-text-info *id3* "TT2") "Byla Cesta" </pre> <p> Now the definition of <code>song</code> is just a matter of passing the right identifier. </p> <pre> (defun song (id3) (get-text-info id3 "TT2")) ID3V2&gt; (song *id3*) "Byla Cesta" </pre> <p> However, this definition of <code>song</code> works only with version 2.2 tags since the identifier changed from "TT2" to "TIT2" between version 2.2 and version 2.3. And all the other tags changed too. Since the user of this library shouldn't have to know about different versions of the ID3 format to do something as simple as get the song title, you should probably handle those details for them. A simple way is to change <code>find-frame</code> to take not just a single identifier but a list of identifiers like this: </p> <pre> (defun find-frame (id3 ids) (find-if #'(lambda (x) (find (id x) ids :test #'string=)) (frames id3))) </pre> <p> Then change <code>get-text-info</code> slightly so it can take one or more identifiers using a <code><b>&amp;rest</b></code> parameter. </p> <pre> (defun get-text-info (id3 &amp;rest ids) (let ((frame (find-frame id3 ids))) (when frame (upto-null (information frame))))) </pre> <p> Then the change needed to allow <code>song</code> to support both version 2.2 and version 2.3 tags is just a matter of adding the version 2.3 identifier. </p> <pre> (defun song (id3) (get-text-info id3 "TT2" "TIT2")) </pre> <p> Then you just need to look up the appropriate version 2.2 and version 2.3 frame identifiers for any fields for which you want to provide an accessor function. Here are the ones you'll need in Chapter 27: </p> <pre> (defun album (id3) (get-text-info id3 "TAL" "TALB")) (defun artist (id3) (get-text-info id3 "TP1" "TPE1")) (defun track (id3) (get-text-info id3 "TRK" "TRCK")) (defun year (id3) (get-text-info id3 "TYE" "TYER" "TDRC")) (defun genre (id3) (get-text-info id3 "TCO" "TCON")) </pre> <p> The last wrinkle is that the way the <code>genre</code> is stored in the TCO or TCON frames isn't always human readable. Recall that in ID3v1, genres were stored as a single byte that encoded a particular genre from a fixed list. Unfortunately, those codes live on in ID3v2--if the text of the genre frame is a number in parentheses, the number is supposed to be interpreted as an ID3v1 genre code. But, again, users of this library probably won't care about that ancient history. So, you should provide a function that automatically translates the genre. The following function uses the <code>genre</code> function just defined to extract the actual genre text and then checks whether it starts with a left parenthesis, decoding the version 1 genre code with a function you'll define in a moment if it does: </p> <pre> (defun translated-genre (id3) (let ((genre (genre id3))) (if (and genre (char= #\( (char genre 0))) (translate-v1-genre genre) genre))) </pre> <p> Since a version 1 genre code is effectively just an index into an array of standard names, the easiest way to implement <code>translate-v1-genre</code> is to extract the number from the genre string and use it as an index into an actual array. </p> <pre> (defun translate-v1-genre (genre) (aref *id3-v1-genres* (parse-integer genre :start 1 :junk-allowed t))) </pre> <p> Then all you need to do is to define the array of names. The following array of names includes the 80 official version 1 genres plus the genres created by the authors of Winamp: </p> <pre> (defparameter *id3-v1-genres* #( ;; These are the official ID3v1 genres. "Blues" "Classic Rock" "Country" "Dance" "Disco" "Funk" "Grunge" "Hip-Hop" "Jazz" "Metal" "New Age" "Oldies" "Other" "Pop" "R&amp;B" "Rap" "Reggae" "Rock" "Techno" "Industrial" "Alternative" "Ska" "Death Metal" "Pranks" "Soundtrack" "Euro-Techno" "Ambient" "Trip-Hop" "Vocal" "Jazz+Funk" "Fusion" "Trance" "Classical" "Instrumental" "Acid" "House" "Game" "Sound Clip" "Gospel" "Noise" "AlternRock" "Bass" "Soul" "Punk" "Space" "Meditative" "Instrumental Pop" "Instrumental Rock" "Ethnic" "Gothic" "Darkwave" "Techno-Industrial" "Electronic" "Pop-Folk" "Eurodance" "Dream" "Southern Rock" "Comedy" "Cult" "Gangsta" "Top 40" "Christian Rap" "Pop/Funk" "Jungle" "Native American" "Cabaret" "New Wave" "Psychadelic" "Rave" "Showtunes" "Trailer" "Lo-Fi" "Tribal" "Acid Punk" "Acid Jazz" "Polka" "Retro" "Musical" "Rock &amp; Roll" "Hard Rock" ;; These were made up by the authors of Winamp but backported into ;; the ID3 spec. "Folk" "Folk-Rock" "National Folk" "Swing" "Fast Fusion" "Bebob" "Latin" "Revival" "Celtic" "Bluegrass" "Avantgarde" "Gothic Rock" "Progressive Rock" "Psychedelic Rock" "Symphonic Rock" "Slow Rock" "Big Band" "Chorus" "Easy Listening" "Acoustic" "Humour" "Speech" "Chanson" "Opera" "Chamber Music" "Sonata" "Symphony" "Booty Bass" "Primus" "Porn Groove" "Satire" "Slow Jam" "Club" "Tango" "Samba" "Folklore" "Ballad" "Power Ballad" "Rhythmic Soul" "Freestyle" "Duet" "Punk Rock" "Drum Solo" "A capella" "Euro-House" "Dance Hall" ;; These were also invented by the Winamp folks but ignored by the ;; ID3 authors. "Goa" "Drum &amp; Bass" "Club-House" "Hardcore" "Terror" "Indie" "BritPop" "Negerpunk" "Polsk Punk" "Beat" "Christian Gangsta Rap" "Heavy Metal" "Black Metal" "Crossover" "Contemporary Christian" "Christian Rock" "Merengue" "Salsa" "Thrash Metal" "Anime" "Jpop" "Synthpop")) </pre> <p> Once again, it probably feels like you wrote a ton of code in this chapter. But if you put it all in a file, or if you download the version from this book's Web site, you'll see it's just not that many lines--most of the pain of writing this library stems from having to understand the intricacies of the ID3 format itself. Anyway, now you have a major piece of what you'll turn into a streaming MP3 server in Chapters 27, 28, and 29. The other major bit of infrastructure you'll need is a way to write server-side Web software, the topic of the next chapter. </p> <hr> <div class="notes"> <p> - <sup>1</sup><i>Ripping</i> is the process by which a song on an audio CD is converted to an MP3 file on your hard drive. These days most ripping software also automatically retrieves information about the songs being ripped from online databases such as Gracenote (née the Compact Disc Database [CDDB]) or FreeDB, which it then embeds in the MP3 files as ID3 tags. + <sup>1</sup><i>Ripping</i> is the process by which a song on an audio CD is converted to an MP3 file on your hard drive. These days most ripping software also automatically retrieves information about the songs being ripped from online databases such as Gracenote (née the Compact Disc Database [CDDB]) or FreeDB, which it then embeds in the MP3 files as ID3 tags. </p> <p> <sup>2</sup>Almost all file systems provide the ability to overwrite existing bytes of a file, but few, if any, provide a way to add or remove data at the beginning or middle of a file without having to rewrite the rest of the file. Since ID3 tags are typically stored at the beginning of a file, to rewrite an ID3 tag without disturbing the rest of the file you must replace the old tag with a new tag of exactly the same length. By writing ID3 tags with a certain amount of padding, you have a better chance of being able to do so--if the new tag has more data than the original tag, you use less padding, and if it's shorter, you use more. </p> <p> <sup>3</sup>The frame data following the ID3 header could also potentially contain the illegal sequence. That's prevented using a different scheme that's turned on via one of the flags in the tag header. The code in this chapter doesn't account for the possibility that this flag might be set; in practice it's rarely used. </p> <p> <sup>4</sup>In ID3v2.4, UCS-2 is replaced by the virtually identical UTF-16, and UTF-16BE and UTF-8 are added as additional encodings. </p> <p> <sup>5</sup>The 2.4 version of the ID3 format also supports placing a footer at the end of a tag, which makes it easier to find a tag appended to the end of a file. </p> <p> <sup>6</sup>Character streams support two functions, <code><b>PEEK-CHAR</b></code> and <code><b>UNREAD-CHAR</b></code>, either of which would be a perfect solution to this problem, but binary streams support no equivalent functions. </p> <p> <sup>7</sup>If a tag had an extended header, you could use this value to determine where the frame data should end. However, if the extended header isn't used, you'd have to use the old algorithm anyway, so it's not worth adding code to do it another way. </p> <p> <sup>8</sup>These flags, in addition to controlling whether the optional fields are included, can affect the parsing of the rest of the tag. In particular, if the seventh bit of the flags is set, then the actual frame data is compressed using the zlib algorithm, and if the sixth bit is set, the data is encrypted. In practice these options are rarely, if ever, used, so you can get away with ignoring them for now. But that would be an area you'd have to address to make this a production-quality ID3 library. One simple half solution would be to change <code>find-frame-class</code> to accept a second argument and pass it the flags; if the frame is compressed or encrypted, you could instantiate a generic frame to hold the data. </p> <p> <sup>9</sup>Ensuring that kind of interfield consistency would be a fine application for <code>:after</code> methods on the accessor generic functions. For instance, you could define this <code>:after</code> method to keep <code>size</code> in sync with the <code>information</code> string: </p> <pre> (defmethod (setf information) :after (value (frame text-info-frame)) (declare (ignore value)) (with-slots (encoding size information) frame (setf size (encoded-string-length information encoding nil)))) </pre> </div> <div class="copyright"> - Copyright © 2003-2005, Peter Seibel + Copyright © 2003-2005, Peter Seibel </div> </body> </html>
akosma/PracticalCommonLisp_ePub
839dd797f6b6a01b64b746e61912904b3b7dd583
Changed GIF files into PNG
diff --git a/html/index.html b/html/index.html index c6dd928..200b184 100644 --- a/html/index.html +++ b/html/index.html @@ -1,187 +1,187 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title> Practical Common Lisp </title> <link rel='stylesheet' type='text/css' href='style.css'><!-- <script language="JavaScript" src="http://www.gvisit.com/record.php?sid=f8af8124c8b07e7f044291fa5b28611b" type="text/javascript"></script> --> <style type='text/css'> <!-- BODY { font-family: sans-serif; margin: .5in; } .INTRO { font-size: 11pt; } TD.NEWS { vertical-align: top; width: 22em; } P.BOX-HEADER { font-weight: bold; margin-bottom: -1ex; } DIV.NEWS { float: right; width: 20em; text-align: center; background-color: #ffc426; margin: 1em; padding: 1em; border-style: solid; border-width: thin; } LI { padding: 0pt 2pt; } H1 { text-align: center; margin-bottom: 0pt; } P.BLURB { text-align: center; font-size: 12pt; font-style: italic; } P.MORE-BLURBS { margin-top: -12pt; text-align: center; font-size: 10pt; font-family: sans-serif; } #jolt-logo { float: right; border: none; } --> </style> </head> <body> <h1> - <img border="0" class='floater' src="small-cover.gif"><img src="http://www.assoc-amazon.com/e/ir?t=gigamonkeys-20&amp;l=as2&amp;o=1&amp;a=1590592395" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;">Practical Common Lisp<img id='jolt-logo' src="jolt_logo16_sm.gif" name="jolt-logo"> + <img border="0" class='floater' src="small-cover.png"><img src="http://www.assoc-amazon.com/e/ir?t=gigamonkeys-20&amp;l=as2&amp;o=1&amp;a=1590592395" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;">Practical Common Lisp<img id='jolt-logo' src="jolt_logo16_sm.png" name="jolt-logo"> </h1> <p class='blurb'> that book is dead sexy —Xach on #lisp </p> <p class='more-blurbs'> (<a href='blurbs.html'>more blurbs</a>) </p> <p class='intro'> This page, and the pages it links to, contain text of the Common Lisp book <i>Practical Common Lisp</i> published by Apress These pages now contain the final text as it appears in the book. If you find errors in these pages, please send email to <a href='mailto:[email protected]'>[email protected]</a>. These pages will remain online in perpetuity—I hope they will serve as a useful introduction to Common Lisp for folks who are curious about Lisp but maybe not yet curious enough to shell out big bucks for a dead-tree book and a good Common Lisp tutorial for folks who want to get down to real coding right away. However, don't let that stop you from buying the printed version available from Apress at your favorite local or online bookseller. For the complete bookstore browsing experience, you can read the <a href='letter-to-reader.html'>letter to the reader</a> that appears on the back cover of the treeware edition of the book. </p> <ol> <li> <a href='introduction-why-lisp.html'>Introduction: Why Lisp?</a> </li> <li> <a href='lather-rinse-repeat-a-tour-of-the-repl.html'>Lather, Rinse, Repeat: A Tour of the REPL</a> </li> <li> <a href='practical-a-simple-database.html'>Practical: A Simple Database</a> </li> <li> <a href='syntax-and-semantics.html'>Syntax and Semantics</a> </li> <li> <a href='functions.html'>Functions</a> </li> <li> <a href='variables.html'>Variables</a> </li> <li> <a href='macros-standard-control-constructs.html'>Macros: Standard Control Constructs</a> </li> <li> <a href='macros-defining-your-own.html'>Macros: Defining Your Own</a> </li> <li> <a href='practical-building-a-unit-test-framework.html'>Practical: Building a Unit Test Framework</a> </li> <li> <a href='numbers-characters-and-strings.html'>Numbers, Characters, and Strings</a> </li> <li> <a href='collections.html'>Collections</a> </li> <li> <a href='they-called-it-lisp-for-a-reason-list-processing.html'>They Called It LISP for a Reason: List Processing</a> </li> <li> <a href='beyond-lists-other-uses-for-cons-cells.html'>Beyond Lists: Other Uses for Cons Cells</a> </li> <li> <a href='files-and-file-io.html'>Files and File I/O</a> </li> <li> <a href='practical-a-portable-pathname-library.html'>Practical: A Portable Pathname Library</a> </li> <li> <a href='object-reorientation-generic-functions.html'>Object Reorientation: Generic Functions</a> </li> <li> <a href='object-reorientation-classes.html'>Object Reorientation: Classes</a> </li> <li> <a href='a-few-format-recipes.html'>A Few FORMAT Recipes</a> </li> <li> <a href='beyond-exception-handling-conditions-and-restarts.html'>Beyond Exception Handling: Conditions and Restarts</a> </li> <li> <a href='the-special-operators.html'>The Special Operators</a> </li> <li> <a href='programming-in-the-large-packages-and-symbols.html'>Programming in the Large: Packages and Symbols</a> </li> <li> <a href='loop-for-black-belts.html'>LOOP for Black Belts</a> </li> <li> <a href='practical-a-spam-filter.html'>Practical: A Spam Filter</a> </li> <li> <a href='practical-parsing-binary-files.html'>Practical: Parsing Binary Files</a> </li> <li> <a href='practical-an-id3-parser.html'>Practical: An ID3 Parser</a> </li> <li> <a href='practical-web-programming-with-allegroserve.html'>Practical: Web Programming with AllegroServe</a> </li> <li> <a href='practical-an-mp3-database.html'>Practical: An MP3 Database</a> </li> <li> <a href='practical-a-shoutcast-server.html'>Practical: A Shoutcast Server</a> </li> <li> <a href='practical-an-mp3-browser.html'>Practical: An MP3 Browser</a> </li> <li> <a href='practical-an-html-generation-library-the-interpreter.html'>Practical: An HTML Generation Library, the Interpreter</a> </li> <li> <a href='practical-an-html-generation-library-the-compiler.html'>Practical: An HTML Generation Library, the Compiler</a> </li> <li> <a href='conclusion-whats-next.html'>Conclusion: What's Next?</a> </li> </ol> <div class='copyright'> Copyright © 2003-2009, Peter Seibel </div><!-- amazon link enhancer foo --> <script type="text/javascript" src="http://www.assoc-amazon.com/s/link-enhancer?tag=gigamonkeys-20"> </script><noscript><img src="http://www.assoc-amazon.com/s/noscript?tag=gigamonkeys-20" alt=""></noscript><!-- end amazon link enhancer foo --> </body> </html>
akosma/PracticalCommonLisp_ePub
5790cda6d73d1d640c4debcc5e83f35338ce8ea9
Changed GIF files into PNG
diff --git a/html/jolt_logo16_sm.gif b/html/jolt_logo16_sm.gif deleted file mode 100644 index 1ba7b32..0000000 Binary files a/html/jolt_logo16_sm.gif and /dev/null differ diff --git a/html/jolt_logo16_sm.png b/html/jolt_logo16_sm.png new file mode 100644 index 0000000..eff0a4b Binary files /dev/null and b/html/jolt_logo16_sm.png differ diff --git a/html/small-cover.gif b/html/small-cover.gif deleted file mode 100644 index 570e7cb..0000000 Binary files a/html/small-cover.gif and /dev/null differ diff --git a/html/small-cover.png b/html/small-cover.png new file mode 100644 index 0000000..79324df Binary files /dev/null and b/html/small-cover.png differ
akosma/PracticalCommonLisp_ePub
5f631d1e070db201770ee20e4fb82d91fd52a15c
Transformed the README into Markdown
diff --git a/README.md b/README.md new file mode 100644 index 0000000..4ce280f --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +Common List Book in ePub Format +=============================== + +This is an unofficial ePub version of the Practical Common Lisp book +[available online](http://www.gigamonkeys.com/book/). The HTML of the +website has been downloaded adapted to be processed with Calibre into an +ePub file, which can be read with [iBooks on the +iPad](http://www.apple.com/ipad/features/ibooks.html). + +Build +----- + +To build the ePub just run `make` at the command line. The `Makefile` +depends on [Pandoc](http://johnmacfarlane.net/pandoc/) to create the +file. + +Download +-------- + +The source code of the book can be downloaded in +[tar.gz](http://www.gigamonkeys.com/book/practicals-1.0.3.tar.gz) and +[zip](http://www.gigamonkeys.com/book/practicals-1.0.3.zip) formats from +the original website. + +Copyright +--------- + +Copyright © 2003-2009, Peter Seibel. + diff --git a/README.textile b/README.textile deleted file mode 100644 index 7623c4d..0000000 --- a/README.textile +++ /dev/null @@ -1,11 +0,0 @@ -h1. Common List Book in ePub Format - -This is an unofficial ePub version of the Practical Common Lisp book "available online":http://www.gigamonkeys.com/book/. The HTML of the website has been downloaded adapted to be processed with Calibre into an ePub file, which can be read with "iBooks on the iPad":http://www.apple.com/ipad/features/ibooks.html. - -h2. Download - -You can download the ePub file directly from the "downloads" section of this Github repository. The source code of the book can be downloaded in "tar.gz":http://www.gigamonkeys.com/book/practicals-1.0.3.tar.gz and "zip":http://www.gigamonkeys.com/book/practicals-1.0.3.zip formats from the original website. - -h2. Copyright - -Copyright © 2003-2009, Peter Seibel.
pacew/img
955436b17a4f9d8025e05cfd7a11d102e30e4546
use older inotify interface for back compatibility
diff --git a/img.c b/img.c index 409d5c7..f6152f1 100644 --- a/img.c +++ b/img.c @@ -1,247 +1,251 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <memory.h> +#include <fcntl.h> #include <sys/time.h> #include <sys/inotify.h> + #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> char *filename; int inotify_fd; int auto_raise = 1; void usage (void) { fprintf (stderr, "usage: img [-n] filename\n"); exit (1); } GtkWidget *window; GdkPixbuf *pixbuf; gboolean expose_event () { if (pixbuf) { gdk_draw_pixbuf (window->window, NULL, pixbuf, 0, 0, 0, 0, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0); } return (TRUE); } int read_image (void) { GdkPixbuf *new_pixbuf; new_pixbuf = gdk_pixbuf_new_from_file (filename, NULL); if (new_pixbuf == NULL) return (-1); if (pixbuf) g_object_unref (pixbuf); pixbuf = new_pixbuf; gtk_window_resize (GTK_WINDOW (window), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); gtk_widget_queue_draw (window); if (auto_raise && window->window) gdk_window_raise (GDK_WINDOW (window->window)); return (0); } gboolean key_press_event (GtkWidget *widget, GdkEventKey *ev, gpointer data) { switch (ev->keyval) { case 'q': /* covers q or ALT-q */ case 'c': /* covers CTL-c */ case 'w': /* covers CTL-w */ case GDK_Escape: gtk_main_quit (); } return (TRUE); } struct monitor_file { struct monitor_file *next; char *dirname; char *filename; void (*func)(struct monitor_file *); }; struct monitor_file *monitor_files; int inotify_fd = -1; gboolean inotify_handler (GIOChannel *source, GIOCondition condition, gpointer data) { char buf[10000]; struct inotify_event ev; ssize_t avail, offset; struct monitor_file *mp; while ((avail = read (inotify_fd, buf, sizeof buf)) > 0) { offset = 0; while (offset + sizeof ev <= avail) { memcpy (&ev, buf + offset, sizeof ev); filename = buf + offset + sizeof ev; if (ev.mask & (IN_CLOSE_WRITE | IN_MOVED_TO)) { for (mp = monitor_files; mp; mp = mp->next) { if (strcmp (mp->filename, filename) == 0) { (*mp->func)(mp); } } } offset += sizeof ev + ev.len; } } return (TRUE); } struct monitor_file * monitor_file (char *filename_arg, void (*file_changed_func)(struct monitor_file *)) { char *dirname; int total_len, dirname_len, filename_len, idx; struct monitor_file *mp; void *mpbuf; if ((total_len = strlen (filename_arg)) == 0) return (NULL); idx = total_len; while (idx > 0 && filename_arg[idx-1] != '/') idx--; filename = filename_arg + idx; filename_len = total_len - idx; while (idx > 0 && filename_arg[idx-1] == '/') idx--; if (idx == 0) { dirname = (filename_arg[0] == '/') ? "/" : "."; dirname_len = 1; } else { dirname = filename_arg; dirname_len = idx; } if ((mpbuf = malloc (sizeof *mp + filename_len + 1 + dirname_len + 1)) == NULL) { return (NULL); } mp = mpbuf; memset (mp, 0, sizeof *mp); mp->filename = mpbuf + sizeof *mp; strncpy (mp->filename, filename, filename_len); mp->filename[filename_len] = 0; mp->dirname = mp->filename + filename_len + 1; strncpy (mp->dirname, dirname, dirname_len); mp->dirname[dirname_len] = 0; if (inotify_add_watch (inotify_fd, mp->dirname, IN_CLOSE_WRITE | IN_MOVED_TO) < 0) { free (mp); return (NULL); } mp->func = file_changed_func; mp->next = monitor_files; monitor_files = mp; return (mp); } void monitor_file_func (struct monitor_file *mp) { read_image (); } int main (int argc, char **argv) { int c; gtk_init (&argc, &argv); while ((c = getopt (argc, argv, "n")) != EOF) { switch (c) { case 'n': auto_raise = 0; break; default: usage (); } } if (optind >= argc) usage (); filename = argv[optind++]; if (optind != argc) usage (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), filename); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "expose_event", G_CALLBACK (expose_event), NULL); g_signal_connect (G_OBJECT (window), "key_press_event", G_CALLBACK (key_press_event), NULL); gtk_widget_show (window); - if ((inotify_fd = inotify_init1 (IN_NONBLOCK | IN_CLOEXEC)) < 0) { + if ((inotify_fd = inotify_init ()) < 0) { fprintf (stderr, "error doing inotify_init\n"); exit (1); } + fcntl (inotify_fd, F_SETFL, O_NONBLOCK | O_EXCL); + g_io_add_watch (g_io_channel_unix_new (inotify_fd), G_IO_IN, inotify_handler, NULL); if (monitor_file (filename, monitor_file_func) == NULL) { fprintf (stderr, "error setting up monitor_file\n"); exit (1); } if (read_image () < 0) { fprintf (stderr, "can't open %s\n", filename); exit (1); } gtk_main (); return (0); }
pacew/img
a71509e2d11e6b71b0c9ce1584130d0d3811a550
removed use of fcntl.h; fixed usage message and one comment
diff --git a/img.c b/img.c index a9b24dd..409d5c7 100644 --- a/img.c +++ b/img.c @@ -1,251 +1,247 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <memory.h> -#include <fcntl.h> #include <sys/time.h> #include <sys/inotify.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> char *filename; int inotify_fd; int auto_raise = 1; void usage (void) { - fprintf (stderr, "usage: img [-a 0|1] file\n"); + fprintf (stderr, "usage: img [-n] filename\n"); exit (1); } GtkWidget *window; GdkPixbuf *pixbuf; gboolean expose_event () { if (pixbuf) { gdk_draw_pixbuf (window->window, NULL, pixbuf, 0, 0, 0, 0, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0); } return (TRUE); } int read_image (void) { GdkPixbuf *new_pixbuf; - new_pixbuf = gdk_pixbuf_new_from_file (filename, NULL); if (new_pixbuf == NULL) return (-1); if (pixbuf) g_object_unref (pixbuf); pixbuf = new_pixbuf; gtk_window_resize (GTK_WINDOW (window), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); gtk_widget_queue_draw (window); if (auto_raise && window->window) gdk_window_raise (GDK_WINDOW (window->window)); return (0); } gboolean key_press_event (GtkWidget *widget, GdkEventKey *ev, gpointer data) { switch (ev->keyval) { case 'q': /* covers q or ALT-q */ case 'c': /* covers CTL-c */ - case 'w': /* covers ALT-w */ + case 'w': /* covers CTL-w */ case GDK_Escape: gtk_main_quit (); } return (TRUE); } struct monitor_file { struct monitor_file *next; char *dirname; char *filename; void (*func)(struct monitor_file *); }; struct monitor_file *monitor_files; int inotify_fd = -1; gboolean inotify_handler (GIOChannel *source, GIOCondition condition, gpointer data) { char buf[10000]; struct inotify_event ev; ssize_t avail, offset; struct monitor_file *mp; while ((avail = read (inotify_fd, buf, sizeof buf)) > 0) { offset = 0; while (offset + sizeof ev <= avail) { memcpy (&ev, buf + offset, sizeof ev); filename = buf + offset + sizeof ev; if (ev.mask & (IN_CLOSE_WRITE | IN_MOVED_TO)) { for (mp = monitor_files; mp; mp = mp->next) { if (strcmp (mp->filename, filename) == 0) { (*mp->func)(mp); } } } offset += sizeof ev + ev.len; } } return (TRUE); } struct monitor_file * monitor_file (char *filename_arg, void (*file_changed_func)(struct monitor_file *)) { char *dirname; int total_len, dirname_len, filename_len, idx; struct monitor_file *mp; void *mpbuf; if ((total_len = strlen (filename_arg)) == 0) return (NULL); idx = total_len; while (idx > 0 && filename_arg[idx-1] != '/') idx--; filename = filename_arg + idx; filename_len = total_len - idx; while (idx > 0 && filename_arg[idx-1] == '/') idx--; if (idx == 0) { dirname = (filename_arg[0] == '/') ? "/" : "."; dirname_len = 1; } else { dirname = filename_arg; dirname_len = idx; } if ((mpbuf = malloc (sizeof *mp + filename_len + 1 + dirname_len + 1)) == NULL) { return (NULL); } mp = mpbuf; memset (mp, 0, sizeof *mp); mp->filename = mpbuf + sizeof *mp; strncpy (mp->filename, filename, filename_len); mp->filename[filename_len] = 0; mp->dirname = mp->filename + filename_len + 1; strncpy (mp->dirname, dirname, dirname_len); mp->dirname[dirname_len] = 0; if (inotify_add_watch (inotify_fd, mp->dirname, IN_CLOSE_WRITE | IN_MOVED_TO) < 0) { free (mp); return (NULL); } mp->func = file_changed_func; mp->next = monitor_files; monitor_files = mp; return (mp); } void monitor_file_func (struct monitor_file *mp) { read_image (); } int main (int argc, char **argv) { int c; gtk_init (&argc, &argv); while ((c = getopt (argc, argv, "n")) != EOF) { switch (c) { case 'n': auto_raise = 0; break; default: usage (); } } if (optind >= argc) usage (); filename = argv[optind++]; if (optind != argc) usage (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), filename); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "expose_event", G_CALLBACK (expose_event), NULL); g_signal_connect (G_OBJECT (window), "key_press_event", G_CALLBACK (key_press_event), NULL); gtk_widget_show (window); if ((inotify_fd = inotify_init1 (IN_NONBLOCK | IN_CLOEXEC)) < 0) { fprintf (stderr, "error doing inotify_init\n"); exit (1); } - fcntl (inotify_fd, F_SETFL, O_NONBLOCK); - g_io_add_watch (g_io_channel_unix_new (inotify_fd), G_IO_IN, inotify_handler, NULL); if (monitor_file (filename, monitor_file_func) == NULL) { fprintf (stderr, "error setting up monitor_file\n"); exit (1); } if (read_image () < 0) { fprintf (stderr, "can't open %s\n", filename); exit (1); } gtk_main (); return (0); }
pacew/img
a4028c46ff9e84356712131626d566e5734d9832
add a little documentation; change autoraise option
diff --git a/README b/README index e4eb459..8a0c463 100644 --- a/README +++ b/README @@ -1,2 +1,13 @@ -By Pace Willisson <[email protected]> 2009 +img by Pace Willisson <[email protected]> +August 2009 Dedicated to the public domain + +img is a simple GTK program that displays an image in a window. It's +claim to fame is that it uses the inotify system call to monitor the +file and automatically refresh the window after any change. + +usage: img [-n] filename + +The -n flag means don't auto-raise the window when it is refreshed. + +keyboard commands: q, CTL-c, ALT-q, ALT-w or Escape to exit diff --git a/img.c b/img.c index 6fc9a6a..a9b24dd 100644 --- a/img.c +++ b/img.c @@ -1,251 +1,251 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <memory.h> #include <fcntl.h> #include <sys/time.h> #include <sys/inotify.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> char *filename; int inotify_fd; int auto_raise = 1; void usage (void) { fprintf (stderr, "usage: img [-a 0|1] file\n"); exit (1); } GtkWidget *window; GdkPixbuf *pixbuf; gboolean expose_event () { if (pixbuf) { gdk_draw_pixbuf (window->window, NULL, pixbuf, 0, 0, 0, 0, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0); } return (TRUE); } int read_image (void) { GdkPixbuf *new_pixbuf; new_pixbuf = gdk_pixbuf_new_from_file (filename, NULL); if (new_pixbuf == NULL) return (-1); if (pixbuf) g_object_unref (pixbuf); pixbuf = new_pixbuf; gtk_window_resize (GTK_WINDOW (window), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); gtk_widget_queue_draw (window); if (auto_raise && window->window) gdk_window_raise (GDK_WINDOW (window->window)); return (0); } gboolean key_press_event (GtkWidget *widget, GdkEventKey *ev, gpointer data) { switch (ev->keyval) { case 'q': /* covers q or ALT-q */ case 'c': /* covers CTL-c */ case 'w': /* covers ALT-w */ case GDK_Escape: gtk_main_quit (); } return (TRUE); } struct monitor_file { struct monitor_file *next; char *dirname; char *filename; void (*func)(struct monitor_file *); }; struct monitor_file *monitor_files; int inotify_fd = -1; gboolean inotify_handler (GIOChannel *source, GIOCondition condition, gpointer data) { char buf[10000]; struct inotify_event ev; ssize_t avail, offset; struct monitor_file *mp; while ((avail = read (inotify_fd, buf, sizeof buf)) > 0) { offset = 0; while (offset + sizeof ev <= avail) { memcpy (&ev, buf + offset, sizeof ev); filename = buf + offset + sizeof ev; if (ev.mask & (IN_CLOSE_WRITE | IN_MOVED_TO)) { for (mp = monitor_files; mp; mp = mp->next) { if (strcmp (mp->filename, filename) == 0) { (*mp->func)(mp); } } } offset += sizeof ev + ev.len; } } return (TRUE); } struct monitor_file * monitor_file (char *filename_arg, void (*file_changed_func)(struct monitor_file *)) { char *dirname; int total_len, dirname_len, filename_len, idx; struct monitor_file *mp; void *mpbuf; if ((total_len = strlen (filename_arg)) == 0) return (NULL); idx = total_len; while (idx > 0 && filename_arg[idx-1] != '/') idx--; filename = filename_arg + idx; filename_len = total_len - idx; while (idx > 0 && filename_arg[idx-1] == '/') idx--; if (idx == 0) { dirname = (filename_arg[0] == '/') ? "/" : "."; dirname_len = 1; } else { dirname = filename_arg; dirname_len = idx; } if ((mpbuf = malloc (sizeof *mp + filename_len + 1 + dirname_len + 1)) == NULL) { return (NULL); } mp = mpbuf; memset (mp, 0, sizeof *mp); mp->filename = mpbuf + sizeof *mp; strncpy (mp->filename, filename, filename_len); mp->filename[filename_len] = 0; mp->dirname = mp->filename + filename_len + 1; strncpy (mp->dirname, dirname, dirname_len); mp->dirname[dirname_len] = 0; if (inotify_add_watch (inotify_fd, mp->dirname, IN_CLOSE_WRITE | IN_MOVED_TO) < 0) { free (mp); return (NULL); } mp->func = file_changed_func; mp->next = monitor_files; monitor_files = mp; return (mp); } void monitor_file_func (struct monitor_file *mp) { read_image (); } int main (int argc, char **argv) { int c; gtk_init (&argc, &argv); - while ((c = getopt (argc, argv, "a:")) != EOF) { + while ((c = getopt (argc, argv, "n")) != EOF) { switch (c) { - case 'a': - auto_raise = atoi (optarg); + case 'n': + auto_raise = 0; break; default: usage (); } } if (optind >= argc) usage (); filename = argv[optind++]; if (optind != argc) usage (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), filename); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "expose_event", G_CALLBACK (expose_event), NULL); g_signal_connect (G_OBJECT (window), "key_press_event", G_CALLBACK (key_press_event), NULL); gtk_widget_show (window); if ((inotify_fd = inotify_init1 (IN_NONBLOCK | IN_CLOEXEC)) < 0) { fprintf (stderr, "error doing inotify_init\n"); exit (1); } fcntl (inotify_fd, F_SETFL, O_NONBLOCK); g_io_add_watch (g_io_channel_unix_new (inotify_fd), G_IO_IN, inotify_handler, NULL); if (monitor_file (filename, monitor_file_func) == NULL) { fprintf (stderr, "error setting up monitor_file\n"); exit (1); } if (read_image () < 0) { fprintf (stderr, "can't open %s\n", filename); exit (1); } gtk_main (); return (0); }
pacew/img
c1686f565caa5f77c320de7ef86af7b5fe353a03
remove poll loop
diff --git a/img.c b/img.c index a5820e5..6fc9a6a 100644 --- a/img.c +++ b/img.c @@ -1,226 +1,251 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <memory.h> +#include <fcntl.h> #include <sys/time.h> #include <sys/inotify.h> #include <gtk/gtk.h> +#include <gdk/gdkkeysyms.h> char *filename; int inotify_fd; +int auto_raise = 1; + void usage (void) { - fprintf (stderr, "usage: img file\n"); + fprintf (stderr, "usage: img [-a 0|1] file\n"); exit (1); } - GtkWidget *window; GdkPixbuf *pixbuf; -GdkGC *gc; gboolean expose_event () { if (pixbuf) { - gdk_draw_rectangle (window->window, - gc, TRUE, 0, 0, - window->allocation.width, - window->allocation.height); - - gdk_pixbuf_render_to_drawable (pixbuf, - GDK_WINDOW (window->window), - gc, - 0, 0, - 0, 0, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - GDK_RGB_DITHER_NORMAL, - 0, 0); + gdk_draw_pixbuf (window->window, NULL, pixbuf, + 0, 0, 0, 0, + -1, -1, + GDK_RGB_DITHER_NORMAL, 0, 0); } return (TRUE); } int read_image (void) { GdkPixbuf *new_pixbuf; new_pixbuf = gdk_pixbuf_new_from_file (filename, NULL); if (new_pixbuf == NULL) return (-1); if (pixbuf) g_object_unref (pixbuf); pixbuf = new_pixbuf; gtk_window_resize (GTK_WINDOW (window), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); + gtk_widget_queue_draw (window); + + if (auto_raise && window->window) + gdk_window_raise (GDK_WINDOW (window->window)); + return (0); } gboolean key_press_event (GtkWidget *widget, GdkEventKey *ev, gpointer data) { switch (ev->keyval) { - case 'r': - read_image (); - gtk_widget_queue_draw_area (window, 0, 0, - window->allocation.width, - window->allocation.height); - break; - case 'q': - case 'c': - case 'w': - exit (0); + case 'q': /* covers q or ALT-q */ + case 'c': /* covers CTL-c */ + case 'w': /* covers ALT-w */ + case GDK_Escape: + gtk_main_quit (); } return (TRUE); } -double -get_secs (void) -{ - struct timeval tv; - gettimeofday (&tv, NULL); - return (tv.tv_sec + tv.tv_usec / 1e6); -} +struct monitor_file { + struct monitor_file *next; + char *dirname; + char *filename; + void (*func)(struct monitor_file *); +}; -enum { - mod_idle, - mod_pending, - mod_deleted, -} mod_state; +struct monitor_file *monitor_files; -double mod_secs; +int inotify_fd = -1; gboolean -tick (gpointer data) +inotify_handler (GIOChannel *source, GIOCondition condition, gpointer data) { - switch (mod_state) { - case mod_idle: - break; - case mod_pending: - if (get_secs () - mod_secs < .5) - break; - - read_image (); - - gtk_widget_queue_draw_area (window, 0, 0, - window->allocation.width, - window->allocation.height); - mod_state = mod_idle; - break; - - case mod_deleted: - if (access (filename, R_OK) < 0) - break; - - if (inotify_add_watch (inotify_fd, filename, - IN_MODIFY | IN_DELETE_SELF) < 0) { - fprintf (stderr, "error doing inotify_add_watch\n"); - exit (1); + char buf[10000]; + struct inotify_event ev; + ssize_t avail, offset; + struct monitor_file *mp; + + while ((avail = read (inotify_fd, buf, sizeof buf)) > 0) { + offset = 0; + while (offset + sizeof ev <= avail) { + memcpy (&ev, buf + offset, sizeof ev); + filename = buf + offset + sizeof ev; + + if (ev.mask & (IN_CLOSE_WRITE | IN_MOVED_TO)) { + for (mp = monitor_files; mp; mp = mp->next) { + if (strcmp (mp->filename, + filename) == 0) { + (*mp->func)(mp); + } + } + } + offset += sizeof ev + ev.len; } - mod_state = mod_pending; - break; } + return (TRUE); } -gboolean -inotify_handler (GIOChannel *source, GIOCondition condition, gpointer data) +struct monitor_file * +monitor_file (char *filename_arg, + void (*file_changed_func)(struct monitor_file *)) { - char buf[10000]; - struct inotify_event ev; + char *dirname; + int total_len, dirname_len, filename_len, idx; + struct monitor_file *mp; + void *mpbuf; + + if ((total_len = strlen (filename_arg)) == 0) + return (NULL); - if (read (inotify_fd, buf, sizeof buf) < 0) - return (TRUE); + idx = total_len; + while (idx > 0 && filename_arg[idx-1] != '/') + idx--; - memcpy (&ev, buf, sizeof ev); + filename = filename_arg + idx; + filename_len = total_len - idx; - if (ev.mask & IN_DELETE_SELF) { - mod_state = mod_deleted; + while (idx > 0 && filename_arg[idx-1] == '/') + idx--; + + if (idx == 0) { + dirname = (filename_arg[0] == '/') ? "/" : "."; + dirname_len = 1; } else { - mod_state = mod_pending; - mod_secs = get_secs (); + dirname = filename_arg; + dirname_len = idx; + } + + if ((mpbuf = malloc (sizeof *mp + + filename_len + 1 + + dirname_len + 1)) == NULL) { + return (NULL); } - return (TRUE); + mp = mpbuf; + memset (mp, 0, sizeof *mp); + + mp->filename = mpbuf + sizeof *mp; + strncpy (mp->filename, filename, filename_len); + mp->filename[filename_len] = 0; + + mp->dirname = mp->filename + filename_len + 1; + strncpy (mp->dirname, dirname, dirname_len); + mp->dirname[dirname_len] = 0; + + if (inotify_add_watch (inotify_fd, mp->dirname, + IN_CLOSE_WRITE | IN_MOVED_TO) < 0) { + free (mp); + return (NULL); + } + + mp->func = file_changed_func; + + mp->next = monitor_files; + monitor_files = mp; + + return (mp); +} + +void +monitor_file_func (struct monitor_file *mp) +{ + read_image (); } int main (int argc, char **argv) { int c; gtk_init (&argc, &argv); - while ((c = getopt (argc, argv, "")) != EOF) { + while ((c = getopt (argc, argv, "a:")) != EOF) { switch (c) { + case 'a': + auto_raise = atoi (optarg); + break; default: usage (); } } if (optind >= argc) usage (); filename = argv[optind++]; if (optind != argc) usage (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), filename); - if (read_image () < 0) { - fprintf (stderr, "can't open %s\n", filename); - exit (1); - } - - gtk_window_set_default_size (GTK_WINDOW (window), - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf)); - - g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "expose_event", G_CALLBACK (expose_event), NULL); g_signal_connect (G_OBJECT (window), "key_press_event", G_CALLBACK (key_press_event), NULL); gtk_widget_show (window); - gc = gdk_gc_new (window->window); - - if ((inotify_fd = inotify_init1 (IN_NONBLOCK)) < 0) { + if ((inotify_fd = inotify_init1 (IN_NONBLOCK | IN_CLOEXEC)) < 0) { fprintf (stderr, "error doing inotify_init\n"); exit (1); } - if (inotify_add_watch (inotify_fd, filename, - IN_MODIFY | IN_DELETE_SELF) < 0) { - fprintf (stderr, "error doing inotify_add_watch\n"); - exit (1); - } - - g_timeout_add (100, tick, NULL); + fcntl (inotify_fd, F_SETFL, O_NONBLOCK); g_io_add_watch (g_io_channel_unix_new (inotify_fd), G_IO_IN, inotify_handler, NULL); + if (monitor_file (filename, monitor_file_func) == NULL) { + fprintf (stderr, "error setting up monitor_file\n"); + exit (1); + } + + if (read_image () < 0) { + fprintf (stderr, "can't open %s\n", filename); + exit (1); + } + gtk_main (); return (0); } +
pacew/img
1b024e18e88f66a291d6d1f32f6059d1e564e115
handle deleted file
diff --git a/img.c b/img.c index 170d1c7..a5820e5 100644 --- a/img.c +++ b/img.c @@ -1,194 +1,226 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <memory.h> #include <sys/time.h> #include <sys/inotify.h> #include <gtk/gtk.h> char *filename; int inotify_fd; void usage (void) { - fprintf (stderr, "usage: pview file\n"); + fprintf (stderr, "usage: img file\n"); exit (1); } GtkWidget *window; GdkPixbuf *pixbuf; GdkGC *gc; gboolean expose_event () { if (pixbuf) { gdk_draw_rectangle (window->window, gc, TRUE, 0, 0, window->allocation.width, window->allocation.height); gdk_pixbuf_render_to_drawable (pixbuf, GDK_WINDOW (window->window), gc, 0, 0, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), GDK_RGB_DITHER_NORMAL, 0, 0); } return (TRUE); } -void +int read_image (void) { + GdkPixbuf *new_pixbuf; + + + new_pixbuf = gdk_pixbuf_new_from_file (filename, NULL); + if (new_pixbuf == NULL) + return (-1); + if (pixbuf) g_object_unref (pixbuf); - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); - if (pixbuf == NULL) { - fprintf (stderr, "can't open %s\n", filename); - return; - } + pixbuf = new_pixbuf; gtk_window_resize (GTK_WINDOW (window), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); + return (0); } gboolean key_press_event (GtkWidget *widget, GdkEventKey *ev, gpointer data) { switch (ev->keyval) { case 'r': read_image (); gtk_widget_queue_draw_area (window, 0, 0, window->allocation.width, window->allocation.height); break; case 'q': case 'c': case 'w': exit (0); } return (TRUE); } double get_secs (void) { struct timeval tv; gettimeofday (&tv, NULL); return (tv.tv_sec + tv.tv_usec / 1e6); } -int mod_state; +enum { + mod_idle, + mod_pending, + mod_deleted, +} mod_state; + double mod_secs; gboolean tick (gpointer data) { switch (mod_state) { - case 0: + case mod_idle: break; - case 1: + case mod_pending: if (get_secs () - mod_secs < .5) break; read_image (); gtk_widget_queue_draw_area (window, 0, 0, window->allocation.width, window->allocation.height); - mod_state = 0; + mod_state = mod_idle; + break; + + case mod_deleted: + if (access (filename, R_OK) < 0) + break; + + if (inotify_add_watch (inotify_fd, filename, + IN_MODIFY | IN_DELETE_SELF) < 0) { + fprintf (stderr, "error doing inotify_add_watch\n"); + exit (1); + } + mod_state = mod_pending; + break; } return (TRUE); } gboolean inotify_handler (GIOChannel *source, GIOCondition condition, gpointer data) { char buf[10000]; + struct inotify_event ev; if (read (inotify_fd, buf, sizeof buf) < 0) return (TRUE); - mod_state = 1; - mod_secs = get_secs (); + memcpy (&ev, buf, sizeof ev); + + if (ev.mask & IN_DELETE_SELF) { + mod_state = mod_deleted; + } else { + mod_state = mod_pending; + mod_secs = get_secs (); + } return (TRUE); } int main (int argc, char **argv) { int c; gtk_init (&argc, &argv); while ((c = getopt (argc, argv, "")) != EOF) { switch (c) { default: usage (); } } if (optind >= argc) usage (); filename = argv[optind++]; if (optind != argc) usage (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), filename); - read_image (); - if (pixbuf == NULL) - exit (1); /* error message already printed */ + if (read_image () < 0) { + fprintf (stderr, "can't open %s\n", filename); + exit (1); + } gtk_window_set_default_size (GTK_WINDOW (window), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "expose_event", G_CALLBACK (expose_event), NULL); g_signal_connect (G_OBJECT (window), "key_press_event", G_CALLBACK (key_press_event), NULL); gtk_widget_show (window); gc = gdk_gc_new (window->window); if ((inotify_fd = inotify_init1 (IN_NONBLOCK)) < 0) { fprintf (stderr, "error doing inotify_init\n"); exit (1); } - if (inotify_add_watch (inotify_fd, filename, IN_MODIFY) < 0) { + if (inotify_add_watch (inotify_fd, filename, + IN_MODIFY | IN_DELETE_SELF) < 0) { fprintf (stderr, "error doing inotify_add_watch\n"); exit (1); } g_timeout_add (100, tick, NULL); g_io_add_watch (g_io_channel_unix_new (inotify_fd), G_IO_IN, inotify_handler, NULL); gtk_main (); return (0); }
pacew/img
61f13edcf55e6adde1766040c935c7399acc83a2
add inotify
diff --git a/img.c b/img.c index f969274..170d1c7 100644 --- a/img.c +++ b/img.c @@ -1,133 +1,194 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <sys/time.h> +#include <sys/inotify.h> #include <gtk/gtk.h> char *filename; +int inotify_fd; void usage (void) { fprintf (stderr, "usage: pview file\n"); exit (1); } GtkWidget *window; GdkPixbuf *pixbuf; GdkGC *gc; gboolean expose_event () { if (pixbuf) { gdk_draw_rectangle (window->window, gc, TRUE, 0, 0, window->allocation.width, window->allocation.height); gdk_pixbuf_render_to_drawable (pixbuf, GDK_WINDOW (window->window), gc, 0, 0, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), GDK_RGB_DITHER_NORMAL, 0, 0); } return (TRUE); } void read_image (void) { if (pixbuf) g_object_unref (pixbuf); pixbuf = gdk_pixbuf_new_from_file (filename, NULL); if (pixbuf == NULL) { fprintf (stderr, "can't open %s\n", filename); return; } gtk_window_resize (GTK_WINDOW (window), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); } gboolean key_press_event (GtkWidget *widget, GdkEventKey *ev, gpointer data) { switch (ev->keyval) { case 'r': read_image (); gtk_widget_queue_draw_area (window, 0, 0, window->allocation.width, window->allocation.height); break; case 'q': case 'c': case 'w': exit (0); } return (TRUE); } +double +get_secs (void) +{ + struct timeval tv; + gettimeofday (&tv, NULL); + return (tv.tv_sec + tv.tv_usec / 1e6); +} + +int mod_state; +double mod_secs; + +gboolean +tick (gpointer data) +{ + switch (mod_state) { + case 0: + break; + case 1: + if (get_secs () - mod_secs < .5) + break; + + read_image (); + + gtk_widget_queue_draw_area (window, 0, 0, + window->allocation.width, + window->allocation.height); + mod_state = 0; + } + return (TRUE); +} + +gboolean +inotify_handler (GIOChannel *source, GIOCondition condition, gpointer data) +{ + char buf[10000]; + + if (read (inotify_fd, buf, sizeof buf) < 0) + return (TRUE); + + mod_state = 1; + mod_secs = get_secs (); + + return (TRUE); +} int main (int argc, char **argv) { int c; gtk_init (&argc, &argv); while ((c = getopt (argc, argv, "")) != EOF) { switch (c) { default: usage (); } } if (optind >= argc) usage (); filename = argv[optind++]; if (optind != argc) usage (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), filename); read_image (); if (pixbuf == NULL) exit (1); /* error message already printed */ gtk_window_set_default_size (GTK_WINDOW (window), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "expose_event", G_CALLBACK (expose_event), NULL); g_signal_connect (G_OBJECT (window), "key_press_event", G_CALLBACK (key_press_event), NULL); - gtk_widget_show (window); - gc = gdk_gc_new (window->window); + + if ((inotify_fd = inotify_init1 (IN_NONBLOCK)) < 0) { + fprintf (stderr, "error doing inotify_init\n"); + exit (1); + } + + if (inotify_add_watch (inotify_fd, filename, IN_MODIFY) < 0) { + fprintf (stderr, "error doing inotify_add_watch\n"); + exit (1); + } + + g_timeout_add (100, tick, NULL); + + g_io_add_watch (g_io_channel_unix_new (inotify_fd), G_IO_IN, + inotify_handler, NULL); + gtk_main (); return (0); }
pacew/img
77e5349be6de588688fa0a709ee01d52746917a8
add .o to .gitignore
diff --git a/.gitignore b/.gitignore index 18629f4..1bf89f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ img *~ ? +*.o
Elbandi/php-geoip
2f820c79738fbc973a855a3862163f824569e0db
changelog update
diff --git a/debian/changelog b/debian/changelog index 2813cf0..92a687c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,62 +1,70 @@ +php-geoip (1.0.7-1ubuntu1-0hst2) lucid; urgency=low + + [ Andras Elso ] + * Add memcache support + * country nevek lekerdezese id alapjan + + -- Andras Elso <[email protected]> Thu, 24 Feb 2011 22:52:15 +0000 + php-geoip (1.0.7-1ubuntu1) lucid; urgency=low * Rebuild for PHP 5.3 -- Chuck Short <[email protected]> Tue, 02 Mar 2010 10:32:51 -0500 php-geoip (1.0.7-1) unstable; urgency=low * New upstream release. * Change copyright format. * Set package Section to php. -- Sergey B Kirpichev <[email protected]> Sun, 29 Mar 2009 14:04:05 +0400 php-geoip (1.0.6-1) unstable; urgency=low * New upstream release. -- Sergey B Kirpichev <[email protected]> Sat, 24 Jan 2009 17:00:37 +0300 php-geoip (1.0.5-1) unstable; urgency=low * New upstream release. * Update the Standards-Version to 3.8.0. * Add ${misc:Depends}. -- Sergey B Kirpichev <[email protected]> Thu, 25 Dec 2008 22:02:04 +0300 php-geoip (1.0.3-1) unstable; urgency=low * New upstream release * Remove cvs entry from debian/copyright -- Sergey B Kirpichev <[email protected]> Fri, 13 Jun 2008 03:31:11 +0400 php-geoip (1.0.2-4) unstable; urgency=low * Fix license issues, it's the PHP 3.01 now * Add the link to the commit with 3.01 * Tune short description * Fix uscan handling -- Sergey B Kirpichev <[email protected]> Fri, 13 Jun 2008 03:23:24 +0400 php-geoip (1.0.2-3) unstable; urgency=low * Add Homepage field * Drop CFLAGS handling in rules -- Sergey B Kirpichev <[email protected]> Wed, 28 May 2008 22:55:38 +0400 php-geoip (1.0.2-2) unstable; urgency=low * Correct description -- Sergey B Kirpichev <[email protected]> Fri, 23 May 2008 18:10:38 +0400 php-geoip (1.0.2-1) unstable; urgency=low * Initial Release (Closes: #478051) -- Sergey B Kirpichev <[email protected]> Sat, 26 Apr 2008 19:56:04 +0400
Elbandi/php-geoip
38735ee2cfbe2363bc97e4f36556e985bb6b4a74
country nevek lekerdezese id alapjan
diff --git a/geoip-1.0.7/geoip.c b/geoip-1.0.7/geoip.c index 7c732cb..586b25c 100644 --- a/geoip-1.0.7/geoip.c +++ b/geoip-1.0.7/geoip.c @@ -1,631 +1,715 @@ /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [email protected] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Olivier Hill <[email protected]> | | Matthew Fonda | +----------------------------------------------------------------------+ Please contact [email protected] with any comments */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <GeoIP.h> #include <GeoIPCity.h> #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_geoip.h" ZEND_DECLARE_MODULE_GLOBALS(geoip) static int le_geoip; /* {{{ */ function_entry geoip_functions[] = { PHP_FE(geoip_database_info, NULL) PHP_FE(geoip_country_code_by_name, NULL) PHP_FE(geoip_country_code3_by_name, NULL) PHP_FE(geoip_country_name_by_name, NULL) PHP_FE(geoip_continent_code_by_name, NULL) + PHP_FE(geoip_country_code_by_id, NULL) + PHP_FE(geoip_country_code3_by_id, NULL) + PHP_FE(geoip_country_name_by_id, NULL) + PHP_FE(geoip_continent_code_by_id, NULL) PHP_FE(geoip_org_by_name, NULL) PHP_FE(geoip_record_by_name, NULL) PHP_FE(geoip_id_by_name, NULL) PHP_FE(geoip_region_by_name, NULL) PHP_FE(geoip_isp_by_name, NULL) PHP_FE(geoip_db_avail, NULL) PHP_FE(geoip_db_get_all_info, NULL) PHP_FE(geoip_db_filename, NULL) #if LIBGEOIP_VERSION >= 1004001 PHP_FE(geoip_region_name_by_code, NULL) PHP_FE(geoip_time_zone_by_country_and_region, NULL) #endif {NULL, NULL, NULL} }; /* }}} */ /* {{{ geoip_module_entry */ zend_module_entry geoip_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, #endif "geoip", geoip_functions, PHP_MINIT(geoip), PHP_MSHUTDOWN(geoip), PHP_RINIT(geoip), PHP_RSHUTDOWN(geoip), PHP_MINFO(geoip), #if ZEND_MODULE_API_NO >= 20010901 PHP_GEOIP_VERSION, /* version number of the extension */ #endif STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_GEOIP ZEND_GET_MODULE(geoip) #endif /* {{{ PHP_INI */ PHP_INI_BEGIN() #ifdef HAVE_CUSTOM_DIRECTORY STD_PHP_INI_ENTRY("geoip.custom_directory", NULL, PHP_INI_ALL, OnUpdateString, custom_directory, zend_geoip_globals, geoip_globals) #endif PHP_INI_END() /* }}} */ /* {{{ php_geoip_init_globals */ static void php_geoip_init_globals(zend_geoip_globals *geoip_globals) { geoip_globals->custom_directory = NULL; } /* }}} */ /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(geoip) { int edition; ZEND_INIT_MODULE_GLOBALS(geoip, php_geoip_init_globals, NULL); REGISTER_INI_ENTRIES(); /* @TODO: Do something for custom_directory before initialization here */ #ifdef HAVE_CUSTOM_DIRECTORY GeoIP_setup_custom_directory(GEOIP_G(custom_directory)); #endif _GeoIP_setup_dbfilename(); /* For database type constants */ REGISTER_LONG_CONSTANT("GEOIP_COUNTRY_EDITION", GEOIP_COUNTRY_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_REGION_EDITION_REV0", GEOIP_REGION_EDITION_REV0, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV0", GEOIP_CITY_EDITION_REV0, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_ORG_EDITION", GEOIP_ORG_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_ISP_EDITION", GEOIP_ISP_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV1", GEOIP_CITY_EDITION_REV1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_REGION_EDITION_REV1", GEOIP_REGION_EDITION_REV1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_PROXY_EDITION", GEOIP_PROXY_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_ASNUM_EDITION", GEOIP_ASNUM_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_NETSPEED_EDITION", GEOIP_NETSPEED_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_DOMAIN_EDITION", GEOIP_DOMAIN_EDITION, CONST_CS | CONST_PERSISTENT); /* For netspeed constants */ REGISTER_LONG_CONSTANT("GEOIP_UNKNOWN_SPEED", GEOIP_UNKNOWN_SPEED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_DIALUP_SPEED", GEOIP_DIALUP_SPEED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_CABLEDSL_SPEED", GEOIP_CABLEDSL_SPEED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_CORPORATE_SPEED", GEOIP_CORPORATE_SPEED, CONST_CS | CONST_PERSISTENT); for (edition=0; edition < NUM_DB_TYPES; edition++) { if (GeoIP_db_avail(edition)) { GEOIP_G(gi[edition]) = GeoIP_open_type(edition, GEOIP_MEMORY_CACHE); } else { GEOIP_G(gi[edition]) = NULL; } } return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(geoip) { int i; for (i=0; i < NUM_DB_TYPES; i++) { if (GEOIP_G(gi[i])) GeoIP_delete(GEOIP_G(gi[i])); } return SUCCESS; } /* }}} */ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(geoip) { return SUCCESS; } /* }}} */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(geoip) { return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(geoip) { char buf[32]; php_info_print_table_start(); php_info_print_table_header(2, "geoip support", "enabled"); php_info_print_table_row(2, "geoip extension version", PHP_GEOIP_VERSION); snprintf(buf, sizeof(buf), "%d", LIBGEOIP_VERSION); php_info_print_table_row(2, "geoip library version", buf); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); } /* }}} */ /* {{{ proto boolean geoip_db_avail( [ int database ] ) */ PHP_FUNCTION(geoip_db_avail) { long edition; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &edition) == FAILURE) { return; } if (edition < 0 || edition >= NUM_DB_TYPES) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Database type given is out of bound."); return; } RETURN_BOOL(GEOIP_G(gi[edition])); } /* }}} */ /* {{{ proto string geoip_db_filename( [ int database ] ) */ PHP_FUNCTION(geoip_db_filename) { long edition; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &edition) == FAILURE) { return; } if (edition < 0 || edition >= NUM_DB_TYPES) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Database type given is out of bound."); return; } if (NULL != GeoIPDBFileName[edition]) RETURN_STRING(GeoIPDBFileName[edition], 1); } /* }}} */ /* {{{ proto array geoip_db_get_all_info( ) */ PHP_FUNCTION(geoip_db_get_all_info) { int i; array_init(return_value); for (i=0; i < NUM_DB_TYPES; i++) { if (NULL != GeoIPDBDescription[i]) { zval *row; ALLOC_INIT_ZVAL(row); array_init(row); add_assoc_bool(row, "available", GeoIP_db_avail(i)); add_assoc_string(row, "description", (char *)GeoIPDBDescription[i], 1); add_assoc_string(row, "filename", GeoIPDBFileName[i], 1); add_index_zval(return_value, i, row); } } } /* }}} */ /* {{{ proto string geoip_database_info( [ int database ] ) Returns GeoIP Database information */ PHP_FUNCTION(geoip_database_info) { GeoIP * gi; char * db_info; long edition = GEOIP_COUNTRY_EDITION; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &edition) == FAILURE) { return; } if (edition < 0 || edition >= NUM_DB_TYPES) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Database type given is out of bound."); return; } if (!GEOIP_G(gi[edition])) { if (NULL != GeoIPDBFileName[edition]) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[edition]); else php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available."); return; } db_info = GeoIP_database_info(GEOIP_G(gi[edition])); RETVAL_STRING(db_info, 1); free(db_info); } /* }}} */ /* {{{ proto string geoip_country_code_by_name( string hostname ) Return the Country Code found in the GeoIP Database */ PHP_FUNCTION(geoip_country_code_by_name) { char * hostname = NULL; const char * country_code; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } if (!GEOIP_G(gi[GEOIP_COUNTRY_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); return; } country_code = GeoIP_country_code_by_name(GEOIP_G(gi[GEOIP_COUNTRY_EDITION]), hostname); if (country_code == NULL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETURN_STRING((char*)country_code, 1); } /* }}} */ +/* {{{ proto string geoip_country_code_by_id( int id ) + Return the Country Code found in the GeoIP Database */ +PHP_FUNCTION(geoip_country_code_by_id) +{ + long id; + const char * country_code; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) { + return; + } + + country_code = GeoIP_code_by_id(id); + if (country_code == NULL) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Id %ld not found", id); + RETURN_FALSE; + } + RETURN_STRING((char*)country_code, 1); +} +/* }}} */ + /* {{{ proto string geoip_country_code_by_name( string hostname ) Return the Country Code found in the GeoIP Database */ PHP_FUNCTION(geoip_country_code3_by_name) { char * hostname = NULL; const char * country_code; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } if (!GEOIP_G(gi[GEOIP_COUNTRY_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); return; } country_code = GeoIP_country_code3_by_name(GEOIP_G(gi[GEOIP_COUNTRY_EDITION]), hostname); if (country_code == NULL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETURN_STRING((char*)country_code, 1); } /* }}} */ +/* {{{ proto string geoip_country_code_by_id( int id ) + Return the Country Code found in the GeoIP Database */ +PHP_FUNCTION(geoip_country_code3_by_id) +{ + long id; + const char * country_code; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) { + return; + } + + country_code = GeoIP_code3_by_id(id); + if (country_code == NULL) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Id %ld not found", id); + RETURN_FALSE; + } + RETURN_STRING((char*)country_code, 1); +} +/* }}} */ + /* {{{ proto string geoip_country_name_by_name( string hostname ) Returns the Country name found in the GeoIP Database */ PHP_FUNCTION(geoip_country_name_by_name) { char * hostname = NULL; const char * country_name; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } if (!GEOIP_G(gi[GEOIP_COUNTRY_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); return; } country_name = GeoIP_country_name_by_name(GEOIP_G(gi[GEOIP_COUNTRY_EDITION]), hostname); if (country_name == NULL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETURN_STRING((char*)country_name, 1); } /* }}} */ +/* {{{ proto string geoip_country_name_by_id( int id ) + Returns the Country name found in the GeoIP Database */ +PHP_FUNCTION(geoip_country_name_by_id) +{ + long id; + const char * country_name; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) { + return; + } + + country_name = GeoIP_name_by_id(id); + if (country_name == NULL) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Id %ld not found", id); + RETURN_FALSE; + } + RETURN_STRING((char*)country_name, 1); +} +/* }}} */ + /* {{{ proto string geoip_continent_code_by_name( string hostname ) Returns the Continent name found in the GeoIP Database */ PHP_FUNCTION(geoip_continent_code_by_name) { char * hostname = NULL; int id; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } if (!GEOIP_G(gi[GEOIP_COUNTRY_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); return; } id = GeoIP_id_by_name(GEOIP_G(gi[GEOIP_COUNTRY_EDITION]), hostname); if (id == 0) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETURN_STRING((char *)GeoIP_country_continent[id], 1); } /* }}} */ +/* {{{ proto string geoip_continent_code_by_id( int id ) + Returns the Continent name found in the GeoIP Database */ +PHP_FUNCTION(geoip_continent_code_by_id) +{ + long id; + const char * continent_name; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) { + return; + } + + continent_name = GeoIP_continent_by_id(id); + if (continent_name == NULL) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Id %ld not found", id); + RETURN_FALSE; + } + RETURN_STRING((char*)continent_name, 1); +} +/* }}} */ + /* {{{ proto string geoip_org_by_name( string hostname ) Returns the Organization Name found in the GeoIP Database */ PHP_FUNCTION(geoip_org_by_name) { char * hostname = NULL; char * org; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } if (!GEOIP_G(gi[GEOIP_ORG_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_ORG_EDITION]); return; } org = GeoIP_org_by_name(GEOIP_G(gi[GEOIP_ORG_EDITION]), hostname); if (org == NULL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETVAL_STRING(org, 1); free(org); } /* }}} */ /* {{{ proto array geoip_record_by_name( string hostname ) Returns the detailed City information found in the GeoIP Database */ PHP_FUNCTION(geoip_record_by_name) { GeoIP * gi; char * hostname = NULL; int arglen; GeoIPRecord * gir; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } if (GEOIP_G(gi[GEOIP_CITY_EDITION_REV1]) || GEOIP_G(gi[GEOIP_CITY_EDITION_REV0])) { if (GEOIP_G(gi[GEOIP_CITY_EDITION_REV1])) { gi = GEOIP_G(gi[GEOIP_CITY_EDITION_REV1]); } else { gi = GEOIP_G(gi[GEOIP_CITY_EDITION_REV0]); } } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_CITY_EDITION_REV0]); return; } gir = GeoIP_record_by_name(gi, hostname); if (NULL == gir) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } array_init(return_value); #if LIBGEOIP_VERSION >= 1004003 add_assoc_string(return_value, "continent_code", (gir->continent_code == NULL) ? "" : gir->continent_code, 1); #endif add_assoc_string(return_value, "country_code", (gir->country_code == NULL) ? "" : gir->country_code, 1); add_assoc_string(return_value, "country_code3", (gir->country_code3 == NULL) ? "" : gir->country_code3, 1); add_assoc_string(return_value, "country_name", (gir->country_name == NULL) ? "" : gir->country_name, 1); add_assoc_string(return_value, "region", (gir->region == NULL) ? "" : gir->region, 1); add_assoc_string(return_value, "city", (gir->city == NULL) ? "" : gir->city, 1); add_assoc_string(return_value, "postal_code", (gir->postal_code == NULL) ? "" : gir->postal_code, 1); add_assoc_double(return_value, "latitude", gir->latitude); add_assoc_double(return_value, "longitude", gir->longitude); #if LIBGEOIP_VERSION >= 1004005 add_assoc_long(return_value, "dma_code", gir->metro_code); #else add_assoc_long(return_value, "dma_code", gir->dma_code); #endif add_assoc_long(return_value, "area_code", gir->area_code); GeoIPRecord_delete(gir); } /* }}} */ /* {{{ proto integer geoip_id_by_name( string hostname ) Returns the Net Speed found in the GeoIP Database */ PHP_FUNCTION(geoip_id_by_name) { char * hostname = NULL; int arglen; int netspeed; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } if (!GEOIP_G(gi[GEOIP_NETSPEED_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_NETSPEED_EDITION]); return; } netspeed = GeoIP_id_by_name(GEOIP_G(gi[GEOIP_NETSPEED_EDITION]), hostname); RETURN_LONG(netspeed); } /* }}} */ /* {{{ proto array geoip_region_by_name( string hostname ) Returns the Country Code and region found in the GeoIP Database */ PHP_FUNCTION(geoip_region_by_name) { GeoIP * gi; char * hostname = NULL; int arglen; GeoIPRegion * region; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } if (GEOIP_G(gi[GEOIP_CITY_EDITION_REV1]) || GEOIP_G(gi[GEOIP_CITY_EDITION_REV0])) { if (GEOIP_G(gi[GEOIP_CITY_EDITION_REV1])) { gi = GEOIP_G(gi[GEOIP_CITY_EDITION_REV1]); } else { gi = GEOIP_G(gi[GEOIP_CITY_EDITION_REV0]); } } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_REGION_EDITION_REV0]); return; } region = GeoIP_region_by_name(gi, hostname); if (NULL == region) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } array_init(return_value); add_assoc_string(return_value, "country_code", region->country_code, 1); add_assoc_string(return_value, "region", region->region, 1); GeoIPRegion_delete(region); } /* }}} */ /* {{{ proto string geoip_isp_by_name( string hostname ) Returns the ISP Name found in the GeoIP Database */ PHP_FUNCTION(geoip_isp_by_name) { char * hostname = NULL; char * isp; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } if (!GEOIP_G(gi[GEOIP_ISP_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_ISP_EDITION]); return; } isp = GeoIP_name_by_name(GEOIP_G(gi[GEOIP_ISP_EDITION]), hostname); if (isp == NULL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETVAL_STRING(isp, 1); free(isp); } #if LIBGEOIP_VERSION >= 1004001 /* {{{ proto string geoip_region_name_by_code( string country_code, string region_code ) Returns the region name for some country code and region code combo */ PHP_FUNCTION(geoip_region_name_by_code) { char * country_code = NULL; char * region_code = NULL; const char * region_name; int countrylen, regionlen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &country_code, &countrylen, &region_code, &regionlen) == FAILURE) { return; } if (!countrylen || !regionlen) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "You need to specify the country and region codes."); RETURN_FALSE; } region_name = GeoIP_region_name_by_code(country_code, region_code); if (region_name == NULL) { RETURN_FALSE; } RETURN_STRING((char*)region_name, 1); } /* }}} */ #endif #if LIBGEOIP_VERSION >= 1004001 /* {{{ proto string geoip_time_zone_by_country_and_region( string country, string region ) Returns the time zone for some country code and region code combo */ PHP_FUNCTION(geoip_time_zone_by_country_and_region) { char * country = NULL; char * region = NULL; const char * timezone; int countrylen, arg2len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &country, &countrylen, &region, &arg2len) == FAILURE) { return; } if (!countrylen) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "You need to specify at least the country code."); RETURN_FALSE; } timezone = GeoIP_time_zone_by_country_and_region(country, region); if (timezone == NULL) { RETURN_FALSE; } RETURN_STRING((char*)timezone, 1); } /* }}} */ #endif /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ diff --git a/geoip-1.0.7/php_geoip.h b/geoip-1.0.7/php_geoip.h index 2e720d1..fc0b3e7 100644 --- a/geoip-1.0.7/php_geoip.h +++ b/geoip-1.0.7/php_geoip.h @@ -1,88 +1,92 @@ /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [email protected] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Olivier Hill <[email protected]> | | Matthew Fonda | +----------------------------------------------------------------------+ Please contact [email protected] with any comments */ #ifndef PHP_GEOIP_H #define PHP_GEOIP_H extern zend_module_entry geoip_module_entry; #define phpext_geoip_ptr &geoip_module_entry #define PHP_GEOIP_VERSION "1.0.7" #ifdef PHP_WIN32 #define PHP_GEOIP_API __declspec(dllexport) #else #define PHP_GEOIP_API #endif #ifdef ZTS #include "TSRM.h" #endif #include <GeoIP.h> #include <GeoIPCity.h> PHP_MINIT_FUNCTION(geoip); PHP_MSHUTDOWN_FUNCTION(geoip); PHP_RINIT_FUNCTION(geoip); PHP_RSHUTDOWN_FUNCTION(geoip); PHP_MINFO_FUNCTION(geoip); PHP_FUNCTION(geoip_database_info); PHP_FUNCTION(geoip_country_code_by_name); PHP_FUNCTION(geoip_country_code3_by_name); PHP_FUNCTION(geoip_country_name_by_name); PHP_FUNCTION(geoip_continent_code_by_name); +PHP_FUNCTION(geoip_country_code_by_id); +PHP_FUNCTION(geoip_country_code3_by_id); +PHP_FUNCTION(geoip_country_name_by_id); +PHP_FUNCTION(geoip_continent_code_by_id); PHP_FUNCTION(geoip_org_by_name); PHP_FUNCTION(geoip_record_by_name); PHP_FUNCTION(geoip_id_by_name); PHP_FUNCTION(geoip_region_by_name); PHP_FUNCTION(geoip_isp_by_name); PHP_FUNCTION(geoip_db_avail); PHP_FUNCTION(geoip_db_get_all_info); PHP_FUNCTION(geoip_db_filename); #if LIBGEOIP_VERSION >= 1004001 PHP_FUNCTION(geoip_region_name_by_code); PHP_FUNCTION(geoip_time_zone_by_country_and_region); #endif ZEND_BEGIN_MODULE_GLOBALS(geoip) char* custom_directory; GeoIP *gi[NUM_DB_TYPES]; ZEND_END_MODULE_GLOBALS(geoip) #ifdef ZTS #define GEOIP_G(v) TSRMG(geoip_globals_id, zend_geoip_globals *, v) #else #define GEOIP_G(v) (geoip_globals.v) #endif #endif /* PHP_GEOIP_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */
Elbandi/php-geoip
1ed8deec402a8d80d249e66dfe3e2e505347618f
Add memcache support
diff --git a/geoip-1.0.7/geoip.c b/geoip-1.0.7/geoip.c index 9077763..7c732cb 100644 --- a/geoip-1.0.7/geoip.c +++ b/geoip-1.0.7/geoip.c @@ -1,651 +1,631 @@ /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [email protected] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Olivier Hill <[email protected]> | | Matthew Fonda | +----------------------------------------------------------------------+ Please contact [email protected] with any comments */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <GeoIP.h> #include <GeoIPCity.h> #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_geoip.h" ZEND_DECLARE_MODULE_GLOBALS(geoip) static int le_geoip; /* {{{ */ function_entry geoip_functions[] = { PHP_FE(geoip_database_info, NULL) PHP_FE(geoip_country_code_by_name, NULL) PHP_FE(geoip_country_code3_by_name, NULL) PHP_FE(geoip_country_name_by_name, NULL) PHP_FE(geoip_continent_code_by_name, NULL) PHP_FE(geoip_org_by_name, NULL) PHP_FE(geoip_record_by_name, NULL) PHP_FE(geoip_id_by_name, NULL) PHP_FE(geoip_region_by_name, NULL) PHP_FE(geoip_isp_by_name, NULL) PHP_FE(geoip_db_avail, NULL) PHP_FE(geoip_db_get_all_info, NULL) PHP_FE(geoip_db_filename, NULL) #if LIBGEOIP_VERSION >= 1004001 PHP_FE(geoip_region_name_by_code, NULL) PHP_FE(geoip_time_zone_by_country_and_region, NULL) #endif {NULL, NULL, NULL} }; /* }}} */ /* {{{ geoip_module_entry */ zend_module_entry geoip_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, #endif "geoip", geoip_functions, PHP_MINIT(geoip), PHP_MSHUTDOWN(geoip), PHP_RINIT(geoip), PHP_RSHUTDOWN(geoip), PHP_MINFO(geoip), #if ZEND_MODULE_API_NO >= 20010901 PHP_GEOIP_VERSION, /* version number of the extension */ #endif STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_GEOIP ZEND_GET_MODULE(geoip) #endif /* {{{ PHP_INI */ PHP_INI_BEGIN() #ifdef HAVE_CUSTOM_DIRECTORY STD_PHP_INI_ENTRY("geoip.custom_directory", NULL, PHP_INI_ALL, OnUpdateString, custom_directory, zend_geoip_globals, geoip_globals) #endif PHP_INI_END() /* }}} */ /* {{{ php_geoip_init_globals */ static void php_geoip_init_globals(zend_geoip_globals *geoip_globals) { geoip_globals->custom_directory = NULL; } /* }}} */ /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(geoip) { + int edition; ZEND_INIT_MODULE_GLOBALS(geoip, php_geoip_init_globals, NULL); REGISTER_INI_ENTRIES(); /* @TODO: Do something for custom_directory before initialization here */ #ifdef HAVE_CUSTOM_DIRECTORY GeoIP_setup_custom_directory(GEOIP_G(custom_directory)); #endif _GeoIP_setup_dbfilename(); /* For database type constants */ REGISTER_LONG_CONSTANT("GEOIP_COUNTRY_EDITION", GEOIP_COUNTRY_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_REGION_EDITION_REV0", GEOIP_REGION_EDITION_REV0, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV0", GEOIP_CITY_EDITION_REV0, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_ORG_EDITION", GEOIP_ORG_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_ISP_EDITION", GEOIP_ISP_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV1", GEOIP_CITY_EDITION_REV1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_REGION_EDITION_REV1", GEOIP_REGION_EDITION_REV1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_PROXY_EDITION", GEOIP_PROXY_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_ASNUM_EDITION", GEOIP_ASNUM_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_NETSPEED_EDITION", GEOIP_NETSPEED_EDITION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_DOMAIN_EDITION", GEOIP_DOMAIN_EDITION, CONST_CS | CONST_PERSISTENT); /* For netspeed constants */ REGISTER_LONG_CONSTANT("GEOIP_UNKNOWN_SPEED", GEOIP_UNKNOWN_SPEED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_DIALUP_SPEED", GEOIP_DIALUP_SPEED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_CABLEDSL_SPEED", GEOIP_CABLEDSL_SPEED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GEOIP_CORPORATE_SPEED", GEOIP_CORPORATE_SPEED, CONST_CS | CONST_PERSISTENT); + for (edition=0; edition < NUM_DB_TYPES; edition++) + { + if (GeoIP_db_avail(edition)) + { + GEOIP_G(gi[edition]) = GeoIP_open_type(edition, GEOIP_MEMORY_CACHE); + } else { + GEOIP_G(gi[edition]) = NULL; + } + } return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(geoip) { + int i; + + for (i=0; i < NUM_DB_TYPES; i++) + { + if (GEOIP_G(gi[i])) GeoIP_delete(GEOIP_G(gi[i])); + } return SUCCESS; } /* }}} */ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(geoip) { return SUCCESS; } /* }}} */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(geoip) { return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(geoip) { char buf[32]; php_info_print_table_start(); php_info_print_table_header(2, "geoip support", "enabled"); php_info_print_table_row(2, "geoip extension version", PHP_GEOIP_VERSION); snprintf(buf, sizeof(buf), "%d", LIBGEOIP_VERSION); php_info_print_table_row(2, "geoip library version", buf); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); } /* }}} */ /* {{{ proto boolean geoip_db_avail( [ int database ] ) */ PHP_FUNCTION(geoip_db_avail) { long edition; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &edition) == FAILURE) { return; } if (edition < 0 || edition >= NUM_DB_TYPES) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Database type given is out of bound."); return; } - RETURN_BOOL(GeoIP_db_avail(edition)); + RETURN_BOOL(GEOIP_G(gi[edition])); } /* }}} */ /* {{{ proto string geoip_db_filename( [ int database ] ) */ PHP_FUNCTION(geoip_db_filename) { long edition; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &edition) == FAILURE) { return; } if (edition < 0 || edition >= NUM_DB_TYPES) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Database type given is out of bound."); return; } if (NULL != GeoIPDBFileName[edition]) RETURN_STRING(GeoIPDBFileName[edition], 1); } /* }}} */ /* {{{ proto array geoip_db_get_all_info( ) */ PHP_FUNCTION(geoip_db_get_all_info) { int i; array_init(return_value); for (i=0; i < NUM_DB_TYPES; i++) { if (NULL != GeoIPDBDescription[i]) { zval *row; ALLOC_INIT_ZVAL(row); array_init(row); add_assoc_bool(row, "available", GeoIP_db_avail(i)); add_assoc_string(row, "description", (char *)GeoIPDBDescription[i], 1); add_assoc_string(row, "filename", GeoIPDBFileName[i], 1); add_index_zval(return_value, i, row); } } } /* }}} */ /* {{{ proto string geoip_database_info( [ int database ] ) Returns GeoIP Database information */ PHP_FUNCTION(geoip_database_info) { GeoIP * gi; char * db_info; long edition = GEOIP_COUNTRY_EDITION; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &edition) == FAILURE) { return; } if (edition < 0 || edition >= NUM_DB_TYPES) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Database type given is out of bound."); return; } - if (GeoIP_db_avail(edition)) { - gi = GeoIP_open_type(edition, GEOIP_STANDARD); - } else { + if (!GEOIP_G(gi[edition])) { if (NULL != GeoIPDBFileName[edition]) - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[edition]); else php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available."); return; } - db_info = GeoIP_database_info(gi); - GeoIP_delete(gi); + db_info = GeoIP_database_info(GEOIP_G(gi[edition])); RETVAL_STRING(db_info, 1); free(db_info); } /* }}} */ /* {{{ proto string geoip_country_code_by_name( string hostname ) Return the Country Code found in the GeoIP Database */ PHP_FUNCTION(geoip_country_code_by_name) { - GeoIP * gi; char * hostname = NULL; const char * country_code; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } - if (GeoIP_db_avail(GEOIP_COUNTRY_EDITION)) { - gi = GeoIP_open_type(GEOIP_COUNTRY_EDITION, GEOIP_STANDARD); - } else { + if (!GEOIP_G(gi[GEOIP_COUNTRY_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); return; } - country_code = GeoIP_country_code_by_name(gi, hostname); - GeoIP_delete(gi); + country_code = GeoIP_country_code_by_name(GEOIP_G(gi[GEOIP_COUNTRY_EDITION]), hostname); if (country_code == NULL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETURN_STRING((char*)country_code, 1); } /* }}} */ /* {{{ proto string geoip_country_code_by_name( string hostname ) Return the Country Code found in the GeoIP Database */ PHP_FUNCTION(geoip_country_code3_by_name) { - GeoIP * gi; char * hostname = NULL; const char * country_code; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } - if (GeoIP_db_avail(GEOIP_COUNTRY_EDITION)) { - gi = GeoIP_open_type(GEOIP_COUNTRY_EDITION, GEOIP_STANDARD); - } else { + if (!GEOIP_G(gi[GEOIP_COUNTRY_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); return; } - country_code = GeoIP_country_code3_by_name(gi, hostname); - GeoIP_delete(gi); + country_code = GeoIP_country_code3_by_name(GEOIP_G(gi[GEOIP_COUNTRY_EDITION]), hostname); if (country_code == NULL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETURN_STRING((char*)country_code, 1); } /* }}} */ /* {{{ proto string geoip_country_name_by_name( string hostname ) Returns the Country name found in the GeoIP Database */ PHP_FUNCTION(geoip_country_name_by_name) { - GeoIP * gi; char * hostname = NULL; const char * country_name; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } - if (GeoIP_db_avail(GEOIP_COUNTRY_EDITION)) { - gi = GeoIP_open_type(GEOIP_COUNTRY_EDITION, GEOIP_STANDARD); - } else { + if (!GEOIP_G(gi[GEOIP_COUNTRY_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); return; } - country_name = GeoIP_country_name_by_name(gi, hostname); - GeoIP_delete(gi); + country_name = GeoIP_country_name_by_name(GEOIP_G(gi[GEOIP_COUNTRY_EDITION]), hostname); if (country_name == NULL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETURN_STRING((char*)country_name, 1); } /* }}} */ /* {{{ proto string geoip_continent_code_by_name( string hostname ) Returns the Continent name found in the GeoIP Database */ PHP_FUNCTION(geoip_continent_code_by_name) { - GeoIP * gi; char * hostname = NULL; int id; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } - if (GeoIP_db_avail(GEOIP_COUNTRY_EDITION)) { - gi = GeoIP_open_type(GEOIP_COUNTRY_EDITION, GEOIP_STANDARD); - } else { + if (!GEOIP_G(gi[GEOIP_COUNTRY_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); return; } - id = GeoIP_id_by_name(gi, hostname); - GeoIP_delete(gi); + id = GeoIP_id_by_name(GEOIP_G(gi[GEOIP_COUNTRY_EDITION]), hostname); if (id == 0) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETURN_STRING((char *)GeoIP_country_continent[id], 1); } /* }}} */ /* {{{ proto string geoip_org_by_name( string hostname ) Returns the Organization Name found in the GeoIP Database */ PHP_FUNCTION(geoip_org_by_name) { - GeoIP * gi; char * hostname = NULL; char * org; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } - if (GeoIP_db_avail(GEOIP_ORG_EDITION)) { - gi = GeoIP_open_type(GEOIP_ORG_EDITION, GEOIP_STANDARD); - } else { + if (!GEOIP_G(gi[GEOIP_ORG_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_ORG_EDITION]); return; } - org = GeoIP_org_by_name(gi, hostname); - GeoIP_delete(gi); + org = GeoIP_org_by_name(GEOIP_G(gi[GEOIP_ORG_EDITION]), hostname); if (org == NULL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETVAL_STRING(org, 1); free(org); } /* }}} */ /* {{{ proto array geoip_record_by_name( string hostname ) Returns the detailed City information found in the GeoIP Database */ PHP_FUNCTION(geoip_record_by_name) { GeoIP * gi; char * hostname = NULL; int arglen; GeoIPRecord * gir; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } - if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1) || GeoIP_db_avail(GEOIP_CITY_EDITION_REV0)) { - if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1)) { - gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV1, GEOIP_STANDARD); + if (GEOIP_G(gi[GEOIP_CITY_EDITION_REV1]) || GEOIP_G(gi[GEOIP_CITY_EDITION_REV0])) { + if (GEOIP_G(gi[GEOIP_CITY_EDITION_REV1])) { + gi = GEOIP_G(gi[GEOIP_CITY_EDITION_REV1]); } else { - gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV0, GEOIP_STANDARD); + gi = GEOIP_G(gi[GEOIP_CITY_EDITION_REV0]); } } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_CITY_EDITION_REV0]); return; } gir = GeoIP_record_by_name(gi, hostname); - GeoIP_delete(gi); - if (NULL == gir) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } array_init(return_value); #if LIBGEOIP_VERSION >= 1004003 add_assoc_string(return_value, "continent_code", (gir->continent_code == NULL) ? "" : gir->continent_code, 1); #endif add_assoc_string(return_value, "country_code", (gir->country_code == NULL) ? "" : gir->country_code, 1); add_assoc_string(return_value, "country_code3", (gir->country_code3 == NULL) ? "" : gir->country_code3, 1); add_assoc_string(return_value, "country_name", (gir->country_name == NULL) ? "" : gir->country_name, 1); add_assoc_string(return_value, "region", (gir->region == NULL) ? "" : gir->region, 1); add_assoc_string(return_value, "city", (gir->city == NULL) ? "" : gir->city, 1); add_assoc_string(return_value, "postal_code", (gir->postal_code == NULL) ? "" : gir->postal_code, 1); add_assoc_double(return_value, "latitude", gir->latitude); add_assoc_double(return_value, "longitude", gir->longitude); #if LIBGEOIP_VERSION >= 1004005 add_assoc_long(return_value, "dma_code", gir->metro_code); #else add_assoc_long(return_value, "dma_code", gir->dma_code); #endif add_assoc_long(return_value, "area_code", gir->area_code); GeoIPRecord_delete(gir); } /* }}} */ /* {{{ proto integer geoip_id_by_name( string hostname ) Returns the Net Speed found in the GeoIP Database */ PHP_FUNCTION(geoip_id_by_name) { - GeoIP * gi; char * hostname = NULL; int arglen; int netspeed; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } - if (GeoIP_db_avail(GEOIP_NETSPEED_EDITION)) { - gi = GeoIP_open_type(GEOIP_NETSPEED_EDITION, GEOIP_STANDARD); - } else { + if (!GEOIP_G(gi[GEOIP_NETSPEED_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_NETSPEED_EDITION]); return; } - netspeed = GeoIP_id_by_name(gi, hostname); - GeoIP_delete(gi); + netspeed = GeoIP_id_by_name(GEOIP_G(gi[GEOIP_NETSPEED_EDITION]), hostname); RETURN_LONG(netspeed); } /* }}} */ /* {{{ proto array geoip_region_by_name( string hostname ) Returns the Country Code and region found in the GeoIP Database */ PHP_FUNCTION(geoip_region_by_name) { GeoIP * gi; char * hostname = NULL; int arglen; GeoIPRegion * region; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } - if (GeoIP_db_avail(GEOIP_REGION_EDITION_REV0) || GeoIP_db_avail(GEOIP_REGION_EDITION_REV1)) { - if (GeoIP_db_avail(GEOIP_REGION_EDITION_REV1)) { - gi = GeoIP_open_type(GEOIP_REGION_EDITION_REV1, GEOIP_STANDARD); + if (GEOIP_G(gi[GEOIP_CITY_EDITION_REV1]) || GEOIP_G(gi[GEOIP_CITY_EDITION_REV0])) { + if (GEOIP_G(gi[GEOIP_CITY_EDITION_REV1])) { + gi = GEOIP_G(gi[GEOIP_CITY_EDITION_REV1]); } else { - gi = GeoIP_open_type(GEOIP_REGION_EDITION_REV0, GEOIP_STANDARD); + gi = GEOIP_G(gi[GEOIP_CITY_EDITION_REV0]); } } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_REGION_EDITION_REV0]); return; } region = GeoIP_region_by_name(gi, hostname); - GeoIP_delete(gi); if (NULL == region) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } array_init(return_value); add_assoc_string(return_value, "country_code", region->country_code, 1); add_assoc_string(return_value, "region", region->region, 1); GeoIPRegion_delete(region); } /* }}} */ /* {{{ proto string geoip_isp_by_name( string hostname ) Returns the ISP Name found in the GeoIP Database */ PHP_FUNCTION(geoip_isp_by_name) { - GeoIP * gi; char * hostname = NULL; char * isp; int arglen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { return; } - if (GeoIP_db_avail(GEOIP_ISP_EDITION)) { - gi = GeoIP_open_type(GEOIP_ISP_EDITION, GEOIP_STANDARD); - } else { + if (!GEOIP_G(gi[GEOIP_ISP_EDITION])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_ISP_EDITION]); return; } - isp = GeoIP_name_by_name(gi, hostname); - GeoIP_delete(gi); + isp = GeoIP_name_by_name(GEOIP_G(gi[GEOIP_ISP_EDITION]), hostname); if (isp == NULL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); RETURN_FALSE; } RETVAL_STRING(isp, 1); free(isp); } #if LIBGEOIP_VERSION >= 1004001 /* {{{ proto string geoip_region_name_by_code( string country_code, string region_code ) Returns the region name for some country code and region code combo */ PHP_FUNCTION(geoip_region_name_by_code) { - GeoIP * gi; char * country_code = NULL; char * region_code = NULL; const char * region_name; int countrylen, regionlen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &country_code, &countrylen, &region_code, &regionlen) == FAILURE) { return; } if (!countrylen || !regionlen) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "You need to specify the country and region codes."); RETURN_FALSE; } region_name = GeoIP_region_name_by_code(country_code, region_code); if (region_name == NULL) { RETURN_FALSE; } RETURN_STRING((char*)region_name, 1); } /* }}} */ #endif #if LIBGEOIP_VERSION >= 1004001 /* {{{ proto string geoip_time_zone_by_country_and_region( string country, string region ) Returns the time zone for some country code and region code combo */ PHP_FUNCTION(geoip_time_zone_by_country_and_region) { - GeoIP * gi; char * country = NULL; char * region = NULL; const char * timezone; int countrylen, arg2len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &country, &countrylen, &region, &arg2len) == FAILURE) { return; } if (!countrylen) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "You need to specify at least the country code."); RETURN_FALSE; } timezone = GeoIP_time_zone_by_country_and_region(country, region); if (timezone == NULL) { RETURN_FALSE; } RETURN_STRING((char*)timezone, 1); } /* }}} */ #endif /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ diff --git a/geoip-1.0.7/php_geoip.h b/geoip-1.0.7/php_geoip.h index 7568990..2e720d1 100644 --- a/geoip-1.0.7/php_geoip.h +++ b/geoip-1.0.7/php_geoip.h @@ -1,87 +1,88 @@ /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [email protected] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Olivier Hill <[email protected]> | | Matthew Fonda | +----------------------------------------------------------------------+ Please contact [email protected] with any comments */ #ifndef PHP_GEOIP_H #define PHP_GEOIP_H extern zend_module_entry geoip_module_entry; #define phpext_geoip_ptr &geoip_module_entry #define PHP_GEOIP_VERSION "1.0.7" #ifdef PHP_WIN32 #define PHP_GEOIP_API __declspec(dllexport) #else #define PHP_GEOIP_API #endif #ifdef ZTS #include "TSRM.h" #endif #include <GeoIP.h> #include <GeoIPCity.h> PHP_MINIT_FUNCTION(geoip); PHP_MSHUTDOWN_FUNCTION(geoip); PHP_RINIT_FUNCTION(geoip); PHP_RSHUTDOWN_FUNCTION(geoip); PHP_MINFO_FUNCTION(geoip); PHP_FUNCTION(geoip_database_info); PHP_FUNCTION(geoip_country_code_by_name); PHP_FUNCTION(geoip_country_code3_by_name); PHP_FUNCTION(geoip_country_name_by_name); PHP_FUNCTION(geoip_continent_code_by_name); PHP_FUNCTION(geoip_org_by_name); PHP_FUNCTION(geoip_record_by_name); PHP_FUNCTION(geoip_id_by_name); PHP_FUNCTION(geoip_region_by_name); PHP_FUNCTION(geoip_isp_by_name); PHP_FUNCTION(geoip_db_avail); PHP_FUNCTION(geoip_db_get_all_info); PHP_FUNCTION(geoip_db_filename); #if LIBGEOIP_VERSION >= 1004001 PHP_FUNCTION(geoip_region_name_by_code); PHP_FUNCTION(geoip_time_zone_by_country_and_region); #endif ZEND_BEGIN_MODULE_GLOBALS(geoip) char* custom_directory; + GeoIP *gi[NUM_DB_TYPES]; ZEND_END_MODULE_GLOBALS(geoip) #ifdef ZTS #define GEOIP_G(v) TSRMG(geoip_globals_id, zend_geoip_globals *, v) #else #define GEOIP_G(v) (geoip_globals.v) #endif #endif /* PHP_GEOIP_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */
Elbandi/php-geoip
36afad8ffe3f2a77d1ceeaf1621b4b64afe71497
Imported Debian patch 1.0.7-1ubuntu1
diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..2813cf0 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,62 @@ +php-geoip (1.0.7-1ubuntu1) lucid; urgency=low + + * Rebuild for PHP 5.3 + + -- Chuck Short <[email protected]> Tue, 02 Mar 2010 10:32:51 -0500 + +php-geoip (1.0.7-1) unstable; urgency=low + + * New upstream release. + * Change copyright format. + * Set package Section to php. + + -- Sergey B Kirpichev <[email protected]> Sun, 29 Mar 2009 14:04:05 +0400 + +php-geoip (1.0.6-1) unstable; urgency=low + + * New upstream release. + + -- Sergey B Kirpichev <[email protected]> Sat, 24 Jan 2009 17:00:37 +0300 + +php-geoip (1.0.5-1) unstable; urgency=low + + * New upstream release. + * Update the Standards-Version to 3.8.0. + * Add ${misc:Depends}. + + -- Sergey B Kirpichev <[email protected]> Thu, 25 Dec 2008 22:02:04 +0300 + +php-geoip (1.0.3-1) unstable; urgency=low + + * New upstream release + * Remove cvs entry from debian/copyright + + -- Sergey B Kirpichev <[email protected]> Fri, 13 Jun 2008 03:31:11 +0400 + +php-geoip (1.0.2-4) unstable; urgency=low + + * Fix license issues, it's the PHP 3.01 now + * Add the link to the commit with 3.01 + * Tune short description + * Fix uscan handling + + -- Sergey B Kirpichev <[email protected]> Fri, 13 Jun 2008 03:23:24 +0400 + +php-geoip (1.0.2-3) unstable; urgency=low + + * Add Homepage field + * Drop CFLAGS handling in rules + + -- Sergey B Kirpichev <[email protected]> Wed, 28 May 2008 22:55:38 +0400 + +php-geoip (1.0.2-2) unstable; urgency=low + + * Correct description + + -- Sergey B Kirpichev <[email protected]> Fri, 23 May 2008 18:10:38 +0400 + +php-geoip (1.0.2-1) unstable; urgency=low + + * Initial Release (Closes: #478051) + + -- Sergey B Kirpichev <[email protected]> Sat, 26 Apr 2008 19:56:04 +0400 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..03dfafe --- /dev/null +++ b/debian/control @@ -0,0 +1,20 @@ +Source: php-geoip +Section: php +Priority: optional +Maintainer: Ubuntu MOTU Developers <[email protected]> +XSBC-Original-Maintainer: Sergey B Kirpichev <[email protected]> +Build-Depends: debhelper (>= 5), php5-dev (>= 5.3.1), libgeoip-dev (>= 1.4.0) +Standards-Version: 3.8.1 +Homepage: http://pecl.php.net/package/geoip/ + +Package: php5-geoip +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, ${php:Depends}, php5-common +Description: GeoIP module for php5 + This PHP module allows you to find the location of an IP address - + City, State, Country, Longitude, Latitude, and other information as + all, such as ISP and connection type. + . + For more info, please visit Maxmind's website: + http://www.maxmind.com/ + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..0249b14 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,77 @@ +Format-Specification: http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=440 +Upstream-Name: geoip +Upstream-Maintainer: Olivier Hill <[email protected]> +Upstream-Author: Olivier Hill <[email protected]> +Upstream-Source: http://pecl.php.net/package/geoip/ + +Files: * +Copyright: 1997-2009 The PHP Group +License: PHP-3.0.1 + This software is subject to version 3.01 of the PHP + license, as shown below. + + -------------------------------------------------------------------- + The PHP License, version 3.01 + Copyright (c) 1999 - 2008 The PHP Group. All rights reserved. + -------------------------------------------------------------------- + + Redistribution and use in source and binary forms, with or without + modification, is permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. The name "PHP" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact [email protected]. + + 4. Products derived from this software may not be called "PHP", nor + may "PHP" appear in their name, without prior written permission + from [email protected]. You may indicate that your software works in + conjunction with PHP by saying "Foo for PHP" instead of calling + it "PHP Foo" or "phpfoo" + + 5. The PHP Group may publish revised and/or new versions of the + license from time to time. Each version will be given a + distinguishing version number. + Once covered code has been published under a particular version + of the license, you may always continue to use it under the terms + of that version. You may also choose to use such covered code + under the terms of any subsequent version of the license + published by the PHP Group. No one other than the PHP Group has + the right to modify the terms applicable to covered code created + under this License. + + 6. Redistributions of any form whatsoever must retain the following + acknowledgment: + "This product includes PHP software, freely available from + <http://www.php.net/software/>". + + THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND + ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP + DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + + -------------------------------------------------------------------- + +Files: debian/* +Copyright: 2008-2009, Sergey B Kirpichev <[email protected]> +License: GPL-2+ + On Debian GNU/Linux systems, the complete text of the GNU General + Public License (GPL) version 2 can be found at + /usr/share/common-licenses/GPL-2. + diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..e845566 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +README diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..11086ea --- /dev/null +++ b/debian/rules @@ -0,0 +1,66 @@ +#!/usr/bin/make -f + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +PECL_PKG_NAME=geoip + +configure: configure-stamp +configure-stamp: + cp -a ${PECL_PKG_NAME}-*/* . + dh_testdir + phpize5 + ./configure -q \ + --prefix=/usr \ + --enable-${PECL_PKG_NAME}=shared \ + --with-php-config=/usr/bin/php-config5 + touch configure-stamp + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + $(MAKE) + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + [ ! -f Makefile ] || $(MAKE) distclean + [ ! -f configure ] || phpize5 --clean + dh_clean + ls -1|sed '/debian/d;/${PECL_PKG_NAME}-[0-9.]\+$$/d;/package\.xml/d'|xargs rm -rf + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(MAKE) INSTALL_ROOT=debian/php5-${PECL_PKG_NAME} install + install -m0755 -d -D debian/php5-${PECL_PKG_NAME}/etc/php5/conf.d/ + echo 'extension=${PECL_PKG_NAME}.so' > debian/php5-${PECL_PKG_NAME}/etc/php5/conf.d/${PECL_PKG_NAME}.ini + +# Build architecture-independent files here. +binary-indep: build install + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs ChangeLog + dh_installdocs + dh_installexamples + dh_installdebconf + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + echo "php:Depends=phpapi-`php-config5 --phpapi`" >> debian/php5-${PECL_PKG_NAME}.substvars + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..02f9ae0 --- /dev/null +++ b/debian/watch @@ -0,0 +1,4 @@ +# watch control file for uscan(1) +version=3 +# Homepage Pattern [Version [Action]] +http://pecl.php.net/package/geoip \/get\/geoip-([\d\.]*)\.tgz debian uupdate
Elbandi/php-geoip
c20c74a48057189688d6a0556562ec463c580b85
Imported Upstream version 1.0.7
diff --git a/geoip-1.0.7/ChangeLog b/geoip-1.0.7/ChangeLog new file mode 100644 index 0000000..41e95d2 --- /dev/null +++ b/geoip-1.0.7/ChangeLog @@ -0,0 +1,76 @@ +1.0.7 2009-03-11 + + * Do not issue a NOTICE when values don't exist for timezone and region name (as added in 1.0.4) + * Fix a compile issue on FreeBSD + * Try to be bulletproof on library features detection. + +1.0.6 2009-01-20 + + * Fixing compile bug when multiple GeoIP libs are installed, bug #15372 + +1.0.5 2008-12-19 + + * Small bug in phpinfo() when printing version number could crash PHP. + +1.0.4 2008-12-19 + + * Fix memleaks, bug #14851 + * Small patch for MacPorts by jhohle + * Add geoip_time_zone_by_country_and_region() and geoip_region_name_by_code() (thanks to Sid Dunayer) + * Add continent_code field for City Database, only if using GeoIP lib 1.4.3 or newer + +1.0.3 2008-06-12 + + * Change license from PHP 3.0 to PHP 3.01 for Debian? + * Added geoip_continent_code_by_name() to get continent instead of country + * Fixing a small casting issue (compiler warning) + * Fixing missing entries in geoip_record_by_name, bug #14131 + +1.0.2 2007-11-20 + + * Added geoip_isp_by_name (patch by Yannick Gard) + +1.0.1 2007-08-22 + + * Added geoip_db_avail() to check for DB availability (file found) + * Added geoip_db_filename() to get the internal file name of the library + * Added geoip_db_get_all_info() to fetch all info about all database types + * Added some tests so that make test can crunch something. + * Added database file path and name in warning when DB is not found. + * Added geoip.custom_directory php.ini option to change default path for DBs + +1.0.0 2007-08-14 + + * Marked as stable + * Fixing wrong version number inside extension + +0.2.0 2006-08-22 + + * Initial PECL Release + * Fixing various memory leaks + * Registering the C API constants in PHP + +0.1.3 2006-7-10 + +Following changes made by Olivier Hill + * Missing PHP function prototypes + * Fixing code foldings in Emacs + * Outputting E_NOTICES instead of E_WARNING when non fatal errors + * Return type of longitude/latitude should be DOUBLE and not LONG + +0.1.2 2006-5-19 + * Following changes all contributed by Guenter Knauf +- moved argument parsing up at various places before we create a GeoIP. +- moved GeoIP_delete() call at various places up to get it called before we error out. +- fixed one place where a missing return caused a segfault on all platforms because + RETURN_STRING() was called with NULL when GeoIP lookup failed. +- added php.ini entry parsing; prepared for usage of geoip.database_standard var. + This works fine so far as you can test with the geoip_database_info() call which uses + the database configured with the geoip.database_standard var; if not set it defaults + to the usual place specified during compile time with GEOIPDATADIR. All other functions + currently still ignore the geoip.database_standard setting, but default usually also + to GEOIPDATADIR from what I see. Search for the dirty '//' comments .... + * Added config.m4, contributed by Jonathan Whiteman of cyberflowsolutions.com + +0.1.1 2005-9-21 + * Initial release, contributed by Matthew Fonda diff --git a/geoip-1.0.7/README b/geoip-1.0.7/README new file mode 100644 index 0000000..0e3b8f5 --- /dev/null +++ b/geoip-1.0.7/README @@ -0,0 +1,7 @@ +This PHP extension allows you to find the location of an IP address - City, State, +Country, Longitude, Latitude, and other information as all, such as ISP and connection type. + +To compile it, you will need to have the GeoIP c library installed. + +For installation instructions for PHP extensions, see: +http://www.php.net/manual/en/install.pecl.php diff --git a/geoip-1.0.7/config.m4 b/geoip-1.0.7/config.m4 new file mode 100644 index 0000000..abc00dc --- /dev/null +++ b/geoip-1.0.7/config.m4 @@ -0,0 +1,127 @@ +dnl $Id: config.m4,v 1.10 2009/03/05 12:52:25 ohill Exp $ +dnl config.m4 for extension geoip + +dnl Base file contributed by Jonathan Whiteman of cyberflowsolutions.com + +PHP_ARG_WITH(geoip, for geoip support, +dnl Make sure that the comment is aligned: +[ --with-geoip Include GeoIP support]) + +if test "$PHP_GEOIP" != "no"; then + + # --with-geoip -> check with-path + SEARCH_PATH="/usr/local /usr /sw /opt/local" + SEARCH_FOR="/include/GeoIP.h" + if test -r $PHP_GEOIP/$SEARCH_FOR; then + GEOIP_DIR=$PHP_GEOIP + else # search default path list + AC_MSG_CHECKING([for geoip files in default path]) + for i in $SEARCH_PATH ; do + if test -r $i/$SEARCH_FOR; then + GEOIP_DIR=$i + AC_MSG_RESULT([found in $i]) + fi + done + fi + + if test -z "$GEOIP_DIR"; then + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([Please reinstall the geoip distribution]) + fi + + # --with-geoip -> add include path + PHP_ADD_INCLUDE($GEOIP_DIR/include) + + # odd PHP4 fix + if test "x$PHP_LIBDIR" = "x"; then + PHP_LIBDIR=lib + fi + + # --with-geoip -> check for lib and symbol presence + LIBNAME=GeoIP # you may want to change this + LIBSYMBOL=GeoIP_open # you most likely want to change this + + PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, + [ + PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $GEOIP_DIR/lib, GEOIP_SHARED_LIBADD) + AC_DEFINE(HAVE_GEOIPLIB,1,[ ]) + ],[ + AC_MSG_ERROR([wrong geoip lib version or lib not found]) + ],[ + -L$GEOIP_DIR/$PHP_LIBDIR -lm + ]) + + # Checking for GeoIP_setup_custom_directory in newer lib + PHP_CHECK_LIBRARY($LIBNAME,GeoIP_setup_custom_directory, + [ + AC_DEFINE(HAVE_CUSTOM_DIRECTORY,1,[ ]) + MIN_GEOIP_VERSION=1004001 + ],[ + ],[ + -L$GEOIP_DIR/$PHP_LIBDIR -lm + ]) + + # Checking for GeoIP_set_charset in newer lib + PHP_CHECK_LIBRARY($LIBNAME,GeoIP_set_charset, + [ + AC_DEFINE(HAVE_SET_CHARSET,1,[ ]) + MIN_GEOIP_VERSION=1004003 + ],[ + ],[ + -L$GEOIP_DIR/$PHP_LIBDIR -lm + ]) + + # Checking for GeoIP_continent_by_id in newer lib + PHP_CHECK_LIBRARY($LIBNAME,GeoIP_continent_by_id, + [ + AC_DEFINE(HAVE_CONTINENT_BY_ID,1,[ ]) + MIN_GEOIP_VERSION=1004005 + ],[ + ],[ + -L$GEOIP_DIR/$PHP_LIBDIR -lm + ]) + + # Check to see if we are using the LGPL library (version 1.4.0 and newer) + AC_MSG_CHECKING([for LGPL compatible GeoIP libs]) + libgeoip_full_version=`find $GEOIP_DIR/$PHP_LIBDIR/ -name libGeoIP.\*.\*.\*.\* | cut -d . -f 2-5 | sort` + for lines in $libgeoip_full_version; do + ac_IFS=$IFS + IFS="." + set $lines + IFS=$ac_IFS + done + + # Version after the suffix (eg: .so.1.4.0) + if test "[$]1" = "$SHLIB_SUFFIX_NAME"; then + LIBGEOIP_VERSION=`expr [$]2 \* 1000000 + [$]3 \* 1000 + [$]4` + # Version before the suffix (eg: 1.4.0.dylib on OS X) + else + LIBGEOIP_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3` + fi + + # Just in case it didn't work, try alternate method, or fail + if test "x$LIBGEOIP_VERSION" = "x"; then + AC_MSG_RESULT([cannot detect]) + + # Alternate method based on library capabilities (not 100% acurate) + AC_MSG_CHECKING([library features to determine version (not acurate)]) + if test "x$MIN_GEOIP_VERSION" = "x"; then + AC_MSG_ERROR([For some reason, libGeoIP is installed, but I cannot determine the version used]) + else + LIBGEOIP_VERSION=$MIN_GEOIP_VERSION + fi + fi + + if test "$LIBGEOIP_VERSION" -lt "1004000"; then + AC_MSG_RESULT([wrong version]) + AC_MSG_ERROR([You need version 1.4.0 or higher of the C API]) + else + AC_MSG_RESULT([found $LIBGEOIP_VERSION]) + AC_DEFINE_UNQUOTED(LIBGEOIP_VERSION, $LIBGEOIP_VERSION, [ ]) + fi + + PHP_SUBST(GEOIP_SHARED_LIBADD) + + PHP_NEW_EXTENSION(geoip, geoip.c, $ext_shared) +fi + diff --git a/geoip-1.0.7/geoip.c b/geoip-1.0.7/geoip.c new file mode 100644 index 0000000..9077763 --- /dev/null +++ b/geoip-1.0.7/geoip.c @@ -0,0 +1,651 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | [email protected] so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Olivier Hill <[email protected]> | + | Matthew Fonda | + +----------------------------------------------------------------------+ + Please contact [email protected] with any comments +*/ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <GeoIP.h> +#include <GeoIPCity.h> + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "php_geoip.h" + + + +ZEND_DECLARE_MODULE_GLOBALS(geoip) + +static int le_geoip; + +/* {{{ */ +function_entry geoip_functions[] = { + PHP_FE(geoip_database_info, NULL) + PHP_FE(geoip_country_code_by_name, NULL) + PHP_FE(geoip_country_code3_by_name, NULL) + PHP_FE(geoip_country_name_by_name, NULL) + PHP_FE(geoip_continent_code_by_name, NULL) + PHP_FE(geoip_org_by_name, NULL) + PHP_FE(geoip_record_by_name, NULL) + PHP_FE(geoip_id_by_name, NULL) + PHP_FE(geoip_region_by_name, NULL) + PHP_FE(geoip_isp_by_name, NULL) + PHP_FE(geoip_db_avail, NULL) + PHP_FE(geoip_db_get_all_info, NULL) + PHP_FE(geoip_db_filename, NULL) +#if LIBGEOIP_VERSION >= 1004001 + PHP_FE(geoip_region_name_by_code, NULL) + PHP_FE(geoip_time_zone_by_country_and_region, NULL) +#endif + {NULL, NULL, NULL} +}; +/* }}} */ + +/* {{{ geoip_module_entry + */ +zend_module_entry geoip_module_entry = { +#if ZEND_MODULE_API_NO >= 20010901 + STANDARD_MODULE_HEADER, +#endif + "geoip", + geoip_functions, + PHP_MINIT(geoip), + PHP_MSHUTDOWN(geoip), + PHP_RINIT(geoip), + PHP_RSHUTDOWN(geoip), + PHP_MINFO(geoip), +#if ZEND_MODULE_API_NO >= 20010901 + PHP_GEOIP_VERSION, /* version number of the extension */ +#endif + STANDARD_MODULE_PROPERTIES +}; +/* }}} */ + +#ifdef COMPILE_DL_GEOIP +ZEND_GET_MODULE(geoip) +#endif + +/* {{{ PHP_INI + */ +PHP_INI_BEGIN() +#ifdef HAVE_CUSTOM_DIRECTORY + STD_PHP_INI_ENTRY("geoip.custom_directory", NULL, PHP_INI_ALL, OnUpdateString, custom_directory, zend_geoip_globals, geoip_globals) +#endif +PHP_INI_END() +/* }}} */ + +/* {{{ php_geoip_init_globals + */ +static void php_geoip_init_globals(zend_geoip_globals *geoip_globals) +{ + geoip_globals->custom_directory = NULL; +} +/* }}} */ + +/* {{{ PHP_MINIT_FUNCTION + */ +PHP_MINIT_FUNCTION(geoip) +{ + ZEND_INIT_MODULE_GLOBALS(geoip, php_geoip_init_globals, NULL); + REGISTER_INI_ENTRIES(); + + /* @TODO: Do something for custom_directory before initialization here */ + +#ifdef HAVE_CUSTOM_DIRECTORY + GeoIP_setup_custom_directory(GEOIP_G(custom_directory)); +#endif + + _GeoIP_setup_dbfilename(); + + /* For database type constants */ + REGISTER_LONG_CONSTANT("GEOIP_COUNTRY_EDITION", GEOIP_COUNTRY_EDITION, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_REGION_EDITION_REV0", GEOIP_REGION_EDITION_REV0, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV0", GEOIP_CITY_EDITION_REV0, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_ORG_EDITION", GEOIP_ORG_EDITION, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_ISP_EDITION", GEOIP_ISP_EDITION, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_CITY_EDITION_REV1", GEOIP_CITY_EDITION_REV1, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_REGION_EDITION_REV1", GEOIP_REGION_EDITION_REV1, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_PROXY_EDITION", GEOIP_PROXY_EDITION, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_ASNUM_EDITION", GEOIP_ASNUM_EDITION, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_NETSPEED_EDITION", GEOIP_NETSPEED_EDITION, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_DOMAIN_EDITION", GEOIP_DOMAIN_EDITION, CONST_CS | CONST_PERSISTENT); + + /* For netspeed constants */ + REGISTER_LONG_CONSTANT("GEOIP_UNKNOWN_SPEED", GEOIP_UNKNOWN_SPEED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_DIALUP_SPEED", GEOIP_DIALUP_SPEED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_CABLEDSL_SPEED", GEOIP_CABLEDSL_SPEED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("GEOIP_CORPORATE_SPEED", GEOIP_CORPORATE_SPEED, CONST_CS | CONST_PERSISTENT); + + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MSHUTDOWN_FUNCTION + */ +PHP_MSHUTDOWN_FUNCTION(geoip) +{ + return SUCCESS; +} +/* }}} */ + + +/* {{{ PHP_RINIT_FUNCTION + */ +PHP_RINIT_FUNCTION(geoip) +{ + return SUCCESS; +} +/* }}} */ + + +/* {{{ PHP_RSHUTDOWN_FUNCTION + */ +PHP_RSHUTDOWN_FUNCTION(geoip) +{ + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MINFO_FUNCTION + */ +PHP_MINFO_FUNCTION(geoip) +{ + char buf[32]; + + php_info_print_table_start(); + php_info_print_table_header(2, "geoip support", "enabled"); + php_info_print_table_row(2, "geoip extension version", PHP_GEOIP_VERSION); + snprintf(buf, sizeof(buf), "%d", LIBGEOIP_VERSION); + php_info_print_table_row(2, "geoip library version", buf); + php_info_print_table_end(); + DISPLAY_INI_ENTRIES(); +} +/* }}} */ + +/* {{{ proto boolean geoip_db_avail( [ int database ] ) */ +PHP_FUNCTION(geoip_db_avail) +{ + long edition; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &edition) == FAILURE) { + return; + } + + if (edition < 0 || edition >= NUM_DB_TYPES) + { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Database type given is out of bound."); + return; + } + + RETURN_BOOL(GeoIP_db_avail(edition)); +} +/* }}} */ + +/* {{{ proto string geoip_db_filename( [ int database ] ) */ +PHP_FUNCTION(geoip_db_filename) +{ + long edition; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &edition) == FAILURE) { + return; + } + + if (edition < 0 || edition >= NUM_DB_TYPES) + { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Database type given is out of bound."); + return; + } + + if (NULL != GeoIPDBFileName[edition]) + RETURN_STRING(GeoIPDBFileName[edition], 1); +} +/* }}} */ + +/* {{{ proto array geoip_db_get_all_info( ) */ +PHP_FUNCTION(geoip_db_get_all_info) +{ + int i; + + array_init(return_value); + + for (i=0; i < NUM_DB_TYPES; i++) + { + if (NULL != GeoIPDBDescription[i]) + { + zval *row; + ALLOC_INIT_ZVAL(row); + array_init(row); + + add_assoc_bool(row, "available", GeoIP_db_avail(i)); + add_assoc_string(row, "description", (char *)GeoIPDBDescription[i], 1); + add_assoc_string(row, "filename", GeoIPDBFileName[i], 1); + + add_index_zval(return_value, i, row); + } + } +} +/* }}} */ + +/* {{{ proto string geoip_database_info( [ int database ] ) + Returns GeoIP Database information */ +PHP_FUNCTION(geoip_database_info) +{ + GeoIP * gi; + char * db_info; + long edition = GEOIP_COUNTRY_EDITION; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &edition) == FAILURE) { + return; + } + + if (edition < 0 || edition >= NUM_DB_TYPES) + { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Database type given is out of bound."); + return; + } + + if (GeoIP_db_avail(edition)) { + gi = GeoIP_open_type(edition, GEOIP_STANDARD); + } else { + if (NULL != GeoIPDBFileName[edition]) + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); + else + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available."); + return; + } + + db_info = GeoIP_database_info(gi); + GeoIP_delete(gi); + + RETVAL_STRING(db_info, 1); + free(db_info); +} +/* }}} */ + +/* {{{ proto string geoip_country_code_by_name( string hostname ) + Return the Country Code found in the GeoIP Database */ +PHP_FUNCTION(geoip_country_code_by_name) +{ + GeoIP * gi; + char * hostname = NULL; + const char * country_code; + int arglen; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { + return; + } + + if (GeoIP_db_avail(GEOIP_COUNTRY_EDITION)) { + gi = GeoIP_open_type(GEOIP_COUNTRY_EDITION, GEOIP_STANDARD); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); + return; + } + + country_code = GeoIP_country_code_by_name(gi, hostname); + GeoIP_delete(gi); + if (country_code == NULL) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); + RETURN_FALSE; + } + RETURN_STRING((char*)country_code, 1); +} +/* }}} */ + +/* {{{ proto string geoip_country_code_by_name( string hostname ) + Return the Country Code found in the GeoIP Database */ +PHP_FUNCTION(geoip_country_code3_by_name) +{ + GeoIP * gi; + char * hostname = NULL; + const char * country_code; + int arglen; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { + return; + } + + if (GeoIP_db_avail(GEOIP_COUNTRY_EDITION)) { + gi = GeoIP_open_type(GEOIP_COUNTRY_EDITION, GEOIP_STANDARD); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); + return; + } + + country_code = GeoIP_country_code3_by_name(gi, hostname); + GeoIP_delete(gi); + if (country_code == NULL) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); + RETURN_FALSE; + } + RETURN_STRING((char*)country_code, 1); +} +/* }}} */ + +/* {{{ proto string geoip_country_name_by_name( string hostname ) + Returns the Country name found in the GeoIP Database */ +PHP_FUNCTION(geoip_country_name_by_name) +{ + GeoIP * gi; + char * hostname = NULL; + const char * country_name; + int arglen; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { + return; + } + + if (GeoIP_db_avail(GEOIP_COUNTRY_EDITION)) { + gi = GeoIP_open_type(GEOIP_COUNTRY_EDITION, GEOIP_STANDARD); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); + return; + } + + country_name = GeoIP_country_name_by_name(gi, hostname); + GeoIP_delete(gi); + if (country_name == NULL) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); + RETURN_FALSE; + } + RETURN_STRING((char*)country_name, 1); +} +/* }}} */ + +/* {{{ proto string geoip_continent_code_by_name( string hostname ) + Returns the Continent name found in the GeoIP Database */ +PHP_FUNCTION(geoip_continent_code_by_name) +{ + GeoIP * gi; + char * hostname = NULL; + int id; + int arglen; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { + return; + } + + if (GeoIP_db_avail(GEOIP_COUNTRY_EDITION)) { + gi = GeoIP_open_type(GEOIP_COUNTRY_EDITION, GEOIP_STANDARD); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_COUNTRY_EDITION]); + return; + } + + id = GeoIP_id_by_name(gi, hostname); + GeoIP_delete(gi); + if (id == 0) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); + RETURN_FALSE; + } + RETURN_STRING((char *)GeoIP_country_continent[id], 1); +} +/* }}} */ + +/* {{{ proto string geoip_org_by_name( string hostname ) + Returns the Organization Name found in the GeoIP Database */ +PHP_FUNCTION(geoip_org_by_name) +{ + GeoIP * gi; + char * hostname = NULL; + char * org; + int arglen; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { + return; + } + + if (GeoIP_db_avail(GEOIP_ORG_EDITION)) { + gi = GeoIP_open_type(GEOIP_ORG_EDITION, GEOIP_STANDARD); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_ORG_EDITION]); + return; + } + + org = GeoIP_org_by_name(gi, hostname); + GeoIP_delete(gi); + if (org == NULL) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); + RETURN_FALSE; + } + RETVAL_STRING(org, 1); + free(org); +} +/* }}} */ + +/* {{{ proto array geoip_record_by_name( string hostname ) + Returns the detailed City information found in the GeoIP Database */ +PHP_FUNCTION(geoip_record_by_name) +{ + GeoIP * gi; + char * hostname = NULL; + int arglen; + GeoIPRecord * gir; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { + return; + } + + if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1) || GeoIP_db_avail(GEOIP_CITY_EDITION_REV0)) { + if (GeoIP_db_avail(GEOIP_CITY_EDITION_REV1)) { + gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV1, GEOIP_STANDARD); + } else { + gi = GeoIP_open_type(GEOIP_CITY_EDITION_REV0, GEOIP_STANDARD); + } + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_CITY_EDITION_REV0]); + return; + } + gir = GeoIP_record_by_name(gi, hostname); + + GeoIP_delete(gi); + + if (NULL == gir) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); + RETURN_FALSE; + } + + array_init(return_value); +#if LIBGEOIP_VERSION >= 1004003 + add_assoc_string(return_value, "continent_code", (gir->continent_code == NULL) ? "" : gir->continent_code, 1); +#endif + add_assoc_string(return_value, "country_code", (gir->country_code == NULL) ? "" : gir->country_code, 1); + add_assoc_string(return_value, "country_code3", (gir->country_code3 == NULL) ? "" : gir->country_code3, 1); + add_assoc_string(return_value, "country_name", (gir->country_name == NULL) ? "" : gir->country_name, 1); + add_assoc_string(return_value, "region", (gir->region == NULL) ? "" : gir->region, 1); + add_assoc_string(return_value, "city", (gir->city == NULL) ? "" : gir->city, 1); + add_assoc_string(return_value, "postal_code", (gir->postal_code == NULL) ? "" : gir->postal_code, 1); + add_assoc_double(return_value, "latitude", gir->latitude); + add_assoc_double(return_value, "longitude", gir->longitude); +#if LIBGEOIP_VERSION >= 1004005 + add_assoc_long(return_value, "dma_code", gir->metro_code); +#else + add_assoc_long(return_value, "dma_code", gir->dma_code); +#endif + add_assoc_long(return_value, "area_code", gir->area_code); + + GeoIPRecord_delete(gir); +} +/* }}} */ + +/* {{{ proto integer geoip_id_by_name( string hostname ) + Returns the Net Speed found in the GeoIP Database */ +PHP_FUNCTION(geoip_id_by_name) +{ + GeoIP * gi; + char * hostname = NULL; + int arglen; + int netspeed; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { + return; + } + + if (GeoIP_db_avail(GEOIP_NETSPEED_EDITION)) { + gi = GeoIP_open_type(GEOIP_NETSPEED_EDITION, GEOIP_STANDARD); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_NETSPEED_EDITION]); + return; + } + + netspeed = GeoIP_id_by_name(gi, hostname); + GeoIP_delete(gi); + RETURN_LONG(netspeed); +} +/* }}} */ + +/* {{{ proto array geoip_region_by_name( string hostname ) + Returns the Country Code and region found in the GeoIP Database */ +PHP_FUNCTION(geoip_region_by_name) +{ + GeoIP * gi; + char * hostname = NULL; + int arglen; + GeoIPRegion * region; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { + return; + } + + if (GeoIP_db_avail(GEOIP_REGION_EDITION_REV0) || GeoIP_db_avail(GEOIP_REGION_EDITION_REV1)) { + if (GeoIP_db_avail(GEOIP_REGION_EDITION_REV1)) { + gi = GeoIP_open_type(GEOIP_REGION_EDITION_REV1, GEOIP_STANDARD); + } else { + gi = GeoIP_open_type(GEOIP_REGION_EDITION_REV0, GEOIP_STANDARD); + } + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_REGION_EDITION_REV0]); + return; + } + + region = GeoIP_region_by_name(gi, hostname); + GeoIP_delete(gi); + + if (NULL == region) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); + RETURN_FALSE; + } + + array_init(return_value); + add_assoc_string(return_value, "country_code", region->country_code, 1); + add_assoc_string(return_value, "region", region->region, 1); + + GeoIPRegion_delete(region); +} +/* }}} */ + +/* {{{ proto string geoip_isp_by_name( string hostname ) + Returns the ISP Name found in the GeoIP Database */ +PHP_FUNCTION(geoip_isp_by_name) +{ + GeoIP * gi; + char * hostname = NULL; + char * isp; + int arglen; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) { + return; + } + + if (GeoIP_db_avail(GEOIP_ISP_EDITION)) { + gi = GeoIP_open_type(GEOIP_ISP_EDITION, GEOIP_STANDARD); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Required database not available at %s.", GeoIPDBFileName[GEOIP_ISP_EDITION]); + return; + } + + isp = GeoIP_name_by_name(gi, hostname); + GeoIP_delete(gi); + if (isp == NULL) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Host %s not found", hostname); + RETURN_FALSE; + } + RETVAL_STRING(isp, 1); + free(isp); +} + +#if LIBGEOIP_VERSION >= 1004001 +/* {{{ proto string geoip_region_name_by_code( string country_code, string region_code ) + Returns the region name for some country code and region code combo */ +PHP_FUNCTION(geoip_region_name_by_code) +{ + GeoIP * gi; + char * country_code = NULL; + char * region_code = NULL; + const char * region_name; + int countrylen, regionlen; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &country_code, &countrylen, &region_code, &regionlen) == FAILURE) { + return; + } + + if (!countrylen || !regionlen) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "You need to specify the country and region codes."); + RETURN_FALSE; + } + + region_name = GeoIP_region_name_by_code(country_code, region_code); + if (region_name == NULL) { + RETURN_FALSE; + } + RETURN_STRING((char*)region_name, 1); +} +/* }}} */ +#endif + +#if LIBGEOIP_VERSION >= 1004001 +/* {{{ proto string geoip_time_zone_by_country_and_region( string country, string region ) + Returns the time zone for some country code and region code combo */ +PHP_FUNCTION(geoip_time_zone_by_country_and_region) +{ + GeoIP * gi; + char * country = NULL; + char * region = NULL; + const char * timezone; + int countrylen, arg2len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &country, &countrylen, &region, &arg2len) == FAILURE) { + return; + } + + if (!countrylen) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "You need to specify at least the country code."); + RETURN_FALSE; + } + + timezone = GeoIP_time_zone_by_country_and_region(country, region); + if (timezone == NULL) { + RETURN_FALSE; + } + RETURN_STRING((char*)timezone, 1); +} +/* }}} */ +#endif + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/geoip-1.0.7/php_geoip.h b/geoip-1.0.7/php_geoip.h new file mode 100644 index 0000000..7568990 --- /dev/null +++ b/geoip-1.0.7/php_geoip.h @@ -0,0 +1,87 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | [email protected] so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Olivier Hill <[email protected]> | + | Matthew Fonda | + +----------------------------------------------------------------------+ + Please contact [email protected] with any comments +*/ + +#ifndef PHP_GEOIP_H +#define PHP_GEOIP_H + +extern zend_module_entry geoip_module_entry; +#define phpext_geoip_ptr &geoip_module_entry + +#define PHP_GEOIP_VERSION "1.0.7" + +#ifdef PHP_WIN32 +#define PHP_GEOIP_API __declspec(dllexport) +#else +#define PHP_GEOIP_API +#endif + +#ifdef ZTS +#include "TSRM.h" +#endif + +#include <GeoIP.h> +#include <GeoIPCity.h> + +PHP_MINIT_FUNCTION(geoip); +PHP_MSHUTDOWN_FUNCTION(geoip); +PHP_RINIT_FUNCTION(geoip); +PHP_RSHUTDOWN_FUNCTION(geoip); +PHP_MINFO_FUNCTION(geoip); + + +PHP_FUNCTION(geoip_database_info); +PHP_FUNCTION(geoip_country_code_by_name); +PHP_FUNCTION(geoip_country_code3_by_name); +PHP_FUNCTION(geoip_country_name_by_name); +PHP_FUNCTION(geoip_continent_code_by_name); +PHP_FUNCTION(geoip_org_by_name); +PHP_FUNCTION(geoip_record_by_name); +PHP_FUNCTION(geoip_id_by_name); +PHP_FUNCTION(geoip_region_by_name); +PHP_FUNCTION(geoip_isp_by_name); +PHP_FUNCTION(geoip_db_avail); +PHP_FUNCTION(geoip_db_get_all_info); +PHP_FUNCTION(geoip_db_filename); +#if LIBGEOIP_VERSION >= 1004001 +PHP_FUNCTION(geoip_region_name_by_code); +PHP_FUNCTION(geoip_time_zone_by_country_and_region); +#endif + +ZEND_BEGIN_MODULE_GLOBALS(geoip) + char* custom_directory; +ZEND_END_MODULE_GLOBALS(geoip) + +#ifdef ZTS +#define GEOIP_G(v) TSRMG(geoip_globals_id, zend_geoip_globals *, v) +#else +#define GEOIP_G(v) (geoip_globals.v) +#endif + +#endif /* PHP_GEOIP_H */ + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/geoip-1.0.7/tests/001.phpt b/geoip-1.0.7/tests/001.phpt new file mode 100644 index 0000000..a548d6e --- /dev/null +++ b/geoip-1.0.7/tests/001.phpt @@ -0,0 +1,14 @@ +--TEST-- +Checking Country (Free) DB availability +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--POST-- +--GET-- +--FILE-- +<?php + +var_dump(geoip_db_avail(GEOIP_COUNTRY_EDITION)); + +?> +--EXPECT-- +bool(true) diff --git a/geoip-1.0.7/tests/002.phpt b/geoip-1.0.7/tests/002.phpt new file mode 100644 index 0000000..03e5bea --- /dev/null +++ b/geoip-1.0.7/tests/002.phpt @@ -0,0 +1,34 @@ +--TEST-- +Checking if all db info and name match +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--FILE-- +<?php + +$t = geoip_db_get_all_info(); + +var_dump( $t[GEOIP_COUNTRY_EDITION]['description'] ); +var_dump( $t[GEOIP_REGION_EDITION_REV0]['description'] ); +var_dump( $t[GEOIP_CITY_EDITION_REV0]['description'] ); +var_dump( $t[GEOIP_ORG_EDITION]['description'] ); +var_dump( $t[GEOIP_ISP_EDITION]['description'] ); +var_dump( $t[GEOIP_CITY_EDITION_REV1]['description'] ); +var_dump( $t[GEOIP_REGION_EDITION_REV1]['description'] ); +var_dump( $t[GEOIP_PROXY_EDITION]['description'] ); +var_dump( $t[GEOIP_ASNUM_EDITION]['description'] ); +var_dump( $t[GEOIP_NETSPEED_EDITION]['description'] ); +var_dump( $t[GEOIP_DOMAIN_EDITION]['description'] ); + +?> +--EXPECT-- +string(21) "GeoIP Country Edition" +string(27) "GeoIP Region Edition, Rev 0" +string(25) "GeoIP City Edition, Rev 0" +string(26) "GeoIP Organization Edition" +string(17) "GeoIP ISP Edition" +string(25) "GeoIP City Edition, Rev 1" +string(27) "GeoIP Region Edition, Rev 1" +string(19) "GeoIP Proxy Edition" +string(19) "GeoIP ASNum Edition" +string(22) "GeoIP Netspeed Edition" +string(25) "GeoIP Domain Name Edition" diff --git a/geoip-1.0.7/tests/003.phpt b/geoip-1.0.7/tests/003.phpt new file mode 100644 index 0000000..37ee4a9 --- /dev/null +++ b/geoip-1.0.7/tests/003.phpt @@ -0,0 +1,12 @@ +--TEST-- +Checking for database filename +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--FILE-- +<?php + +var_dump( geoip_db_filename(GEOIP_COUNTRY_EDITION) ); + +?> +--EXPECTF-- +string(%d) "%sGeoIP.dat" diff --git a/geoip-1.0.7/tests/004.phpt b/geoip-1.0.7/tests/004.phpt new file mode 100644 index 0000000..23624c6 --- /dev/null +++ b/geoip-1.0.7/tests/004.phpt @@ -0,0 +1,16 @@ +--TEST-- +Checking for out of bound type with geoip_db_filename() +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--FILE-- +<?php + +geoip_db_filename(-1000); +geoip_db_filename(1000); + +?> +--EXPECTF-- +Warning: geoip_db_filename(): Database type given is out of bound. in %s on line %d + +Warning: geoip_db_filename(): Database type given is out of bound. in %s on line %d + diff --git a/geoip-1.0.7/tests/005.phpt b/geoip-1.0.7/tests/005.phpt new file mode 100644 index 0000000..c758655 --- /dev/null +++ b/geoip-1.0.7/tests/005.phpt @@ -0,0 +1,16 @@ +--TEST-- +Checking for out of bound type with geoip_db_avail() +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--FILE-- +<?php + +geoip_db_avail(-1000); +geoip_db_avail(1000); + +?> +--EXPECTF-- +Warning: geoip_db_avail(): Database type given is out of bound. in %s on line %d + +Warning: geoip_db_avail(): Database type given is out of bound. in %s on line %d + diff --git a/geoip-1.0.7/tests/006.phpt b/geoip-1.0.7/tests/006.phpt new file mode 100644 index 0000000..2170c1f --- /dev/null +++ b/geoip-1.0.7/tests/006.phpt @@ -0,0 +1,14 @@ +--TEST-- +Checking for custom directory INI entry +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--INI-- +geoip.custom_directory="/test" +--FILE-- +<?php + +var_dump( geoip_db_filename(GEOIP_COUNTRY_EDITION) ); + +?> +--EXPECT-- +string(15) "/test/GeoIP.dat" diff --git a/geoip-1.0.7/tests/007.phpt b/geoip-1.0.7/tests/007.phpt new file mode 100644 index 0000000..8943712 --- /dev/null +++ b/geoip-1.0.7/tests/007.phpt @@ -0,0 +1,14 @@ +--TEST-- +Checking for custom directory INI entry (with trailing slash) +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--INI-- +geoip.custom_directory="/test/" +--FILE-- +<?php + +var_dump( geoip_db_filename(GEOIP_COUNTRY_EDITION) ); + +?> +--EXPECT-- +string(15) "/test/GeoIP.dat" diff --git a/geoip-1.0.7/tests/008.phpt b/geoip-1.0.7/tests/008.phpt new file mode 100644 index 0000000..59c9080 --- /dev/null +++ b/geoip-1.0.7/tests/008.phpt @@ -0,0 +1,12 @@ +--TEST-- +Calling geoip_db_filename() with a non-existant database type within bound. +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--FILE-- +<?php + +var_dump( geoip_db_filename(14) ); + +?> +--EXPECT-- +NULL diff --git a/geoip-1.0.7/tests/009.phpt b/geoip-1.0.7/tests/009.phpt new file mode 100644 index 0000000..aed2aa8 --- /dev/null +++ b/geoip-1.0.7/tests/009.phpt @@ -0,0 +1,12 @@ +--TEST-- +Calling geoip_db_avail() with a non-existant database type within bound. +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--FILE-- +<?php + +var_dump( geoip_db_avail(14) ); + +?> +--EXPECT-- +bool(false) diff --git a/geoip-1.0.7/tests/010.phpt b/geoip-1.0.7/tests/010.phpt new file mode 100644 index 0000000..c268c5d --- /dev/null +++ b/geoip-1.0.7/tests/010.phpt @@ -0,0 +1,16 @@ +--TEST-- +Checking for out of bound type with geoip_database_info() +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--FILE-- +<?php + +geoip_database_info(-1000); +geoip_database_info(1000); + +?> +--EXPECTF-- +Warning: geoip_database_info(): Database type given is out of bound. in %s on line %d + +Warning: geoip_database_info(): Database type given is out of bound. in %s on line %d + diff --git a/geoip-1.0.7/tests/011.phpt b/geoip-1.0.7/tests/011.phpt new file mode 100644 index 0000000..391f3a8 --- /dev/null +++ b/geoip-1.0.7/tests/011.phpt @@ -0,0 +1,12 @@ +--TEST-- +Calling geoip_database_info() with a non-existant database type within bound. +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--FILE-- +<?php + +geoip_database_info(14); + +?> +--EXPECTF-- +Warning: geoip_database_info(): Required database not available. in %s on line %d diff --git a/geoip-1.0.7/tests/013.phpt b/geoip-1.0.7/tests/013.phpt new file mode 100644 index 0000000..24b27cf --- /dev/null +++ b/geoip-1.0.7/tests/013.phpt @@ -0,0 +1,15 @@ +--TEST-- +Checking timezone info +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--POST-- +--GET-- +--FILE-- +<?php + +var_dump(geoip_time_zone_by_country_and_region('CA','QC')); +var_dump(geoip_time_zone_by_country_and_region('JP','01')); +?> +--EXPECT-- +string(16) "America/Montreal" +string(10) "Asia/Tokyo" diff --git a/geoip-1.0.7/tests/014.phpt b/geoip-1.0.7/tests/014.phpt new file mode 100644 index 0000000..a673963 --- /dev/null +++ b/geoip-1.0.7/tests/014.phpt @@ -0,0 +1,26 @@ +--TEST-- +Checking timezone info with (some) empty fields +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--POST-- +--GET-- +--FILE-- +<?php + +var_dump(geoip_time_zone_by_country_and_region('CA','')); +var_dump(geoip_time_zone_by_country_and_region('CA',NULL)); +var_dump(geoip_time_zone_by_country_and_region('CA')); +var_dump(geoip_time_zone_by_country_and_region(NULL,'')); +var_dump(geoip_time_zone_by_country_and_region(NULL,NULL)); + +?> +--EXPECTF-- +string(%d) "America/%s" +string(%d) "America/%s" +string(%d) "America/%s" + +Warning: geoip_time_zone_by_country_and_region(): You need to specify at least the country code. in %s on line %d +bool(false) + +Warning: geoip_time_zone_by_country_and_region(): You need to specify at least the country code. in %s on line %d +bool(false) diff --git a/geoip-1.0.7/tests/015.phpt b/geoip-1.0.7/tests/015.phpt new file mode 100644 index 0000000..bd67851 --- /dev/null +++ b/geoip-1.0.7/tests/015.phpt @@ -0,0 +1,14 @@ +--TEST-- +Checking geoip_region_name_by_code for Canada/Quebec +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--POST-- +--GET-- +--FILE-- +<?php + +var_dump(geoip_region_name_by_code('CA','QC')); + +?> +--EXPECT-- +string(6) "Quebec" diff --git a/geoip-1.0.7/tests/016.phpt b/geoip-1.0.7/tests/016.phpt new file mode 100644 index 0000000..83c5250 --- /dev/null +++ b/geoip-1.0.7/tests/016.phpt @@ -0,0 +1,32 @@ +--TEST-- +Checking geoip_region_name_by_code with (some) empty fields +--SKIPIF-- +<?php if (!extension_loaded("geoip")) print "skip"; ?> +--POST-- +--GET-- +--FILE-- +<?php + +var_dump(geoip_region_name_by_code('CA','')); +var_dump(geoip_region_name_by_code('CA',NULL)); +var_dump(geoip_region_name_by_code('CA',1)); +var_dump(geoip_region_name_by_code('','QC')); +var_dump(geoip_region_name_by_code(NULL,'QC')); +var_dump(geoip_region_name_by_code(1,'QC')); + +?> +--EXPECTF-- + +Warning: geoip_region_name_by_code(): You need to specify the country and region codes. in %s on line %d +bool(false) + +Warning: geoip_region_name_by_code(): You need to specify the country and region codes. in %s on line %d +bool(false) +bool(false) + +Warning: geoip_region_name_by_code(): You need to specify the country and region codes. in %s on line %d +bool(false) + +Warning: geoip_region_name_by_code(): You need to specify the country and region codes. in %s on line %d +bool(false) +bool(false) diff --git a/package.xml b/package.xml new file mode 100644 index 0000000..a61a864 --- /dev/null +++ b/package.xml @@ -0,0 +1,196 @@ +<?xml version="1.0" encoding="UTF-8"?> +<package packagerversion="1.7.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> + <name>geoip</name> + <channel>pecl.php.net</channel> + <summary>Map IP address to geographic places</summary> + <description>This PHP extension allows you to find the location of an IP address - City, State, Country, Longitude, Latitude, and other information as all, such as ISP and connection type. For more info, please visit Maxmind&apos;s website.</description> + <lead> + <name>Olivier Hill</name> + <user>ohill</user> + <email>[email protected]</email> + <active>yes</active> + </lead> + <date>2009-03-11</date> + <time>13:43:29</time> + <version> + <release>1.0.7</release> + <api>1.0.3</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.php.net/license">PHP License</license> + <notes>* Do not issue a NOTICE when values don&apos;t exist for timezone and region name (as added in 1.0.4) +* Fix a compile issue on FreeBSD +* Try to be bulletproof on library features detection.</notes> + <contents> + <dir name="/"> + <file md5sum="b06052cd0a4e66132e1bcc98c5739ecd" name="tests/001.phpt" role="test" /> + <file md5sum="5756f1cfb634d23c765435f57b5b9575" name="tests/002.phpt" role="test" /> + <file md5sum="9349f89dbad73a1ce171100f186a3f4a" name="tests/003.phpt" role="test" /> + <file md5sum="48573355b6270090878243065e03dc12" name="tests/004.phpt" role="test" /> + <file md5sum="36160cb94ff89f1cf2bf6b0ca445ed59" name="tests/005.phpt" role="test" /> + <file md5sum="916fd2691a419719349ca441e4a13ba7" name="tests/006.phpt" role="test" /> + <file md5sum="ac7f1f611cf80ab6bc19dcdc08ed3004" name="tests/007.phpt" role="test" /> + <file md5sum="15512214adb247c86d577764f70419af" name="tests/008.phpt" role="test" /> + <file md5sum="d7ac6c1ef8bfea62142dbbba2e33d150" name="tests/009.phpt" role="test" /> + <file md5sum="7ce6f4ed5737f65dab3f0b7771856712" name="tests/010.phpt" role="test" /> + <file md5sum="d636093e2a76993c2a3d76c6f5d45bc4" name="tests/011.phpt" role="test" /> + <file md5sum="9b71da0d066ed2eef0fb6971ce69ab89" name="tests/013.phpt" role="test" /> + <file md5sum="7a2b0ee9a1b27a66759b5489a22b51a6" name="tests/014.phpt" role="test" /> + <file md5sum="678e4965f7b7a797f7563e76958b9afd" name="tests/015.phpt" role="test" /> + <file md5sum="726935ffc75d98b0e051f035a192dbd2" name="tests/016.phpt" role="test" /> + <file md5sum="17da62b01fcc77666fc9f714ec5d12d1" name="ChangeLog" role="doc" /> + <file md5sum="d67a36bba90a60933304e2214164500d" name="config.m4" role="src" /> + <file md5sum="5f5b4a0637cb8be6f57b5040ee52cc86" name="geoip.c" role="src" /> + <file md5sum="d8f810b598698f00ec59637935baa266" name="php_geoip.h" role="src" /> + <file md5sum="00add03af2620b8c9b64106f6178d866" name="README" role="doc" /> + </dir> + </contents> + <dependencies> + <required> + <php> + <min>4.3.0</min> + </php> + <pearinstaller> + <min>1.4.0b1</min> + </pearinstaller> + </required> + </dependencies> + <providesextension>geoip</providesextension> + <extsrcrelease /> + <changelog> + <release> + <version> + <release>1.0.7</release> + <api>1.0.3</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2009-03-11</date> + <license uri="http://www.php.net/license">PHP License</license> + <notes>* Do not issue a NOTICE when values don&apos;t exist for timezone and region name (as added in 1.0.4) +* Fix a compile issue on FreeBSD +* Try to be bulletproof on library features detection.</notes> + </release> + <release> + <version> + <release>1.0.6</release> + <api>1.0.3</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2009-01-20</date> + <license uri="http://www.php.net/license">PHP License</license> + <notes>* Fixing compile bug when multiple GeoIP libs are installed, bug #15372.</notes> + </release> + <release> + <version> + <release>1.0.5</release> + <api>1.0.3</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2008-12-19</date> + <license uri="http://www.php.net/license">PHP License</license> + <notes>* Small bug in phpinfo() when printing version number could crash PHP.</notes> + </release> + <release> + <version> + <release>1.0.4</release> + <api>1.0.3</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2008-12-19</date> + <license uri="http://www.php.net/license">PHP License</license> + <notes>* Fix memleaks, bug #14851 +* Small patch for MacPorts by jhohle +* Add geoip_time_zone_by_country_and_region() and geoip_region_name_by_code() (thanks to Sid Dunayer) +* Add continent_code field for City Database, only if using GeoIP lib 1.4.3 or newer</notes> + </release> + <release> + <version> + <release>1.0.3</release> + <api>1.0.3</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2008-06-12</date> + <license uri="http://www.php.net/license">PHP License</license> + <notes>* Change license from PHP 3.0 to PHP 3.01 for Debian? +* Added geoip_continent_code_by_name() to get continent instead of country +* Fixing a small casting issue (compiler warning) +* Fixing missing entries in geoip_record_by_name(), bug #14131</notes> + </release> + <release> + <version> + <release>1.0.2</release> + <api>1.0.2</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2007-11-20</date> + <license uri="http://www.php.net/license">PHP</license> + <notes>* Added geoip_isp_by_name (patch by Yannick Gard)</notes> + </release> + <release> + <version> + <release>1.0.1</release> + <api>1.0.1</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2007-08-22</date> + <license uri="http://www.php.net/license">PHP</license> + <notes>* Added geoip_db_avail() to check for DB availability (file found) +* Added geoip_db_filename() to get the internal file name of the library +* Added geoip_db_get_all_info() to fetch all info about all database types +* Added some tests so that make test can crunch something. +* Added database file path and name in warning when DB is not found. +* Added geoip.custom_directory php.ini option to change default path for DBs</notes> + </release> + <release> + <version> + <release>1.0.0</release> + <api>1.0.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2007-08-14</date> + <license uri="http://www.php.net/license">PHP</license> + <notes>* Marked as stable +* Fixing wrong version number inside extension</notes> + </release> + <release> + <version> + <release>0.2.0</release> + <api>0.2.0</api> + </version> + <stability> + <release>beta</release> + <api>beta</api> + </stability> + <date>2006-08-22</date> + <license uri="http://www.php.net/license">PHP</license> + <notes>Initial PECL release</notes> + </release> + </changelog> +</package>
JNRowe/surfraw
215cbcfe08aba002f7a361c2f3ffe6277bcf2b78
XE changed their URLs
diff --git a/elvi/currency b/elvi/currency index ebc4038..cc4fe04 100755 --- a/elvi/currency +++ b/elvi/currency @@ -1,391 +1,391 @@ #!/bin/sh # $Id$ # elvis: currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) . surfraw || exit 1 list_currency_symbols () { cat <<EOT Symbol Country and Currency AFA Afghanistan, Afghani ALL Albania, Lek DZD Algeria, Dinar USD America (United States), Dollar USD American Samoa, United States Dollar EUR Andorra, Euro AOA Angola, Kwanza XCD Anguilla, East Caribbean Dollar XCD Antigua and Barbuda, East Caribbean Dollar ARS Argentina, Peso AMD Armenia, Dram AWG Aruba, Guilder AUD Ashmore and Cartier Islands, Australia Dollar AUD Australia, Dollar EUR Austria, Euro ATS Austria, Schilling [obsolete] AZM Azerbaijan, Manat EUR Azores, Euro BSD Bahamas, Dollar BHD Bahrain, Dinar BBD Bajan (Barbados), Dollar EUR Balearic Islands, Euro BDT Bangladesh, Taka BBD Barbados, Dollar BYR Belarus, Ruble EUR Belgium, Euro BEF Belgium, Franc [obsolete] BZD Belize, Dollar XOF Benin, CFA Franc BCEAO BMD Bermuda, Dollar INR Bhutan, India Rupee BTN Bhutan, Ngultrum BOB Bolivia, Boliviano ANG Bonaire, Netherlands Antilles Guilder BAM Bosnia and Herzegovina, Convertible Marka BWP Botswana, Pula BRL Brazil, Real GBP Britain (United Kingdom), Pound GBP British Indian Ocean Territory, United Kingdom Pound USD British Indian Ocean Territory, United States Dollar USD British Virgin Islands, United States Dollar BND Brunei, Dollar SGD Brunei, Singapore Dollar BGN Bulgaria, Lev XOF Burkina Faso, CFA Franc BCEAO MMK Burma (Myanmar), Kyat BIF Burundi, Franc KHR Cambodia, Riel XAF Cameroon, CFA Franc BEAC CAD Canada, Dollar EUR Canary Islands, Euro CVE Cape Verde, Escudo KYD Cayman Islands, Dollar XAF Central African Republic, CFA Franc BEAC XAF CFA Communauté Financière Africaine BEAC Franc XOF CFA Communauté Financière Africaine BCEAO Franc XAF Chad, CFA Franc BEAC CLP Chile, Peso CNY China, Yuan Renminbi AUD Christmas Island, Australia Dollar AUD Cocos (Keeling Islands, Australia Dollar COP Colombia, Peso XAF Communauté Financière Africaine BEAC Franc XOF Communauté Financière Africaine BCEAO Franc KMF Comoros, Franc XPF Comptoirs Français du Pacifique Franc XAF Congo/Brazzaville, CFA Franc BEAC CDF Congo/Kinshasa, Franc NZD Cook Islands, New Zealand Dollar AUD Coral Sea Islands, Australia Dollar CRC Costa Rica, Colon XOF Côte d'Ivoire, CFA Franc BCEAO HRK Croatia, Kuna CUC Cuba, Convertible Peso CUP Cuba, Peso ANG Curaço, Netherlands Antilles Guilder CYP Cyprus, Pound CZK Czech Republic, Koruna DKK Denmark, Krone DJF Djibouti, Franc XCD Dominica, East Caribbean Dollar DOP Dominican Republic, Peso EUR Dutch (Netherlands), Euro NLG Dutch (Netherlands), Guilder [obsolete] XCD East Caribbean Dollar USD East Timor, United States Dollar USD Ecuador, United States Dollar EGP Egypt, Pound SVC El Salvador, Colon GBP England (United Kingdom), Pound XAF Equatorial Guinea, CFA Franc BEAC ERN Eritrea, Nakfa EEK Estonia, Kroon ETB Ethiopia, Birr EUR Euro EUR Europa Island, Euro FKP Falkland Islands, Pound DKK Faroe Islands, Denmark Krone FJD Fiji, Dollar EUR Finland, Euro FIM Finland, Markka [obsolete] EUR France, Euro FRF France, Franc [obsolete] EUR French Guiana, Euro XPF French Polynesia, Comptoirs Français du Pacifique Franc EUR French Polynesia, Euro EUR French Southern and Antarctic Lands, Euro XAF Gabon, CFA Franc BEAC GMD Gambia, Dalasi ILS Gaza Strip, Israel New Shekel GEL Georgia, Lari DEM Germany, Deutsche Mark [obsolete] EUR Germany, Euro GHC Ghana, Cedi GIP Gibraltar, Pound XAU Gold Ounce GBP Great Britain (United Kingdom), Pound EUR Greece, Euro GRD Greece, Drachma [obsolete] DKK Greenland, Denmark Krone XCD Grenada, East Caribbean Dollar EUR Guadeloupe, Euro USD Guam, United States Dollar GTQ Guatemala, Quetzal GGP Guernsey, Pound GNF Guinea, Franc XOF Guinea-Bissau, CFA Franc BCEAO GYD Guyana, Dollar HTG Haiti, Gourde EUR Holland (Netherlands), Euro NLG Holland (Netherlands), Guilder [obsolete] EUR Holy See (Vatican City), Euro VAL Holy See (Vatican City), Lira [obsolete] HNL Honduras, Lempira HKD Hong Kong, Dollar HUF Hungary, Forint ISK Iceland, Krona INR India, Rupee IDR Indonesia, Rupiah XDR International Monetary Fund Special Drawing Right IRR Iran, Rial IQD Iraq, Dinar EUR Ireland, Euro IEP Ireland, Pound [obsolete] FKP Islas Malvinas (Falkland Islands), Pound IMP Isle of Man, Pound ILS Israel, New Shekel EUR Italy, Euro ITL Italy, Lira [obsolete] XOF Ivory Coast (Côte d'Ivoire), CFA Franc BCEAO JMD Jamaica, Dollar JPY Japan, Yen JEP Jersey, Pound USD Johnson, United States Dollar JOD Jordan, Dinar EUR Juan de Nova, Euro KZT Kazakhstan, Tenge KES Kenya, Shilling AUD Kiribati, Australia Dollar KWD Kuwait, Dinar KGS Kyrgyzstan, Som LAK Laos, Kip LVL Latvia, Lat LBP Lebanon, Pound LSL Lesotho, Loti LRD Liberia, Dollar LYD Libya, Dinar CHF Liechtenstein, Switzerland Franc LTL Lithuania, Litas EUR Luxembourg, Euro LUF Luxembourg, Franc [obsolete] MOP Macau, Pataca MKD Macedonia, Denar MGA Madagascar, Ariary MGF Madagascar, Franc [obsolete] EUR Madeira Islands, Euro MWK Malawi, Kwacha MYR Malaysia, Ringgit MVR Maldives, Rufiyaa XOF Mali, CFA Franc BCEAO MTL Malta, Lira FKP Malvinas (Falkland Islands), Pound USD Marshall Islands, United States Dollar EUR Martinique, Euro MRO Mauritania, Ouguiya MUR Mauritius, Rupee EUR Mayotte, Euro MXN Mexico, Peso USD Micronesia, United States Dollar USD Midway Islands, United States Dollar MDL Moldova, Leu EUR Monaco, Euro MNT Mongolia, Tughrik EUR Montenegro, Euro XCD Montserrat, East Caribbean Dollar MAD Morocco, Dirham MZM Mozambique, Metical MMK Myanmar (Burma), Kyat NAD Namibia, Dollar AUD Nauru, Australia Dollar HTG Navassa, Haiti Gourde USD Navassa, United States Dollar CNY Nepal, China Yuan Renminbi NPR Nepal, Rupee ANG Netherlands Antilles, Guilder EUR Netherlands, Euro NLG Netherlands, Guilder [obsolete] XPF New Caledonia, Comptoirs Français du Pacifique Franc NZD New Zealand, Dollar NIO Nicaragua, Cordoba XOF Niger, CFA Franc BCEAO NGN Nigeria, Naira NZD Niue, New Zealand Dollar AUD Norfolk Island, Australia Dollar KPW North Korea, Won USD Northern Mariana Islands, United States Dollar NOK Norway, Krone OMR Oman, Rial PKR Pakistan, Rupee USD Palau, United States Dollar XPD Palladium Ounce PAB Panama, Balboa USD Panama, United States Dollar PGK Papua New Guinea, Kina CNY Paracel Islands, China Yuan Renminbi VND Paracel Islands, Vietnam Dong PYG Paraguay, Guarani PEN Peru, Nuevo Sol PHP Philippines, Peso NZD Pitcairn, New Zealand Dollar XPT Platinum Ounce PLN Poland, Zloty EUR Portugal, Euro PTE Portugal, Escudo [obsolete] USD Puerto Rico, United States Dollar QAR Qatar, Riyal EUR Reunion, Euro ROL Romania, Leu RUB Russia, Ruble RWF Rwanda, Franc ANG Saba, Netherlands Antilles Guilder SHP Saint Helena, Pound XCD Saint Kitts and Nevis, East Caribbean Dollar XCD Saint Lucia, East Caribbean Dollar EUR Saint Pierre and Miquelon, Euro XCD Saint Vincent and The Grenadines, East Caribbean Dollar EUR Saint-Martin, Euro WST Samoa, Tala EUR San Marino, Euro STD São Tome and Principe, Dobra SAR Saudi Arabia, Riyal GBP Scotland (United Kingdom), Pound SPL Seborga, Luigino XOF Senegal, CFA Franc BCEAO CSD Serbia, Dinar SCR Seychelles, Rupee SLL Sierra Leone, Leone XAG Silver Ounce SGD Singapore, Dollar ANG Sint Eustatius, Netherlands Antilles Guilder ANG Sint Maarten, Netherlands Antilles Guilder SKK Slovakia, Koruna SIT Slovenia, Tolar SBD Solomon Islands, Dollar SOS Somalia, Shilling ZAR South Africa, Rand GBP South Georgia, United Kingdom Pound KRW South Korea, Won GBP South Sandwich Islands, United Kingdom Pound EUR Spain, Euro ESP Spain, Peseta [obsolete] LKR Sri Lanka, Rupee SDD Sudan, Dinar SRD Suriname, Dollar SRG Suriname, Guilder NOK Svalbard and Jan Mayen, Norway Krone SZL Swaziland, Lilangeni ZAR Swaziland, South Africa Rand SEK Sweden, Krona CHF Switzerland, Franc SYP Syria, Pound TWD Taiwan, New Dollar TJS Tajikistan, Somoni RUB Tajikistan, Russia Ruble TZS Tanzania, Shilling THB Thailand, Baht XOF Togo, CFA Franc BCEAO NZD Tokelau, New Zealand Dollar TOP Tonga, Pa'anga MDL Transnistria, Moldova Leu TTD Trinidad and Tobago, Dollar TND Tunisia, Dinar TRY Turkey, New Lira TRL Turkey, Lira TMM Turkmenistan, Manat USD Turks and Caicos Islands, United States Dollar AUD Tuvalu, Australia Dollar TVD Tuvalu, Dollar UGX Uganda, Shilling UAH Ukraine, Hryvna AED United Arab Emirates, Dirham GBP United Kingdom, Pound USD United States, Dollar UYU Uruguay, Peso UZS Uzbekistan, Som VUV Vanuatu, Vatu EUR Vatican City, Euro VAL Vatican City, Lira [obsolete] VEB Venezuela, Bolivar VND Vietnam, Dong USD Virgin Islands, United States Dollar USD Wake Island, United States Dollar XPF Wallis and Futuna Islands, Comptoirs Français du Pacifique Franc ILS West Bank, Israel New Shekel JOD West Bank, Jordan Dinar MAD Western Sahara, Morocco Dirham WST Western Samoa (Samoa), Tala YER Yemen, Rial ZMK Zambia, Kwacha ZWD Zimbabwe, Dollar EOT } w3_config_hook () { def SURFRAW_currency_from USD def SURFRAW_currency_to EUR } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Convert currencies with the Universal Currency Converter (www.xe.net/ucc) Local options: -l List all known currency symbols. -from=SYM Symbol for currency to convert from. Default: $SURFRAW_currency_from Environment: SURFRAW_currency_from -to=SYM Symbol for currency to convert to. Default: $SURFRAW_currency_to Environment: SURFRAW_currency_to Example currency symbols: EUR (Euro), USD (US Dollars), GBP (UK Pounds), CAD (Canada Dollars), AUD (Australia Dollars), JPY (Japan Yen), INR (India Rupees), NZD (New Zealand Dollars), CHF (Switzerland Francs), ZAR (South Africa Rand) EOF w3_global_usage } mkopts l from= to= w3_complete_hook_opt () { local opt="$1" case "$opt" in -from=*|-to=*) list_currency_symbols | cut -f1 ;; *) return 1 ;; esac } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -from=*) setopt SURFRAW_currency_from $optarg ;; -to=*) setopt SURFRAW_currency_to $optarg ;; -l) list_currency_symbols; exit 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.xe.com/currencyconverter/" else escaped_args=$(w3_url_of_arg $w3_args) - w3_browse_url "http://www.xe.com/currencyconverter/Amount=${escaped_args}&From=${SURFRAW_currency_from}&To=${SURFRAW_currency_to}&submit=Perform+Currency+Conversion" + w3_browse_url "http://www.xe.com/currencyconverter/convert/?Amount=${escaped_args}&From=${SURFRAW_currency_from}&To=${SURFRAW_currency_to}&submit=Perform+Currency+Conversion" fi
JNRowe/surfraw
6b05db36a5f39b45a65a17802dff7fd14e858414
elvi: add elvi for doc.rust-lang.org
diff --git a/AUTHORS b/AUTHORS index d8ff268..28b3aaa 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,180 +1,183 @@ AUTHORS Julian Assange <[email protected]> original author Christian Surchi <[email protected]> original debian maintainer elvi: debcontents, debbugs, debpackages Ian Beckwith <[email protected]> current debian maintainer elvi: alioth, bbcnews, bugzilla, deblists, freedb, imdb, scpan, codesearch, debwiki, lastfm, musicbrainz, opensearch, scholar, ctan, fsfdir, gutenberg, wayback, dmoz, w3html, w3link, w3css, w3rdf, debpts, rfc, lsm, finkpkg, rpmsearch, macports, debpkghome, debvcsbrowse, scroogle, scirus, scitopia, worldwidescience, debcodesearch, jquery, mdn, mysqldoc, pgdoc, oraclesearch, S, yacy, gmane plus various tweaks/bugfixes/features. Moritz Muehlenhoff <[email protected]> elvi: debsec, ebay, leodict, wikipedia, sharereactor, pgpkeys, happypenguin plus various patches/maintenance. Thomas Smith <[email protected]> Bugfixes, uploading. Stephen Stafford <[email protected]> Bug fixes Kevin Kreamer <[email protected]> Bug fixes Christian Weisgerber <[email protected]> elvi: fast, thesaurus, webster Jason Harris <[email protected]> elvi: freebsd, openbsd, filesearching, ftpfind Ruben Pollan <[email protected]> elvi: rae Ian Broadfoot <[email protected]> elvi: yubnub James Rowe <[email protected]> plus useful patches/maintenance. Aparna Jaitly <[email protected]> elvi: ixquick Justin B. Rye <[email protected]> elvi: cia, deblogs, etym, foldoc plus useful patches. Patroklos Argyroudis <[email protected]> elvi: discogs Simon Ernst <[email protected]> elvi: archpkg Ivy Foster <[email protected]> elvi: bookfinder, bugmenot plus various patches/maintenance Sumant Oemrawsingh <[email protected]> elvi: cliki, l1sp, mathworth, mininova, youtube plus patches, including the uzbl examples. Sadako <[email protected]> imdb fixes tczy <[email protected]> elvi: bing Simone Fittabile <[email protected]> elvi: acronym, gcache, jamendo plus patches. Micah Anderson <[email protected]> various patches René Reigel <[email protected]> elvi: aur J.R. Mauro <[email protected]> elvi: urban, piratebay, genportage Wim van Hoydonck <[email protected]> elvi: ntrs, springer, sc John Briggs <[email protected]> patch to google John Gruenenfelder <[email protected]> elvi: arxiv csh patch James TD Smith <[email protected]> elvi: javasun google country-specific options Charles Twardy <[email protected]> fixed cia Uspenskiy Andrey <[email protected]> elvi: yandex Jameson Rollins <[email protected]> elvi: ads plus tweaks. Jakob <[email protected]> elvi: pasearch Kyle Isom <[email protected]> elvi: cablesearch, duckduckgo, openports, wolfram plus various fixes/maintenance. Jason Ryan <[email protected]> elvi: archwiki, deli, github, stack, pin plus various fixes/maintenance Sara Fauzia <[email protected]> archpkg fix. Thomas Zervogiannis <[email protected]> Searchable bookmarks. Paulo Almeida <[email protected]> elvi: priberam Shain Singh <[email protected]> elvi: cisco, f5 Manolo Martínez <[email protected]> examples: elinks integration (hooks.lua) Jon Yamokoski <[email protected]> elvi: phpdoc Lucas Hoffmann <l-m-h at web.de> elvi: commandlinefu ng0 <[email protected]> elvi: searx Gabriel Lisaca <[email protected]> elvis-specific (bash) completions package name completions more consistent surfraw script and bash completions plus various tweaks/bugfixes/features. Sascha <[email protected]> Bug fixes +Thomas Böhler <[email protected]> + elvi: add elvi for doc.rust-lang.org + THANKS TO Brian Nelson <[email protected]> Christian Garbs <[email protected]> Hector Blanco <[email protected]> Jeff Bailey <[email protected]> Mark W. Eichin <[email protected]> Teófilo Ruiz Suárez <[email protected]> Maru Dubshinki <[email protected]> Matt Kraai <[email protected]> Brian Mcdonald <[email protected]> Carl Fredrik Hammar <[email protected]> Andy Valencia <[email protected]> Philip Armstrong <[email protected]> Dan Jacobson <[email protected]> Sunil Nimmagadda <[email protected]> Michel <[email protected]> Nikos Apostolakis <[email protected]> Facundo Aguirre <[email protected]> Raphael Geissert <[email protected]> If we've missed anyone, let us know. diff --git a/ChangeLog b/ChangeLog index c63900b..2a89843 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,512 +1,516 @@ +2024-01-28 Thomas Böhler <[email protected]> + + * elvi: add elvi for doc.rust-lang.org + 2021-11-08 Gabriel Lisaca <[email protected]> * Remove fallback for graphical remotes: it doesn't work with exec * Actually use browser args if not none with graphical remotes 2021-06-14 Gabriel Lisaca <[email protected]> * Add elvis-specific completions support, with package name completions: - In addition to apt-cache, package name completions also come from pacman, yum, and fink if available, with only one package manager used as the source. - archpkg, genportage, debpkghome: now support package name completions just like debpackages, fsfdir, and co. - finkpkg: package name completions with -pkg= * google: allow -country= in addition to -c= to match docs * musicbrainz: sync help text with code * aur: remove categories support since it's dead code (see #14) * finkpkg: update values of -dist= and -section= * debbugs: update available tags 2021-02-24 Gabriel Lisaca <[email protected]> * opensearch-discover, opensearch-genquery: support HTTPS: tries HTTPS and then HTTP if no URL scheme in input * etym: update for HTTPS 2021-02-16 Gabriel Lisaca <[email protected]> * ebay: update URLS Support for the Indian eBay site was removed because it redirects to https://sellglobal.ebay.in/seller-central/seller-benefits/ 2020-12-23 Sascha <[email protected]> * Fix - test: too many arguments 2020-08-15 Dmitry Bogatov <[email protected]> * debbugs: add support for usertags search 2020-03-08 Gabriel Lisaca <[email protected]> * Use datadir and `sr` when installing bash completions: allows completions to be loaded on demand * Re-allow bash completions to be installed when building from source 2020-02-04 B. Wilson <[email protected]> * Launch browser with exec 2019-12-31 Gabriel Lisaca <[email protected]> * Uniformly handle options before and after elvis determined: surfraw -version now works the same as surfraw elvis -version 2019-12-14 Gabriel Lisaca <[email protected]> * Bash-complete local and global bookmarks: surfraw and completions now agree on what counts as bookmarks * Allow spaces in second arg of {setopt,def}{yn,}: allows elvi to have option-arguments with embedded spaces 2019-09-20 Gabriel Lisaca <[email protected]> * Bash-complete local elvi names: uses surfraw to get elvi names for consistency 2018-10-09 Dmitry Bogatov <[email protected]> * new elvi: dockerhub 2018-01-13 Jason Ryan <[email protected]> * Bump version to 2.3.0 * Select Perl version at buildtime (Mark Meyer) * Remove lynx-cur (closes #882286) * Packages the https elvi 2017-06-07 Jason Ryan <[email protected]> * new elvi: wiktionary 2017-07-14 Jason Ryan <[email protected]> * Moved all elvi to https * Removed elvi that don't support https: - cablesearch - dmoz - openports - opensearch - pasearch - rhyme - rpmsearch - scicom - scirus - wetandwild - yacy - yubnub 2015-09-13 Kyle Isom <[email protected]> * use awk instead of sed for listing elvi This provides better cross-platform behaviour. 2015-08-23 Jason Ryan <[email protected]> * new elvi: searx 2014-09-20 Lucas Hoffmann <l-m-h at web.de> * new elvi: commandlinefu 2104-06-04 Jason Ryan <[email protected]> * new elvi: nlab 2013-12-10 Ian Beckwith <[email protected]> * yandex: disabled test: redirects to captcha when used with LWP. * Fix make distcheck: remove last traces of codesearch and scitopia. 2013-12-09 Ian Beckwith <[email protected]> * deja: disable tests, google groups now requires javascript. * gmane: fix test. * codesearch: removed, service shut down. * scitopia: removed, service shut down. * scicom: down, status unknown, made note in NEWS. 2013-12-08 Ian Beckwith <[email protected]> * new elvi: gmane * openbsd -mail: use gmane (directly, not via gmane elvi) * fix tests: ads, pgdoc, pin, yacy 2013-10-27 Ian Beckwith <[email protected]> * surfraw.IN: w3_custom_search_google: don't give full path to surfraw. * pgdoc, wayback: fixed tests. 2013-10-20 Ian Beckwith <[email protected]> * new elvi: yacy: search using yacy p2p search. -S searches ScienceNet, a yacy-based science search engine. * rae: fix url, remove -tipo option (no longer supported), disable test as there is now gratuitous javascript. 2013-10-06 Ian Beckwith <[email protected]> * Replaced phpdoc with version posted back in 2011 by Jon Yamokoski <[email protected]> Thanks, and apologies for missing it! * S: add test. * Include debian packaging in upstream tarball. 2013-10-05 Ian Beckwith <[email protected]> * ask, cisco: fix elvi. * new elvi: + oraclesearch - Replaces removed sunonesearch <sigh>. + S - search using w3_custom_search. * google: -g for groups clashed with -g for graphical browser. Invoke groups with -G, -gr, -groups or -search=groups. * mdn: site invokes google custom search via gratuitous javascript, so switch to w3_custom_search. * alioth: changed test to SKIP:, works OK but won't talk to LWP, hence test breaks. * discogs, openbsd: fixed tests. * mdn, mysqldoc, pgdoc, phpdoc: added tests. * w3_custom_search: + document in README. + remove documentation for ixquick support. It still works(ish), but doesn't support enough features to support (eg) mysqldoc -v=. + add -custom-search= commandline option. * updated copyright years to 2013. 2013-09-30 Ian Beckwith <[email protected]> * new elvi: mdn, mysqldoc, pgdoc, phpdoc * new function: w3_custom_search Is used by elvi that use a generic search engine with (eg) site: or inurl: to narrow down the search. Pass it -s=site -u=url for site: and inurl: args plus the quoted search args * new environment variable: SURFRAW_customsearch_provider to set provider used by w3_custom_search can be set to: google, duckduckgo or ixquick. Currently affects: mysqldoc, netbsd(*), openbsd(*), pgdoc, phpdoc, mysqldoc. (*) = only used by some options of elvi. * new internal variable w3_shquoted_args, contains arguments 'quoted' 'like this' for passing to w3_custom_search * Fixed url-encoding for '\' 2013-05-07 Ian Beckwith <[email protected]> * new elvi: jquery 2013-05-04 Ian Beckwith <[email protected]> * bump version to 2.2.9 * rae: fixed, at least as far as the test passing. Could really do with some love from someone who actually speaks spanish. * ctan: fixed search, updated options. Note command-line options have changed. * genportage: switch to gpo.zugaina.org * debcodesearch: new (trivial) elvi for codesearch.debian.net * jamendo: fix url, disable test (search now javascript) * deli: fix url; remove options; disable test (search now javascript) 2013-04-28 Ian Beckwith <[email protected]> * musicbrainz: fixed mbid search. * springer: fixed test. 2013-04-27 Ian Beckwith <[email protected]> * javasun: fixed test. 2013-04-24 Ian Beckwith <[email protected]> * Rewrote deblists for new xapian search. + -author, -lists, -lang no longer supported. + added -ml and -mv to show message id links and list view. * Removed happypenguin. Currently defunct and they are talking about a rewrite, so when it is back it will need fixing anyway. 2012-10-22 Ian Beckwith <[email protected]> * Fixed elvi: cisco, slashdot, slinuxdoc. * Removed elvi: scroogle (site gone). * Fixed tests: acronym, bbcnews, bugzilla, cisco, cite[1], currency, discogs, excite, fsfdir, gcache, github, imdb, ixquick, lastfm, leodict, openbsd[2], scholar. * test/Makefile.am: Added missing tests to EXTRA_DIST 2012-06-28 Manolo Martínez <[email protected]> * examples/hooks.lua: Added elinks integration script 2012-06-28 Ivy Foster <[email protected]> * Further simplified searchable bookmarks 2012-06-28 Thomas Zervogiannis <[email protected]> * Simplified searchable bookmarks 2012-06-27 Ivy Foster <[email protected]> * Fixed arg parsing in searchable bookmarks * New variable: SURFRAW_bookmark_search_elvis + When using searchable bookmarks, if all else fails run this elvis. Defaults to google * Updated manual to reflect changes to bookmarks * duckduckgo: Removed -p option. -safe still works. + Prevents clobbering global option -p[rint]. 2012-06-27 Thomas Zervogiannis <[email protected]> * Added searchable bookmarks + Bookmarks can now be searchable by adding '%s' to the url string. 2012-06-01 Jason Ryan <[email protected]> * New elvi: github (search github.com) 2012-03-17 Ivy Foster <[email protected]> * Fix a typo in duckduckgo code. 2012-03-17 Ivy Foster <[email protected]> * Keep duckduckgo's -l[ucky] from clobbering -lh 2012-01-10 Ivy Foster <[email protected]> * aur: now uses HTTPS by default + On the AUR, connecting via HTTP disables login. + Added switch -no-https to enable connection via plain HTTP 2011-10-10 Ian Beckwith <[email protected]> * surfraw.IN: test_elvi(): tweak sed regex * add tests for f5, cisco and pin. 2011-10-10 Shain Singh <[email protected]> * New elvi: f5, cisco 2011-10-10 Jason Ryan <[email protected]> * New elvi: pin (search pinboard.in). 2011-09-09 Kyle Isom <[email protected]> * New elvi: wolfram - query Wolfram Alpha * Author: Kyle Isom <[email protected]> * Added test for wolfram. 2011-08-09 Ian Beckwith <[email protected]> * New elvi: priberam - search Portuguese dictionary. Author: Paulo Almeida <[email protected]> * Added test for priberam. 2011-07-11 Ian Beckwith <[email protected]> * netbsd: fix normal & mail search. google custom searches were complaining I was a bot, so I switched to normal google searches with site:{mail-index,}.netbsd.org. * cia: fix search URL 2011-06-17 Ian Beckwith <[email protected]> * arxiv: fix -scope=author with single-word queries. Thanks to Nikos Apostolakis. * btw, note about entry below, netbsd make *does* support '$<', but only in suffix rules. 2011-06-16 Ian Beckwith <[email protected]> * Fix more make(1) portability problems. Either I am horribly confused or netbsd make (or at least pmake in debian) doesn't support '$<'. Switched to '$?'. * Also switched submit-lsm rule to '$?'. Thanks to Kyle Isom. * Removed long-obsolete commented-out sourceforge upload rules. 2011-06-15 Ian Beckwith <[email protected]> * scitopia, worldwidescience: fixed URLs. * Fixed make portability problems. We cannot portably combine single suffix rules (foo.IN->foo) and separated dependencies so we have to explicitly specify all the .IN rules. The solution we used for this until now was specific to GNU make. * Removed Makefile.include, no longer used. * './configure --enable-opensearch' now only controls installation of the (direct) dependencies for opensearch, not opensearch itself, as opensearch now falls back to using a remote reflector if opensearch-discover(1) and opensearch-genquery(1) aren't found. * yandex: fix test. 2011-06-14 Ian Beckwith <[email protected]> * musicbrainz, codesearch, rpmsearch: Fixed URLs, options and tests. The sites have all changed significantly which means both new options and no-longer-supported options. Codesearch has gone all ajaxy, so I've implemented the options via the search string, e.g. adding " package:foo". Disabled codesearch.test, as it now needs javascript. Codesearch on both google.com and google.co.uk was acting up, so I've pointed it at google.fr. * Removed filesearching elvi, it now requires a 'Referer:' header to work. There is no browser-portable way to specify a 'Refer[r]er:' header, plus we should probably take it as a hint. * Tweaked debian packaging. * Updated NEWS. 2011-06-13 Ian Beckwith <[email protected]> * w3link: fixed URLs. 2011-06-10 Ian Beckwith <[email protected]> * Fixed ctan. Option -doc has been replaced by -id. Options are no longer mutually exclusive, you can now do (eg) ctan -d -i -n texlive. 2011-06-09 Ian Beckwith <[email protected]> * fixed tests: debwiki, ntrs, wayback. 2011-06-07 Ian Beckwith <[email protected]> * Default to surfraw_graphical_remote=no, as chromium doesn't support "-remote openURL". 2011-05-31 Jason Ryan <[email protected]> * Add options to archpkg. 2011-05-12 Sara Fauzia <[email protected]> * Fix archpkg URL. 2011-05-12 Ian Beckwith <[email protected]> * surfraw.IN: + if elvi doesn't exist, send usage to stderr not stdout. + bookmark names: do exact match not substring match. * Added tests for archwiki, deli & stack. * README: + added INTEGRATION section on uzbl and pentadactyl. + upcased section headings for clarity. 2011-05-12 Jason Ryan <[email protected]> * New elvi: + archwiki: search the arch wiki. + deli: search delicious.com. + stack: search stackoverflow.com and friends. 2011-03-21 Ian Beckwith <[email protected]> * google: Added -safe=default|off|moderate|strict option for Safe Search. 2011-03-21 Ivy Foster <[email protected]> * Added Google Translate to elvi/translate. 2011-03-03 Ian Beckwith <[email protected]> * opensearch: new option -r, uses redirector at http://erislabs.net/ianb/webtools/opensearch/ instead of calling opensearch-discover and opensearch-genquery. -r is selected automatically if those tools are not installed. This enables us to ship opensearch in the main surfraw package and it still functions if the dependencies are not installed. See debian/changelog. * wikipedia: new options: + -d, uses a redirector at http://erislabs.net/ianb/webtools/wpdp/ This redirector searches for a page with that name at wikipedia. If not found, it searches deletionpedia, if not found there it falls back to a normal wikipedia search. + -f=w|d, -fallback=wikipedia|deletionpedia Implies -d. If page not found at either wikipedia or deletionpedia, whether to fallback to wikipedia search or deletionpedia search. * google: + support video, maps and news. + new options -i, -v, -m, -n, shortcuts for -search={images,videos,maps,news}. * debcontents, debpackages: update docs for new arches and distributions. * bugzilla: + fix url so it works with redhat & eclipse bugzillas too. + enable -s=redhat. * ixquick, w3css: fix tests. * opensearch, wikipedia: add redirector tests. 2011-02-20 Ian Beckwith <[email protected]> * New elvi: bugzilla - searches various bugzillas, defaults to kernel. * pgpkeys: add more options, support more keyservers, default to sks-keyservers.net. * bump version to 2.2.8. * test/Makefile.am: add cablesearch.test. 2011-02-19 Ian Beckwith <[email protected]> * lastfm: fix url to avoid a redirect that mangled args with spaces. * debbugs: add -s as an alias for -search=src. * surfraw.IN: (finally) update copyright year to 2011. * remove traces of port elvi from build system. 2011-02-09 Kyle Isom <[email protected]> * fix a number of tests to match current site formats 2011-01-12 Kyle Isom <[email protected]> * New elvi: + cablesearch - search wikileaks cables + duckduckgo - replace with better implementation + openports - search openbsd ports 2010-12-04 Jakob <[email protected]> * new elvis: pasearch. 2010-12-08 Ian Beckwith <[email protected]> * arxiv: Thanks to MT <[email protected]> for patch that fixes: 1. Search queries with more than two terms would fail, e.g. 'supermassive black hole'. 2. Full text search was broken, it works now. 3. Enhancement: quoting the query now does an exact string match. 2010-10-29 Ian Beckwith <[email protected]> * wayback: advanced search is broken, rip out all options and use basic search. * w3_url_escape: add /g to '/'->'%2F' replacement. * uzbl_load_url_from_surfraw: use @AWK@ to pick up ./configure's choice of awk implementation. 2010-10-28 Ian Beckwith <[email protected]> * Support -local-help, --local-help or -lh to get elvi-specific help without displaying the global options. This works for all elvi and the main surfraw script. * google, duckduckgo, opensearch, wayback: tweak overbroad option parsing so it doesn't interfere with -lh. * Support -h as a synonym for -help. 2010-10-25 Ian Beckwith <[email protected]> diff --git a/README b/README index ba842b3..fd9d300 100644 --- a/README +++ b/README @@ -1,346 +1,347 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Home Page: https://gitlab.com/surfraw/Surfraw ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web New: https://gitlab.com/surfraw/Surfraw Old: http://surfraw.alioth.debian.org Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS Surfraw now supports bookmarks. To add a bookmark, add it to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/stack -u -s=vote shell OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) discogs -- Search the Discogs database of music information (www.discogs.com) dockerhub -- Search for Docker images (https://hub.docker.com) duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) oraclesearch -- Search an OpenSearch-enabled website pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) +rustdocs -- Search doc.rust-lang.org scholar -- Search Google Scholar (scholar.google.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) wikipedia -- Search the free encyclopedia wikipedia wiktionary -- Search the free multilingual dictionary (wiktionary.org) woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) All elvi have useful low calorie help, for example: sr bbcnews -help Usage: bbcnews [options] [search words]... Description: Surfraw search BBC News (news.bbc.co.uk) Local options: -scope=world | uk Search world or uk news Default: world Environment: SURFRAW_bbcnews_scope If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________ diff --git a/elvi/Makefile.am b/elvi/Makefile.am index 95e244c..e2b49fd 100644 --- a/elvi/Makefile.am +++ b/elvi/Makefile.am @@ -1,122 +1,123 @@ # $Id$ elvidir=$(ELVIDIR) dist_elvi_SCRIPTS = \ S \ W \ acronym \ ads \ alioth \ amazon \ archpkg \ archwiki \ arxiv \ ask \ aur \ austlii \ bing \ bbcnews \ bookfinder \ bugmenot \ bugzilla \ cia \ cisco \ cite \ cliki \ cnn \ comlaw \ commandlinefu \ ctan \ currency \ cve \ debbugs \ debcodesearch \ debcontents \ deblists \ deblogs \ debpackages \ debpkghome \ debpts \ debsec \ debvcsbrowse \ debwiki \ deja \ discogs \ dockerhub \ duckduckgo \ ebay \ etym \ excite \ f5 \ foldoc \ finkpkg \ freebsd \ freedb \ freshmeat \ fsfdir \ gcache \ genbugs \ genportage \ github \ gmane \ google \ gutenberg \ imdb \ ixquick \ jamendo \ javasun \ jquery \ l1sp \ lastfm \ leodict \ lsm \ macports \ mathworld \ mdn \ mininova \ musicbrainz \ mysqldoc \ netbsd \ nlab \ ntrs \ openbsd \ oraclesearch \ pgdoc \ pgpkeys \ phpdoc \ pin \ piratebay \ priberam \ pubmed \ rae \ rfc \ + rustdocs \ scholar \ scpan \ searx \ slashdot \ slinuxdoc \ sourceforge \ springer \ stack \ stockquote \ thesaurus \ translate \ urban \ w3css \ w3html \ w3link \ w3rdf \ wayback \ webster \ wikipedia \ wiktionary \ woffle \ wolfram \ worldwidescience \ yahoo \ yahoofinance \ yandex \ youtube uninstall-local: -rmdir $(DESTDIR)$(PREFIX)/$(ELVIDIR) diff --git a/elvi/rustdocs b/elvi/rustdocs new file mode 100755 index 0000000..9583c11 --- /dev/null +++ b/elvi/rustdocs @@ -0,0 +1,30 @@ +#!/bin/sh +# +# AUTHOR: Thomas Böhler <[email protected]> +# +# DATE: Sun Jan 28 2024 +# +# DESC: Elvi to search doc.rust-lang.org +# elvis: rustdocs -- Search doc.rust-lang.org +. surfraw || exit 1 + +w3_usage_hook () { + cat <<EOF +Usage: $w3_argv0 [options] [search words]... +Description: + Search the Rust standard library on doc.rust-lang.org +EOF + w3_global_usage +} + +w3_config +w3_parse_args "$@" + +prefix="https://doc.rust-lang.org/std/index.html" + +if test -z "$w3_args"; then + w3_browse_url "$prefix" +else + escaped_args=`w3_url_of_arg $w3_args` + w3_browse_url "$prefix?search=${escaped_args}" +fi diff --git a/links.IN b/links.IN index 18c4911..f0b7694 100644 --- a/links.IN +++ b/links.IN @@ -1,109 +1,110 @@ elvi.1sr.gz @mandir@/man1/W.1.gz elvi.1sr.gz @mandir@/man1/S.1sr.gz elvi.1sr.gz @mandir@/man1/acronym.1sr.gz elvi.1sr.gz @mandir@/man1/ads.1sr.gz elvi.1sr.gz @mandir@/man1/alioth.1sr.gz elvi.1sr.gz @mandir@/man1/amazon.1sr.gz elvi.1sr.gz @mandir@/man1/archpkg.1sr.gz elvi.1sr.gz @mandir@/man1/archwiki.1sr.gz elvi.1sr.gz @mandir@/man1/arxiv.1sr.gz elvi.1sr.gz @mandir@/man1/ask.1sr.gz elvi.1sr.gz @mandir@/man1/aur.1sr.gz elvi.1sr.gz @mandir@/man1/austlii.1sr.gz elvi.1sr.gz @mandir@/man1/bing.1sr.gz elvi.1sr.gz @mandir@/man1/bbcnews.1sr.gz elvi.1sr.gz @mandir@/man1/bookfinder.1sr.gz elvi.1sr.gz @mandir@/man1/bugmenot.1sr.gz elvi.1sr.gz @mandir@/man1/bugzilla.1sr.gz elvi.1sr.gz @mandir@/man1/cite.1sr.gz elvi.1sr.gz @mandir@/man1/cia.1sr.gz elvi.1sr.gz @mandir@/man1/cliki.1sr.gz elvi.1sr.gz @mandir@/man1/cnn.1sr.gz elvi.1sr.gz @mandir@/man1/comlaw.1sr.gz elvi.1sr.gz @mandir@/man1/commandlinefu.1sr.gz elvi.1sr.gz @mandir@/man1/ctan.1sr.gz elvi.1sr.gz @mandir@/man1/currency.1sr.gz elvi.1sr.gz @mandir@/man1/cve.1sr.gz elvi.1sr.gz @mandir@/man1/debbugs.1sr.gz elvi.1sr.gz @mandir@/man1/debcodesearch.1sr.gz elvi.1sr.gz @mandir@/man1/debcontents.1sr.gz elvi.1sr.gz @mandir@/man1/deblists.1sr.gz elvi.1sr.gz @mandir@/man1/deblogs.1sr.gz elvi.1sr.gz @mandir@/man1/debpackages.1sr.gz elvi.1sr.gz @mandir@/man1/debpkghome.1sr.gz elvi.1sr.gz @mandir@/man1/debpts.1sr.gz elvi.1sr.gz @mandir@/man1/debsec.1sr.gz elvi.1sr.gz @mandir@/man1/debvcsbrowse.1sr.gz elvi.1sr.gz @mandir@/man1/debwiki.1sr.gz elvi.1sr.gz @mandir@/man1/deja.1sr.gz elvi.1sr.gz @mandir@/man1/discogs.1sr.gz elvi.1sr.gz @mandir@/man1/duckduckgo.1sr.gz elvi.1sr.gz @mandir@/man1/dockerhub.1sr.gz elvi.1sr.gz @mandir@/man1/ebay.1sr.gz elvi.1sr.gz @mandir@/man1/etym.1sr.gz elvi.1sr.gz @mandir@/man1/excite.1sr.gz elvi.1sr.gz @mandir@/man1/finkpkg.1sr.gz elvi.1sr.gz @mandir@/man1/foldoc.1sr.gz elvi.1sr.gz @mandir@/man1/freebsd.1sr.gz elvi.1sr.gz @mandir@/man1/freedb.1sr.gz elvi.1sr.gz @mandir@/man1/freshmeat.1sr.gz elvi.1sr.gz @mandir@/man1/fsfdir.1sr.gz elvi.1sr.gz @mandir@/man1/gcache.1sr.gz elvi.1sr.gz @mandir@/man1/genbugs.1sr.gz elvi.1sr.gz @mandir@/man1/genportage.1sr.gz elvi.1sr.gz @mandir@/man1/github.1sr.gz elvi.1sr.gz @mandir@/man1/google.1sr.gz elvi.1sr.gz @mandir@/man1/gutenberg.1sr.gz elvi.1sr.gz @mandir@/man1/imdb.1sr.gz elvi.1sr.gz @mandir@/man1/ixquick.1sr.gz elvi.1sr.gz @mandir@/man1/jamendo.1sr.gz elvi.1sr.gz @mandir@/man1/javasun.1sr.gz elvi.1sr.gz @mandir@/man1/lastfm.1sr.gz elvi.1sr.gz @mandir@/man1/leodict.1sr.gz elvi.1sr.gz @mandir@/man1/l1sp.1sr.gz elvi.1sr.gz @mandir@/man1/lsm.1sr.gz elvi.1sr.gz @mandir@/man1/macports.1sr.gz elvi.1sr.gz @mandir@/man1/mathworld.1sr.gz elvi.1sr.gz @mandir@/man1/mdn.1sr.gz elvi.1sr.gz @mandir@/man1/mininova.1sr.gz elvi.1sr.gz @mandir@/man1/musicbrainz.1sr.gz elvi.1sr.gz @mandir@/man1/mysqldoc.1sr.gz elvi.1sr.gz @mandir@/man1/netbsd.1sr.gz elvi.1sr.gz @mandir@/man1/ntrs.1sr.gz elvi.1sr.gz @mandir@/man1/openbsd.1sr.gz elvi.1sr.gz @mandir@/man1/oraclesearch.1sr.gz elvi.1sr.gz @mandir@/man1/pgdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pgpkeys.1sr.gz elvi.1sr.gz @mandir@/man1/phpdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pin.1sr.gz elvi.1sr.gz @mandir@/man1/piratebay.1sr.gz elvi.1sr.gz @mandir@/man1/priberam.1sr.gz elvi.1sr.gz @mandir@/man1/pubmed.1sr.gz elvi.1sr.gz @mandir@/man1/rae.1sr.gz elvi.1sr.gz @mandir@/man1/rfc.1sr.gz +elvi.1sr.gz @mandir@/man1/rustdocs.1sr.gz elvi.1sr.gz @mandir@/man1/scholar.1sr.gz elvi.1sr.gz @mandir@/man1/scpan.1sr.gz elvi.1sr.gz @mandir@/man1/searx.1sr.gz elvi.1sr.gz @mandir@/man1/slashdot.1sr.gz elvi.1sr.gz @mandir@/man1/slinuxdoc.1sr.gz elvi.1sr.gz @mandir@/man1/sourceforge.1sr.gz elvi.1sr.gz @mandir@/man1/springer.1sr.gz elvi.1sr.gz @mandir@/man1/stack.1sr.gz elvi.1sr.gz @mandir@/man1/stockquote.1sr.gz elvi.1sr.gz @mandir@/man1/thesaurus.1sr.gz elvi.1sr.gz @mandir@/man1/translate.1sr.gz elvi.1sr.gz @mandir@/man1/urban.1sr.gz elvi.1sr.gz @mandir@/man1/w3css.1sr.gz elvi.1sr.gz @mandir@/man1/w3html.1sr.gz elvi.1sr.gz @mandir@/man1/w3link.1sr.gz elvi.1sr.gz @mandir@/man1/w3rdf.1sr.gz elvi.1sr.gz @mandir@/man1/wayback.1sr.gz elvi.1sr.gz @mandir@/man1/webster.1sr.gz elvi.1sr.gz @mandir@/man1/wikipedia.1sr.gz elvi.1sr.gz @mandir@/man1/wiktionary.1sr.gz elvi.1sr.gz @mandir@/man1/woffle.1sr.gz elvi.1sr.gz @mandir@/man1/wolfram.1sr.gz elvi.1sr.gz @mandir@/man1/worldwidescience.1sr.gz elvi.1sr.gz @mandir@/man1/yahoo.1sr.gz elvi.1sr.gz @mandir@/man1/yandex.1sr.gz elvi.1sr.gz @mandir@/man1/youtube.1sr.gz diff --git a/test/Makefile.am b/test/Makefile.am index e44454f..ce0cd79 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,31 +1,31 @@ EXTRA_DIST = runtests elviwithouttests README COOKIES W.test S.test \ acronym.test ads.test alioth.test amazon.test archpkg.test \ archwiki.test arxiv.test ask.test aur.test austlii.test \ bbcnews.test bing.test bookfinder.test bugmenot.test \ bugzilla.test cia.test cisco.test cite.test cliki.test cnn.test \ comlaw.test commandlinefu.test ctan.test currency.test cve.test \ debbugs.test debcodesearch.test debcontents.test deblists.test \ deblogs.test debpackages.test debpkghome.test debpts.test \ debsec.test debvcsbrowse.test debwiki.test deja.test discogs.test \ dockerhub.test duckduckgo.test ebay.test etym.test excite.test \ f5.test finkpkg.test foldoc.test freebsd.test freedb.test \ freshmeat.test fsfdir.test gcache.test genbugs.test genportage.test \ github.test gmane.test google.test gutenberg.test imdb.test \ ixquick.test jamendo.test javasun.test jquery.test lastfm.test \ leodict.test l1sp.test lsm.test macports.test mathworld.test \ mdn.test mininova.test musicbrainz.test mysqldoc.test netbsd.test \ nlab.test ntrs.test openbsd.test oraclesearch.test pgdoc.test \ phpdoc.test pin.test piratebay.test pgpkeys.test priberam.test \ - pubmed.test rae.test rfc.test scholar.test scpan.test searx.test \ - slashdot.test slinuxdoc.test sourceforge.test springer.test \ - stack.test stockquote.test thesaurus.test translate.test \ - urban.test w3css.test w3html.test w3link.test w3rdf.test \ - wayback.test webster.test wikipedia.test wiktionary.test \ + pubmed.test rae.test rfc.test rustdocs.test scholar.test scpan.test \ + searx.test slashdot.test slinuxdoc.test sourceforge.test \ + springer.test stack.test stockquote.test thesaurus.test \ + translate.test urban.test w3css.test w3html.test w3link.test \ + w3rdf.test wayback.test webster.test wikipedia.test wiktionary.test \ wolfram.test woffle.test worldwidescience.test yahoo.test \ yandex.test youtube.test test: ./runtests ./elviwithouttests diff --git a/test/rustdocs.test b/test/rustdocs.test new file mode 100644 index 0000000..b3baf61 --- /dev/null +++ b/test/rustdocs.test @@ -0,0 +1,4 @@ +rustdocs +The Rust Standard Library +rustdocs option +std::option::Option
JNRowe/surfraw
9cc0540cdbbe024a6f9d87a0f0bf0242cee4a5c6
AUTHORS: add new contributor
diff --git a/AUTHORS b/AUTHORS index d8ff268..aff89ae 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,180 +1,183 @@ AUTHORS Julian Assange <[email protected]> original author Christian Surchi <[email protected]> original debian maintainer elvi: debcontents, debbugs, debpackages Ian Beckwith <[email protected]> current debian maintainer elvi: alioth, bbcnews, bugzilla, deblists, freedb, imdb, scpan, codesearch, debwiki, lastfm, musicbrainz, opensearch, scholar, ctan, fsfdir, gutenberg, wayback, dmoz, w3html, w3link, w3css, w3rdf, debpts, rfc, lsm, finkpkg, rpmsearch, macports, debpkghome, debvcsbrowse, scroogle, scirus, scitopia, worldwidescience, debcodesearch, jquery, mdn, mysqldoc, pgdoc, oraclesearch, S, yacy, gmane plus various tweaks/bugfixes/features. Moritz Muehlenhoff <[email protected]> elvi: debsec, ebay, leodict, wikipedia, sharereactor, pgpkeys, happypenguin plus various patches/maintenance. Thomas Smith <[email protected]> Bugfixes, uploading. Stephen Stafford <[email protected]> Bug fixes Kevin Kreamer <[email protected]> Bug fixes Christian Weisgerber <[email protected]> elvi: fast, thesaurus, webster Jason Harris <[email protected]> elvi: freebsd, openbsd, filesearching, ftpfind Ruben Pollan <[email protected]> elvi: rae Ian Broadfoot <[email protected]> elvi: yubnub James Rowe <[email protected]> plus useful patches/maintenance. Aparna Jaitly <[email protected]> elvi: ixquick Justin B. Rye <[email protected]> elvi: cia, deblogs, etym, foldoc plus useful patches. Patroklos Argyroudis <[email protected]> elvi: discogs Simon Ernst <[email protected]> elvi: archpkg Ivy Foster <[email protected]> elvi: bookfinder, bugmenot plus various patches/maintenance Sumant Oemrawsingh <[email protected]> elvi: cliki, l1sp, mathworth, mininova, youtube plus patches, including the uzbl examples. Sadako <[email protected]> imdb fixes tczy <[email protected]> elvi: bing Simone Fittabile <[email protected]> elvi: acronym, gcache, jamendo plus patches. Micah Anderson <[email protected]> various patches René Reigel <[email protected]> elvi: aur J.R. Mauro <[email protected]> elvi: urban, piratebay, genportage Wim van Hoydonck <[email protected]> elvi: ntrs, springer, sc John Briggs <[email protected]> patch to google John Gruenenfelder <[email protected]> elvi: arxiv csh patch James TD Smith <[email protected]> elvi: javasun google country-specific options Charles Twardy <[email protected]> fixed cia Uspenskiy Andrey <[email protected]> elvi: yandex Jameson Rollins <[email protected]> elvi: ads plus tweaks. Jakob <[email protected]> elvi: pasearch Kyle Isom <[email protected]> elvi: cablesearch, duckduckgo, openports, wolfram plus various fixes/maintenance. Jason Ryan <[email protected]> elvi: archwiki, deli, github, stack, pin plus various fixes/maintenance Sara Fauzia <[email protected]> archpkg fix. Thomas Zervogiannis <[email protected]> Searchable bookmarks. Paulo Almeida <[email protected]> elvi: priberam Shain Singh <[email protected]> elvi: cisco, f5 Manolo Martínez <[email protected]> examples: elinks integration (hooks.lua) Jon Yamokoski <[email protected]> elvi: phpdoc Lucas Hoffmann <l-m-h at web.de> elvi: commandlinefu ng0 <[email protected]> elvi: searx Gabriel Lisaca <[email protected]> elvis-specific (bash) completions package name completions more consistent surfraw script and bash completions plus various tweaks/bugfixes/features. Sascha <[email protected]> Bug fixes +Thomas Böhler <[email protected]> + wikipedia: Fix search showing page instead + THANKS TO Brian Nelson <[email protected]> Christian Garbs <[email protected]> Hector Blanco <[email protected]> Jeff Bailey <[email protected]> Mark W. Eichin <[email protected]> Teófilo Ruiz Suárez <[email protected]> Maru Dubshinki <[email protected]> Matt Kraai <[email protected]> Brian Mcdonald <[email protected]> Carl Fredrik Hammar <[email protected]> Andy Valencia <[email protected]> Philip Armstrong <[email protected]> Dan Jacobson <[email protected]> Sunil Nimmagadda <[email protected]> Michel <[email protected]> Nikos Apostolakis <[email protected]> Facundo Aguirre <[email protected]> Raphael Geissert <[email protected]> If we've missed anyone, let us know.
JNRowe/surfraw
4953946bf4411e089762370c37f28507c302348a
wikipedia: Fix search showing page instead
diff --git a/elvi/wikipedia b/elvi/wikipedia index 2023d95..c50ade2 100755 --- a/elvi/wikipedia +++ b/elvi/wikipedia @@ -1,58 +1,58 @@ #!/bin/sh # elvis: wikipedia -- Search the free encyclopedia wikipedia # $Id$ # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_config_hook () { def SURFRAW_wikipedia_language "$SURFRAW_lang" defyn SURFRAW_wikipedia_deletionpedia no def SURFRAW_wikipedia_fallback wikipedia } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Wikipedia online encyclopedia Local options: -language=ISOCODE | -l=ISOCODE Two letter language code (resembles ISO country codes) Default: en Environment: SURFRAW_wikipedia_language, SURFRAW_lang Examples: $w3_argv0 -language=de Richard Stallman EOF w3_global_usage } mkopts language= w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_wikipedia_language $optarg ;; -l=*) setopt SURFRAW_wikipedia_language $optarg ;; *) return 1 ;; esac return 0 } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" if [ -z "$SURFRAW_wikipedia_language" ]; then SURFRAW_wikipedia_language="en" fi -prefix="https://${SURFRAW_wikipedia_language}.wikipedia.org/w/index.php?search=" +prefix="https://${SURFRAW_wikipedia_language}.wikipedia.org/w/index.php?title=Special:Search&search=" if null "$w3_args"; then w3_browse_url "https://${SURFRAW_wikipedia_language}.wikipedia.org/wiki/Main_Page" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${prefix}${escaped_args}" fi
JNRowe/surfraw
69f291dfb59613c44b9b14d746210f3ef368d495
ixquick: Use Startpage URL
diff --git a/elvi/ixquick b/elvi/ixquick index 06336fc..75322c4 100755 --- a/elvi/ixquick +++ b/elvi/ixquick @@ -1,107 +1,110 @@ #!/bin/sh # $Id$ -# elvis: ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) +# elvis: ixquick -- Search the web using startpage [HTTPS] (startpage.com) . surfraw || exit 1 w3_config_hook () { -def SURFRAW_ixquick_search 'do/metasearch.pl' +def SURFRAW_ixquick_search web def SURFRAW_ixquick_lang "$SURFRAW_lang" defyn SURFRAW_ixquick_ssl yes } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: - Surfraw search the web using Ixquick metasearch [HTTPS] (www.ixquick.com) + Surfraw search the web using Startpage (formerly Ixquick) metasearch [HTTPS] (startpage.com) Local options: -nossl Don't use https Environment: SURFRAW_ixquick_ssl -search= Specialized search on topic web | web pics | images Environment: SURFRAW_ixquick_search -lang= Language interface of ixquick english dansk deutsch espanol francais italiano nederlands norsk polski portugues suomi svenska turkce jiantizhongwen nihongo fantizhengwen hangul Default: english Environment: SURFRAW_ixquick_lang, SURFRAW_lang EOF w3_global_usage } mkopts nossl search= lang= w3_complete_hook_opt () { local opt="$1" case "$opt" in -search=*) echo web pics ;; -lang=*) echo english dansk deutsch espanol francais italiano nederlands norsk polski portugues suomi svenska turkce jiantizhongwen nihongo fantizhengwen hangul ;; *) return 1 ;; esac } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -no*) setoptyn SURFRAW_ixquick_ssl no ;; -search=*) setopt SURFRAW_ixquick_search $optarg ;; -lang=*) setopt SURFRAW_ixquick_lang $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if ifyes SURFRAW_ixquick_ssl then proto="https" else proto="http" fi # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "${proto}://www.ixquick.com/" else case "$SURFRAW_ixquick_lang" in en|english) SURFRAW_ixquick_lang="english" ;; dk|dansk) SURFRAW_ixquick_lang="dansk" ;; de|deutsch) SURFRAW_ixquick_lang="deutsch" ;; es|espanol) SURFRAW_ixquick_lang="espanol" ;; fr|francais) SURFRAW_ixquick_lang="francais" ;; it|italiano) SURFRAW_ixquick_lang="italiano" ;; nl|nederlands) SURFRAW_ixquick_lang="nederlands" ;; no|nb|nn|norsk) SURFRAW_ixquick_lang="norsk" ;; pl|polski) SURFRAW_ixquick_lang="polski" ;; pt|portugues) SURFRAW_ixquick_lang="portugues" ;; fi|suomi) SURFRAW_ixquick_lang="suomi" ;; sv|svenska) SURFRAW_ixquick_lang="svenska" ;; tr|turkce) SURFRAW_ixquick_lang="turkce" ;; cn|zh|jiantizhongwen) SURFRAW_ixquick_lang="jiantizhongwen" ;; ja|jp|nihongo) SURFRAW_ixquick_lang="nihongo" ;; zt|fantizhengwen) SURFRAW_ixquick_lang="fantizhengwen" ;; ko|kr|kp|hangul) SURFRAW_ixquick_lang="hangul" ;; *) SURFRAW_ixquick_lang="english" ;; esac + case "$SURFRAW_ixquick_search" in + pics) SURFRAW_ixquick_search=images ;; + esac escaped_args=$(w3_url_of_arg $w3_args) - w3_browse_url "${proto}://www.ixquick.com/do/metasearch.pl?cat=${SURFRAW_ixquick_search}&cmd=process_search&language=${SURFRAW_ixquick_lang}&query=${escaped_args}" + w3_browse_url "${proto}://startpage.com/sp/search?cat=${SURFRAW_ixquick_search}&language=${SURFRAW_ixquick_lang}&query=${escaped_args}" fi
JNRowe/surfraw
3f27d182b4a4c9c98feb68459604c4792651b737
Clarify why completion-related options aren't included in completions
diff --git a/surfraw.IN b/surfraw.IN index 894984f..8c5da39 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,825 +1,826 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 # $0 can be -bash when sourced for tab completions. # POSIX seems to assume `--` support. w3_argv0=$(basename -- "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default conf="@sysconfdir@/xdg/surfraw.$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value="\"\$${1}\"" case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value="\"\$${1}\"" # Do nothing if already have a value. test -z "$value" && eval ${1}="\"$2\"" return 0 } defyn () { def "$@" yesno "$1" } setopt () { eval value="\"\$${1}\"" eval ${1}="\"$2\"" } setoptyn () { setopt "$@" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } # Should only complete for specific options # Called before declared-options completions w3_complete_hook_opt () { return 1 } # Provide package-name completions # TODO: add more distro package managers w3_complete_packages () { if command -v apt-cache >/dev/null 2>&1 then apt-cache --generate pkgnames -- "$1" elif command -v pacman >/dev/null 2>&1 then # Do prefix searches like the others. # TODO: prevent accidental regex searching by users. # How often is this likely to occur though? pacman -Ssq "^$1" elif command -v yum >/dev/null 2>&1 then # Get plain name excluding arch (to match the others)--assuming names have no dots. yum list all -- "${1}*" | cut -d . -f 1 elif command -v fink >/dev/null 2>&1 then fink list -- "${1}*" | cut -f 2 else return 1 fi } # Completions for main surfraw script w3_complete_hook_opt_global () { local opt="$1" case "$opt" in -bookmark-search-elvis=*) cd "$(get_local_elvi_dir)" 2>/dev/null && echo * cd "$elvidir" && echo * ;; # -browser=* can be anything -custom-search=*) echo google duckduckgo ;; -escape-url-args=*) echo yes no ;; # -o=* can be anything -new=*|-ns=*|-newscreen=*) echo yes no ;; *) return 1 ;; esac } # Allowed to use a plain '*' in case statements # Called before declared-options completions # These must print newline-delimited completion alternatives (if any are defined for the argument) w3_complete_hook_arg_default () { local arg="$1" if command -v look >/dev/null 2>&1 then look -- "${arg:-''}" else return 1 fi } w3_complete_hook_arg () { if ok SURFRAW_default_arg_completions then w3_complete_hook_arg_default "$@" else return 1 fi } w3_complete () { local arg="$1" w3_complete_hook_opt "$arg" && return 0 w3_complete_hook_opt_global "$arg" && return 0 # At this point, `arg` is either: # 1. an option that takes an argument BUT doesn't define completions for it; # 2. a flag; # 3. an incomplete option name; or # 4. a non-option argument. case "$arg" in # Avoid completing options that don't define completions for the optarg -*=*) return 0 ;; # Complete options -*) # Remove ' ' "options" echo "$SURFRAW__complete_flags $SURFRAW__complete_options" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -s '[:space:]' return 0 ;; esac w3_complete_hook_arg "$arg" return 0 } # Properly complete calls like "sr fooelvis -- -notanoption" w3_complete_arg () { local arg="$1" w3_complete_hook_arg "$arg" return 0 } # Declare options (and valid arguments, TODO) # Does not need leading hyphen # Example use: # mkopts flag optwithvar= mkopts () { for opt in "$@" do case "$opt" in *=*) SURFRAW__complete_options="$SURFRAW__complete_options -$(echo $opt | sed 's/^\([^=]*=\).*/\1/')" ;; *) SURFRAW__complete_flags="$SURFRAW__complete_flags -$opt" ;; esac done } # Options with arguments mkopts bookmark-search-elvis= browser= escape-url-args= new= ns= newscreen= custom-search= o= # Flags mkopts elvi graphical help local-help quote new ns newscreen o text version print +# Completion-related options won't be included because they aren't needed for ordinary use. w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi*) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh|-\? ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --complete=* | \ -complete=*) w3_complete "$optarg"; exit 0 ;; --complete-arg=* | \ -complete-arg=*) w3_complete_arg "$optarg"; exit 0 ;; --default-arg-completions=* | -default-arg-completions=*) setoptyn SURFRAW_default_arg_completions "$optarg" ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then exec $SURFRAW_browser -remote "openURL($*$newwin)" else exec $SURFRAW_browser $SURFRAW_browser_args -remote "openURL($*$newwin)" fi else if test $SURFRAW_browser_args = "none"; then exec $SURFRAW_browser "$@" else exec $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then w3_parse_option "$arg" fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="$(quote "$arg")" unquoted_opts="$arg" else opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then exec sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then exec sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=$(bookmark_lookup $elvi) if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else echo "$w3_argv0: $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." exec $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
d1282f6073acccc8e96153afc154ad994ceb5d68
Allow disabling default completions for the arguments of an elvis
diff --git a/surfraw.IN b/surfraw.IN index 747b757..894984f 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,818 +1,825 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 # $0 can be -bash when sourced for tab completions. # POSIX seems to assume `--` support. w3_argv0=$(basename -- "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default conf="@sysconfdir@/xdg/surfraw.$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value="\"\$${1}\"" case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value="\"\$${1}\"" # Do nothing if already have a value. test -z "$value" && eval ${1}="\"$2\"" return 0 } defyn () { def "$@" yesno "$1" } setopt () { eval value="\"\$${1}\"" eval ${1}="\"$2\"" } setoptyn () { setopt "$@" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } # Should only complete for specific options # Called before declared-options completions w3_complete_hook_opt () { return 1 } # Provide package-name completions # TODO: add more distro package managers w3_complete_packages () { if command -v apt-cache >/dev/null 2>&1 then apt-cache --generate pkgnames -- "$1" elif command -v pacman >/dev/null 2>&1 then # Do prefix searches like the others. # TODO: prevent accidental regex searching by users. # How often is this likely to occur though? pacman -Ssq "^$1" elif command -v yum >/dev/null 2>&1 then # Get plain name excluding arch (to match the others)--assuming names have no dots. yum list all -- "${1}*" | cut -d . -f 1 elif command -v fink >/dev/null 2>&1 then fink list -- "${1}*" | cut -f 2 else return 1 fi } # Completions for main surfraw script w3_complete_hook_opt_global () { local opt="$1" case "$opt" in -bookmark-search-elvis=*) cd "$(get_local_elvi_dir)" 2>/dev/null && echo * cd "$elvidir" && echo * ;; # -browser=* can be anything -custom-search=*) echo google duckduckgo ;; -escape-url-args=*) echo yes no ;; # -o=* can be anything -new=*|-ns=*|-newscreen=*) echo yes no ;; *) return 1 ;; esac } # Allowed to use a plain '*' in case statements # Called before declared-options completions # These must print newline-delimited completion alternatives (if any are defined for the argument) w3_complete_hook_arg_default () { local arg="$1" if command -v look >/dev/null 2>&1 then look -- "${arg:-''}" else return 1 fi } w3_complete_hook_arg () { - w3_complete_hook_arg_default "$@" + if ok SURFRAW_default_arg_completions + then + w3_complete_hook_arg_default "$@" + else + return 1 + fi } w3_complete () { local arg="$1" w3_complete_hook_opt "$arg" && return 0 w3_complete_hook_opt_global "$arg" && return 0 # At this point, `arg` is either: # 1. an option that takes an argument BUT doesn't define completions for it; # 2. a flag; # 3. an incomplete option name; or # 4. a non-option argument. case "$arg" in # Avoid completing options that don't define completions for the optarg -*=*) return 0 ;; # Complete options -*) # Remove ' ' "options" echo "$SURFRAW__complete_flags $SURFRAW__complete_options" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -s '[:space:]' return 0 ;; esac w3_complete_hook_arg "$arg" return 0 } # Properly complete calls like "sr fooelvis -- -notanoption" w3_complete_arg () { local arg="$1" w3_complete_hook_arg "$arg" return 0 } # Declare options (and valid arguments, TODO) # Does not need leading hyphen # Example use: # mkopts flag optwithvar= mkopts () { for opt in "$@" do case "$opt" in *=*) SURFRAW__complete_options="$SURFRAW__complete_options -$(echo $opt | sed 's/^\([^=]*=\).*/\1/')" ;; *) SURFRAW__complete_flags="$SURFRAW__complete_flags -$opt" ;; esac done } # Options with arguments mkopts bookmark-search-elvis= browser= escape-url-args= new= ns= newscreen= custom-search= o= # Flags mkopts elvi graphical help local-help quote new ns newscreen o text version print w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi*) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh|-\? ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --complete=* | \ -complete=*) w3_complete "$optarg"; exit 0 ;; --complete-arg=* | \ -complete-arg=*) w3_complete_arg "$optarg"; exit 0 ;; + --default-arg-completions=* | -default-arg-completions=*) + setoptyn SURFRAW_default_arg_completions "$optarg" ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then exec $SURFRAW_browser -remote "openURL($*$newwin)" else exec $SURFRAW_browser $SURFRAW_browser_args -remote "openURL($*$newwin)" fi else if test $SURFRAW_browser_args = "none"; then exec $SURFRAW_browser "$@" else exec $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then w3_parse_option "$arg" fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="$(quote "$arg")" unquoted_opts="$arg" else opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then exec sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then exec sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=$(bookmark_lookup $elvi) if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else echo "$w3_argv0: $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." exec $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi diff --git a/surfraw.conf.IN b/surfraw.conf.IN index 4821fd2..cc1cc75 100644 --- a/surfraw.conf.IN +++ b/surfraw.conf.IN @@ -1,92 +1,102 @@ # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # $Id$ # # (c) 2000-2001 Julian Assange, all rights reserved. # (c) 2001 Australian Institute for Collaborative Research, all rights reserved. # (c) 2000 Melbourne Institute for Advanced Study, all rights reserved. # # see the file COPYING for further copyright details # # this file is shell script # # defintion commands: # # def -- define configuration variable unless already defined # (i.e by the environment) # defyn -- define boolean configuration variable unless # already defined # # WARNING: This file has a different format to that of $HOME/.surfraw.conf! # $HOME/.surfraw.conf entries should always be written sh style: # # SURFRAW_text_browser=w3m # etc # autoconf guessed prefix prefix=@prefix@ # graphical browser? defaults to yes for meatminds. text browser users can # work it out how to change it. defyn SURFRAW_graphical yes # name/path of text browser executable # e.g links, lynx, w3m def SURFRAW_text_browser @TEXTBROWSER@ # name/path of browser executable # e.g mozilla, netscape etc. Default to $BROWSER if no listed ones found def SURFRAW_graphical_browser "${BROWSER:-@GRAPHICALBROWSER@}" # text browser arguments, or "none" def SURFRAW_text_browser_args none # graphical browser arguments, or "none" def SURFRAW_graphical_browser_args none # use -remote openURL for graphical browser defyn SURFRAW_graphical_remote no # when using the -remote, open a new window? defyn SURFRAW_new_window no # name of screen command to run def SURFRAW_screen screen # If surfraw is running under screen(1), start a new screen # for each text browser invocation? defyn SURFRAW_new_screen no # arguments for the screen command def SURFRAW_screen_args "" # "quote" arguments defyn SURFRAW_quote_args no # requote arguments if they have spaces in # ie so: # sr google foo "bar baz" bam # works. defyn SURFRAW_quote_ifs yes # default number of results to return def SURFRAW_results 30 # escape [% "@$%&+,/:;<=>?@@[\^{|}~'] characters in command line arguments # subsequently used to construct a url defyn SURFRAW_escape_url_args yes # just print search url? defyn SURFRAW_print no # Fetch and dump url? defyn SURFRAW_dump no # Language/country (for elvi that support it) # Should be a 2-letter iso country code def SURFRAW_lang "" # provider for searches that use a search engine # with (eg) site: specifiers # supported: google duckduckgo def SURFRAW_customsearch_provider duckduckgo + +# Do useful but potentially expensive default completions for the +# arguments of an elvis? +# This can be useful for completion interfaces (e.g., Bash, Zsh, Emacs) +# to provide better default suggestions than surfraw. +# For example, this option applies to (1) but not to (2) or (3): +# 1. surfraw <TAB> +# 2. surfraw -<TAB> +# 3. surfraw -opt=<TAB> +defyn SURFRAW_default_arg_completions yes
JNRowe/surfraw
426fdf873f45c0a6253aa0df30706682a94787fc
Fix backwards compatibility with old global config files
diff --git a/surfraw.IN b/surfraw.IN index fcc5842..747b757 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,560 +1,560 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 # $0 can be -bash when sourced for tab completions. # POSIX seems to assume `--` support. w3_argv0=$(basename -- "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default - conf="@sysconfdir@/xdg/surfraw/$base" + conf="@sysconfdir@/xdg/surfraw.$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value="\"\$${1}\"" case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value="\"\$${1}\"" # Do nothing if already have a value. test -z "$value" && eval ${1}="\"$2\"" return 0 } defyn () { def "$@" yesno "$1" } setopt () { eval value="\"\$${1}\"" eval ${1}="\"$2\"" } setoptyn () { setopt "$@" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } # Should only complete for specific options # Called before declared-options completions w3_complete_hook_opt () { return 1 } # Provide package-name completions # TODO: add more distro package managers w3_complete_packages () { if command -v apt-cache >/dev/null 2>&1 then apt-cache --generate pkgnames -- "$1" elif command -v pacman >/dev/null 2>&1 then # Do prefix searches like the others. # TODO: prevent accidental regex searching by users. # How often is this likely to occur though? pacman -Ssq "^$1" elif command -v yum >/dev/null 2>&1 then # Get plain name excluding arch (to match the others)--assuming names have no dots. yum list all -- "${1}*" | cut -d . -f 1 elif command -v fink >/dev/null 2>&1 then fink list -- "${1}*" | cut -f 2 else return 1 fi } # Completions for main surfraw script w3_complete_hook_opt_global () { local opt="$1" case "$opt" in -bookmark-search-elvis=*) cd "$(get_local_elvi_dir)" 2>/dev/null && echo * cd "$elvidir" && echo * ;; # -browser=* can be anything -custom-search=*) echo google duckduckgo ;; -escape-url-args=*) echo yes no ;; # -o=* can be anything -new=*|-ns=*|-newscreen=*) echo yes no ;; *) return 1 ;; esac } # Allowed to use a plain '*' in case statements # Called before declared-options completions # These must print newline-delimited completion alternatives (if any are defined for the argument) w3_complete_hook_arg_default () { local arg="$1" if command -v look >/dev/null 2>&1 then look -- "${arg:-''}" else return 1 fi } w3_complete_hook_arg () { w3_complete_hook_arg_default "$@" } w3_complete () { local arg="$1" w3_complete_hook_opt "$arg" && return 0 w3_complete_hook_opt_global "$arg" && return 0 # At this point, `arg` is either: # 1. an option that takes an argument BUT doesn't define completions for it; # 2. a flag; # 3. an incomplete option name; or # 4. a non-option argument. case "$arg" in # Avoid completing options that don't define completions for the optarg -*=*) return 0 ;; # Complete options -*) # Remove ' ' "options" echo "$SURFRAW__complete_flags $SURFRAW__complete_options" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -s '[:space:]' return 0 ;; esac w3_complete_hook_arg "$arg" return 0 } # Properly complete calls like "sr fooelvis -- -notanoption" w3_complete_arg () { local arg="$1" w3_complete_hook_arg "$arg" return 0 } # Declare options (and valid arguments, TODO) # Does not need leading hyphen # Example use: # mkopts flag optwithvar= mkopts () { for opt in "$@" do case "$opt" in *=*) SURFRAW__complete_options="$SURFRAW__complete_options -$(echo $opt | sed 's/^\([^=]*=\).*/\1/')" ;; *) SURFRAW__complete_flags="$SURFRAW__complete_flags -$opt" ;; esac done } # Options with arguments mkopts bookmark-search-elvis= browser= escape-url-args= new= ns= newscreen= custom-search= o= # Flags mkopts elvi graphical help local-help quote new ns newscreen o text version print w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi*) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh|-\? ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --complete=* | \ -complete=*) w3_complete "$optarg"; exit 0 ;; --complete-arg=* | \ -complete-arg=*) w3_complete_arg "$optarg"; exit 0 ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () {
JNRowe/surfraw
a03c11f927303756040d57d561a24e47b6eea373
aur: Update URLs after search API changed
diff --git a/elvi/aur b/elvi/aur index c473a85..d3684dc 100755 --- a/elvi/aur +++ b/elvi/aur @@ -1,129 +1,129 @@ #!/bin/sh # # AUTHOR: René Reigel based on piratebay by J.R. Mauro # Ivy Foster added additional search options # # DESC: Search the Arch User Repository # $ID$ # elvis: aur -- Search aur.archlinux.org for PKGBUILDs . surfraw || exit 1 w3_config_hook () { - def SURFRAW_aur_action "Search=Go" + def SURFRAW_aur_action "submit=Go" def SURFRAW_aur_order "a" def SURFRAW_aur_language en defyn SURFRAW_aur_outdated 0 def SURFRAW_aur_protocol "https" def SURFRAW_aur_results "$SURFRAW_results" def SURFRAW_aur_search name def SURFRAW_aur_sort name } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search aur.archlinux.org for PKGBUILDS Local options -language Search in your your language See aur.archlinux.org for available languages Default: en -no-https Connect using HTTP, rather than HTTPS. This disables logging in. Default: use $SURFRAW_aur_protocol -order=ascending|descending Organize in ascending or descending order Default: ascending -orphans Search orphaned packages -outdated Search for out-of-date packages -results=NUM Number of search results returned Default: $SURFRAW_aur_results Must be in range 25-100 -search= Search for one of... name | Package name maintainer | Maintainer submitter | Submitter Default: name -sort= Sort by... name | Package name location | Package location votes | Number of votes maintainer | Package maintainer age | Package age Default: name EOF w3_global_usage } mkopts language= no-https order= orphans outdated results= search= sort= w3_complete_hook_opt () { local opt="$1" case "$opt" in # What are the categories for the AUR? It seems to have been removed from the web interface. -language=*) echo ca cs de en es fr hr hu it nb_no nb_NO pl pt ro ru sr tr uk zh_cn zh_CN ;; -order=*) echo ascending descending ;; -search=*) echo name maintainer submitter ;; -sort=*) echo name location votes maintainer age ;; *) return 1 ;; esac } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_aur_language "$optarg" ;; -no-https) setopt SURFRAW_aur_protocol "http" ;; -orphans*) setopt SURFRAW_aur_action "Orphans=Orphans" ;; -order=d*) setopt SURFRAW_aur_order d ;; -order=*) setopt SURFRAW_aur_order a ;; -outdated*) setoptyn SURFRAW_aur_outdated 1 ;; -results=*) setopt SURFRAW_aur_results "$optarg" ;; -search=*) setopt SURFRAW_aur_search "$optarg" ;; -sort=*) setopt SURFRAW_aur_sort "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_aur_search" in n*) aur_search_by=nd ;; m*) aur_search_by=m ;; s*) aur_search_by=s ;; *) aur_search_by=nd ;; esac case "$SURFRAW_aur_sort" in n*) aur_sort_by=n ;; c*) aur_sort_by=c ;; l*) aur_sort_by=l ;; v*) aur_sort_by=v ;; m*) aur_sort_by=m ;; a*) aur_sort_by=a ;; *) aur_sort_by=n ;; esac # Use SURFRAW_lang if present and the country has not been changed # More or less verbatim from the google elvis if test -n "$SURFRAW_lang" -a "$SURFRAW_aur_language" = "en"; then SURFRAW_aur_language="$SURFRAW_lang"; fi case "$SURFRAW_aur_language" in ca|cs|de|en|es|fr|hr|hu|it|nb_no|nb_NO|pl|pt|ro|ru|sr|tr|uk|zh_cn|zh_CN) aur_lang="$SURFRAW_aur_language" ;; *) aur_lang=en ;; esac # w3_args now contains a list of arguments -if test -z "$w3_args" && test "$SURFRAW_aur_action" = "Search=Go"; then - w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?setlang=${aur_lang}" +if test -z "$w3_args" && test "$SURFRAW_aur_action" = "submit=Go"; then + w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages?setlang=${aur_lang}" else escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_aur_outdated" = 1 ]; then - w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?O=0&L=0&detail=1&&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&do_${SURFRAW_aur_action}&outdated=on&setlang=${aur_lang}" + w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages?O=0&L=0&detail=1&&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&${SURFRAW_aur_action}&outdated=on&setlang=${aur_lang}" else - w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?O=0&L=0&detail=1&&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&do_${SURFRAW_aur_action}&setlang=${aur_lang}" + w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages?O=0&L=0&detail=1&&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&${SURFRAW_aur_action}&setlang=${aur_lang}" fi fi
JNRowe/surfraw
0cc7a91f288544fe666dfa49fd0be654dfa550ab
Apply Debian patch to update debpts search URL
diff --git a/elvi/debpts b/elvi/debpts index 601a8c4..9d6e6fe 100755 --- a/elvi/debpts +++ b/elvi/debpts @@ -1,48 +1,48 @@ #!/bin/sh # $Id$ # elvis: debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) # [email protected] 20040729 . surfraw || exit 1 w3_config_hook () { def SURFRAW_debpts_viewdocs 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Debian Package Tracking System (packages.qa.debian.org) Local options: -doc View PTS documentation EOF w3_global_usage } mkopts doc w3_complete_hook_arg () { w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -d*) setopt SURFRAW_debpts_viewdocs 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ $SURFRAW_debpts_viewdocs -eq 1 ]; then w3_browse_url "https://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system" elif test -z "$w3_args"; then w3_browse_url "https://packages.qa.debian.org/common/index.html" else escaped_args=$(w3_url_of_arg $w3_args) - w3_browse_url "https://packages.qa.debian.org/common/index.html?src=${escaped_args}" + w3_browse_url "https://tracker.debian.org/pkg/${escaped_args}" fi
JNRowe/surfraw
dc2ae99d3eececaf85969818fd052bf39c56a06a
Fix spelling errors in manpages
diff --git a/elvi.1sr.IN b/elvi.1sr.IN index b2b4bf4..12fc274 100644 --- a/elvi.1sr.IN +++ b/elvi.1sr.IN @@ -1,173 +1,173 @@ .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH ELVI 1sr "Feb 03, 2004" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp <n> insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME elvi \- surfraw(1) search tools .SH SYNOPSIS .B surfraw .I elviname [options] search words ... .br .B sr .I elviname [options] search words ... .br .B sr .I elviname \-help .br .B sr \-elvi .br .SH DESCRIPTION This is the man page for the elvi, a set of search tools that form part of \fBsurfraw(1)\fP. Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, dejanews, freshmeat, research index, slashdot and many others from the false\(hyprophet, pox\(hyinfested heathen lands of html\(hyforms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. To search using this elvis, do: sr elvisname [options] search terms. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google \-l debian ports To find out about options specific to this elvis, do: sr elvisname \-local\-help To find out about surfraw, see the man page for surfraw(1). To see the full list of elvi, do: sr \-elvi .SS Adding the elvi to your path If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (\%@ELVIDIR@) to your path, either manually or using \fBsurfraw\-update\-path(1)\fP. .SH OPTIONS Use \fB\%sr elviname \-local-help\fP for elvi\(hyspecific options. The following options work with all elvi. .TP .B \-help Show summary of options (including elvi\(hyspecific options). .TP .B \-local-help Show elvi\(hyspecific options. .TP .B \-version Show version of program. .TP \fB\-browser=\fP\fIEXECUTABLE\fP Set browser (default: sensible\-browser). .TP .B \-elvi Display a list of other Surfraw mechanisms for conquering evil. .TP .B \-escape\-url\-args=yes|no Apply url escaping to arguments (default: yes) .TP .B \-q|\-quote Bracket arguments with " characters (default: no) Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine .SH EXAMPLES $ sr ask why is jeeves gay? $ surfraw google \-results=100 RMS, GNU, which is sinner, which is sin? $ sr austlii \-method=phrase dog like $ @ELVIDIR@/rhyme \-method=perfect Julian .SH BUGS Please report any bugs found (or any web sites in need of surfrawizing) either via the debian bug tracking system (\%http://bugs.debian.org/) or to the surfraw\-devel list (\%surfraw\[email protected]). .SH SEE ALSO http://alioth.debian.org/projects/surfraw/ .SH PROPAGANDA .ce 1000 Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! .ce 0 Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the \fBS\fPhell \fBU\fPsers' \fBR\fPevolutionary \fBFr\fPont \fBA\fPgainst the WW\fBW\fP by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on surfraw\[email protected] .SH AUTHORS Originally written by Julian Assange. Now maintained by the surfraw\-devel team <\%surfraw\[email protected]>. See the file AUTHORS for the full list of contributors. Man page by Ian Beckwith, based on the original README and an earlier man page for surfraw(1) by Christian Surchi. .SH COPYRIGHT Copyright (c) 2003\(hy2018 The Surfraw\-Devel Team <surfraw\[email protected]> Copyright (c) 2000\(hy2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study The copyright holders listed above assert no rights on this release -of the software ``surfraw'' and thereby explicity place this release into +of the software ``surfraw'' and thereby explicitly place this release into the into the public domain. Do what you will. diff --git a/surfraw.1.IN b/surfraw.1.IN index 7609ced..d6dc5ba 100644 --- a/surfraw.1.IN +++ b/surfraw.1.IN @@ -1,398 +1,398 @@ .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH SURFRAW 1 "Feb 03, 2004" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp <n> insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME surfraw \- a fast unix command line interface to WWW services .SH SYNOPSIS .B surfraw .I elviname [options] search words ... .br .B sr .I elviname [options] search words ... .br .B sr \-elvi .br .B sr .I [options] bookmark [search words] .br .SH DESCRIPTION Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, dejanews, freshmeat, research index, slashdot and many others from the false\(hyprophet, pox\(hyinfested heathen lands of html\(hyforms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. .PP Surfraw consists of a collection of \fBelvi\fP, each of which knows how to search a specific web site. To see the list of elvi type: surfraw \-elvi Note that sr is an alias for surfraw, so that could equally be sr \-elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google \-l debian ports .SS Adding the elvi to your path If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (\%@ELVIDIR@) to your path, either manually or using \fB\%surfraw\-update\-path(1)\fP. .SS Bookmarks Surfraw supports bookmarks. To add a bookmark, add it to \fB\%@sysconfdir@/xdg/surfraw/bookmarks\fP or \fB\%$HOME/.config/surfraw/bookmarks\fP The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ If the url contains the string \fB%s\fP, you can specify an optional argument to the bookmark. Without an argument, only the domain will be returned. With arguments, \fb%s\fP will be replaced by the arguments. This obviates the need to create elvi for sites with very simple search options. To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in \%@sysconfdir@/xdg/surfraw/bookmarks .SH OPTIONS Use \fB\%sr elviname \-local\-help\fP for elvi\(hyspecific options. The following options work with all elvi. .TP .B \-help Show summary of options (including elvi\(hyspecific options). .TP .B \-local-help Show elvi\(hyspecific options. .TP .B \-version Show version of program. .TP \fB\-browser=\fP\fIEXECUTABLE\fP Set browser (default: sensible\-browser). .TP .B \-elvi Display a list of other Surfraw mechanisms for conquering evil. .TP .B \-escape\-url\-args=yes|no Apply url escaping to arguments (default: yes) .TP .B \-q|\-quote Bracket all arguments with " characters (default: no). Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine .SH EXAMPLES $ sr ask why is jeeves gay? $ surfraw google \-results=100 RMS, GNU, which is sinner, which is sin? $ sr austlii \-method=phrase dog like $ @ELVIDIR@/rhyme \-method=perfect Julian .SH CONFIGURATION Surfraw uses the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) to locate config files. The default locations are shown below, but can be modified by setting the environment variables .B $XDG_CONFIG_HOME and .B $XDG_CONFIG_DIRS. See the spec for more details. Surfraw gets its configuration from three sources, in order: .IP 1. 4 Environment variables .IP 2. \%@sysconfdir@/xdg/surfraw/conf .IP 3. \%$HOME/.config/surfraw/conf .PP @sysconfdir@/xdg/surfraw.conf and $HOME/.config/surfraw/conf are both fragments of bourne\(hyshell style shell script. @sysconfdir@/xdg/surfraw.conf should use def and defyn to define variables. These functions set variables unless they are already set by the environment. defyn is used for boolean configuration variables, def for all others. For instance: def SURFRAW_text_browser /usr/bin/lynx defyn SURFRAW_graphical no $HOME/.config/surfraw/conf should use sh\(hystyle entries, eg: SURFRAW_text_browser=/usr/bin/lynx SURFRAW_graphical=no This is because you want them to override environment variables unconditionally. .SH CONFIGURATION VARIABLES .TP .B SURFRAW_global_conf Location of global configuration file. Default: def SURFRAW_global_conf @sysconfdir@/xdg/surfraw/conf .TP .B SURFRAW_conf Location of per\(hyuser configuration file. Default: def SURFRAW_conf $HOME/.config/surfraw/conf .TP .B SURFRAW_graphical Whether to use a graphical browser. Default: defyn SURFRAW_graphical no .TP .B SURFRAW_text_browser Name/path of text browser executable. e.g. links, lynx, w3m Default: def SURFRAW_text_browser sensible\-browser .TP .B SURFRAW_graphical_browser Name/path of graphical browser executable. e.g mozilla, netscape etc. Default: def SURFRAW_graphical_browser sensible\-browser .TP .B SURFRAW_text_browser_args Text browser arguments, or "none". Default: def SURFRAW_text_browser_args none .TP .B SURFRAW_graphical_browser_args Graphical browser arguments, or "none". Default: def SURFRAW_graphical_browser_args none .TP .B SURFRAW_graphical_remote Whether to use "\fB\-remote openURL\fP" for graphical browser. Default: defyn SURFRAW_graphical_remote yes .TP .B SURFRAW_new_window When using SURFRAW_graphical_remote, open a new window? Default: defyn SURFRAW_new_window no .TP .B SURFRAW_screen Name of screen command to run. Default: def SURFRAW_screen screen .TP .B SURFRAW_new_screen If surfraw is running under screen(1), start a new screen for each text browser invocation? Default: defyn SURFRAW_new_screen no .TP .B SURFRAW_screen_args Arguments to pass to the SURFRAW_screen command Default: def SURFRAW_screen_args "" .TP .B SURFRAW_quote_args Whether to "quote" all the arguments. Default: defyn SURFRAW_quote_args no .TP .B SURFRAW_quote_ifs Whether to re\(hyquote arguments if they have spaces in, ie so: sr google foo "bar baz" bam .br works as expected. Default: defyn SURFRAW_quote_ifs yes .TP .B SURFRAW_results Default number of results to return (not supported by all elvi). Default: def SURFRAW_results 30 .TP .B SURFRAW_escape_url_args Whether to escape [% "$%&+,/:;<=>?@[\^{|}~'] characters in command line arguments subsequently used to construct a url. Default: defyn SURFRAW_escape_url_args yes .SH FILES .TP .B @ELVIDIR@ Location of the elvi. .TP .B ${HOME}/.config/surfraw/elvi Per\(hyuser elvi. .TP .B @sysconfdir@/xdg/surfraw/conf Default system wide configuration file. .TP .B $HOME/.config/surfraw/conf Default per\(hyuser config file .TP .B @sysconfdir@/xdg/surfraw/bookmarks System wide bookmarks file. .TP .B $HOME/.config/surfraw/bookmarks Per\(hyuser bookmarks file. .SH BUGS Please report any bugs found (or any web sites in need of surfrawizing) either via the debian bug tracking system (\%http://bugs.debian.org/) or to the surfraw\-devel list (\%surfraw\[email protected]). .SH SEE ALSO http://alioth.debian.org/projects/surfraw/ .SH PROPAGANDA .ce 1000 Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! .ce 0 Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the \fBS\fPhell \fBU\fPsers' \fBR\fPevolutionary \fBFr\fPont \fBA\fPgainst the WW\fBW\fP by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on surfraw\[email protected] .SH AUTHORS Originally written by Julian Assange. Now maintained by the surfraw\-devel team <\%surfraw\[email protected]>. See the file AUTHORS for the full list of contributors. Man page by Ian Beckwith, based on the original README and an earlier man page by Christian Surchi. .SH COPYRIGHT Copyright (c) 2003-2018 The Surfraw\-Devel Team <surfraw\[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study The copyright holders listed above assert no rights on this release -of the software ``surfraw'' and thereby explicity place this release into +of the software ``surfraw'' and thereby explicitly place this release into the into the public domain. Do what you will.
JNRowe/surfraw
68a161e6be6bb9e5bc1750abe4ec3f1d3792557b
Actually use browser args if not none with graphical remotes
diff --git a/surfraw.IN b/surfraw.IN index 3344dce..d116d29 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,696 +1,696 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=$(basename "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default conf="@sysconfdir@/xdg/surfraw/$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value=\$${1} case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value=\$${1} test -z "$value" || return 0 eval ${1}="$2" return 0 } defyn () { eval value=\$${1} test -z "$value" && eval ${1}="$2" yesno "$1" } setopt () { eval value=\$${1} eval ${1}="$2" } setoptyn () { eval value=\$${1} eval ${1}="$2" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi*) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh|-\? ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then exec $SURFRAW_browser -remote "openURL($*$newwin)" else - exec $SURFRAW_browser -remote "openURL($*$newwin)" + exec $SURFRAW_browser $SURFRAW_browser_args -remote "openURL($*$newwin)" fi else if test $SURFRAW_browser_args = "none"; then exec $SURFRAW_browser "$@" else exec $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then w3_parse_option "$arg" fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="$(quote "$arg")" unquoted_opts="$arg" else opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then exec sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then exec sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=$(bookmark_lookup $elvi) if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else echo "$(basename $0): $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." exec $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
f7da389ca387032965bf3233721fe6127683244e
Remove fallback if graphical remote on browser fails
diff --git a/surfraw.IN b/surfraw.IN index 37da223..3344dce 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,696 +1,696 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=$(basename "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default conf="@sysconfdir@/xdg/surfraw/$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value=\$${1} case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value=\$${1} test -z "$value" || return 0 eval ${1}="$2" return 0 } defyn () { eval value=\$${1} test -z "$value" && eval ${1}="$2" yesno "$1" } setopt () { eval value=\$${1} eval ${1}="$2" } setoptyn () { eval value=\$${1} eval ${1}="$2" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi*) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh|-\? ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then - exec $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & + exec $SURFRAW_browser -remote "openURL($*$newwin)" else - exec $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & + exec $SURFRAW_browser -remote "openURL($*$newwin)" fi else if test $SURFRAW_browser_args = "none"; then exec $SURFRAW_browser "$@" else exec $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then w3_parse_option "$arg" fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="$(quote "$arg")" unquoted_opts="$arg" else opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then exec sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then exec sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=$(bookmark_lookup $elvi) if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else echo "$(basename $0): $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." exec $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
2c721e7f9e9386c18e54371345a380d609e860be
archwiki: Add jp to -language= completions
diff --git a/elvi/archwiki b/elvi/archwiki index 88cefc0..29acce9 100755 --- a/elvi/archwiki +++ b/elvi/archwiki @@ -1,87 +1,87 @@ #!/bin/sh # elvis: archwiki -- Search the Arch Linux Wiki # Author: http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_archwiki_language "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Arch Linux Wiki (wiki.archlinux.org) Local options -language=ISOCODE Two letter language code (resembles ISO country codes) -l=ISOCODE en | Main Arch Wiki site (default) fr | French de | German he | Hebrew jp | Japan pl | Polish pt | Portugese ro | Romanian es | Spanish sv | Swedish uk | Ukranian Environment: SURFRAW_archwiki_language, SURFRAW_lang Default: en EOF w3_global_usage } mkopts language= w3_complete_hook_opt () { local opt="$1" case "$opt" in - -l=*|-language=*) echo en fr de he pl pt ro es sv uk ;; + -l=*|-language=*) echo en fr de he jp pl pt ro es sv uk ;; *) return 1 ;; esac } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_archwiki_language $optarg ;; -l=*) setopt SURFRAW_archwiki_language $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains list of arguments case "$SURFRAW_archwiki_language" in en) domain=".org" ;; fr) domain=".fr" ;; de) domain=".de" ;; he) domain=".il" ;; jp) domain=".jp" ;; pl) domain=".pl" ;; pt) domain="-br.org" ;; ro) domain=".ro" ;; es) domain=".cl" ;; sv) domain=".sv" ;; uk) domain=".ua" ;; *) domain=".org" ;; esac # handle ssl if [ $domain = ".org" -o $domain = ".de" ]; then protocol="https://"; else protocol="http://"; fi if [ -z "$w3_args" ]; then w3_browse_url "${protocol}wiki.archlinux${domain}/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${protocol}wiki.archlinux${domain}/index.php?search=${escaped_args}" fi
JNRowe/surfraw
3e831c020336e0e41fd027777283030377c1376b
Document bash completions
diff --git a/HACKING b/HACKING index 78ff5af..c1f6c1d 100644 --- a/HACKING +++ b/HACKING @@ -1,198 +1,236 @@ ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! H A C K I N G Or... How to Eat The CHEESE 1) First, find a front end (`an elvi, types of elvis -- makes evil nice') in the elvi/ directory that does something similar to what you want. In this example we shall use the `google' elvis. 2) Copy the `google' elvis to the name of your new elvis. In this example we shall create an elvis for the Peoples' Front Against Forum Stealing Dogs http://www.pfafsd.org/ mailing-list search service 3) At the top of the file, you will see something like: # elvis: google -- Search the web using Google (http://www.google.com) Keep the "elvis:" take and change the rest of the line. This description is used at Surfraw installation time to generate a list of Surfraw clients Immediately after we see: . surfraw || exit 1 Which pulls in the Surfraw functions. Keep it. 4) Next we (optionally) define w3_config_hook(). It is called by w3_config and is used to define default configuration variables. It is called after the global configuration file is interpreted, but before ~/.surfraw. You will notice the use of: def -- define configuration variable unless already defined (i.e by the environment) defyn -- define boolean configuration variable unless already defined Which are pre-defined surfraw functions, but you can of course use your own arbitrary broken shell code instead. 5) Any non-trivial program will then define w3_usage_hook(). $w3_argv0 is set to contain $0, otherwise usage is self explanatory. You must call w3_global_usage at the end of this function and follow the surfraw usage style least you be marked a quiche eater. +5.5)Surfraw now supports elvis-specific tab-completions, eg: + sr debpackages -<TAB> + sr debpackages -release=<TAB> + sr debpackages <TAB> + can all be defined by an elvis. + + Use mkopts() to provide option name completions, eg: + mkopts optwitharg= optwithoutarg + usually after the definition of w3_usage_hook(). + + Optionally define w3_complete_hook_opt() for option argument completions. + Arguments: $1 - current option being completed. + Output: the possible values of $1, separated by whitespace. + Return value: 0 if the option exists and has completions, 1 otherwise. + Completes global options as a fallback. + Default: do nothing, just complete global options. + + Optionally define w3_complete_hook_arg() for elvis argument completions. + Arguments: $1 - current argument being completed. + Output: the possible values of $1, separated by *newline* characters. + Note the difference between the separators of this function and + w3_complete_hook_opt(). + You can use external programs, so be sure to guard it with: + if command -v PROGRAM >/dev/null 2>&1 + then + # your code + else + return 1 + fi + Inside this function, you can also use: + w3_complete_packages "$1" + to complete package names using your distro's package manager. + Return value: 0 if the argument can be completed, 1 otherwise. + Default: uses look to match the argument with the system dictionary. + + You can look at w3_complete_hook_opt_global() and + w3_complete_hook_arg_default(), as well as other elvi for examples. + 6) Next define w3_parse_option_hook(). This is called at w3_config() time, and takes two arguments. The first is the current option being examined, the second is only present if the option was of the form `-foo=bar'. It's the `bar'. w3_parse_option_hook() is called before Surfraw global options are parsed and so you can selectively over-ride them. Return value: 0 if the option was recognised, 1 otherwise. 7) After this, w3_config() and w3_parse_args "$@" are called. w3_config() scans the configuration files and calls w3_config_hook(). w3_parse_args "$@" processes options, called w3_parse_option_hook() as needed and builds $w3_args -- the list non-option arguments. This ends the regular initialisation code. 7.5)Note that surfraw now supports quoting arguments, eg with: sr google foo "bar baz" bam it adds the quotes back. Not all sites support arguments in double quotes. If you want to disable it for your elvis, add SURFRAW_quote_ifs=0 in between the calls to w3_config and w3_parse_args. 8) What happens next depends on the type of evil we are dealing with. In the Peoples' Front Against Forum Stealing Dogs case, we have previously performed a search on the http://www.pfafsd.org search service, and noted (with the '=' key in lynx, links) the url returned. We then analyse this url to work out which CGI variable is being used to convey search the search string, number of results et al. Q: What about those proslytizers of iniquity that worship idols like method=POST? A: Most sites will take GETs in the place of POSTs, even if they preach method=POST in forms. For those that don't? Walking with the devil should not be a an exercise in relaxed discourse. The problem is getting the browser to automatically submit the data using POST as a method. One partial solution is to have surfraw generate a pre-filled method=POST form as a local file and have the browser read it. Exploration of other ideas is encouraged. w3_url_of_arg() is then used to escape the command line search string argument into something that can be seen in a URL without embarrassment. i.e escaped_args=$(w3_url_of_arg $w3_args) In our last exhilarating moments we then build the final URL and pass it onto the currently selected browser with w3_browse_url, proud in the knowledge that the Shell Users' Revolutionary Front Against the WWW has brought the holy word of the command line to yet another heathen land. -Julian Assange <[email protected]> APPENDIX 1 Adding an elvi to the distribution: 1: write it (see above) 2: copy elviname to the elvi directory 3: make the elvi executable (chmod 755 elvipath) so the test suite can run it directly. 4: add elviname to the elvi_SCRIPTS list in elvi/Makefile.am 5: add a link for the manpage in links.IN 6: update the elvi list in README 7: add an entry to the ChangeLog and NEWS 8: add yourself or the author to AUTHORS 9: test 10: add tests to test suite, see test/README 11: if the elvi has heavy dependencies, consider moving it to the surfraw-extra package by adding its files to debian/surfraw-extra.files 12: if using git, 'git add elvi/elviname' then commit and push. APPENDIX 2 Preparing a release of surfraw: 1: git clone git://git.debian.org/surfraw/surfraw 2: git clone git://git.debian.org/surfraw/web 3: cd surfraw 4: git tag surfraw-versionnumber-debianversion 5: git push --tags 6: mkdir -p ../release/upload ; cd ../release 7: git clone git://git.debian.org/surfraw/surfraw 8: cd surfraw 9: git checkout surfraw-versionnumber-debianversion 10: rm -rf .git 11: ./prebuild && ./configure && make distcheck 12: # test surfraw-version.tar.gz 13: cp surfraw-version.tar.gz ../surfraw_version.orig.tar.gz 14: mv surfraw-version.tar.gz ../upload 15: pdebuild --buildresult ../upload --auto-debsign --logfile ../pbuilder.log 16: cd ../upload 17: # test and upload the debian packages 18: cp * ../../web/dist 19: cd ../../web 20: make install # see README.WEB for more info
JNRowe/surfraw
a24201934ff11368afdbcd51ba52e2cf9b187853
debbugs: Update available tags
diff --git a/elvi/debbugs b/elvi/debbugs index 0aa2647..2704faf 100755 --- a/elvi/debbugs +++ b/elvi/debbugs @@ -1,315 +1,318 @@ #!/bin/sh # $Id$ # elvis: debbugs -- Search the debian BTS (bugs.debian.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debbugs_search pkg def SURFRAW_debbugs_version "" def SURFRAW_debbugs_dist "" def SURFRAW_debbugs_user "" defyn SURFRAW_debbugs_archive 0 defyn SURFRAW_debbugs_merge 0 defyn SURFRAW_debbugs_statussort 1 defyn SURFRAW_debbugs_head 1 defyn SURFRAW_debbugs_foot 1 def SURFRAW_debbugs_incstatus "" def SURFRAW_debbugs_excstatus "" def SURFRAW_debbugs_incsev "" def SURFRAW_debbugs_excsev "" def SURFRAW_debbugs_inctag "" def SURFRAW_debbugs_exctag "" defyn SURFRAW_debbugs_asmbox 0 defyn SURFRAW_debbugs_headers 0 defyn SURFRAW_debbugs_boring 0 defyn SURFRAW_debbugs_revstat 0 defyn SURFRAW_debbugs_revsev 0 defyn SURFRAW_debbugs_revbugs 0 defyn setsearch 0 defyn search_usertag 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [package | bug number | maintainer email] Description: Surfraw search debian BTS (bugs.debian.org) Examples: debbugs 20000 | show report for bug #20000 debbugs [email protected] | show bugs for csurchi debbugs surfraw | show bugs for surfraw package debbugs -raw -rb surfraw | show surfraw bugs newest first Defaults if -search is not supplied: If arg is numeric, searches by bug number, If it contains '@', searches by maintainer, Otherwise, searches by package. Local options: -search= pkg | Search type. src | bug | (bug number) maint | tag | submitter | severity | - tag | - usertag + usertag | -s Alias for -search=src -user=EMAIL User for usertag search, defaults to value of \$DEBEMAIL environment. Ignored if search type is not "usertag". -version=VERSION Package version. -dist=oldstable | Distribution stable | proposed-updates | testing | unstable | experimental | testing-proposed-updates -arc Show archived bugs. -raw Do not sort by status or severity. -rb Reverse order of bugs shown. -rst Reverse order of statuses shown. -rse Reverse order of severities shown. -merge Display merged bugs only once. -nohead Do not show table of contents header. -nofoot Do not show statistics in the footer. -mbox View results in mbox format. * -sh Show headers. * -boring Show boring messages. * (* = only when searching by bug number.) -incstat=stat1,stat2 Include given status list. -exstat=stat3,stat4 Exclude given status list. Available statuses: open, forwarded, pending, fixed, done. -incsev=sev1,sev2 Include given severities. -exsev=sev3,sev4 Exclude given severities. Available severities: critical, grave, serious, important, normal, minor, wishlist, fixed. -inctag=tag1,tag2 Include given tags. -extag=tag3,tag4 Exclude given tags. Available tags: - potato, woody, sarge, sarge-ignore, - etch, etch-ignore, sid, experimental, - confirmed, d-i, fixed, fixed-in-experimental, - fixed-upstream, help, l10n, moreinfo, patch, - pending, security, unreproducible, upstream, - wontfix, ipv6, lfs + patch, wontfix, moreinfo, unreproducible, + help, security, upstream, pending, confirmed, + ipv6, lfs, d-i, l10n, newcomer, a11y, ftbfs, + fixed-upstream, fixed, fixed-in-experimental, + potato, woody, sarge, etch, lenny, squeeze, + wheezy, jessie, stretch, buster, bullseye, + bookworm, trixie, sid, experimental, + sarge-ignore, etch-ignore, lenny-ignore, + squeeze-ignore, wheezy-ignore, jessie-ignore, + stretch-ignore, buster-ignore, bullseye-ignore, + bookworm-ignore, trixie-ignore EOF w3_global_usage } mkopts search= version= dist= user= mkopts arc raw rb rst rse merge nohead nofoot mbox sh mkopts incstat= exstat= incsev= exsev= inctag= extag= w3_complete_hook_opt () { local opt="$1" case "$opt" in - # "tag" is duplicated in help. Error? -search=*) echo pkg src bug maint tag submitter severity usertag ;; -dist=*) echo oldstable stable proposed-updates testing unstable experimental testing-proposed-updates ;; # At most one csv-like value can be completed at once. -incstat=*|-exstat=*) echo open forwarded pending fixed done ;; -incsev=*|-exsev=*) echo critical grave serious important normal minor wishlist fixed ;; - -inctag=*|-extag=*) echo potato woody sarge sarge-ignore etch etch-ignore sid experimental confirmed d-i fixed fixed-in-experimental fixed-upstream help l10n moreinfo patch pending security unreproducible upstream wontfix ipv6 lfs ;; + -inctag=*|-extag=*) echo patch wontfix moreinfo unreproducible help security upstream pending confirmed ipv6 lfs d-i l10n newcomer a11y ftbfs fixed-upstream fixed fixed-in-experimental potato woody sarge etch lenny squeeze wheezy jessie stretch buster bullseye bookworm trixie sid experimental sarge-ignore etch-ignore lenny-ignore squeeze-ignore wheezy-ignore jessie-ignore stretch-ignore buster-ignore bullseye-ignore bookworm-ignore trixie-ignore ;; *) return 1 ;; esac } w3_complete_hook_arg () { w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s) setopt SURFRAW_debbugs_search src ; setoptyn setsearch 1 ;; -se*=*) setopt SURFRAW_debbugs_search $optarg; setoptyn setsearch 1 ;; -ve*=*) setopt SURFRAW_debbugs_version $optarg ;; -dis*=*) setopt SURFRAW_debbugs_dist $optarg ;; -arc*) setoptyn SURFRAW_debbugs_archive 1;; -mer*) setoptyn SURFRAW_debbugs_merge 1;; -raw*) setoptyn SURFRAW_debbugs_statussort 0;; -noh*) setoptyn SURFRAW_debbugs_head 0;; -nof*) setoptyn SURFRAW_debbugs_foot 0;; -in*stat*=*) setopt SURFRAW_debbugs_incstatus $optarg;; -ex*stat*=*) setopt SURFRAW_debbugs_excstatus $optarg;; -in*sev*=*) setopt SURFRAW_debbugs_incsev $optarg;; -ex*sev*=*) setopt SURFRAW_debbugs_excsev $optarg;; -in*tag*=*) setopt SURFRAW_debbugs_inctag $optarg;; -ex*tag*=*) setopt SURFRAW_debbugs_exctag $optarg;; -u*=*) setopt SURFRAW_debbugs_user $optarg;; -rb*) setoptyn SURFRAW_debbugs_revbugs 1;; -rst*) setoptyn SURFRAW_debbugs_revstat 1;; -rse*) setoptyn SURFRAW_debbugs_revsev 1;; -mb*) setoptyn SURFRAW_debbugs_asmbox 1;; -sh*) setoptyn SURFRAW_debbugs_headers 1;; -bo*) setoptyn SURFRAW_debbugs_boring 1;; *) return 1 ;; esac return 0 } # Email normalization # ~~~~~~~~~~~~~~~~~~~ # # Debbugs search have bug: even if email have upper-case letters, it # must be lower-cased when writing search request, or nothing will be # found. # # For example, to search bugs in packages, maintained by # J. Random Hacker <[email protected]> one have to request following url: # # https://bugs.debian.org/[email protected] # # No search results will be returned at this requst: # # https://bugs.debian.org/[email protected] # # Environment variable $DEBEMAIL is used by many developer tools, # maintainers tend to place their email in preferred capitalization. # # When using this variable as fallback for -user option, it is lowercased # to work-around described beviour (reported as #921970). # # Strictly speaking, local part of email address must be considered # opaque, having meaning only to receiving email server. w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.debian.org/Bugs" else escaped_args=$(w3_url_of_arg $w3_args) setoptyn donum 0 setoptyn domaint 0 setoptyn dousertag 0 case "$SURFRAW_debbugs_search" in bug*) setoptyn donum 1;; user*) setopt SURFRAW_debbugs_search tag setoptyn dousertag 1;; esac # default search unless searchtype set on cmdline if ifno setsearch then export escaped_args if perl -e 'if($ENV{escaped_args} =~/^((\#|\%23)(\s|\%20)*)?\d+$/) { exit 0; } exit 1;' then # %23 = uri escaped '#', %20=' ' setoptyn donum 1 elif perl -e 'if($ENV{escaped_args} =~/\%40|@/) { exit 0; } exit 1;' then # %40 = uri escaped '@' setopt SURFRAW_debbugs_search "maint" fi fi if ifyes donum then url="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${escaped_args}" if yesno SURFRAW_debbugs_asmbox then url="$url&mbox=yes" fi if yesno SURFRAW_debbugs_headers then url="$url&trim=no" fi if yesno SURFRAW_debbugs_boring then url="$url&boring=yes" fi else url="https://bugs.debian.org/cgi-bin/pkgreport.cgi?which=${SURFRAW_debbugs_search}&version=${SURFRAW_debbugs_version}&dist=${SURFRAW_debbugs_dist}&data=${escaped_args}" if ifyes dousertag then user=${SURFRAW_debbugs_user} if null "${user}" then user="${DEBEMAIL:-}" if null "${user}" then cat <<EOF >&2 $w3_argv0 ERROR: can not do usertag search -- user is unknown. * option -user is not provided * environment variable "SURFRAW_debbugs_user" is not set * environment variable "DEBEMAIL" is not set EOF exit 1 fi # See [Email normalization] user=$(printf '%s' "${user}" | tr '[:upper:]' '[:lower:]') fi url="$url&users=$user" fi if yesno SURFRAW_debbugs_archive then url="$url&archive=yes" else url="$url&archive=no" fi if ifyes SURFRAW_debbugs_merge then url="$url&repeatmerged=no" fi if ifno SURFRAW_debbugs_statussort then url="$url&raw=yes" fi if ifno SURFRAW_debbugs_head then url="$url&show_list_header=no" fi if ifno SURFRAW_debbugs_foot then url="$url&show_list_footer=no" fi if ifyes SURFRAW_debbugs_revstat then url="$url&pend-rev=yes" fi if ifyes SURFRAW_debbugs_revsev then url="$url&sev-rev=yes" fi if ifyes SURFRAW_debbugs_revbugs then url="$url&bug-rev=yes" fi if [ "$SURFRAW_debbugs_incstatus" != "" ] then add=$(echo "$SURFRAW_debbugs_incstatus"|perl -ne 's/pending/pending-fixed/g;s/open/pending/g;print(join("&pend-inc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_excstatus" != "" ] then add=$(echo "$SURFRAW_debbugs_excstatus"|perl -ne 'print(join("&pend-exc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_incsev" != "" ] then add=$(echo "$SURFRAW_debbugs_incsev"|perl -ne 'print(join("&sev-inc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_excsev" != "" ] then add=$(echo "$SURFRAW_debbugs_excsev"|perl -ne 'print(join("&sev-exc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_inctag" != "" ] then add=$(echo "$SURFRAW_debbugs_inctag"|perl -ne 'print(join("&include=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_exctag" != "" ] then add=$(echo "$SURFRAW_debbugs_exctag"|perl -ne 'print(join("&exclude=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi fi w3_browse_url "$url" fi
JNRowe/surfraw
b2908ca918195c41dae3189abf4adb34f16eb569
finkpkg: Update values of -dist= and -section=
diff --git a/elvi/finkpkg b/elvi/finkpkg index 4713684..ab9ab94 100755 --- a/elvi/finkpkg +++ b/elvi/finkpkg @@ -1,183 +1,199 @@ #!/bin/sh # elvis: finkpkg -- Search Fink packages (pdb.finkproject.org) # [email protected] 20091111 . surfraw || exit 1 w3_config_hook () { def SURFRAW_finkpkg_pkgname "" def SURFRAW_finkpkg_maintainer "" def SURFRAW_finkpkg_distro default def SURFRAW_finkpkg_arch any def SURFRAW_finkpkg_tree any def SURFRAW_finkpkg_section any defyn SURFRAW_finkpkg_exact no defyn SURFRAW_finkpkg_nomaint no defyn SURFRAW_finkpkg_nochildren no defyn SURFRAW_finkpkg_noshlibsdev no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search Fink packages (pdb.finkproject.org) Local options: -pkg=NAME Search by packagename for NAME -maintainer=NAME Search by maintainer for NAME -dist=DIST Specify distribution DIST - default | Supported [10.5 & 10.6] (default) + default | Supported [10.9 through 10.15] (default) any | Any + 10.1 | 10.1 + 10.2 | 10.2 + 10.2-gcc3.3 | 10.2-gcc3.3 + 10.3 | 10.4 10.4 | 10.4 10.5 | 10.5 10.6 | 10.6 + 10.7 | 10.7 + 10.8 | 10.8 + 10.9 | 10.9 + 10.10 | 10.10 + 10.11 | 10.11 + 10.12 | 10.12 + 10.13 | 10.13 + 10.14 | 10.14 + 10.14.5 | 10.14.5 + 10.15 | 10.15 Default: $SURFRAW_finkpkg_distro Environment: SURFRAW_finkpkg_distro -arch=ARCH Search in arch ARCH any | Any (default) i386 | i386 x86_64 | X86_64 (aka AMD64) powerpc | powerpc Default: $SURFRAW_finkpkg_arch Environment: SURFRAW_finkpkg_arch -tree=TREE Search in tree TREE any | Any (default) unstable | Unstable stable | Stable bindist | Binary Distribution testing | Packages that need testing Default: $SURFRAW_finkpkg_tree Environment: SURFRAW_finkpkg_tree -section=SEC Search in section SEC any | Any (default) base | Core packages crypto | Cryptographic software (subject to national regulations) database | SQL and other database software devel | Software for software development editors | Text editors games | Games and other fun stuff gnome | The GNOME desktop environment (version 2.26) graphics | Graphics applications and libraries kde | K Desktop Environment (version 3.5.10 and 4.2.4) + kde/po | Translations for the K Desktop Environment (version 3.5.10 and 4.2.4) languages | Programming languages (compilers, interpreters) libs | General purpose libraries + libs/ghc | Glasgow Haskell Compiler libraries libs/perlmods | Perl libraries libs/pythonmods | Python libraries libs/rubymods | Ruby libraries net | Network-related applications and libraries sci | Scientific applications shells | Shells (command line interpreters) sound | Audio software text | Text-processing software utils | Utilities that do not fit elsewhere web | Web-related software x11 | General X11 packages - toolkits and utilities x11-system | X Window System core packages x11-wm | Window managers for the X Window System Default: $SURFRAW_finkpkg_section Environment: SURFRAW_finkpkg_section -exact Exact package matches only Default: $SURFRAW_finkpkg_exact Environment: SURFRAW_finkpkg_exact -nomaint Find packages with no maintainer Default: $SURFRAW_finkpkg_nomaint Environment: SURFRAW_finkpkg_nomaint -nochildren Exclude packages with parent (includes most "-dev", "-shlibs", ... splitoffs) Default: $SURFRAW_finkpkg_nochildren Environment: SURFRAW_finkpkg_nochildren -noshlibsdev Exclude -shlibs, -dev, -bin, -common, -doc packages Default: $SURFRAW_finkpkg_noshlibsdev Environment: SURFRAW_finkpkg_noshlibsdev EOF w3_global_usage } mkopts pkg= maintainer= dist= arch= tree= section= exact nomaint nochildren noshlibsdev w3_complete_hook_opt () { local opt="$1" case "$opt" in # Not going to get optarg here because this should be enough. Bash should be able to fill in the gaps. -pkg=*) w3_complete_packages ;; # Is this outdated? - -dist=*) echo default any 10.4 10.5 10.6 ;; + -dist=*) echo default any 10.1 10.2 10.2-gcc3.3 10.3 10.4 10.5 10.6 10.7 10.8 10.9 10.10 10.11 10.12 10.13 10.14 10.14.5 10.15 ;; -arch=*) echo any i386 x86_64 powerpc ;; -tree=*) echo any unstable stable bindist testing ;; - -section=*) echo any base crypto database devel editors games gnome graphics kde languages libs libs/perlmods libs/pythonmods libs/rubymods net sci shells sound text utils web x11 x11-system x11-wm ;; + -section=*) echo any base crypto database devel editors games gnome graphics kde kde/po languages libs libs/ghc libs/perlmods libs/pythonmods libs/rubymods net sci shells sound text utils web x11 x11-system x11-wm ;; *) return 1 ;; esac } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -pkg*=*) setopt SURFRAW_finkpkg_pkgname $optarg ;; -maint*=*) setopt SURFRAW_finkpkg_maintainer $optarg ;; -dist*=*) setopt SURFRAW_finkpkg_distro $optarg ;; -arch=*) setopt SURFRAW_finkpkg_arch $optarg ;; -tree*=*) setopt SURFRAW_finkpkg_tree $optarg ;; -sec*=*) setopt SURFRAW_finkpkg_section $optarg ;; -ex*) setoptyn SURFRAW_finkpkg_exact yes ;; -nomaint*) setoptyn SURFRAW_finkpkg_nomaint yes ;; -noch*) setoptyn SURFRAW_finkpkg_nochildren yes ;; -noshlib*) setoptyn SURFRAW_finkpkg_noshlibsdev yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) url="http://pdb.finkproject.org/pdb/browse.php" if [ -z "$escaped_args" ] && [ -z "$SURFRAW_finkpkg_pkgname" ] && [ -z "$SURFRAW_finkpkg_maintainer" ] then w3_browse_url "$url" else if [ "$SURFRAW_finkpkg_arch" = any ] then SURFRAW_finkpkg_arch="" fi if [ "$SURFRAW_finkpkg_section" = any ] then SURFRAW_finkpkg_section="" fi url="${url}?dist_name=${SURFRAW_finkpkg_distro}" url="${url}&architecture=${SURFRAW_finkpkg_arch}" url="${url}&tree=${SURFRAW_finkpkg_tree}" url="${url}&sec=${SURFRAW_finkpkg_section}" if [ -n "$escaped_args" ] then url="${url}&summary=${escaped_args}" fi if [ -n "$SURFRAW_finkpkg_pkgname" ] then url="${url}&name=${SURFRAW_finkpkg_pkgname}" fi if [ -n "$SURFRAW_finkpkg_maintainer" ] then url="${url}&maintainer=${SURFRAW_finkpkg_maintainer}" fi if ifyes SURFRAW_finkpkg_exact then url="${url}&name_exact=on" fi if ifyes SURFRAW_finkpkg_nomaint then url="$url&nomaintainer=on" fi if ifyes SURFRAW_finkpkg_nochildren then url="$url&nochildren=on" fi if ifyes SURFRAW_finkpkg_noshlibsdev then url="$url&noshlibsdev=on" fi w3_browse_url "$url" fi
JNRowe/surfraw
9dba613d44ebe09d28c21412ed49dd03f5cf8ef9
aur: Remove categories code
diff --git a/elvi/aur b/elvi/aur index 987a6f2..c473a85 100755 --- a/elvi/aur +++ b/elvi/aur @@ -1,159 +1,129 @@ #!/bin/sh # # AUTHOR: René Reigel based on piratebay by J.R. Mauro # Ivy Foster added additional search options # # DESC: Search the Arch User Repository # $ID$ # elvis: aur -- Search aur.archlinux.org for PKGBUILDs . surfraw || exit 1 w3_config_hook () { def SURFRAW_aur_action "Search=Go" - def SURFRAW_aur_category "any" def SURFRAW_aur_order "a" def SURFRAW_aur_language en defyn SURFRAW_aur_outdated 0 def SURFRAW_aur_protocol "https" def SURFRAW_aur_results "$SURFRAW_results" def SURFRAW_aur_search name def SURFRAW_aur_sort name } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search aur.archlinux.org for PKGBUILDS Local options - -category Search the given AUR category - Consult aur.archlinux.org/packages.php for - a complete list. - Default: any -language Search in your your language See aur.archlinux.org for available languages Default: en -no-https Connect using HTTP, rather than HTTPS. This disables logging in. Default: use $SURFRAW_aur_protocol -order=ascending|descending Organize in ascending or descending order Default: ascending -orphans Search orphaned packages -outdated Search for out-of-date packages -results=NUM Number of search results returned Default: $SURFRAW_aur_results Must be in range 25-100 -search= Search for one of... name | Package name maintainer | Maintainer submitter | Submitter Default: name -sort= Sort by... name | Package name - category | Package category location | Package location votes | Number of votes maintainer | Package maintainer age | Package age Default: name EOF w3_global_usage } -mkopts category= language= no-https order= orphans outdated results= search= sort= +mkopts language= no-https order= orphans outdated results= search= sort= w3_complete_hook_opt () { local opt="$1" case "$opt" in # What are the categories for the AUR? It seems to have been removed from the web interface. -language=*) echo ca cs de en es fr hr hu it nb_no nb_NO pl pt ro ru sr tr uk zh_cn zh_CN ;; -order=*) echo ascending descending ;; -search=*) echo name maintainer submitter ;; - -sort=*) echo name category location votes maintainer age ;; + -sort=*) echo name location votes maintainer age ;; *) return 1 ;; esac } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in - -category=*) setopt SURFRAW_aur_category "$optarg" ;; -language=*) setopt SURFRAW_aur_language "$optarg" ;; -no-https) setopt SURFRAW_aur_protocol "http" ;; -orphans*) setopt SURFRAW_aur_action "Orphans=Orphans" ;; -order=d*) setopt SURFRAW_aur_order d ;; -order=*) setopt SURFRAW_aur_order a ;; -outdated*) setoptyn SURFRAW_aur_outdated 1 ;; -results=*) setopt SURFRAW_aur_results "$optarg" ;; -search=*) setopt SURFRAW_aur_search "$optarg" ;; -sort=*) setopt SURFRAW_aur_sort "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" -case "$SURFRAW_aur_category" in - a*) aur_category=0 ;; - da*) aur_category=2 ;; - de*) aur_category=3 ;; - ed*) aur_category=4 ;; - em*) aur_category=5 ;; - ga*) aur_category=6 ;; - gn*) aur_category=7 ;; - i*) aur_category=8 ;; - kd*) aur_category=9 ;; - ke*) aur_category=19 ;; - l*) aur_category=10 ;; - mo*) aur_category=11 ;; - mu*) aur_category=12 ;; - n*) aur_category=13 ;; - o*) aur_category=14 ;; - sc*) aur_category=15 ;; - sy*) aur_category=16 ;; - x1*) aur_category=17 ;; - xf*) aur_category=18 ;; - *) aur_category=0 ;; -esac - case "$SURFRAW_aur_search" in n*) aur_search_by=nd ;; m*) aur_search_by=m ;; s*) aur_search_by=s ;; *) aur_search_by=nd ;; esac case "$SURFRAW_aur_sort" in n*) aur_sort_by=n ;; c*) aur_sort_by=c ;; l*) aur_sort_by=l ;; v*) aur_sort_by=v ;; m*) aur_sort_by=m ;; a*) aur_sort_by=a ;; *) aur_sort_by=n ;; esac # Use SURFRAW_lang if present and the country has not been changed # More or less verbatim from the google elvis if test -n "$SURFRAW_lang" -a "$SURFRAW_aur_language" = "en"; then SURFRAW_aur_language="$SURFRAW_lang"; fi case "$SURFRAW_aur_language" in ca|cs|de|en|es|fr|hr|hu|it|nb_no|nb_NO|pl|pt|ro|ru|sr|tr|uk|zh_cn|zh_CN) aur_lang="$SURFRAW_aur_language" ;; *) aur_lang=en ;; esac # w3_args now contains a list of arguments if test -z "$w3_args" && test "$SURFRAW_aur_action" = "Search=Go"; then w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?setlang=${aur_lang}" else escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_aur_outdated" = 1 ]; then - w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?O=0&L=0&detail=1&C=${aur_category}&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&do_${SURFRAW_aur_action}&outdated=on&setlang=${aur_lang}" + w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?O=0&L=0&detail=1&&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&do_${SURFRAW_aur_action}&outdated=on&setlang=${aur_lang}" else - w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?O=0&L=0&detail=1&C=${aur_category}&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&do_${SURFRAW_aur_action}&setlang=${aur_lang}" + w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?O=0&L=0&detail=1&&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&do_${SURFRAW_aur_action}&setlang=${aur_lang}" fi fi
JNRowe/surfraw
15458b3f05dce0391eaf079b3087321da4164764
musicbrainz: Sync help text with code
diff --git a/elvi/musicbrainz b/elvi/musicbrainz index 2336ce6..60a7f1b 100755 --- a/elvi/musicbrainz +++ b/elvi/musicbrainz @@ -1,176 +1,175 @@ #!/bin/sh # $Id$ # elvis: musicbrainz -- Search MusicBrainz (musicbrainz.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_musicbrainz_limit $SURFRAW_results def SURFRAW_musicbrainz_search artist def SURFRAW_musicbrainz_tagrelease "" def SURFRAW_musicbrainz_tagtrack "" def SURFRAW_musicbrainz_tagnum "" def SURFRAW_musicbrainz_taglen "" def SURFRAW_musicbrainz_tagpuid "" def SURFRAW_musicbrainz_tagfile "" defyn SURFRAW_musicbrainz_advanced 0 defyn SURFRAW_musicbrainz_direct 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search MusicBrainz (musicbrainz.org) Local options: -d Direct (old) search. -a Enable advanced query syntax. See: https://musicbrainz.org/popup/TextSearchSyntax -results=NUM Number of search results returned Default: $SURFRAW_musicbrainz_results Environment: SURFRAW_musicbrainz_results 0 means all results. -search= Search type: artist | Artist [default] <*> release | Release (album) <*> release_group | Release Group label | Label <*> annotation | Annotation barcode | Barcode catno | Catalog number cdstub | CD Stub discid | Disc ID editor | Editor freedb | FreeDB - freedb | FreeDB ID + freedbid | FreeDB ID isrc | ISRC iswc | ISWC mbid | MBID puid | PUID recording | Recording trmid | TRM ID work | Work tag Tag Search With Tag Search, [search words] are treated as artist name, use -tag* below to specify other fields. <*> = supported by direct search (-d) Environment: SURFRAW_musicbrainz_search -tagrelease=ALBUM Album/Release tag search (implies -search=tag) -tagnum=TRACKNUM Track number tag search (implies -search=tag) -tagtrack=SONG Track tag search (implies -search=tag) -taglen=DURATION Track length tag search (implies -search=tag) -tagfile=FILENAME Filename tag search (implies -search=tag) -tagpuid=FILENAME PUID tag search (implies -search=tag) EOF w3_global_usage } mkopts d a results= search= mkopts tagrelease= tagnum= tagtrack= taglen= tagfile= tagpuid= w3_complete_hook_opt () { local opt="$1" case "$opt" in - # "freedb" duplicated in help. Error? - -search=*) echo artist release release_group label annotation barcode catno cdstub discid editor freedb isrc iswc mbid puid recording trmid work tag ;; + -search=*) echo artist release release_group label annotation barcode catno cdstub discid editor freedb freedbid isrc iswc mbid puid recording trmid work tag ;; *) return 1 ;; esac } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_musicbrainz_results $optarg ;; -tagrel*=*) setopt SURFRAW_musicbrainz_tagrelease $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagnu*=*) setopt SURFRAW_musicbrainz_tagnum $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagtra*=*) setopt SURFRAW_musicbrainz_tagtrack $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagle*=*) setopt SURFRAW_musicbrainz_taglen $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagp*=*) setopt SURFRAW_musicbrainz_tagpuid $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagf*=*) setopt SURFRAW_musicbrainz_tagfile $optarg setopt SURFRAW_musicbrainz_search tag ;; -a) setoptyn SURFRAW_musicbrainz_advanced 1 ;; -d) setoptyn SURFRAW_musicbrainz_direct 1 ;; -search=*) searchtype="$optarg" case "$searchtype" in ar*) setopt SURFRAW_musicbrainz_search artist ;; release_*) setopt SURFRAW_musicbrainz_search release_group ;; release|rel|al*) setopt SURFRAW_musicbrainz_search release ;; an*) setopt SURFRAW_musicbrainz_search annotation ;; ba*) setopt SURFRAW_musicbrainz_search barcode ;; ca*) setopt SURFRAW_musicbrainz_search catno ;; cd*) setopt SURFRAW_musicbrainz_search cdstub ;; d*) setopt SURFRAW_musicbrainz_search discid ;; e*) setopt SURFRAW_musicbrainz_search editor ;; freedb|fr) setopt SURFRAW_musicbrainz_search freedb ;; freedbid) setopt SURFRAW_musicbrainz_search freedbid ;; isr*) setopt SURFRAW_musicbrainz_search isrc ;; isw*) setopt SURFRAW_musicbrainz_search iswc ;; l*) setopt SURFRAW_musicbrainz_search label ;; m*) setopt SURFRAW_musicbrainz_search mbid ;; p*) setopt SURFRAW_musicbrainz_search puid ;; rec*) setopt SURFRAW_musicbrainz_search recording ;; tr*) setopt SURFRAW_musicbrainz_search trmid ;; w*) setopt SURFRAW_musicbrainz_search work ;; ta*) setopt SURFRAW_musicbrainz_search tag ;; *) err "Search type not known" esac ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args" && test -z "$SURFRAW_musicbrainz_tagrelease" && test -z "$SURFRAW_musicbrainz_tagnum" && test -z "$SURFRAW_musicbrainz_tagtrack" && test -z "$SURFRAW_musicbrainz_taglen" && test -z "$SURFRAW_musicbrainz_tagpuid" && test -z "$SURFRAW_musicbrainz_tagfile" then w3_browse_url "https://musicbrainz.org/search.html" else escaped_args=$(w3_url_of_arg $w3_args) url="https://musicbrainz.org" if ifyes SURFRAW_musicbrainz_direct then case "$SURFRAW_musicbrainz_search" in artist|release|label) url="${url}/search/oldsearch.html?query=${escaped_args}&type=${SURFRAW_musicbrainz_search}&limit=${SURFAW_musicbrainz_results}&handlearguments=1" ;; *) err "Search type $SURFRAW_musicbrainz_search not supported by Direct Search (-d)" ;; esac else case "$SURFRAW_musicbrainz_search" in artist|release_group|release|recording|work| \ label|annotation|cdstub|editor| \ freedb) url="${url}/search?query=${escaped_args}&type=${SURFRAW_musicbrainz_search}&limit=${SURFRAW_musicbrainz_limit}" if ifyes SURFRAW_musicbrainz_advanced then url="${url}&adv=on" fi ;; catno|barcode|discid|freedbid|freedb| \ puid|trmid|isrc|iswc| \ discid) url="${url}/otherlookup?${SURFRAW_musicbrainz_search}=${escaped_args}" ;; mbid) url="${url}/release/${escaped_args}" ;; tag) url="${url}/taglookup?artist=${escaped_args}&release=${SURFRAW_musicbrainz_tagrelease}&track=${SURFRAW_musicbrainz_tagtrack}&tracknum=${SURFRAW_musicbrainz_tagnum}&duration=${SURFRAW_musicbrainz_taglen}&filename=${SURFRAW_musicbrainz_tagfile}&puid=${SURFRAW_musicbrainz_puid}" ;; *) err Unknown search type "${SURFRAW_musicbrainz_search}" ;; esac fi w3_browse_url "$url" fi
JNRowe/surfraw
9329f3d0bb24efffec1c0af3444738dfeb681f40
debpkghome: Add package completion
diff --git a/elvi/debpkghome b/elvi/debpkghome index cfc0003..fbeefeb 100755 --- a/elvi/debpkghome +++ b/elvi/debpkghome @@ -1,76 +1,92 @@ #!/bin/sh # elvis: debpkghome -- Visit the home page for a Debian package . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [package|file.dsc|controlfile] Description: Visit the home page for a Debian package EOF w3_global_usage } +w3_complete_hook_arg () +{ + # If the control files are within reach, it's likely that we want them + local dir="${1:-.}" + if [ -n "$(find "$(dirname "$dir")" -maxdepth 2 \( -name '*.dsc' -o -name 'control' \) -print -quit)" ] + then + # Don't want to modify the bash completion script, so here we are. + # These should stay elvis-specific. + case "$1" in + ./*|.) find "$(dirname "$dir")" -maxdepth 2 \( -name '*.dsc' -o -name 'control' \) ;; + *) find "$(dirname "$dir")" -maxdepth 2 \( -name '*.dsc' -o -name 'control' \) | sed 's,^\./,,' ;; + esac + else + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" + fi +} extract_home_page () { # sed /I is a gnu extension grep -i '^homepage:' | head -1 | \ sed 's/^[Hh][Oo][Mm][Ee][Pp][Aa][Gg][Ee]: *//;' } do_control() { if [ ! -f $1 ] then err $1": file not found" return fi OUT="$(cat $1 | extract_home_page)" if [ -z "$OUT" ] then err $1": no Homepage field" else echo "$OUT" fi } do_package() { if [ ! -x "$(which apt-cache)" ] then err "apt-cache not installed. Try finding the homepage via debpts instead" return fi OUT="$(apt-cache showsrc $1)" if [ -z "$OUT" ] then err $1": package not found" return fi OUT="$(echo "$OUT" | extract_home_page)" if [ -z "$OUT" ] then err $1": no Homepage field" else echo "$OUT" fi } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_usage_hook exit fi case "$w3_args" in *.dsc|*control) url="$(do_control "$w3_args")" ;; *) url="$(do_package "$w3_args")" ;; esac if [ -n "$url" ] then w3_browse_url "$url" fi
JNRowe/surfraw
b3f664dd9a8ccf8289cbd531cb89b79cb7555094
Add package completions for archpkg and genportage
diff --git a/elvi/archpkg b/elvi/archpkg index 4fb2f22..de76f8a 100755 --- a/elvi/archpkg +++ b/elvi/archpkg @@ -1,108 +1,112 @@ #!/bin/sh # elvis: archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) # Author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_arch_ix "$SURFRAW_ix" def SURFRAW_arch_repo "$SURFRAW_repo" def SURFRAW_arch_date "$SURFRAW_date" def SURFRAW_arch_results 25 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search string] Description: Surfraw search Arch Linux packages (www.archlinux.org) Local options: -arch=ARCHITECTURES | -a=ARCHITECTURES any | Any (default) i686 | i686 x86_64 | x86_64 -repo=REPOSITORIES | -r=REPOSITORIES comm | Community commtest | Community-Testing core | Core extra | Extra multi | Multilib multitest | Multilib-Testing test | Testing Default: All -date=UPDATED | -d=UPDATED (format: YYYY-MM-DD) -num=NUMBER | Number of results per page Default: $SURFRAW_arch_results EOF w3_global_usage } mkopts arch= repo= date= num= w3_complete_hook_opt () { local opt="$1" case "$opt" in -arch=*) echo any i686 x86_64 ;; -repo=*) echo comm commtest core extra multi multitest test ;; *) return 1 ;; esac } +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -a*=*) setopt SURFRAW_arch_ix $optarg ;; -r*=*) setopt SURFRAW_arch_repo $optarg ;; -d*=*) setopt SURFRAW_arch_date $optarg ;; -n*=*) setopt SURFRAW_arch_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # selected repository case "$SURFRAW_arch_repo" in comm) repo="Community" ;; commtest) repo="Community-Testing" ;; core) repo="Core" ;; extra) repo="Extra" ;; multi) repo="Multilib" ;; multitest)repo="Multilib-Testing" ;; test) repo="Testing" ;; *) repo="" ;; esac # no arguments present if [ -z "$w3_args" ]; then w3_browse_url "https://www.archlinux.org/packages/" else # if w3_args contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) base="https://www.archlinux.org/packages/?sort=" # repository and architecture if [ -n "$SURFRAW_arch_repo" -a "$SURFRAW_arch_ix" ]; then w3_browse_url "${base}&arch=${SURFRAW_arch_ix}&repo=${repo}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" # check for repository elif [ -n "$SURFRAW_arch_repo" ]; then w3_browse_url "${base}&repo=${repo}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" # just architecture elif [ -n "$SURFRAW_arch_ix" ]; then w3_browse_url "${base}&arch=${SURFRAW_arch_ix}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" # none of the above... else w3_browse_url "${base}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" fi fi diff --git a/elvi/genportage b/elvi/genportage index fb7bf41..a39dd66 100755 --- a/elvi/genportage +++ b/elvi/genportage @@ -1,28 +1,32 @@ #!/bin/sh # # Original Author: J.R. Mauro # # Modified to use Gentoo Portage Overlays # as gentoo-portage.com has gone -- ianb # # elvis: genportage -- Search gentoo-portage.com for packages . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search gentoo portage overlays for packages EOF w3_global_usage } +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://gpo.zugaina.org" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://gpo.zugaina.org/Search?search=${escaped_args}" fi
JNRowe/surfraw
d3186c074521824070acefb0fd011dd3df37148d
finkpkg: Add completion for -pkg=
diff --git a/elvi/finkpkg b/elvi/finkpkg index 0459bb4..4713684 100755 --- a/elvi/finkpkg +++ b/elvi/finkpkg @@ -1,181 +1,183 @@ #!/bin/sh # elvis: finkpkg -- Search Fink packages (pdb.finkproject.org) # [email protected] 20091111 . surfraw || exit 1 w3_config_hook () { def SURFRAW_finkpkg_pkgname "" def SURFRAW_finkpkg_maintainer "" def SURFRAW_finkpkg_distro default def SURFRAW_finkpkg_arch any def SURFRAW_finkpkg_tree any def SURFRAW_finkpkg_section any defyn SURFRAW_finkpkg_exact no defyn SURFRAW_finkpkg_nomaint no defyn SURFRAW_finkpkg_nochildren no defyn SURFRAW_finkpkg_noshlibsdev no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search Fink packages (pdb.finkproject.org) Local options: -pkg=NAME Search by packagename for NAME -maintainer=NAME Search by maintainer for NAME -dist=DIST Specify distribution DIST default | Supported [10.5 & 10.6] (default) any | Any 10.4 | 10.4 10.5 | 10.5 10.6 | 10.6 Default: $SURFRAW_finkpkg_distro Environment: SURFRAW_finkpkg_distro -arch=ARCH Search in arch ARCH any | Any (default) i386 | i386 x86_64 | X86_64 (aka AMD64) powerpc | powerpc Default: $SURFRAW_finkpkg_arch Environment: SURFRAW_finkpkg_arch -tree=TREE Search in tree TREE any | Any (default) unstable | Unstable stable | Stable bindist | Binary Distribution testing | Packages that need testing Default: $SURFRAW_finkpkg_tree Environment: SURFRAW_finkpkg_tree -section=SEC Search in section SEC any | Any (default) base | Core packages crypto | Cryptographic software (subject to national regulations) database | SQL and other database software devel | Software for software development editors | Text editors games | Games and other fun stuff gnome | The GNOME desktop environment (version 2.26) graphics | Graphics applications and libraries kde | K Desktop Environment (version 3.5.10 and 4.2.4) languages | Programming languages (compilers, interpreters) libs | General purpose libraries libs/perlmods | Perl libraries libs/pythonmods | Python libraries libs/rubymods | Ruby libraries net | Network-related applications and libraries sci | Scientific applications shells | Shells (command line interpreters) sound | Audio software text | Text-processing software utils | Utilities that do not fit elsewhere web | Web-related software x11 | General X11 packages - toolkits and utilities x11-system | X Window System core packages x11-wm | Window managers for the X Window System Default: $SURFRAW_finkpkg_section Environment: SURFRAW_finkpkg_section -exact Exact package matches only Default: $SURFRAW_finkpkg_exact Environment: SURFRAW_finkpkg_exact -nomaint Find packages with no maintainer Default: $SURFRAW_finkpkg_nomaint Environment: SURFRAW_finkpkg_nomaint -nochildren Exclude packages with parent (includes most "-dev", "-shlibs", ... splitoffs) Default: $SURFRAW_finkpkg_nochildren Environment: SURFRAW_finkpkg_nochildren -noshlibsdev Exclude -shlibs, -dev, -bin, -common, -doc packages Default: $SURFRAW_finkpkg_noshlibsdev Environment: SURFRAW_finkpkg_noshlibsdev EOF w3_global_usage } mkopts pkg= maintainer= dist= arch= tree= section= exact nomaint nochildren noshlibsdev w3_complete_hook_opt () { local opt="$1" case "$opt" in + # Not going to get optarg here because this should be enough. Bash should be able to fill in the gaps. + -pkg=*) w3_complete_packages ;; # Is this outdated? -dist=*) echo default any 10.4 10.5 10.6 ;; -arch=*) echo any i386 x86_64 powerpc ;; -tree=*) echo any unstable stable bindist testing ;; -section=*) echo any base crypto database devel editors games gnome graphics kde languages libs libs/perlmods libs/pythonmods libs/rubymods net sci shells sound text utils web x11 x11-system x11-wm ;; *) return 1 ;; esac } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -pkg*=*) setopt SURFRAW_finkpkg_pkgname $optarg ;; -maint*=*) setopt SURFRAW_finkpkg_maintainer $optarg ;; -dist*=*) setopt SURFRAW_finkpkg_distro $optarg ;; -arch=*) setopt SURFRAW_finkpkg_arch $optarg ;; -tree*=*) setopt SURFRAW_finkpkg_tree $optarg ;; -sec*=*) setopt SURFRAW_finkpkg_section $optarg ;; -ex*) setoptyn SURFRAW_finkpkg_exact yes ;; -nomaint*) setoptyn SURFRAW_finkpkg_nomaint yes ;; -noch*) setoptyn SURFRAW_finkpkg_nochildren yes ;; -noshlib*) setoptyn SURFRAW_finkpkg_noshlibsdev yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) url="http://pdb.finkproject.org/pdb/browse.php" if [ -z "$escaped_args" ] && [ -z "$SURFRAW_finkpkg_pkgname" ] && [ -z "$SURFRAW_finkpkg_maintainer" ] then w3_browse_url "$url" else if [ "$SURFRAW_finkpkg_arch" = any ] then SURFRAW_finkpkg_arch="" fi if [ "$SURFRAW_finkpkg_section" = any ] then SURFRAW_finkpkg_section="" fi url="${url}?dist_name=${SURFRAW_finkpkg_distro}" url="${url}&architecture=${SURFRAW_finkpkg_arch}" url="${url}&tree=${SURFRAW_finkpkg_tree}" url="${url}&sec=${SURFRAW_finkpkg_section}" if [ -n "$escaped_args" ] then url="${url}&summary=${escaped_args}" fi if [ -n "$SURFRAW_finkpkg_pkgname" ] then url="${url}&name=${SURFRAW_finkpkg_pkgname}" fi if [ -n "$SURFRAW_finkpkg_maintainer" ] then url="${url}&maintainer=${SURFRAW_finkpkg_maintainer}" fi if ifyes SURFRAW_finkpkg_exact then url="${url}&name_exact=on" fi if ifyes SURFRAW_finkpkg_nomaint then url="$url&nomaintainer=on" fi if ifyes SURFRAW_finkpkg_nochildren then url="$url&nochildren=on" fi if ifyes SURFRAW_finkpkg_noshlibsdev then url="$url&noshlibsdev=on" fi w3_browse_url "$url" fi
JNRowe/surfraw
ed6d4f9a6d3cc3993a5390bf1dfd2af122af0f89
Re-implement package-name completions
diff --git a/elvi/alioth b/elvi/alioth index 8653732..e4d6844 100755 --- a/elvi/alioth +++ b/elvi/alioth @@ -1,57 +1,61 @@ #!/bin/sh # $Id$ # elvis: alioth -- Search Alioth (alioth.debian.org) # [email protected] 20030910 # adapted from sourceforge elvi . surfraw || exit 1 w3_config_hook () { def SURFRAW_alioth_searchtype soft } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Alioth (alioth.debian.org) Local options: -type= soft | Software / Group skill | Skills people People Default: $SURFRAW_alioth_searchtype Environment: SURFRAW_alioth_searchtype EOF w3_global_usage } mkopts type= w3_complete_hook_opt () { local opt="$1" case "$opt" in -type=*) echo soft skill people ;; *) return 1 ;; esac } +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -t*=*) setopt SURFRAW_alioth_searchtype $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://alioth.debian.org/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://alioth.debian.org/search/?words=${escaped_args}&type_of_search=$SURFRAW_alioth_searchtype" fi diff --git a/elvi/debbugs b/elvi/debbugs index fb287ab..0aa2647 100755 --- a/elvi/debbugs +++ b/elvi/debbugs @@ -1,311 +1,315 @@ #!/bin/sh # $Id$ # elvis: debbugs -- Search the debian BTS (bugs.debian.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debbugs_search pkg def SURFRAW_debbugs_version "" def SURFRAW_debbugs_dist "" def SURFRAW_debbugs_user "" defyn SURFRAW_debbugs_archive 0 defyn SURFRAW_debbugs_merge 0 defyn SURFRAW_debbugs_statussort 1 defyn SURFRAW_debbugs_head 1 defyn SURFRAW_debbugs_foot 1 def SURFRAW_debbugs_incstatus "" def SURFRAW_debbugs_excstatus "" def SURFRAW_debbugs_incsev "" def SURFRAW_debbugs_excsev "" def SURFRAW_debbugs_inctag "" def SURFRAW_debbugs_exctag "" defyn SURFRAW_debbugs_asmbox 0 defyn SURFRAW_debbugs_headers 0 defyn SURFRAW_debbugs_boring 0 defyn SURFRAW_debbugs_revstat 0 defyn SURFRAW_debbugs_revsev 0 defyn SURFRAW_debbugs_revbugs 0 defyn setsearch 0 defyn search_usertag 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [package | bug number | maintainer email] Description: Surfraw search debian BTS (bugs.debian.org) Examples: debbugs 20000 | show report for bug #20000 debbugs [email protected] | show bugs for csurchi debbugs surfraw | show bugs for surfraw package debbugs -raw -rb surfraw | show surfraw bugs newest first Defaults if -search is not supplied: If arg is numeric, searches by bug number, If it contains '@', searches by maintainer, Otherwise, searches by package. Local options: -search= pkg | Search type. src | bug | (bug number) maint | tag | submitter | severity | tag | usertag -s Alias for -search=src -user=EMAIL User for usertag search, defaults to value of \$DEBEMAIL environment. Ignored if search type is not "usertag". -version=VERSION Package version. -dist=oldstable | Distribution stable | proposed-updates | testing | unstable | experimental | testing-proposed-updates -arc Show archived bugs. -raw Do not sort by status or severity. -rb Reverse order of bugs shown. -rst Reverse order of statuses shown. -rse Reverse order of severities shown. -merge Display merged bugs only once. -nohead Do not show table of contents header. -nofoot Do not show statistics in the footer. -mbox View results in mbox format. * -sh Show headers. * -boring Show boring messages. * (* = only when searching by bug number.) -incstat=stat1,stat2 Include given status list. -exstat=stat3,stat4 Exclude given status list. Available statuses: open, forwarded, pending, fixed, done. -incsev=sev1,sev2 Include given severities. -exsev=sev3,sev4 Exclude given severities. Available severities: critical, grave, serious, important, normal, minor, wishlist, fixed. -inctag=tag1,tag2 Include given tags. -extag=tag3,tag4 Exclude given tags. Available tags: potato, woody, sarge, sarge-ignore, etch, etch-ignore, sid, experimental, confirmed, d-i, fixed, fixed-in-experimental, fixed-upstream, help, l10n, moreinfo, patch, pending, security, unreproducible, upstream, wontfix, ipv6, lfs EOF w3_global_usage } mkopts search= version= dist= user= mkopts arc raw rb rst rse merge nohead nofoot mbox sh mkopts incstat= exstat= incsev= exsev= inctag= extag= w3_complete_hook_opt () { local opt="$1" case "$opt" in # "tag" is duplicated in help. Error? -search=*) echo pkg src bug maint tag submitter severity usertag ;; -dist=*) echo oldstable stable proposed-updates testing unstable experimental testing-proposed-updates ;; # At most one csv-like value can be completed at once. -incstat=*|-exstat=*) echo open forwarded pending fixed done ;; -incsev=*|-exsev=*) echo critical grave serious important normal minor wishlist fixed ;; -inctag=*|-extag=*) echo potato woody sarge sarge-ignore etch etch-ignore sid experimental confirmed d-i fixed fixed-in-experimental fixed-upstream help l10n moreinfo patch pending security unreproducible upstream wontfix ipv6 lfs ;; *) return 1 ;; esac } +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s) setopt SURFRAW_debbugs_search src ; setoptyn setsearch 1 ;; -se*=*) setopt SURFRAW_debbugs_search $optarg; setoptyn setsearch 1 ;; -ve*=*) setopt SURFRAW_debbugs_version $optarg ;; -dis*=*) setopt SURFRAW_debbugs_dist $optarg ;; -arc*) setoptyn SURFRAW_debbugs_archive 1;; -mer*) setoptyn SURFRAW_debbugs_merge 1;; -raw*) setoptyn SURFRAW_debbugs_statussort 0;; -noh*) setoptyn SURFRAW_debbugs_head 0;; -nof*) setoptyn SURFRAW_debbugs_foot 0;; -in*stat*=*) setopt SURFRAW_debbugs_incstatus $optarg;; -ex*stat*=*) setopt SURFRAW_debbugs_excstatus $optarg;; -in*sev*=*) setopt SURFRAW_debbugs_incsev $optarg;; -ex*sev*=*) setopt SURFRAW_debbugs_excsev $optarg;; -in*tag*=*) setopt SURFRAW_debbugs_inctag $optarg;; -ex*tag*=*) setopt SURFRAW_debbugs_exctag $optarg;; -u*=*) setopt SURFRAW_debbugs_user $optarg;; -rb*) setoptyn SURFRAW_debbugs_revbugs 1;; -rst*) setoptyn SURFRAW_debbugs_revstat 1;; -rse*) setoptyn SURFRAW_debbugs_revsev 1;; -mb*) setoptyn SURFRAW_debbugs_asmbox 1;; -sh*) setoptyn SURFRAW_debbugs_headers 1;; -bo*) setoptyn SURFRAW_debbugs_boring 1;; *) return 1 ;; esac return 0 } # Email normalization # ~~~~~~~~~~~~~~~~~~~ # # Debbugs search have bug: even if email have upper-case letters, it # must be lower-cased when writing search request, or nothing will be # found. # # For example, to search bugs in packages, maintained by # J. Random Hacker <[email protected]> one have to request following url: # # https://bugs.debian.org/[email protected] # # No search results will be returned at this requst: # # https://bugs.debian.org/[email protected] # # Environment variable $DEBEMAIL is used by many developer tools, # maintainers tend to place their email in preferred capitalization. # # When using this variable as fallback for -user option, it is lowercased # to work-around described beviour (reported as #921970). # # Strictly speaking, local part of email address must be considered # opaque, having meaning only to receiving email server. w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.debian.org/Bugs" else escaped_args=$(w3_url_of_arg $w3_args) setoptyn donum 0 setoptyn domaint 0 setoptyn dousertag 0 case "$SURFRAW_debbugs_search" in bug*) setoptyn donum 1;; user*) setopt SURFRAW_debbugs_search tag setoptyn dousertag 1;; esac # default search unless searchtype set on cmdline if ifno setsearch then export escaped_args if perl -e 'if($ENV{escaped_args} =~/^((\#|\%23)(\s|\%20)*)?\d+$/) { exit 0; } exit 1;' then # %23 = uri escaped '#', %20=' ' setoptyn donum 1 elif perl -e 'if($ENV{escaped_args} =~/\%40|@/) { exit 0; } exit 1;' then # %40 = uri escaped '@' setopt SURFRAW_debbugs_search "maint" fi fi if ifyes donum then url="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${escaped_args}" if yesno SURFRAW_debbugs_asmbox then url="$url&mbox=yes" fi if yesno SURFRAW_debbugs_headers then url="$url&trim=no" fi if yesno SURFRAW_debbugs_boring then url="$url&boring=yes" fi else url="https://bugs.debian.org/cgi-bin/pkgreport.cgi?which=${SURFRAW_debbugs_search}&version=${SURFRAW_debbugs_version}&dist=${SURFRAW_debbugs_dist}&data=${escaped_args}" if ifyes dousertag then user=${SURFRAW_debbugs_user} if null "${user}" then user="${DEBEMAIL:-}" if null "${user}" then cat <<EOF >&2 $w3_argv0 ERROR: can not do usertag search -- user is unknown. * option -user is not provided * environment variable "SURFRAW_debbugs_user" is not set * environment variable "DEBEMAIL" is not set EOF exit 1 fi # See [Email normalization] user=$(printf '%s' "${user}" | tr '[:upper:]' '[:lower:]') fi url="$url&users=$user" fi if yesno SURFRAW_debbugs_archive then url="$url&archive=yes" else url="$url&archive=no" fi if ifyes SURFRAW_debbugs_merge then url="$url&repeatmerged=no" fi if ifno SURFRAW_debbugs_statussort then url="$url&raw=yes" fi if ifno SURFRAW_debbugs_head then url="$url&show_list_header=no" fi if ifno SURFRAW_debbugs_foot then url="$url&show_list_footer=no" fi if ifyes SURFRAW_debbugs_revstat then url="$url&pend-rev=yes" fi if ifyes SURFRAW_debbugs_revsev then url="$url&sev-rev=yes" fi if ifyes SURFRAW_debbugs_revbugs then url="$url&bug-rev=yes" fi if [ "$SURFRAW_debbugs_incstatus" != "" ] then add=$(echo "$SURFRAW_debbugs_incstatus"|perl -ne 's/pending/pending-fixed/g;s/open/pending/g;print(join("&pend-inc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_excstatus" != "" ] then add=$(echo "$SURFRAW_debbugs_excstatus"|perl -ne 'print(join("&pend-exc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_incsev" != "" ] then add=$(echo "$SURFRAW_debbugs_incsev"|perl -ne 'print(join("&sev-inc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_excsev" != "" ] then add=$(echo "$SURFRAW_debbugs_excsev"|perl -ne 'print(join("&sev-exc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_inctag" != "" ] then add=$(echo "$SURFRAW_debbugs_inctag"|perl -ne 'print(join("&include=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_exctag" != "" ] then add=$(echo "$SURFRAW_debbugs_exctag"|perl -ne 'print(join("&exclude=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi fi w3_browse_url "$url" fi diff --git a/elvi/debcontents b/elvi/debcontents index 2b043c5..bea39df 100755 --- a/elvi/debcontents +++ b/elvi/debcontents @@ -1,175 +1,179 @@ #!/bin/sh # $Id$ # elvis: debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debcontents_arch i386 def SURFRAW_debcontents_distro stable def SURFRAW_debcontents_search "files" defyn SURFRAW_debcontents_ubuntu no defyn SURFRAW_debcontents_archive no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) Local options: -a Search archived debian releases -u Search ubuntu packages instead of debian -search= Type of search files | Packages that contain files named like this path | Paths ending with the keyword word | Packages that contain files or directories whose names contain the keyword Default: $SURFRAW_debcontents_search Environment: SURFRAW_debcontents_search -arch= Specialized search on architecture i386 | Intel x86 (all) powerpc | PowerPC (all) amd64 | AMD64 (all) m68k | Motorola 680x0 (debian, archive.debian) alpha | Alpha (debian, archive.debian) sparc | SPARC (debian, archive.debian) arm | ARM (debian, archive.debian) hppa | HP PA/RISC (debian, archive.debian) ia64 | Intel IA-64 (debian, archive.debian) mips | MIPS (debian, archive.debian) mipsel | MIPS (DEC) (debian, archive.debian) s390 | IBM S/390 (debian, archive.debian) hurd-i386 | Hurd (i386) (debian) kfreebsd-amd64 | kFreeBSD (amd64) (debian) kfreebsd-i386 kFreeBSD (i386) (debian) Default: $SURFRAW_debcontents_arch Environment: SURFRAW_debcontents_arch -distro= Specific distribution Debian: stable | Stable testing | Testing unstable | Unstable oldstable | Old Stable Archived Debian (-a): bo | 1.3.1 hamm | 2.0 slink | 2.1 potato | 2.2 woody | 3.0 sarge | 3.1 etch | 4.0 Ubuntu (-u): dapper | Dapper dapper-updates | Dapper Updates dapper-backports | Dapper Backports hardy | Hardy hardy-updates | Hardy Updates hardy-backports | Hardy Backports intrepid | Intrepid intrepid-updates | Intrepid Updates intrepid-backports| Intrepid Backports jaunty | Jaunty jaunty-updates | Jaunty Updates jaunty-backports | Jaunty Backports karmic | Karmic karmic-updates | Karmic Updates karmic-backports | Karmic Backports lucid | Lucid lucid-updates | Lucid Updates lucid-backports | Lucid Backports maverick | Maverick maverick-updates | Maverick Updates maverick-backports| Maverick Backports natty | Natty natty-updates | Natty Updates natty-backports | Natty Backports Default: $SURFRAW_debcontents_distro Environment: SURFRAW_debcontents_distro EOF w3_global_usage } mkopts a u search= arch= distro= w3_complete_hook_opt () { local opt="$1" case "$opt" in -search=*) echo files path word ;; -arch=*) echo i386 powerpc amd64 m68k alpha sparc arch hppa ia64 mips mipsel s390 hurd-i386 kfreebsd-amd64 kfreebsd-i386 ;; # The values for -distro= in the help are outdated. -distro=*) echo stable testing unstable oldstable bo hamm slink potato woody sarge etch for ubuntu_dist in dapper hardy intrepid jaunty karmic lucid maverick natty do echo "$ubuntu_dist" echo "${ubuntu_dist}-updates" echo "${ubuntu_dist}-backports" done ;; *) return 1 ;; esac } +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -arch=*) setopt SURFRAW_debcontents_arch $optarg ;; -distro=*) setopt SURFRAW_debcontents_distro $optarg ;; -search=*) setopt SURFRAW_debcontents_search $optarg ;; -u*) setoptyn SURFRAW_debcontents_ubuntu yes ;; -a*) setoptyn SURFRAW_debcontents_archive yes ;; -ca*) setoptyn SURFRAW_debcontents_usecase yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if ifyes SURFRAW_debcontents_ubuntu then searchpage="http://packages.ubuntu.com/#search_contents" searchurl="http://packages.ubuntu.com/search" elif ifyes SURFRAW_debcontents_archive then searchpage="https://archive.debian.net/#search_contents" searchurl="https://archive.debian.net/search" else searchpage="https://packages.debian.org/#search_contents" searchurl="https://packages.debian.org/search" fi if test -z "$w3_args"; then w3_browse_url "$searchpage" else escaped_args=$(w3_url_of_arg $w3_args) if ifyes SURFRAW_debcontents_ubuntu then if [ "$SURFRAW_debcontents_distro" = "stable" ] then SURFRAW_debcontents_distro=raring fi fi url="$searchurl?keywords=${escaped_args}&searchon=contents" url="$url&arch=${SURFRAW_debcontents_arch}" url="$url&suite=${SURFRAW_debcontents_distro}" case "$SURFRAW_debcontents_search" in p*) if ifyes SURFRAW_debcontents_ubuntu || ifyes SURFRAW_debcontents_archive then searchmode="" else searchmode=path fi;; f*) searchmode=exactfilename ;; w*) searchmode=filename ;; *) err "Unknown search type" ;; esac url="${url}&mode=${searchmode}" w3_browse_url "$url" fi diff --git a/elvi/debpackages b/elvi/debpackages index 39906e0..acd1e3a 100755 --- a/elvi/debpackages +++ b/elvi/debpackages @@ -1,169 +1,173 @@ #!/bin/sh # $Id$ # elvis: debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debian_release any def SURFRAW_debian_distro any def SURFRAW_debian_search pkg defyn SURFRAW_debian_ubuntu no defyn SURFRAW_debian_subwords yes defyn SURFRAW_debian_archive no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) Local options: -a Search archived debian distributions -u Search ubuntu packages instead of debian -release= Specialized search on release Debian: any | all releases main | main release contrib | contrib non-free | packages not meeting DFSG Ubuntu (-u): any | all releases main | restricted | universe | multiverse | Default: $SURFRAW_debian_release Environment: SURFRAW_debian_release -distro= Specific distribution Debian: any | All distributions stable | Stable testing | Testing unstable | Unstable oldstable | Old Stable experimental | Experimental Archived Debian (-a): bo | 1.3.1 hamm | 2.0 slink | 2.1 potato | 2.2 woody | 3.0 sarge | 3.1 etch | 4.0 Ubuntu (-u): any | All distributions dapper | dapper-updates | dapper-backports | hardy | hardy-updates | hardy-backports | intrepid | intrepid-updates | intrepid-backports| jaunty | jaunty-updates | jaunty-backports | karmic | karmic-updates | karmic-backports | lucid | lucid-updates | lucid-backports | maverick | maverick-updates | maverick-backports| natty | natty-updates | natty-backports Default: $SURFRAW_debian_distro Environment: SURFRAW_debian_distro -search= Field to search pkg | Package names only desc | Descriptions src | Source package names -nosub Don't allow subword matches (exact matches only) EOF w3_global_usage } mkopts release= distro= search= nosub a u w3_complete_hook_opt () { local opt="$1" case "$opt" in -release=*) echo any main contrib non-free restricted universe multiverse ;; # The values for -distro= in the help are outdated. -distro=*) echo any stable testing unstable oldstable experimental bo hamm slink potato woody sarge etch # "any" already exists for Debian, so don't need to do here too. for ubuntu_dist in dapper hardy intrepid jaunty karmic lucid maverick natty do echo "$ubuntu_dist" echo "${ubuntu_dist}-updates" echo "${ubuntu_dist}-backports" done ;; -search=*) echo pkg desc src ;; *) return 1 ;; esac } +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -release=*) setopt SURFRAW_debian_release $optarg ;; -distro=*) setopt SURFRAW_debian_distro $optarg ;; -search=*) setopt SURFRAW_debian_search $optarg ;; -a*) setoptyn SURFRAW_debian_archive yes ;; -u*) setoptyn SURFRAW_debian_ubuntu yes ;; -nos*) setoptyn SURFRAW_debian_subwords no ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if ifyes SURFRAW_debian_ubuntu then searchpage="http://packages.ubuntu.com/" searchurl="http://packages.ubuntu.com/search" elif ifyes SURFRAW_debian_archive then searchpage="http://archive.debian.net/" searchurl="http://archive.debian.net/search" else searchpage="https://packages.debian.org/#search_packages" searchurl="https://packages.debian.org/search" fi if test -z "$w3_args"; then w3_browse_url "$searchpage" else escaped_args=$(w3_url_of_arg $w3_args) if [ "${SURFRAW_debian_distro}" = "any" ]; then SURFRAW_debian_distro="all" fi if [ "${SURFRAW_debian_release}" = "any" ]; then SURFRAW_debian_release="all" fi url="$searchurl?keywords=${escaped_args}&suite=${SURFRAW_debian_distro}&section=${SURFRAW_debian_release}" case "$SURFRAW_debian_search" in pkg*) url="$url&searchon=names" ;; src*) url="$url&searchon=sourcenames" ;; desc*) url="$url&searchon=all" ;; *) err "Unknown search type" ;; esac if ifno SURFRAW_debian_subwords then url="$url&exact=1" fi w3_browse_url "$url" fi diff --git a/elvi/debpts b/elvi/debpts index 165755c..601a8c4 100755 --- a/elvi/debpts +++ b/elvi/debpts @@ -1,44 +1,48 @@ #!/bin/sh # $Id$ # elvis: debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) # [email protected] 20040729 . surfraw || exit 1 w3_config_hook () { def SURFRAW_debpts_viewdocs 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Debian Package Tracking System (packages.qa.debian.org) Local options: -doc View PTS documentation EOF w3_global_usage } mkopts doc +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -d*) setopt SURFRAW_debpts_viewdocs 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ $SURFRAW_debpts_viewdocs -eq 1 ]; then w3_browse_url "https://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system" elif test -z "$w3_args"; then w3_browse_url "https://packages.qa.debian.org/common/index.html" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://packages.qa.debian.org/common/index.html?src=${escaped_args}" fi diff --git a/elvi/debsec b/elvi/debsec index 9797314..6223d86 100755 --- a/elvi/debsec +++ b/elvi/debsec @@ -1,23 +1,27 @@ #!/bin/sh # elvis: debsec -- Search the Debian Security Tracker for CVE ids or package names # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Search the Debian Security Tracker for CVE ids or package names EOF w3_global_usage } +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_config w3_parse_args "$@" if test -z "$w3_args"; then w3_browse_url "https://security-tracker.debian.org/tracker" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://security-tracker.debian.org/tracker/${escaped_args}" fi diff --git a/elvi/freshmeat b/elvi/freshmeat index f897557..b41a941 100755 --- a/elvi/freshmeat +++ b/elvi/freshmeat @@ -1,23 +1,27 @@ #!/bin/sh # $Id$ # elvis: freshmeat -- Search Freshmeat (www.freshmeat.net) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Freshmeat (www.freshmeat.net) EOF w3_global_usage } +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.freecode.com/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.freecode.com/search?q=${escaped_args}" fi diff --git a/elvi/fsfdir b/elvi/fsfdir index 90b29f7..642ab21 100755 --- a/elvi/fsfdir +++ b/elvi/fsfdir @@ -1,24 +1,28 @@ #!/bin/sh # $Id$ # elvis: fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the FSF/UNESCO Free Software Directory (directory.fsf.org) EOF w3_global_usage } +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://directory.fsf.org/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://directory.fsf.org/search/?query=${escaped_args}" fi diff --git a/elvi/sourceforge b/elvi/sourceforge index 77587ef..fb8715a 100755 --- a/elvi/sourceforge +++ b/elvi/sourceforge @@ -1,73 +1,77 @@ #!/bin/sh # elvis: sourceforge -- Search SourceForge (www.sourceforge.net) # $Id$ . surfraw || exit 1 # version 0.2 [email protected] 20030910 # added -exact and -type # version 0.1 # this great work has been achieved by Caiaphas Pechorin ([email protected]) w3_config_hook () { defyn SURFRAW_sourceforge_exact no def SURFRAW_sourceforge_searchtype soft } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search SourceForge (www.sourceforge.net) Local options: -exact=yes|no Require all words Default: $SURFRAW_sourceforge_exact Environment: SURFRAW_sourceforge_exact -type= soft | Software / Group people | People freshmeat Freshmeat Default: $SURFRAW_sourceforge_searchtype Environment: SURFRAW_sourceforge_searchtype EOF w3_global_usage } mkopts exact exact= type= w3_complete_hook_opt () { local opt="$1" case "$opt" in -exact=*) echo yes no ;; -type=*) echo soft people freshmeat ;; *) return 1 ;; esac } +w3_complete_hook_arg () +{ + w3_complete_packages "$@" || w3_complete_hook_arg_default "$@" +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -e*=*) setoptyn SURFRAW_sourceforge_exact $optarg ;; -e*) setoptyn SURFRAW_sourceforge_exact yes ;; -t*=*) setopt SURFRAW_sourceforge_searchtype $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.sourceforge.net/" else escaped_args=$(w3_url_of_arg $w3_args) if $(yesno SURFRAW_sourceforge_exact) then isexact=1 else isexact=0 fi w3_browse_url "https://sourceforge.net/search/?words=${escaped_args}&exact=$isexact&typeofsearch=$SURFRAW_sourceforge_searchtype" fi
JNRowe/surfraw
2704635a3da7f4c15efba699d0fda0913b3b0c71
Add package-name completion function
diff --git a/surfraw.IN b/surfraw.IN index d7435b6..f31c109 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,794 +1,818 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 # $0 can be -bash when sourced for tab completions. # POSIX seems to assume `--` support. w3_argv0=$(basename -- "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default conf="@sysconfdir@/xdg/surfraw/$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value="\"\$${1}\"" case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value="\"\$${1}\"" # Do nothing if already have a value. test -z "$value" && eval ${1}="\"$2\"" return 0 } defyn () { def "$@" yesno "$1" } setopt () { eval value="\"\$${1}\"" eval ${1}="\"$2\"" } setoptyn () { setopt "$@" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } # Should only complete for specific options # Called before declared-options completions w3_complete_hook_opt () { return 1 } +# Provide package-name completions +# TODO: add more distro package managers +w3_complete_packages () +{ + if command -v apt-cache >/dev/null 2>&1 + then + apt-cache --generate pkgnames -- "$1" + elif command -v pacman >/dev/null 2>&1 + then + # Do prefix searches like the others. + # TODO: prevent accidental regex searching by users. + # How often is this likely to occur though? + pacman -Ssq "^$1" + elif command -v yum >/dev/null 2>&1 + then + # Get plain name excluding arch (to match the others)--assuming names have no dots. + yum list all -- "${1}*" | cut -d . -f 1 + elif command -v fink >/dev/null 2>&1 + then + fink list -- "${1}*" | cut -f 2 + else + return 1 + fi +} # Completions for main surfraw script w3_complete_hook_opt_global () { local opt="$1" case "$opt" in -bookmark-search-elvis=*) cd "$(get_local_elvi_dir)" 2>/dev/null && echo * cd "$elvidir" && echo * ;; # -browser=* can be anything -custom-search=*) echo google duckduckgo ;; -escape-url-args=*) echo yes no ;; # -o=* can be anything -new=*|-ns=*|-newscreen=*) echo yes no ;; *) return 1 ;; esac } # Allowed to use a plain '*' in case statements # Called before declared-options completions # These must print newline-delimited completion alternatives (if any are defined for the argument) w3_complete_hook_arg_default () { local arg="$1" if command -v look >/dev/null 2>&1 then look -- "${arg:-''}" else return 1 fi } w3_complete_hook_arg () { w3_complete_hook_arg_default "$@" } w3_complete () { local arg="$1" w3_complete_hook_opt "$arg" && return 0 w3_complete_hook_opt_global "$arg" && return 0 # At this point, `arg` is either: # 1. an option that takes an argument BUT doesn't define completions for it; # 2. a flag; # 3. an incomplete option name; or # 4. a non-option argument. case "$arg" in # Avoid completing options that don't define completions for the optarg -*=*) return 0 ;; # Complete options -*) # Remove ' ' "options" echo "$SURFRAW__complete_flags $SURFRAW__complete_options" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -s '[:space:]' return 0 ;; esac w3_complete_hook_arg "$arg" return 0 } # Properly complete calls like "sr fooelvis -- -notanoption" w3_complete_arg () { local arg="$1" w3_complete_hook_arg "$arg" return 0 } # Declare options (and valid arguments, TODO) # Does not need leading hyphen # Example use: # mkopts flag optwithvar= mkopts () { for opt in "$@" do case "$opt" in *=*) SURFRAW__complete_options="$SURFRAW__complete_options -$(echo $opt | sed 's/^\([^=]*=\).*/\1/')" ;; *) SURFRAW__complete_flags="$SURFRAW__complete_flags -$opt" ;; esac done } # Options with arguments mkopts bookmark-search-elvis= browser= escape-url-args= new= ns= newscreen= custom-search= o= # Flags mkopts elvi graphical help local-help quote new ns newscreen o text version print w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi*) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh|-\? ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --complete=* | \ -complete=*) w3_complete "$optarg"; exit 0 ;; --complete-arg=* | \ -complete-arg=*) w3_complete_arg "$optarg"; exit 0 ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then w3_parse_option "$arg" fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="$(quote "$arg")" unquoted_opts="$arg" else opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then exec sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then exec sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=$(bookmark_lookup $elvi) if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else echo "$w3_argv0: $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
6747c95f53190271259d1f9e72c65b26cbfc1221
Add custom completions for each elvis
diff --git a/elvi/S b/elvi/S index dd2f62b..d209085 100755 --- a/elvi/S +++ b/elvi/S @@ -1,46 +1,47 @@ #!/bin/sh # [email protected] 20131006 # elvis: S -- Search using custom search provider . surfraw || exit 1 w3_config_hook () { def SURFRAW_S_site "" def SURFRAW_S_inurl "" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search using a custom search provider Local options: -s=SITE Limit search to SITE -u=INURL Limit search to URLs containing INURL EOF w3_custom_search_usage w3_global_usage } +mkopts s= u= w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s=*) SURFRAW_S_site="$SURFRAW_S_site -s=$optarg" ;; -u=*) SURFRAW_S_inurl="$SURFRAW_S_inurl -u=$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if test -z "$w3_args" then w3_custom_search else # FIXME: sort out quoting w3_custom_search $SURFRAW_S_site $SURFRAW_S_inurl "$w3_shquoted_args" fi diff --git a/elvi/W b/elvi/W index afb04b5..3afbbf9 100755 --- a/elvi/W +++ b/elvi/W @@ -1,17 +1,23 @@ #!/bin/sh # $Id$ # elvis: W -- Activate Surfraw defined web-browser . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [browser-options] url Description: Surfraw activate the currently configured web-browser ($SURFRAW_browser) EOF w3_global_usage } +# Do default argument completions--which should be filenames. +w3_complete_hook_arg () +{ + return 1 +} + w3_config w3_parse_args "$@" w3_browse_url "$w3_args" diff --git a/elvi/acronym b/elvi/acronym index 9aa0d8a..fa624dc 100755 --- a/elvi/acronym +++ b/elvi/acronym @@ -1,168 +1,169 @@ #!/bin/sh # $Id$ # elvis: acronym -- Look for acronyms definitions (www.acronymfinder.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_acronym_ict 0 defyn SURFRAW_acronym_sci 0 defyn SURFRAW_acronym_gov 0 defyn SURFRAW_acronym_org 0 defyn SURFRAW_acronym_biz 0 defyn SURFRAW_acronym_pop 0 defyn SURFRAW_acronym_exa 1 defyn SURFRAW_acronym_wim 0 defyn SURFRAW_acronym_zip 0 defyn SURFRAW_acronym_ran 0 defyn SURFRAW_acronym_gen 0 defyn SURFRAW_acronym_alpha 0 defyn SURFRAW_acronym_attic 0 def SURFRAW_acronym_path def SURFRAW_acronym_par } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [option] [keyword] Description: Surfraw searches for possible definitions of acronyms using acronymfinder.com Local option: -i -ict List all acronyms matching in Information Technology category -s -sci List all acronyms matching in Science & Medicine category -g -gov List all acronyms matching in Government & Military category -o -org List all acronyms matching in Organizations & Schools category -b -biz List all acronyms matching in Business & Finance category -c -common List all acronyms matching in Slang & Pop Culture category -e -exact List all acronyms matching with exact match (Default when keyword specified) -w -wim List all acronyms matching with Word(s) in meaning match -z -zip List all acronyms matching with Location (postal code, name) match -r -random List a random acronym (Default when no keyword specified) -f -fake List a fake acronym generated with the Acronym Finder Random Systematic Buzz Phrase Projector (AFRSBPP) -a -alphabetic List all acronyms matching sorted alphabetically instead of by rank -u -unverified List all acronyms matching, included those unverified by men and potentially misleading (Acronym Attic) EOF w3_global_usage } +mkopts ict sci gov org biz common exact wim zip random fake alphabetic unverified w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in #Information Technology category - -i*) setoptyn SURFRAW_acronym_ict 1 + -i|-ict) setoptyn SURFRAW_acronym_ict 1 setoptyn SURFRAW_acronym_sci 0 setoptyn SURFRAW_acronym_gov 0 setoptyn SURFRAW_acronym_org 0 setoptyn SURFRAW_acronym_biz 0 setoptyn SURFRAW_acronym_pop 0 ;; #Science & Medicine category - -s*) setoptyn SURFRAW_acronym_sci 1 + -s|-sci) setoptyn SURFRAW_acronym_sci 1 setoptyn SURFRAW_acronym_ict 0 setoptyn SURFRAW_acronym_gov 0 setoptyn SURFRAW_acronym_org 0 setoptyn SURFRAW_acronym_biz 0 setoptyn SURFRAW_acronym_pop 0 ;; #Government & Military category - -g*) setoptyn SURFRAW_acronym_gov 1 + -g|-gov) setoptyn SURFRAW_acronym_gov 1 setoptyn SURFRAW_acronym_sci 0 setoptyn SURFRAW_acronym_ict 0 setoptyn SURFRAW_acronym_org 0 setoptyn SURFRAW_acronym_biz 0 setoptyn SURFRAW_acronym_pop 0 ;; #Organizations & Schools category - -o*) setoptyn SURFRAW_acronym_org 1 + -o|-org) setoptyn SURFRAW_acronym_org 1 setoptyn SURFRAW_acronym_sci 0 setoptyn SURFRAW_acronym_gov 0 setoptyn SURFRAW_acronym_ict 0 setoptyn SURFRAW_acronym_biz 0 setoptyn SURFRAW_acronym_pop 0 ;; #Business & Finance category - -b*) setoptyn SURFRAW_acronym_biz 1 + -b|-biz) setoptyn SURFRAW_acronym_biz 1 setoptyn SURFRAW_acronym_sci 0 setoptyn SURFRAW_acronym_gov 0 setoptyn SURFRAW_acronym_org 0 setoptyn SURFRAW_acronym_ict 0 setoptyn SURFRAW_acronym_pop 0 ;; #Slang & Pop Culture category - -c*) setoptyn SURFRAW_acronym_pop 1 + -c|-common) setoptyn SURFRAW_acronym_pop 1 setoptyn SURFRAW_acronym_sci 0 setoptyn SURFRAW_acronym_gov 0 setoptyn SURFRAW_acronym_org 0 setoptyn SURFRAW_acronym_biz 0 setoptyn SURFRAW_acronym_ict 0 ;; #exact match - -e*) setoptyn SURFRAW_acronym_exa 1 + -e|-exact) setoptyn SURFRAW_acronym_exa 1 setoptyn SURFRAW_acronym_wim 0 setoptyn SURFRAW_acronym_zip 0 ;; #Word(s) in meaning match - -w*) setoptyn SURFRAW_acronym_wim 1 + -w|-wim) setoptyn SURFRAW_acronym_wim 1 setoptyn SURFRAW_acronym_exa 0 setoptyn SURFRAW_acronym_zip 0 ;; #Location (postal code, name) match - -z*) setoptyn SURFRAW_acronym_zip 1 + -z|-zip) setoptyn SURFRAW_acronym_zip 1 setoptyn SURFRAW_acronym_wim 0 setoptyn SURFRAW_acronym_exa 0 ;; #Random acronym - -r*) setoptyn SURFRAW_acronym_ran 1 + -r|-random) setoptyn SURFRAW_acronym_ran 1 setoptyn SURFRAW_acronym_gen 0 ;; #Fake acronym - -f*) setoptyn SURFRAW_acronym_gen 1 + -f|-fake) setoptyn SURFRAW_acronym_gen 1 setoptyn SURFRAW_acronym_ran 0 ;; #Sort alphabetically - -a*) setoptyn SURFRAW_acronym_alpha 1 ;; + -a|-alphabetic) setoptyn SURFRAW_acronym_alpha 1 ;; #Match from Acronym Attic - -u*) setoptyn SURFRAW_acronym_attic 1 ;; + -u|-unverified) setoptyn SURFRAW_acronym_attic 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then if [ "$SURFRAW_acronym_gen" = 1 ]; then SURFRAW_acronym_path="http://www.acronymfinder.com/buzzgen.asp" # Fake Acronym else SURFRAW_acronym_path="http://www.acronymfinder.com/random.aspx" # Random Acronym fi else escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_acronym_attic" = 1 ]; then SURFRAW_acronym_path="http://www.acronymattic.com/~/search/aa.aspx?Acronym=" # Acronym Attic else SURFRAW_acronym_path="http://www.acronymfinder.com/~/search/af.aspx?Acronym=" # Acronym Finder if [ "$SURFRAW_acronym_exa" = 1 ]; then par="exact" elif [ "$SURFRAW_acronym_wim" = 1 ]; then par="on" elif [ "$SURFRAW_acronym_zip" = 1 ]; then par="zip" fi SURFRAW_acronym_par="&Find=find&string=$par&Page=1" if [ "$SURFRAW_acronym_ict" = 1 ]; then par="IT" elif [ "$SURFRAW_acronym_sci" = 1 ]; then par="SciMed" elif [ "$SURFRAW_acronym_gov" = 1 ]; then par="MilGov" elif [ "$SURFRAW_acronym_org" = 1 ]; then par="Org" elif [ "$SURFRAW_acronym_biz" = 1 ]; then par="Business" elif [ "$SURFRAW_acronym_pop" = 1 ]; then par="Slang" fi SURFRAW_acronym_par="$SURFRAW_acronym_par&Category=$par" fi if [ "$SURFRAW_acronym_alpha" = 1 ]; then SURFRAW_acronym_par="$SURFRAW_acronym_par&s=a" fi fi w3_browse_url "$SURFRAW_acronym_path${escaped_args}$SURFRAW_acronym_par" diff --git a/elvi/alioth b/elvi/alioth index c6abcdf..8653732 100755 --- a/elvi/alioth +++ b/elvi/alioth @@ -1,48 +1,57 @@ #!/bin/sh # $Id$ # elvis: alioth -- Search Alioth (alioth.debian.org) # [email protected] 20030910 # adapted from sourceforge elvi . surfraw || exit 1 w3_config_hook () { def SURFRAW_alioth_searchtype soft } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Alioth (alioth.debian.org) Local options: -type= soft | Software / Group skill | Skills people People Default: $SURFRAW_alioth_searchtype Environment: SURFRAW_alioth_searchtype EOF w3_global_usage } +mkopts type= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -type=*) echo soft skill people ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -t*=*) setopt SURFRAW_alioth_searchtype $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://alioth.debian.org/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://alioth.debian.org/search/?words=${escaped_args}&type_of_search=$SURFRAW_alioth_searchtype" fi diff --git a/elvi/amazon b/elvi/amazon index cc20cdb..4a67ad9 100755 --- a/elvi/amazon +++ b/elvi/amazon @@ -1,244 +1,254 @@ #!/bin/sh # $Id$ # elvis: amazon -- Search the amazon.com bookstore . surfraw || exit 1 w3_config_hook () { def SURFRAW_amazon_country "$SURFRAW_lang" def SURFRAW_amazon_search all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search amazon Local options: -country=COUNTRY Two letter domain-style country code com | Main amazon.com site (default) ca | Canada cn | China de | Germany fr | France jp | Japan uk UK Environment: SURFRAW_amazon_country, SURFRAW_lang Default: $SURFRAW_amazon_country -search= Specialised search on topic all All Departments. amazon.com: apparel Apparel & Accessories automotive Automotive baby-products Baby beauty Beauty books Books wireless-aps Cell Phones & Service electronics Electronics misc Everything Else gourmet Gourmet Food grocery Grocery hpc Health & Personal Care garden Home & Garden tools Home Improvement industrial Industrial & Scientific jewelry Jewelry digital-text Kindle Store magazines Magazines dvd Movies & TV digital-music MP3 Downloads popular Music mi Musical Instruments office-products Office Products & Supplies shoes Shoes software Software sporting Sports & Outdoors toys-and-games Toys & Games vhs VHS videogames Video Games amazontv Video On Demand watches Watches uk: books Books electronics Electronics popular Music classical Classical Music digital-music MP3 Downloads dvd DVD vhs VHS software Software videogames Video Games software-videogames Software & Games diy DIY & Tools outdoor Garden & Outdoors kitchen Kitchen & Home drugstore Health & Beauty beauty Beauty toys Toys & Games sports Sports & Leisure jewelry-watches Jewellery & Watches clothing Clothing shoes Shoes & Accessories baby Baby fr: books Livres en français english-books Livres en anglais electronics High-tech popular Musique classical Musique classique dvd DVD & Vidéo blu-ray Blu-ray software Logiciels videogames Jeux vidéo toys Jeux et Jouets kitchen Cuisine & Maison jewelry-watches Montres & Bijoux de: books Bücher english-books Englische Bücher magazines Zeitschriften popular Musik classical Klassische Musik dvd DVD blu-ray Blu-ray electronics Elektronik & Foto computer Computer photo Kamera & Foto kitchen Küche & Haushalt diy Baumarkt automotive Auto & Motorrad outdoor Garten & Freizeit drugstore Drogerie & Bad beauty Parfümerie & Kosmetik software Software videogames Games toys Spielzeug sports Sport & Freizeit jewelry-watches Uhren & Schmuck baby Babyausstattung clothing Bekleidung shoes Schuhe & Handtaschen ca: books Books popular Music classical Classical Music dvd DVD vhs VHS electronics Electronics software Software videogames Video Games jp: books a書 english-books m酪 electronics 痩d&塔Jメラ kitchen zメ[ム&Lャb\`ャ popular 塔~ュ[<WbャN classical Nャ宴VbャN音y dvd DVD software PC潟\tャg videogames Qメ[ム toys おもちゃ&zャr[ sporting <X|メ[c&ャAEャghャA hpc wャ泣X&rャ[eャB[ beauty <RXャ food-beverage $Hi&譜料 watch 時v baby 激xrメ[&}ャ^jャeB apparel ャApャ激&æ³£t@ャbVャ梼G貨 cn: 1 图书 2 音乐 3 影视 5 手机 6 家电 7 化妆 8 厨具 9 家居 10 运动健康 11 玩具 12 钟表首饰 14 个人护理 15 软件 16 游戏/娱乐 17 礼品箱包 20 摄影摄像 21 Mp3/Mp4 22 视听设备 23 电脑配件 25 教育音像 Default: $SURFRAW_amazon_search Environment: SURFRAW_amazon_search Examples: $w3_argv0 -search=books -country=uk -q The Lotus and The Robot EOF w3_global_usage } +mkopts country= search= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -country=*) echo com ca cn zh zt de fr jp uk;; + # There are so many *site-specific* values for `-search=` that it's not useful to complete. + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -search=*) setopt SURFRAW_amazon_search $optarg ;; -country=*) setopt SURFRAW_amazon_country $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_amazon_country" in uk) host=www.amazon.co.uk ;; de) host=www.amazon.de ;; fr) host=www.amazon.fr ;; jp) host=www.amazon.co.jp ;; ca) host=www.amazon.ca ;; cn|zh|zt) host=www.amazon.cn ;; *) host=www.amazon.com ;; esac if null "$w3_args"; then w3_browse_url "https://${host}/" else escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_amazon_search" = books ] ; then SURFRAW_amazon_search=stripbooks elif [ "$SURFRAW_amazon_search" = all ] ; then SURFRAW_amazon_search=aps fi case "$host" in www.amazon.cn) path="mn/searchApp" if [ "$SURFRAW_amazon_search" = "aps" ] ;then SURFRAW_amazon_search="" fi args="ix=sunray&pageletid=headsearch&searchType=${SURFRAW_amazon_search}&keywords=${escaped_args}&Go.x=0&Go.y=0&bestSaleNum=0" break;; www.amazon.co.jp) path="s/ref=nb_ss_gw" args="__mk_ja_JP=%83J%83%5E%83J%83i&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.co.uk) path="s/ref=nb_ss_w_h_" args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.fr) path="s/ref=nb_ss_w" args="__mk_fr_FR=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.de) path="s/ref=nb_ss_w" args="__mk_de_DE=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.ca) path="s/ref=nb_ss_gw" args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; *) path="s/ref=nb_ss_gw" args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" esac w3_browse_url "https://${host}/${path}?${args}" fi diff --git a/elvi/archpkg b/elvi/archpkg index 0b73410..4fb2f22 100755 --- a/elvi/archpkg +++ b/elvi/archpkg @@ -1,98 +1,108 @@ #!/bin/sh # elvis: archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) # Author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_arch_ix "$SURFRAW_ix" def SURFRAW_arch_repo "$SURFRAW_repo" def SURFRAW_arch_date "$SURFRAW_date" def SURFRAW_arch_results 25 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search string] Description: Surfraw search Arch Linux packages (www.archlinux.org) Local options: -arch=ARCHITECTURES | -a=ARCHITECTURES any | Any (default) i686 | i686 x86_64 | x86_64 -repo=REPOSITORIES | -r=REPOSITORIES comm | Community commtest | Community-Testing core | Core extra | Extra multi | Multilib multitest | Multilib-Testing test | Testing Default: All -date=UPDATED | -d=UPDATED (format: YYYY-MM-DD) -num=NUMBER | Number of results per page Default: $SURFRAW_arch_results EOF w3_global_usage } +mkopts arch= repo= date= num= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -arch=*) echo any i686 x86_64 ;; + -repo=*) echo comm commtest core extra multi multitest test ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -a*=*) setopt SURFRAW_arch_ix $optarg ;; -r*=*) setopt SURFRAW_arch_repo $optarg ;; -d*=*) setopt SURFRAW_arch_date $optarg ;; -n*=*) setopt SURFRAW_arch_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # selected repository case "$SURFRAW_arch_repo" in comm) repo="Community" ;; commtest) repo="Community-Testing" ;; core) repo="Core" ;; extra) repo="Extra" ;; multi) repo="Multilib" ;; multitest)repo="Multilib-Testing" ;; test) repo="Testing" ;; *) repo="" ;; esac # no arguments present if [ -z "$w3_args" ]; then w3_browse_url "https://www.archlinux.org/packages/" else # if w3_args contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) base="https://www.archlinux.org/packages/?sort=" # repository and architecture if [ -n "$SURFRAW_arch_repo" -a "$SURFRAW_arch_ix" ]; then w3_browse_url "${base}&arch=${SURFRAW_arch_ix}&repo=${repo}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" # check for repository elif [ -n "$SURFRAW_arch_repo" ]; then w3_browse_url "${base}&repo=${repo}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" # just architecture elif [ -n "$SURFRAW_arch_ix" ]; then w3_browse_url "${base}&arch=${SURFRAW_arch_ix}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" # none of the above... else w3_browse_url "${base}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" fi fi diff --git a/elvi/archwiki b/elvi/archwiki index ad5fef8..c677699 100755 --- a/elvi/archwiki +++ b/elvi/archwiki @@ -1,76 +1,85 @@ #!/bin/sh # elvis: archwiki -- Search the Arch Linux Wiki # Author: http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_archwiki_language "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Arch Linux Wiki (wiki.archlinux.org) Local options -language=ISOCODE Two letter language code (resembles ISO country codes) -l=ISOCODE en | Main Arch Wiki site (default) fr | French de | German he | Hebrew pl | Polish pt | Portugese ro | Romanian es | Spanish sv | Swedish uk | Ukranian Environment: SURFRAW_archwiki_language, SURFRAW_lang Default: en EOF w3_global_usage } +mkopts language= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -l=*|-language=*) echo en fr de he pl pt ro es sv uk ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_archwiki_language $optarg ;; -l=*) setopt SURFRAW_archwiki_language $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains list of arguments case "$SURFRAW_archwiki_language" in en) domain=".org" ;; fr) domain=".fr" ;; de) domain=".de" ;; he) domain=".il" ;; pl) domain=".pl" ;; pt) domain="-br.org" ;; ro) domain=".ro" ;; es) domain=".cl" ;; sv) domain=".sv" ;; uk) domain=".ua" ;; *) domain=".org" ;; esac # handle ssl if [ $domain = ".org" -o $domain = ".de" ]; then protocol="https://"; else protocol="http://"; fi if [ -z "$w3_args" ]; then w3_browse_url "${protocol}wiki.archlinux${domain}/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${protocol}wiki.archlinux${domain}/index.php?search=${escaped_args}" fi diff --git a/elvi/arxiv b/elvi/arxiv index 3c64609..d6f55ba 100755 --- a/elvi/arxiv +++ b/elvi/arxiv @@ -1,141 +1,149 @@ #!/bin/sh # # $Id$ # # elvis: arxiv -- Search arXiv E-Print Archive for articles # # 2008-June-03 - By John Gruenenfelder ([email protected]) # Rewrote 'xxx' script to allow searching arXiv site by various # means. # . surfraw || exit 1 w3_config_hook () { def SURFRAW_arxiv_scope all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search terms] Description: Surfraw the Los Alamos Science E-Print Archive (arXiv) Local options: -scope= Limit scope of arXiv search all | Search all fields title | Search article titles author | Search article authors abstract | Search article abstracts fulltext Search the full text of articles Default: $SURFRAW_arxiv_scope Environment: SURFRAW_arxiv_scope EOF w3_global_usage } - +mkopts scope= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -scope=*) echo all title author abstract fulltext ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -scope=*) setopt SURFRAW_arxiv_scope $optarg ;; *) return 1 ;; esac return 0 } # Parse config w3_config # Parse search terms SURFRAW_escape_url_args=no w3_parse_args "$@" # Mangle search terms into something useable terms="" cnt=0 if [ ! -z "$w3_args" ]; then case $SURFRAW_arxiv_scope in all | title | abstract) if [ $(w3_url_of_arg $w3_args | cut -c1) = \" ]; then terms="+EXACT+"$(echo $w3_args | sed -e 's/ /_/g') else for w in $w3_args ; do terms="+"$(w3_url_of_arg $w)$terms cnt=$((cnt + 1)) if [ $cnt -gt 1 ]; then terms="+AND"$terms fi done fi terms=$(echo $terms | sed -e 's/"//g') ;; author) # Names without commas need to be reversed echo "$w3_args" | grep -q "," if [ $? -eq 0 ]; then # Name already in last, first format. terms=$(echo "$w3_args" | sed -e "s/,/_/g" -e "s/ //g") terms="+"$(w3_url_of_arg $terms) else # Name in first last format. Need to reverse. first="" last="" for n in $w3_args ; do if [ -z $first ]; then first=$n elif [ -z $last ]; then last=$n fi done terms="" if [ -n "$last" ]; then terms="${last}_" fi terms="$terms$first" terms="+"$(w3_url_of_arg $terms) fi ;; fulltext) terms=$(w3_url_escape $w3_args) ;; *) return 1 ;; esac fi # Form URL if [ -z "$w3_args" ]; then url="https://arXiv.org/" else case $SURFRAW_arxiv_scope in all) url="https://arXiv.org/find/all/1/all:"$terms"/0/1/0/all/0/1" ;; title) url="https://arXiv.org/find/all/1/ti:"$terms"/0/1/0/all/0/1" ;; abstract) url="https://arXiv.org/find/all/1/abs:"$terms"/0/1/0/all/0/1" ;; author) url="https://arXiv.org/find/all/1/au:"$terms"/0/1/0/all/0/1" ;; fulltext) url="https://search.arXiv.org:8081/?query="$terms"&in=" ;; *) return 1 ;; esac fi w3_browse_url $url diff --git a/elvi/aur b/elvi/aur index a8a21a3..987a6f2 100755 --- a/elvi/aur +++ b/elvi/aur @@ -1,146 +1,159 @@ #!/bin/sh # # AUTHOR: René Reigel based on piratebay by J.R. Mauro # Ivy Foster added additional search options # # DESC: Search the Arch User Repository # $ID$ # elvis: aur -- Search aur.archlinux.org for PKGBUILDs . surfraw || exit 1 w3_config_hook () { def SURFRAW_aur_action "Search=Go" def SURFRAW_aur_category "any" def SURFRAW_aur_order "a" def SURFRAW_aur_language en defyn SURFRAW_aur_outdated 0 def SURFRAW_aur_protocol "https" def SURFRAW_aur_results "$SURFRAW_results" def SURFRAW_aur_search name def SURFRAW_aur_sort name } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search aur.archlinux.org for PKGBUILDS Local options -category Search the given AUR category Consult aur.archlinux.org/packages.php for a complete list. Default: any -language Search in your your language See aur.archlinux.org for available languages Default: en -no-https Connect using HTTP, rather than HTTPS. This disables logging in. Default: use $SURFRAW_aur_protocol -order=ascending|descending Organize in ascending or descending order Default: ascending -orphans Search orphaned packages -outdated Search for out-of-date packages -results=NUM Number of search results returned Default: $SURFRAW_aur_results Must be in range 25-100 -search= Search for one of... name | Package name maintainer | Maintainer submitter | Submitter Default: name -sort= Sort by... name | Package name category | Package category location | Package location votes | Number of votes maintainer | Package maintainer age | Package age Default: name EOF w3_global_usage } +mkopts category= language= no-https order= orphans outdated results= search= sort= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + # What are the categories for the AUR? It seems to have been removed from the web interface. + -language=*) echo ca cs de en es fr hr hu it nb_no nb_NO pl pt ro ru sr tr uk zh_cn zh_CN ;; + -order=*) echo ascending descending ;; + -search=*) echo name maintainer submitter ;; + -sort=*) echo name category location votes maintainer age ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -category=*) setopt SURFRAW_aur_category "$optarg" ;; -language=*) setopt SURFRAW_aur_language "$optarg" ;; -no-https) setopt SURFRAW_aur_protocol "http" ;; -orphans*) setopt SURFRAW_aur_action "Orphans=Orphans" ;; -order=d*) setopt SURFRAW_aur_order d ;; -order=*) setopt SURFRAW_aur_order a ;; -outdated*) setoptyn SURFRAW_aur_outdated 1 ;; -results=*) setopt SURFRAW_aur_results "$optarg" ;; -search=*) setopt SURFRAW_aur_search "$optarg" ;; -sort=*) setopt SURFRAW_aur_sort "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_aur_category" in a*) aur_category=0 ;; da*) aur_category=2 ;; de*) aur_category=3 ;; ed*) aur_category=4 ;; em*) aur_category=5 ;; ga*) aur_category=6 ;; gn*) aur_category=7 ;; i*) aur_category=8 ;; kd*) aur_category=9 ;; ke*) aur_category=19 ;; l*) aur_category=10 ;; mo*) aur_category=11 ;; mu*) aur_category=12 ;; n*) aur_category=13 ;; o*) aur_category=14 ;; sc*) aur_category=15 ;; sy*) aur_category=16 ;; x1*) aur_category=17 ;; xf*) aur_category=18 ;; *) aur_category=0 ;; esac case "$SURFRAW_aur_search" in n*) aur_search_by=nd ;; m*) aur_search_by=m ;; s*) aur_search_by=s ;; *) aur_search_by=nd ;; esac case "$SURFRAW_aur_sort" in n*) aur_sort_by=n ;; c*) aur_sort_by=c ;; l*) aur_sort_by=l ;; v*) aur_sort_by=v ;; m*) aur_sort_by=m ;; a*) aur_sort_by=a ;; *) aur_sort_by=n ;; esac # Use SURFRAW_lang if present and the country has not been changed # More or less verbatim from the google elvis if test -n "$SURFRAW_lang" -a "$SURFRAW_aur_language" = "en"; then SURFRAW_aur_language="$SURFRAW_lang"; fi case "$SURFRAW_aur_language" in ca|cs|de|en|es|fr|hr|hu|it|nb_no|nb_NO|pl|pt|ro|ru|sr|tr|uk|zh_cn|zh_CN) aur_lang="$SURFRAW_aur_language" ;; *) aur_lang=en ;; esac # w3_args now contains a list of arguments if test -z "$w3_args" && test "$SURFRAW_aur_action" = "Search=Go"; then w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?setlang=${aur_lang}" else escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_aur_outdated" = 1 ]; then w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?O=0&L=0&detail=1&C=${aur_category}&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&do_${SURFRAW_aur_action}&outdated=on&setlang=${aur_lang}" else w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?O=0&L=0&detail=1&C=${aur_category}&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&do_${SURFRAW_aur_action}&setlang=${aur_lang}" fi fi diff --git a/elvi/austlii b/elvi/austlii index c66e0d4..dfc0754 100755 --- a/elvi/austlii +++ b/elvi/austlii @@ -1,54 +1,63 @@ #!/bin/sh # $Id$ # elvis: austlii -- Search Australian Law docs (www.austlii.edu.au) . surfraw || exit 1 w3_config_hook () { def SURFRAW_austlii_results $SURFRAW_results def SURFRAW_austlii_method auto } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Australian & world case law, legislation and policy documents at Austlii (www.austlii.edu.au), the Australian Legal Information Institute Local options: -method=auto | boolean | any | all | phrase | legis | title Define search method Default: $SURFRAW_austlii_method Environment: SURFRAW_austlii_method -results=NUM Number of search results returned Default: $SURFRAW_austlii_results Environment: SURFRAW_austlii_results EOF w3_global_usage } +mkopts method= results= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -method=*) echo auto boolean any all phrase legis title ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -method=*) setopt SURFRAW_austlii_method $optarg ;; -results=*) setopt SURFRAW_austlii_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.austlii.edu.au/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.austlii.edu.au/cgi-bin/sinosrch.cgi?method=${SURFRAW_austlii_method}&meta=%2Fau&query=${escaped_args}&results=${SURFRAW_austlii_results}&submit=Search&callback=on&mask_world=&mask_path=" fi diff --git a/elvi/bbcnews b/elvi/bbcnews index 19141b1..1bc4fe0 100755 --- a/elvi/bbcnews +++ b/elvi/bbcnews @@ -1,53 +1,62 @@ #!/bin/sh # $Id$ # elvis: bbcnews -- Search BBC News (news.bbc.co.uk) # [email protected] 20030209 . surfraw || exit 1 w3_config_hook () { if [ "$SURFRAW_lang" = "uk" ]; then def SURFRAW_bbcnews_scope uk else def SURFRAW_bbcnews_scope world fi } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search BBC News (news.bbc.co.uk) Local options: -scope=world | uk Search world or uk news Default: $SURFRAW_bbcnews_scope Environment: SURFRAW_bbcnews_scope EOF w3_global_usage } +mkopts scope= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -scope=*) echo world uk ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -scope=*) setopt SURFRAW_bbcnews_scope $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://news.bbc.co.uk/" else escaped_args=$(w3_url_of_arg $w3_args) if [ $SURFRAW_bbcnews_scope = uk ]; then w3_browse_url "http://search.bbc.co.uk/search?scope=uk&tab=ns&q=${escaped_args}" else w3_browse_url "http://search.bbc.co.uk/search?scope=all&tab=ns&q=${escaped_args}" fi fi diff --git a/elvi/bookfinder b/elvi/bookfinder index d33fda5..93843e8 100755 --- a/elvi/bookfinder +++ b/elvi/bookfinder @@ -1,131 +1,143 @@ #!/bin/sh # $Id$ # elvis: bookfinder -- Search for books using www.bookfinder.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_bookfinder_binding "any" defyn SURFRAW_bookfinder_classic 0 def SURFRAW_bookfinder_currency "USD" def SURFRAW_bookfinder_destination "us" defyn SURFRAW_bookfinder_first 0 def SURFRAW_bookfinder_language "en" def SURFRAW_bookfinder_search "title" defyn SURFRAW_bookfinder_signed 0 def SURFRAW_bookfinder_type "any" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search terms]... Description: Surfraw: Search for books using www.bookfinder.com Example: Local Options: -author="..." Search for an author. Complements -search=title -binding= Search for copies with a particular binding any | Any hard | Hardbacks only soft | Softcovers/paperbacks only Default: $SURFRAW_bookfinder_binding Environment: SURFRAW_bookfinder_binding -classic Use classic search display Default: no Environment: SURFRAW_bookfinder_classic -currency= Display prices in the given currency (ISO currency code) Default: $SURFRAW_bookfinder_currency Environment: SURFRAW_bookfinder_destination -destination= Shipping destination (Two-digit ISO country code) Default: $SURFRAW_bookfinder_destination Environment: SURFRAW_bookfinder_destination -first Search first editions -keywords="..." Search for keywords -language= Search for books in... de | German en | English es | Spanish fr | French it | Italian nl | Dutch Default: $SURFRAW_bookfinder_language Environment: SURFRAW_bookfinder_language -maxprice= Set the maximum acceptable price -minprice= Set the minimum acceptable price -search= Search by... title author isbn Default: $SURFRAW_bookfinder_search Environment: SURFRAW_bookfinder_search -signed Search for signed copies -title="..." Search for a title. Complements -search=author -type= Search books that are... any | Any new | New used | Used and/or out of print Default: $SURFRAW_bookfinder_type Environment: SURFRAW_bookfinder_type EOF w3_global_usage } +mkopts author= binding= classic currency= destination= first keywords= language= maxprice= minprice= search= signed title= type= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -binding=*) echo any hard soft ;; + -language=*) echo de en es fr it nl ;; + -search=*) echo title author isbn ;; + -type=*) echo any new used ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -author=*) setopt SURFRAW_bookfinder_author $(w3_url_of_arg "$optarg") ;; -binding=any) setopt SURFRAW_bookfinder_binding '*' ;; -binding=*) setopt SURFRAW_bookfinder_binding "$optarg" ;; -classic) setoptyn SURFRAW_bookfinder_classic 1 ;; -currency=*) setopt SURFRAW_bookfinder_currency "$optarg" ;; -destination=*) setopt SURFRAW_bookfinder_destination "$optarg" ;; -first) setoptyn SURFRAW_bookfinder_first 1 ;; -keywords=*) setopt SURFRAW_bookfinder_keywords $(w3_url_of_arg "$optarg") ;; -language=*) setopt SURFRAW_bookfinder_language "$optarg" ;; -maxprice=*) setopt SURFRAW_bookfinder_maxprice "$optarg" ;; -minprice=*) setopt SURFRAW_bookfinder_minprice "$optarg" ;; -search=*) setopt SURFRAW_bookfinder_search "$optarg" ;; -signed) setoptyn SURFRAW_bookfinder_signed 1 ;; -title=*) setopt SURFRAW_bookfinder_title $(w3_url_of_arg "$optarg") ;; -type=any) setopt SURFRAW_bookfinder_type '*' ;; -type=*) setopt SURFRAW_bookfinder_type "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then url="http://www.bookfinder.com/" else escaped_args=$(w3_url_of_arg $w3_args) case "$SURFRAW_bookfinder_search" in author) setopt SURFRAW_bookfinder_author "$escaped_args" ;; isbn) setopt SURFRAW_bookfinder_isbn "$escaped_args" ;; title) setopt SURFRAW_bookfinder_title "$escaped_args" ;; *) return 1 ;; esac url="http://www.bookfinder.com/search/?author=${SURFRAW_bookfinder_author}&title=${SURFRAW_bookfinder_title}&lang=${SURFRAW_bookfinder_language}&submit=Begin%20search&new_used=${SURFRAW_bookfinder_type}&destination=${SURFRAW_bookfinder_destination}&currency=${SURFRAW_bookfinder_currency}&binding=${SURFRAW_bookfinder_binding}&isbn=${SURFRAW_bookfinder_isbn}&keywords=${SURFRAW_bookfinder_keywords}&minprice=${SURFRAW_bookfinder_minprice}&maxprice=${SURFRAW_bookfinder_maxprice}&mode=advanced&st=sr&ac=qr" if [ "$SURFRAW_bookfinder_classic" = 1 ]; then url="${url}&classic=on" fi if [ "$SURFRAW_bookfinder_first" = 1 ]; then url="${url}&first=on" fi if [ "$SURFRAW_bookfinder_signed" = 1 ]; then url="${url}&signed=on" fi fi w3_browse_url "$url" # End of file diff --git a/elvi/bugzilla b/elvi/bugzilla index 070587b..f9a676d 100755 --- a/elvi/bugzilla +++ b/elvi/bugzilla @@ -1,87 +1,98 @@ #!/bin/sh # elvis: bugzilla -- Search for bugs on Bugzilla bugtrackers . surfraw || exit 1 w3_config_hook () { def SURFRAW_bugzilla_site kernel def SURFRAW_bugzilla_status open def SURFRAW_bugzilla_product all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search for bugs on Bugzilla bugtrackers Local options: -site=URL Bugzilla site to search The site URL can be specified, or the following aliases can be used: kernel, mozilla, gnome, kde, apache, freedesktop, eclipse, redhat, mandriva, gentoo, novell Default: $SURFRAW_bugzilla_site Environment: SURFRAW_bugzilla_site Examples: bugzilla -s=https://bugs.kde.org ipv6 bugzilla -s=kde ipv6 -status=open | Bug status closed | all Default: $SURFRAW_bugzilla_status Environment: SURFRAW_bugzilla_status -product=all | Product to search for bugs in. <product name> Default: $SURFRAW_bugzilla_product Environment: SURFRAW_bugzilla_product EOF w3_global_usage } +mkopts site= status= product= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -site=*) echo kernel mozilla gnome kde apache freedesktop eclipse redhat mandriva gentoo novell ;; + -status=*) echo open closed all ;; + -product=*) echo all ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -st*=*) setopt SURFRAW_bugzilla_status "$optarg" ;; -s*=*) setopt SURFRAW_bugzilla_site "$optarg" ;; -p*=*) setopt SURFRAW_bugzilla_product "$(w3_url_of_arg "$optarg")" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ "$SURFRAW_bugzilla_product" = all ] ; then setopt SURFRAW_bugzilla_product "" fi case "$SURFRAW_bugzilla_status" in open) setopt SURFRAW_bugzilla_status "__open__" ;; closed) setopt SURFRAW_bugzilla_status "__closed__" ;; all) setopt SURFRAW_bugzilla_status "__all__" ;; esac case "$SURFRAW_bugzilla_site" in kernel) setopt SURFRAW_bugzilla_site "https://bugzilla.kernel.org" ;; mozilla) setopt SURFRAW_bugzilla_site "https://bugzilla.mozilla.org" ;; gnome) setopt SURFRAW_bugzilla_site "https://bugzilla.gnome.org" ;; kde) setopt SURFRAW_bugzilla_site "https://bugs.kde.org" ;; apache) setopt SURFRAW_bugzilla_site "https://issues.apache.org/bugzilla" ;; freedesktop) setopt SURFRAW_bugzilla_site "https://bugs.freedesktop.org" ;; eclipse) setopt SURFRAW_bugzilla_site "https://bugs.eclipse.org/bugs" ;; redhat) setopt SURFRAW_bugzilla_site "https://bugzilla.redhat.com/" ;; gentoo) setopt SURFRAW_bugzilla_site "https://bugs.gentoo.org" ;; novell) setopt SURFRAW_bugzilla_site "https://bugzilla.novell.com" ;; esac if test -z "$w3_args"; then w3_browse_url "${SURFRAW_bugzilla_site}/query.cgi?format=advanced" else escaped_args=$(w3_url_of_arg $w3_args) # params="short_desc_type=allwordssubstr&short_desc=${escaped_args}&bug_status=${SURFRAW_bugzilla_status}" params="content=${escaped_args}&bug_status=${SURFRAW_bugzilla_status}" params="${params}&product=${SURFRAW_bugzilla_product}" w3_browse_url "${SURFRAW_bugzilla_site}/buglist.cgi?${params}" fi diff --git a/elvi/cite b/elvi/cite index dcf6a99..74ccb89 100755 --- a/elvi/cite +++ b/elvi/cite @@ -1,54 +1,55 @@ #!/bin/sh # $Id$ # elvis: cite -- Search computer science papers (citeseerx.ist.psu.edu) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_cite_citations 0 defyn SURFRAW_cite_authors 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search CiteSeer^X (citeseerx.ist.psu.edu) CiteSeer is a scientific literature digital library that indexes the full text of spidered PDF and PS documents and performes sophisticated clustering and citation analysis on the results. Local options: -cite Include citations. -author Search authors instead of documents. EOF w3_global_usage } +mkopts cite author w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -cit*) setoptyn SURFRAW_cite_citations 1 ;; -auth*) setoptyn SURFRAW_cite_authors 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://citeseerx.ist.psu.edu/" else escaped_args=$(w3_url_of_arg $w3_args) url="http://citeseerx.ist.psu.edu/search?q=${escaped_args}&submit=Search" if ifyes SURFRAW_cite_citations; then url="${url}&ic=1" fi if ifyes SURFRAW_cite_authors; then url="${url}&uauth=1" fi w3_browse_url "$url" fi diff --git a/elvi/commandlinefu b/elvi/commandlinefu index 56b7f3a..1fe0563 100755 --- a/elvi/commandlinefu +++ b/elvi/commandlinefu @@ -1,65 +1,66 @@ #!/bin/sh # $Id$ # elvis: commandlinefu -- search on www.commandlinefu.com # The API of the site is described at http://www.commandlinefu.com/site/api. . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_commandlinefu_votes 1 def SURFRAW_commandlinefu_format html } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search www.commandlinefu.com Local options: -html get results as html -txt get results as plain text -json get results as json -rss get results as rss data Default: $SURFRAW_commandlinefu_format -v, -s, -votes, -sort sort results by votes -u, -n, -unsort, -nosort do not sort results Default: $SURFRAW_commandlinefu_votes EOF w3_global_usage } +mkopts html txt json rss votes sort unsort nosort w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -json) setopt SURFRAW_commandlinefu_format json ;; -html) setopt SURFRAW_commandlinefu_format html ;; -rss) setopt SURFRAW_commandlinefu_format rss ;; -txt) setopt SURFRAW_commandlinefu_format plaintext ;; -v|-votes|-s|-sort) setoptyn SURFRAW_commandlinefu_votes 1 ;; -u|-unsort|-n|-nosort) setoptyn SURFRAW_commandlinefu_votes 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments url=https://www.commandlinefu.com/commands/matching # The next part of the url is a normalized plaintext version of the search # query. It seems to be unused by the CGI but it needs to be present. So we # normalize to "x". url=$url/x # What is really used is the base64 encoded query. (echo -n is not portable) url=$url/"$(printf %s "$w3_args" | base64)" # possibly add the sorting option if test $SURFRAW_commandlinefu_votes -eq 1; then url="$url/sort-by-votes" fi # add the output format option if test $SURFRAW_commandlinefu_format != html; then url="$url/$SURFRAW_commandlinefu_format" fi w3_browse_url "$url" diff --git a/elvi/ctan b/elvi/ctan index 64a0b28..c03a218 100755 --- a/elvi/ctan +++ b/elvi/ctan @@ -1,70 +1,71 @@ #!/bin/sh # $Id$ # elvis: ctan -- Search the Comprehensive TeX Archive Network (ctan.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_ctan_topics 0 defyn SURFRAW_ctan_desc 0 defyn SURFRAW_ctan_authors 0 def SURFRAW_ctan_results $SURFRAW_results } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Comprehensive TeX Archive Network (ctan.org) Local options: -desc Search descriptions (default) -topics Search by filename -authors Search package identifiers Options can be combined to search multiple types at once. EOF w3_global_usage } +mkopts desc topics authors w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -top*) setoptyn SURFRAW_ctan_topics 1 ;; -d*) setoptyn SURFRAW_ctan_desc 1 ;; -au*) setoptyn SURFRAW_ctan_authors 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.ctan.org/" else escaped_args=$(w3_url_of_arg $w3_args) if ifno SURFRAW_ctan_topics && ifno SURFRAW_ctan_desc && ifno SURFRAW_ctan_authors then SURFRAW_ctan_desc=1 fi url="https://www.ctan.org/search/?x=1&PORTAL=on" url="${url}&phrase=${escaped_args}&max=${SURFRAW_results}" if ifyes SURFRAW_ctan_topics then url="${url}&TOPICS=on" fi if ifyes SURFRAW_ctan_desc then url="${url}&PKG=on" fi if ifyes SURFRAW_ctan_authors then url="${url}&AUTHORS=on" fi w3_browse_url "$url" fi diff --git a/elvi/currency b/elvi/currency index 2efa44a..ebc4038 100755 --- a/elvi/currency +++ b/elvi/currency @@ -1,382 +1,391 @@ #!/bin/sh # $Id$ # elvis: currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) . surfraw || exit 1 list_currency_symbols () { cat <<EOT Symbol Country and Currency AFA Afghanistan, Afghani ALL Albania, Lek DZD Algeria, Dinar USD America (United States), Dollar USD American Samoa, United States Dollar EUR Andorra, Euro AOA Angola, Kwanza XCD Anguilla, East Caribbean Dollar XCD Antigua and Barbuda, East Caribbean Dollar ARS Argentina, Peso AMD Armenia, Dram AWG Aruba, Guilder AUD Ashmore and Cartier Islands, Australia Dollar AUD Australia, Dollar EUR Austria, Euro ATS Austria, Schilling [obsolete] AZM Azerbaijan, Manat EUR Azores, Euro BSD Bahamas, Dollar BHD Bahrain, Dinar BBD Bajan (Barbados), Dollar EUR Balearic Islands, Euro BDT Bangladesh, Taka BBD Barbados, Dollar BYR Belarus, Ruble EUR Belgium, Euro BEF Belgium, Franc [obsolete] BZD Belize, Dollar XOF Benin, CFA Franc BCEAO BMD Bermuda, Dollar INR Bhutan, India Rupee BTN Bhutan, Ngultrum BOB Bolivia, Boliviano ANG Bonaire, Netherlands Antilles Guilder BAM Bosnia and Herzegovina, Convertible Marka BWP Botswana, Pula BRL Brazil, Real GBP Britain (United Kingdom), Pound GBP British Indian Ocean Territory, United Kingdom Pound USD British Indian Ocean Territory, United States Dollar USD British Virgin Islands, United States Dollar BND Brunei, Dollar SGD Brunei, Singapore Dollar BGN Bulgaria, Lev XOF Burkina Faso, CFA Franc BCEAO MMK Burma (Myanmar), Kyat BIF Burundi, Franc KHR Cambodia, Riel XAF Cameroon, CFA Franc BEAC CAD Canada, Dollar EUR Canary Islands, Euro CVE Cape Verde, Escudo KYD Cayman Islands, Dollar XAF Central African Republic, CFA Franc BEAC XAF CFA Communauté Financière Africaine BEAC Franc XOF CFA Communauté Financière Africaine BCEAO Franc XAF Chad, CFA Franc BEAC CLP Chile, Peso CNY China, Yuan Renminbi AUD Christmas Island, Australia Dollar AUD Cocos (Keeling Islands, Australia Dollar COP Colombia, Peso XAF Communauté Financière Africaine BEAC Franc XOF Communauté Financière Africaine BCEAO Franc KMF Comoros, Franc XPF Comptoirs Français du Pacifique Franc XAF Congo/Brazzaville, CFA Franc BEAC CDF Congo/Kinshasa, Franc NZD Cook Islands, New Zealand Dollar AUD Coral Sea Islands, Australia Dollar CRC Costa Rica, Colon XOF Côte d'Ivoire, CFA Franc BCEAO HRK Croatia, Kuna CUC Cuba, Convertible Peso CUP Cuba, Peso ANG Curaço, Netherlands Antilles Guilder CYP Cyprus, Pound CZK Czech Republic, Koruna DKK Denmark, Krone DJF Djibouti, Franc XCD Dominica, East Caribbean Dollar DOP Dominican Republic, Peso EUR Dutch (Netherlands), Euro NLG Dutch (Netherlands), Guilder [obsolete] XCD East Caribbean Dollar USD East Timor, United States Dollar USD Ecuador, United States Dollar EGP Egypt, Pound SVC El Salvador, Colon GBP England (United Kingdom), Pound XAF Equatorial Guinea, CFA Franc BEAC ERN Eritrea, Nakfa EEK Estonia, Kroon ETB Ethiopia, Birr EUR Euro EUR Europa Island, Euro FKP Falkland Islands, Pound DKK Faroe Islands, Denmark Krone FJD Fiji, Dollar EUR Finland, Euro FIM Finland, Markka [obsolete] EUR France, Euro FRF France, Franc [obsolete] EUR French Guiana, Euro XPF French Polynesia, Comptoirs Français du Pacifique Franc EUR French Polynesia, Euro EUR French Southern and Antarctic Lands, Euro XAF Gabon, CFA Franc BEAC GMD Gambia, Dalasi ILS Gaza Strip, Israel New Shekel GEL Georgia, Lari DEM Germany, Deutsche Mark [obsolete] EUR Germany, Euro GHC Ghana, Cedi GIP Gibraltar, Pound XAU Gold Ounce GBP Great Britain (United Kingdom), Pound EUR Greece, Euro GRD Greece, Drachma [obsolete] DKK Greenland, Denmark Krone XCD Grenada, East Caribbean Dollar EUR Guadeloupe, Euro USD Guam, United States Dollar GTQ Guatemala, Quetzal GGP Guernsey, Pound GNF Guinea, Franc XOF Guinea-Bissau, CFA Franc BCEAO GYD Guyana, Dollar HTG Haiti, Gourde EUR Holland (Netherlands), Euro NLG Holland (Netherlands), Guilder [obsolete] EUR Holy See (Vatican City), Euro VAL Holy See (Vatican City), Lira [obsolete] HNL Honduras, Lempira HKD Hong Kong, Dollar HUF Hungary, Forint ISK Iceland, Krona INR India, Rupee IDR Indonesia, Rupiah XDR International Monetary Fund Special Drawing Right IRR Iran, Rial IQD Iraq, Dinar EUR Ireland, Euro IEP Ireland, Pound [obsolete] FKP Islas Malvinas (Falkland Islands), Pound IMP Isle of Man, Pound ILS Israel, New Shekel EUR Italy, Euro ITL Italy, Lira [obsolete] XOF Ivory Coast (Côte d'Ivoire), CFA Franc BCEAO JMD Jamaica, Dollar JPY Japan, Yen JEP Jersey, Pound USD Johnson, United States Dollar JOD Jordan, Dinar EUR Juan de Nova, Euro KZT Kazakhstan, Tenge KES Kenya, Shilling AUD Kiribati, Australia Dollar KWD Kuwait, Dinar KGS Kyrgyzstan, Som LAK Laos, Kip LVL Latvia, Lat LBP Lebanon, Pound LSL Lesotho, Loti LRD Liberia, Dollar LYD Libya, Dinar CHF Liechtenstein, Switzerland Franc LTL Lithuania, Litas EUR Luxembourg, Euro LUF Luxembourg, Franc [obsolete] MOP Macau, Pataca MKD Macedonia, Denar MGA Madagascar, Ariary MGF Madagascar, Franc [obsolete] EUR Madeira Islands, Euro MWK Malawi, Kwacha MYR Malaysia, Ringgit MVR Maldives, Rufiyaa XOF Mali, CFA Franc BCEAO MTL Malta, Lira FKP Malvinas (Falkland Islands), Pound USD Marshall Islands, United States Dollar EUR Martinique, Euro MRO Mauritania, Ouguiya MUR Mauritius, Rupee EUR Mayotte, Euro MXN Mexico, Peso USD Micronesia, United States Dollar USD Midway Islands, United States Dollar MDL Moldova, Leu EUR Monaco, Euro MNT Mongolia, Tughrik EUR Montenegro, Euro XCD Montserrat, East Caribbean Dollar MAD Morocco, Dirham MZM Mozambique, Metical MMK Myanmar (Burma), Kyat NAD Namibia, Dollar AUD Nauru, Australia Dollar HTG Navassa, Haiti Gourde USD Navassa, United States Dollar CNY Nepal, China Yuan Renminbi NPR Nepal, Rupee ANG Netherlands Antilles, Guilder EUR Netherlands, Euro NLG Netherlands, Guilder [obsolete] XPF New Caledonia, Comptoirs Français du Pacifique Franc NZD New Zealand, Dollar NIO Nicaragua, Cordoba XOF Niger, CFA Franc BCEAO NGN Nigeria, Naira NZD Niue, New Zealand Dollar AUD Norfolk Island, Australia Dollar KPW North Korea, Won USD Northern Mariana Islands, United States Dollar NOK Norway, Krone OMR Oman, Rial PKR Pakistan, Rupee USD Palau, United States Dollar XPD Palladium Ounce PAB Panama, Balboa USD Panama, United States Dollar PGK Papua New Guinea, Kina CNY Paracel Islands, China Yuan Renminbi VND Paracel Islands, Vietnam Dong PYG Paraguay, Guarani PEN Peru, Nuevo Sol PHP Philippines, Peso NZD Pitcairn, New Zealand Dollar XPT Platinum Ounce PLN Poland, Zloty EUR Portugal, Euro PTE Portugal, Escudo [obsolete] USD Puerto Rico, United States Dollar QAR Qatar, Riyal EUR Reunion, Euro ROL Romania, Leu RUB Russia, Ruble RWF Rwanda, Franc ANG Saba, Netherlands Antilles Guilder SHP Saint Helena, Pound XCD Saint Kitts and Nevis, East Caribbean Dollar XCD Saint Lucia, East Caribbean Dollar EUR Saint Pierre and Miquelon, Euro XCD Saint Vincent and The Grenadines, East Caribbean Dollar EUR Saint-Martin, Euro WST Samoa, Tala EUR San Marino, Euro STD São Tome and Principe, Dobra SAR Saudi Arabia, Riyal GBP Scotland (United Kingdom), Pound SPL Seborga, Luigino XOF Senegal, CFA Franc BCEAO CSD Serbia, Dinar SCR Seychelles, Rupee SLL Sierra Leone, Leone XAG Silver Ounce SGD Singapore, Dollar ANG Sint Eustatius, Netherlands Antilles Guilder ANG Sint Maarten, Netherlands Antilles Guilder SKK Slovakia, Koruna SIT Slovenia, Tolar SBD Solomon Islands, Dollar SOS Somalia, Shilling ZAR South Africa, Rand GBP South Georgia, United Kingdom Pound KRW South Korea, Won GBP South Sandwich Islands, United Kingdom Pound EUR Spain, Euro ESP Spain, Peseta [obsolete] LKR Sri Lanka, Rupee SDD Sudan, Dinar SRD Suriname, Dollar SRG Suriname, Guilder NOK Svalbard and Jan Mayen, Norway Krone SZL Swaziland, Lilangeni ZAR Swaziland, South Africa Rand SEK Sweden, Krona CHF Switzerland, Franc SYP Syria, Pound TWD Taiwan, New Dollar TJS Tajikistan, Somoni RUB Tajikistan, Russia Ruble TZS Tanzania, Shilling THB Thailand, Baht XOF Togo, CFA Franc BCEAO NZD Tokelau, New Zealand Dollar TOP Tonga, Pa'anga MDL Transnistria, Moldova Leu TTD Trinidad and Tobago, Dollar TND Tunisia, Dinar TRY Turkey, New Lira TRL Turkey, Lira TMM Turkmenistan, Manat USD Turks and Caicos Islands, United States Dollar AUD Tuvalu, Australia Dollar TVD Tuvalu, Dollar UGX Uganda, Shilling UAH Ukraine, Hryvna AED United Arab Emirates, Dirham GBP United Kingdom, Pound USD United States, Dollar UYU Uruguay, Peso UZS Uzbekistan, Som VUV Vanuatu, Vatu EUR Vatican City, Euro VAL Vatican City, Lira [obsolete] VEB Venezuela, Bolivar VND Vietnam, Dong USD Virgin Islands, United States Dollar USD Wake Island, United States Dollar XPF Wallis and Futuna Islands, Comptoirs Français du Pacifique Franc ILS West Bank, Israel New Shekel JOD West Bank, Jordan Dinar MAD Western Sahara, Morocco Dirham WST Western Samoa (Samoa), Tala YER Yemen, Rial ZMK Zambia, Kwacha ZWD Zimbabwe, Dollar EOT } w3_config_hook () { def SURFRAW_currency_from USD def SURFRAW_currency_to EUR } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Convert currencies with the Universal Currency Converter (www.xe.net/ucc) Local options: -l List all known currency symbols. -from=SYM Symbol for currency to convert from. Default: $SURFRAW_currency_from Environment: SURFRAW_currency_from -to=SYM Symbol for currency to convert to. Default: $SURFRAW_currency_to Environment: SURFRAW_currency_to Example currency symbols: EUR (Euro), USD (US Dollars), GBP (UK Pounds), CAD (Canada Dollars), AUD (Australia Dollars), JPY (Japan Yen), INR (India Rupees), NZD (New Zealand Dollars), CHF (Switzerland Francs), ZAR (South Africa Rand) EOF w3_global_usage } +mkopts l from= to= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -from=*|-to=*) list_currency_symbols | cut -f1 ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -from=*) setopt SURFRAW_currency_from $optarg ;; -to=*) setopt SURFRAW_currency_to $optarg ;; -l) list_currency_symbols; exit 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.xe.com/currencyconverter/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.xe.com/currencyconverter/Amount=${escaped_args}&From=${SURFRAW_currency_from}&To=${SURFRAW_currency_to}&submit=Perform+Currency+Conversion" fi diff --git a/elvi/debbugs b/elvi/debbugs index 51a9d19..fb287ab 100755 --- a/elvi/debbugs +++ b/elvi/debbugs @@ -1,294 +1,311 @@ #!/bin/sh # $Id$ # elvis: debbugs -- Search the debian BTS (bugs.debian.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debbugs_search pkg def SURFRAW_debbugs_version "" def SURFRAW_debbugs_dist "" def SURFRAW_debbugs_user "" defyn SURFRAW_debbugs_archive 0 defyn SURFRAW_debbugs_merge 0 defyn SURFRAW_debbugs_statussort 1 defyn SURFRAW_debbugs_head 1 defyn SURFRAW_debbugs_foot 1 def SURFRAW_debbugs_incstatus "" def SURFRAW_debbugs_excstatus "" def SURFRAW_debbugs_incsev "" def SURFRAW_debbugs_excsev "" def SURFRAW_debbugs_inctag "" def SURFRAW_debbugs_exctag "" defyn SURFRAW_debbugs_asmbox 0 defyn SURFRAW_debbugs_headers 0 defyn SURFRAW_debbugs_boring 0 defyn SURFRAW_debbugs_revstat 0 defyn SURFRAW_debbugs_revsev 0 defyn SURFRAW_debbugs_revbugs 0 defyn setsearch 0 defyn search_usertag 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [package | bug number | maintainer email] Description: Surfraw search debian BTS (bugs.debian.org) Examples: debbugs 20000 | show report for bug #20000 debbugs [email protected] | show bugs for csurchi debbugs surfraw | show bugs for surfraw package debbugs -raw -rb surfraw | show surfraw bugs newest first Defaults if -search is not supplied: If arg is numeric, searches by bug number, If it contains '@', searches by maintainer, Otherwise, searches by package. Local options: -search= pkg | Search type. src | bug | (bug number) maint | tag | submitter | severity | tag | usertag -s Alias for -search=src -user=EMAIL User for usertag search, defaults to value of \$DEBEMAIL environment. Ignored if search type is not "usertag". -version=VERSION Package version. -dist=oldstable | Distribution stable | proposed-updates | testing | unstable | experimental | testing-proposed-updates -arc Show archived bugs. -raw Do not sort by status or severity. -rb Reverse order of bugs shown. -rst Reverse order of statuses shown. -rse Reverse order of severities shown. -merge Display merged bugs only once. -nohead Do not show table of contents header. -nofoot Do not show statistics in the footer. -mbox View results in mbox format. * -sh Show headers. * -boring Show boring messages. * (* = only when searching by bug number.) -incstat=stat1,stat2 Include given status list. -exstat=stat3,stat4 Exclude given status list. Available statuses: open, forwarded, pending, fixed, done. -incsev=sev1,sev2 Include given severities. -exsev=sev3,sev4 Exclude given severities. Available severities: critical, grave, serious, important, normal, minor, wishlist, fixed. -inctag=tag1,tag2 Include given tags. -extag=tag3,tag4 Exclude given tags. Available tags: potato, woody, sarge, sarge-ignore, etch, etch-ignore, sid, experimental, confirmed, d-i, fixed, fixed-in-experimental, fixed-upstream, help, l10n, moreinfo, patch, pending, security, unreproducible, upstream, wontfix, ipv6, lfs EOF w3_global_usage } +mkopts search= version= dist= user= +mkopts arc raw rb rst rse merge nohead nofoot mbox sh +mkopts incstat= exstat= incsev= exsev= inctag= extag= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + # "tag" is duplicated in help. Error? + -search=*) echo pkg src bug maint tag submitter severity usertag ;; + -dist=*) echo oldstable stable proposed-updates testing unstable experimental testing-proposed-updates ;; + # At most one csv-like value can be completed at once. + -incstat=*|-exstat=*) echo open forwarded pending fixed done ;; + -incsev=*|-exsev=*) echo critical grave serious important normal minor wishlist fixed ;; + -inctag=*|-extag=*) echo potato woody sarge sarge-ignore etch etch-ignore sid experimental confirmed d-i fixed fixed-in-experimental fixed-upstream help l10n moreinfo patch pending security unreproducible upstream wontfix ipv6 lfs ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s) setopt SURFRAW_debbugs_search src ; setoptyn setsearch 1 ;; -se*=*) setopt SURFRAW_debbugs_search $optarg; setoptyn setsearch 1 ;; -ve*=*) setopt SURFRAW_debbugs_version $optarg ;; -dis*=*) setopt SURFRAW_debbugs_dist $optarg ;; -arc*) setoptyn SURFRAW_debbugs_archive 1;; -mer*) setoptyn SURFRAW_debbugs_merge 1;; -raw*) setoptyn SURFRAW_debbugs_statussort 0;; -noh*) setoptyn SURFRAW_debbugs_head 0;; -nof*) setoptyn SURFRAW_debbugs_foot 0;; -in*stat*=*) setopt SURFRAW_debbugs_incstatus $optarg;; -ex*stat*=*) setopt SURFRAW_debbugs_excstatus $optarg;; -in*sev*=*) setopt SURFRAW_debbugs_incsev $optarg;; -ex*sev*=*) setopt SURFRAW_debbugs_excsev $optarg;; -in*tag*=*) setopt SURFRAW_debbugs_inctag $optarg;; -ex*tag*=*) setopt SURFRAW_debbugs_exctag $optarg;; -u*=*) setopt SURFRAW_debbugs_user $optarg;; -rb*) setoptyn SURFRAW_debbugs_revbugs 1;; -rst*) setoptyn SURFRAW_debbugs_revstat 1;; -rse*) setoptyn SURFRAW_debbugs_revsev 1;; -mb*) setoptyn SURFRAW_debbugs_asmbox 1;; -sh*) setoptyn SURFRAW_debbugs_headers 1;; -bo*) setoptyn SURFRAW_debbugs_boring 1;; *) return 1 ;; esac return 0 } # Email normalization # ~~~~~~~~~~~~~~~~~~~ # # Debbugs search have bug: even if email have upper-case letters, it # must be lower-cased when writing search request, or nothing will be # found. # # For example, to search bugs in packages, maintained by # J. Random Hacker <[email protected]> one have to request following url: # # https://bugs.debian.org/[email protected] # # No search results will be returned at this requst: # # https://bugs.debian.org/[email protected] # # Environment variable $DEBEMAIL is used by many developer tools, # maintainers tend to place their email in preferred capitalization. # # When using this variable as fallback for -user option, it is lowercased # to work-around described beviour (reported as #921970). # # Strictly speaking, local part of email address must be considered # opaque, having meaning only to receiving email server. w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.debian.org/Bugs" else escaped_args=$(w3_url_of_arg $w3_args) setoptyn donum 0 setoptyn domaint 0 setoptyn dousertag 0 case "$SURFRAW_debbugs_search" in bug*) setoptyn donum 1;; user*) setopt SURFRAW_debbugs_search tag setoptyn dousertag 1;; esac # default search unless searchtype set on cmdline if ifno setsearch then export escaped_args if perl -e 'if($ENV{escaped_args} =~/^((\#|\%23)(\s|\%20)*)?\d+$/) { exit 0; } exit 1;' then # %23 = uri escaped '#', %20=' ' setoptyn donum 1 elif perl -e 'if($ENV{escaped_args} =~/\%40|@/) { exit 0; } exit 1;' then # %40 = uri escaped '@' setopt SURFRAW_debbugs_search "maint" fi fi if ifyes donum then url="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${escaped_args}" if yesno SURFRAW_debbugs_asmbox then url="$url&mbox=yes" fi if yesno SURFRAW_debbugs_headers then url="$url&trim=no" fi if yesno SURFRAW_debbugs_boring then url="$url&boring=yes" fi else url="https://bugs.debian.org/cgi-bin/pkgreport.cgi?which=${SURFRAW_debbugs_search}&version=${SURFRAW_debbugs_version}&dist=${SURFRAW_debbugs_dist}&data=${escaped_args}" if ifyes dousertag then user=${SURFRAW_debbugs_user} if null "${user}" then user="${DEBEMAIL:-}" if null "${user}" then cat <<EOF >&2 $w3_argv0 ERROR: can not do usertag search -- user is unknown. * option -user is not provided * environment variable "SURFRAW_debbugs_user" is not set * environment variable "DEBEMAIL" is not set EOF exit 1 fi # See [Email normalization] user=$(printf '%s' "${user}" | tr '[:upper:]' '[:lower:]') fi url="$url&users=$user" fi if yesno SURFRAW_debbugs_archive then url="$url&archive=yes" else url="$url&archive=no" fi if ifyes SURFRAW_debbugs_merge then url="$url&repeatmerged=no" fi if ifno SURFRAW_debbugs_statussort then url="$url&raw=yes" fi if ifno SURFRAW_debbugs_head then url="$url&show_list_header=no" fi if ifno SURFRAW_debbugs_foot then url="$url&show_list_footer=no" fi if ifyes SURFRAW_debbugs_revstat then url="$url&pend-rev=yes" fi if ifyes SURFRAW_debbugs_revsev then url="$url&sev-rev=yes" fi if ifyes SURFRAW_debbugs_revbugs then url="$url&bug-rev=yes" fi if [ "$SURFRAW_debbugs_incstatus" != "" ] then add=$(echo "$SURFRAW_debbugs_incstatus"|perl -ne 's/pending/pending-fixed/g;s/open/pending/g;print(join("&pend-inc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_excstatus" != "" ] then add=$(echo "$SURFRAW_debbugs_excstatus"|perl -ne 'print(join("&pend-exc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_incsev" != "" ] then add=$(echo "$SURFRAW_debbugs_incsev"|perl -ne 'print(join("&sev-inc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_excsev" != "" ] then add=$(echo "$SURFRAW_debbugs_excsev"|perl -ne 'print(join("&sev-exc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_inctag" != "" ] then add=$(echo "$SURFRAW_debbugs_inctag"|perl -ne 'print(join("&include=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_exctag" != "" ] then add=$(echo "$SURFRAW_debbugs_exctag"|perl -ne 'print(join("&exclude=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi fi w3_browse_url "$url" fi diff --git a/elvi/debcontents b/elvi/debcontents index 8e3c762..2b043c5 100755 --- a/elvi/debcontents +++ b/elvi/debcontents @@ -1,155 +1,175 @@ #!/bin/sh # $Id$ # elvis: debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debcontents_arch i386 def SURFRAW_debcontents_distro stable def SURFRAW_debcontents_search "files" defyn SURFRAW_debcontents_ubuntu no defyn SURFRAW_debcontents_archive no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) Local options: -a Search archived debian releases -u Search ubuntu packages instead of debian -search= Type of search files | Packages that contain files named like this path | Paths ending with the keyword word | Packages that contain files or directories whose names contain the keyword Default: $SURFRAW_debcontents_search Environment: SURFRAW_debcontents_search -arch= Specialized search on architecture i386 | Intel x86 (all) powerpc | PowerPC (all) amd64 | AMD64 (all) m68k | Motorola 680x0 (debian, archive.debian) alpha | Alpha (debian, archive.debian) sparc | SPARC (debian, archive.debian) arm | ARM (debian, archive.debian) hppa | HP PA/RISC (debian, archive.debian) ia64 | Intel IA-64 (debian, archive.debian) mips | MIPS (debian, archive.debian) mipsel | MIPS (DEC) (debian, archive.debian) s390 | IBM S/390 (debian, archive.debian) hurd-i386 | Hurd (i386) (debian) kfreebsd-amd64 | kFreeBSD (amd64) (debian) kfreebsd-i386 kFreeBSD (i386) (debian) Default: $SURFRAW_debcontents_arch Environment: SURFRAW_debcontents_arch -distro= Specific distribution Debian: stable | Stable testing | Testing unstable | Unstable oldstable | Old Stable Archived Debian (-a): bo | 1.3.1 hamm | 2.0 slink | 2.1 potato | 2.2 woody | 3.0 sarge | 3.1 etch | 4.0 Ubuntu (-u): dapper | Dapper dapper-updates | Dapper Updates dapper-backports | Dapper Backports hardy | Hardy hardy-updates | Hardy Updates hardy-backports | Hardy Backports intrepid | Intrepid intrepid-updates | Intrepid Updates intrepid-backports| Intrepid Backports jaunty | Jaunty jaunty-updates | Jaunty Updates jaunty-backports | Jaunty Backports karmic | Karmic karmic-updates | Karmic Updates karmic-backports | Karmic Backports lucid | Lucid lucid-updates | Lucid Updates lucid-backports | Lucid Backports maverick | Maverick maverick-updates | Maverick Updates maverick-backports| Maverick Backports natty | Natty natty-updates | Natty Updates natty-backports | Natty Backports Default: $SURFRAW_debcontents_distro Environment: SURFRAW_debcontents_distro EOF w3_global_usage } +mkopts a u search= arch= distro= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -search=*) echo files path word ;; + -arch=*) echo i386 powerpc amd64 m68k alpha sparc arch hppa ia64 mips mipsel s390 hurd-i386 kfreebsd-amd64 kfreebsd-i386 ;; + # The values for -distro= in the help are outdated. + -distro=*) + echo stable testing unstable oldstable bo hamm slink potato woody sarge etch + for ubuntu_dist in dapper hardy intrepid jaunty karmic lucid maverick natty + do + echo "$ubuntu_dist" + echo "${ubuntu_dist}-updates" + echo "${ubuntu_dist}-backports" + done + ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -arch=*) setopt SURFRAW_debcontents_arch $optarg ;; -distro=*) setopt SURFRAW_debcontents_distro $optarg ;; -search=*) setopt SURFRAW_debcontents_search $optarg ;; -u*) setoptyn SURFRAW_debcontents_ubuntu yes ;; -a*) setoptyn SURFRAW_debcontents_archive yes ;; -ca*) setoptyn SURFRAW_debcontents_usecase yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if ifyes SURFRAW_debcontents_ubuntu then searchpage="http://packages.ubuntu.com/#search_contents" searchurl="http://packages.ubuntu.com/search" elif ifyes SURFRAW_debcontents_archive then searchpage="https://archive.debian.net/#search_contents" searchurl="https://archive.debian.net/search" else searchpage="https://packages.debian.org/#search_contents" searchurl="https://packages.debian.org/search" fi if test -z "$w3_args"; then w3_browse_url "$searchpage" else escaped_args=$(w3_url_of_arg $w3_args) if ifyes SURFRAW_debcontents_ubuntu then if [ "$SURFRAW_debcontents_distro" = "stable" ] then SURFRAW_debcontents_distro=raring fi fi url="$searchurl?keywords=${escaped_args}&searchon=contents" url="$url&arch=${SURFRAW_debcontents_arch}" url="$url&suite=${SURFRAW_debcontents_distro}" case "$SURFRAW_debcontents_search" in p*) if ifyes SURFRAW_debcontents_ubuntu || ifyes SURFRAW_debcontents_archive then searchmode="" else searchmode=path fi;; f*) searchmode=exactfilename ;; w*) searchmode=filename ;; *) err "Unknown search type" ;; esac url="${url}&mode=${searchmode}" w3_browse_url "$url" fi diff --git a/elvi/deblists b/elvi/deblists index f7297b4..321f87a 100755 --- a/elvi/deblists +++ b/elvi/deblists @@ -1,104 +1,113 @@ #!/bin/sh # elvis: deblists -- Search debian mailing lists (lists.debian.org/search.html) # [email protected] 2003919 . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_deblists_matchany no defyn SURFRAW_deblists_searchmsgid no def SURFRAW_deblists_msgidsearchtype direct def SURFRAW_deblists_sort relevance def SURFRAW_deblists_results $SURFRAW_results } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search patterns]... Description: Surfraw search debian mailing lists (lists.debian.org/search.html) Local options: -results=NUM Number of search results returned Default: $SURFRAW_deblists_results Environment: SURFRAW_deblists_results -m|-msgid Search by message-id, jump to result -mv Search by message-id and show matches -ml Search by message-id and show links -any Match any word in search rather than all words -sort=relevance | How to sort the results date | revdate Default: $SURFRAW_deblists_sort Environment: SURFRAW_deblists_sort EOF w3_global_usage } +mkopts results= msgid mv ml any sort= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -sort=*) echo relevance date revdate ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -result*=*) setopt SURFRAW_deblists_results $optarg ;; -mv) setoptyn SURFRAW_deblists_searchmsgid yes ; setopt SURFRAW_deblists_msgidsearchtype view ;; -ml) setoptyn SURFRAW_deblists_searchmsgid yes ; setopt SURFRAW_deblists_msgidsearchtype links ;; -m|-msg*) setoptyn SURFRAW_deblists_searchmsgid yes ;; -any) setoptyn SURFRAW_deblists_matchany yes ;; -sort*=*) setopt SURFRAW_deblists_sort $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then if ifyes SURFRAW_deblists_searchmsgid then w3_browse_url "https://lists.debian.org/msgid-search" else w3_browse_url "https://lists.debian.org/search.html" fi elif ifyes SURFRAW_deblists_searchmsgid then if [ "$SURFRAW_deblists_msgidsearchtype" = links ] then searchtype="&links=Query" elif [ "$SURFRAW_deblists_msgidsearchtype" = view ] then searchtype="" else searchtype="&firsthit=I%27m+feeling+lucky" fi escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://lists.debian.org/msgid-search/?m=${escaped_args}${searchtype}" else escaped_args=$(w3_url_of_arg $w3_args) url="https://lists.debian.org/cgi-bin/search?P=${escaped_args}" if ifyes SURFRAW_deblists_matchany then url="$url&DEFAULTOP=or" else url="$url&DEFAULTOP=and" fi case "$SURFRAW_deblists_sort" in rel*) SURFRAW_deblists_sort="relevance" ;; rev*) SURFRAW_deblists_sort="revdate" ;; d*) SURFRAW_deblists_sort="date" ;; *) err "Unknown sort method: $SURFRAW_deblists_sort" esac url="$url&sort=${SURFRAW_deblists_sort}" if [ "$SURFRAW_deblists_results" = "" ] then SURFRAW_deblists_results=10 fi url="$url&HITSPERPAGE=${SURFRAW_deblists_results}" w3_browse_url "$url" fi diff --git a/elvi/debpackages b/elvi/debpackages index 8201f29..39906e0 100755 --- a/elvi/debpackages +++ b/elvi/debpackages @@ -1,148 +1,169 @@ #!/bin/sh # $Id$ # elvis: debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debian_release any def SURFRAW_debian_distro any def SURFRAW_debian_search pkg defyn SURFRAW_debian_ubuntu no defyn SURFRAW_debian_subwords yes defyn SURFRAW_debian_archive no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) Local options: -a Search archived debian distributions -u Search ubuntu packages instead of debian -release= Specialized search on release Debian: any | all releases main | main release contrib | contrib non-free | packages not meeting DFSG Ubuntu (-u): any | all releases main | restricted | universe | multiverse | Default: $SURFRAW_debian_release Environment: SURFRAW_debian_release -distro= Specific distribution Debian: any | All distributions stable | Stable testing | Testing unstable | Unstable oldstable | Old Stable experimental | Experimental Archived Debian (-a): bo | 1.3.1 hamm | 2.0 slink | 2.1 potato | 2.2 woody | 3.0 sarge | 3.1 etch | 4.0 Ubuntu (-u): any | All distributions dapper | dapper-updates | dapper-backports | hardy | hardy-updates | hardy-backports | intrepid | intrepid-updates | intrepid-backports| jaunty | jaunty-updates | jaunty-backports | karmic | karmic-updates | karmic-backports | lucid | lucid-updates | lucid-backports | maverick | maverick-updates | maverick-backports| natty | natty-updates | natty-backports Default: $SURFRAW_debian_distro Environment: SURFRAW_debian_distro -search= Field to search pkg | Package names only desc | Descriptions src | Source package names -nosub Don't allow subword matches (exact matches only) EOF w3_global_usage } +mkopts release= distro= search= nosub a u +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -release=*) echo any main contrib non-free restricted universe multiverse ;; + # The values for -distro= in the help are outdated. + -distro=*) + echo any stable testing unstable oldstable experimental bo hamm slink potato woody sarge etch + # "any" already exists for Debian, so don't need to do here too. + for ubuntu_dist in dapper hardy intrepid jaunty karmic lucid maverick natty + do + echo "$ubuntu_dist" + echo "${ubuntu_dist}-updates" + echo "${ubuntu_dist}-backports" + done + ;; + -search=*) echo pkg desc src ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -release=*) setopt SURFRAW_debian_release $optarg ;; -distro=*) setopt SURFRAW_debian_distro $optarg ;; -search=*) setopt SURFRAW_debian_search $optarg ;; -a*) setoptyn SURFRAW_debian_archive yes ;; -u*) setoptyn SURFRAW_debian_ubuntu yes ;; -nos*) setoptyn SURFRAW_debian_subwords no ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if ifyes SURFRAW_debian_ubuntu then searchpage="http://packages.ubuntu.com/" searchurl="http://packages.ubuntu.com/search" elif ifyes SURFRAW_debian_archive then searchpage="http://archive.debian.net/" searchurl="http://archive.debian.net/search" else searchpage="https://packages.debian.org/#search_packages" searchurl="https://packages.debian.org/search" fi if test -z "$w3_args"; then w3_browse_url "$searchpage" else escaped_args=$(w3_url_of_arg $w3_args) if [ "${SURFRAW_debian_distro}" = "any" ]; then SURFRAW_debian_distro="all" fi if [ "${SURFRAW_debian_release}" = "any" ]; then SURFRAW_debian_release="all" fi url="$searchurl?keywords=${escaped_args}&suite=${SURFRAW_debian_distro}&section=${SURFRAW_debian_release}" case "$SURFRAW_debian_search" in pkg*) url="$url&searchon=names" ;; src*) url="$url&searchon=sourcenames" ;; desc*) url="$url&searchon=all" ;; *) err "Unknown search type" ;; esac if ifno SURFRAW_debian_subwords then url="$url&exact=1" fi w3_browse_url "$url" fi diff --git a/elvi/debpts b/elvi/debpts index 479870d..165755c 100755 --- a/elvi/debpts +++ b/elvi/debpts @@ -1,43 +1,44 @@ #!/bin/sh # $Id$ # elvis: debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) # [email protected] 20040729 . surfraw || exit 1 w3_config_hook () { def SURFRAW_debpts_viewdocs 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Debian Package Tracking System (packages.qa.debian.org) Local options: -doc View PTS documentation EOF w3_global_usage } +mkopts doc w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -d*) setopt SURFRAW_debpts_viewdocs 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ $SURFRAW_debpts_viewdocs -eq 1 ]; then w3_browse_url "https://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system" elif test -z "$w3_args"; then w3_browse_url "https://packages.qa.debian.org/common/index.html" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://packages.qa.debian.org/common/index.html?src=${escaped_args}" fi diff --git a/elvi/debwiki b/elvi/debwiki index 9f6ffca..b4d8ab0 100755 --- a/elvi/debwiki +++ b/elvi/debwiki @@ -1,71 +1,72 @@ #!/bin/sh # $Id$ # elvis: debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) # by Ian Beckwith <[email protected]> . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_debwiki_title 0 defyn SURFRAW_debwiki_context 1 defyn SURFRAW_debwiki_case 0 defyn SURFRAW_debwiki_direct 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Debian Wiki (wiki.debian.org) Local options: -c Make search case-sensitive. -n Don't show context of search result. -t Limit search to title. -d Go direct to page (or create it). EOF w3_global_usage } +mkopts c n t d w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -c) setoptyn SURFRAW_debwiki_case 1 ;; -n) setoptyn SURFRAW_debwiki_context 0 ;; -d) setoptyn SURFRAW_debwiki_direct 1 ;; -t) setoptyn SURFRAW_debwiki_title 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments url="https://wiki.debian.org" if test -z "$w3_args" then w3_browse_url "$url" else escaped_args=$(w3_url_of_arg $w3_args) url="${url}/FindPage?" if ifyes SURFRAW_debwiki_direct then url="${url}goto=${escaped_args}&submit=Go+To+Page" elif ifyes SURFRAW_debwiki_title then url="${url}action=fullsearch&titlesearch=1&value=${escaped_args}&submit=Search+Titles" else url="${url}action=fullsearch&titlesearch=0&value=${escaped_args}&submit=Search+Text" if ifyes SURFRAW_debwiki_context then url="${url}&context=160" fi if ifyes SURFRAW_debwiki_case then url="${url}&case=1" fi fi w3_browse_url "$url" fi diff --git a/elvi/deja b/elvi/deja index 90c6ac4..589850b 100755 --- a/elvi/deja +++ b/elvi/deja @@ -1,48 +1,49 @@ #!/bin/sh # $Id$ # elvis: deja -- Search usenet using Google Groups (groups.google.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_deja_results $SURFRAW_results def SURFRAW_deja_style "normal" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search usenet using Google Groups (groups.google.com) Local options: -results=NUM Number of search results returned Default: $SURFRAW_deja_results Environment: SURFRAW_deja_results -m Search for Message-ID EOF w3_global_usage } +mkopts results= m w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_deja_results $optarg ;; -m*) setopt SURFRAW_deja_style "message-id" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://groups.google.com/" else escaped_args=$(w3_url_of_arg $w3_args) if test "${SURFRAW_deja_style}" = "normal"; then w3_browse_url "https://groups.google.com/groups?q=${escaped_args}&num=${SURFRAW_deja_results}" else w3_browse_url "https://groups.google.com/groups?as_umsgid=${escaped_args}&num=${SURFRAW_deja_results}" fi fi diff --git a/elvi/discogs b/elvi/discogs index 7757397..06b1a5b 100755 --- a/elvi/discogs +++ b/elvi/discogs @@ -1,53 +1,62 @@ #!/bin/sh # elvis: discogs -- Search the Discogs database of music information (www.discogs.com) # Patroklos Argyroudis, argp at domain cs.tcd.ie, 20060823 . surfraw || exit 1 w3_config_hook() { def SURFRAW_discogs_category all } w3_usage_hook() { cat << EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Discogs database of music information (www.discogs.com) Local options: -category= Category to search all | artists | labels | releases | catno Default: $SURFRAW_discogs_category Environment: SURFRAW_discogs_category EOF w3_global_usage } +mkopts category= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -category=*) echo all artists labels releases catno ;; + *) return 1 ;; + esac +} w3_parse_option_hook() { opt="$1" optarg="$2" case "$opt" in -category=*) setopt SURFRAW_discogs_category $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.discogs.com/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.discogs.com/search?type=${SURFRAW_discogs_category}&q=${escaped_args}&btn=Search" fi # EOF diff --git a/elvi/dockerhub b/elvi/dockerhub index 4b8838f..bac1139 100755 --- a/elvi/dockerhub +++ b/elvi/dockerhub @@ -1,60 +1,61 @@ #!/bin/sh # $Id$ # elvis: dockerhub -- Search for Docker images (https://hub.docker.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_dockerhub_automatic 0 defyn SURFRAW_dockerhub_official 0 def SURFRAW_dockerhub_pulls 0 def SURFRAW_dockerhub_stars 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words] Description: Surfraw search the Docker images. Local options: -automatic Search only for automatically built images Default: $SURFRAW_dockerhub_automatic Environment: SURFRAW_dockerhub_automatic -official Search only for official images Default: $SURFRAW_dockerhub_official -pulls Search only for images with no less than given number of pulls Default: $SURFRAW_dockerhub_pulls Environment: SURFRAW_dockerhub_pulls -stars Search only for images with no less than given number of stars Default: $SURFRAW_dockerhub_stars Environment: SURFRAW_dockerhub_stars EOF w3_global_usage } +mkopts automatic official pulls stars w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in (-a|-auto*) setoptyn SURFRAW_dockerhub_automatic 1 ;; (-f|-off*) setoptyn SURFRAW_dockerhub_official 1 ;; (-s=*|-stars=*) setopt SURFRAW_dockerhub_stars "$optarg" ;; (-p=*|-pulls=*) setopt SURFRAW_dockerhub_pulls "$optarg" ;; (*) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" escaped_args=$(w3_url_of_arg $w3_args) url='https://hub.docker.com/search/' url="${url}?isAutomated=${SURFRAW_dockerhub_automatic}" url="${url}&isOfficial=${SURFRAW_dockerhub_official}" url="${url}&pullCount=${SURFRAW_dockerhub_pulls}" url="${url}&starCount=${SURFRAW_dockerhub_stars}" url="${url}&q=${escaped_args}" w3_browse_url "${url}" diff --git a/elvi/duckduckgo b/elvi/duckduckgo index af96401..f9e0831 100755 --- a/elvi/duckduckgo +++ b/elvi/duckduckgo @@ -1,82 +1,83 @@ #!/bin/sh # elvis: duckduckgo -- Securely search the web using duckduckgo (duckduckgo.com) # [email protected] 20110105 # relevant: https://duckduckgo.com/params.html # similar to duckduckgo elvi, adds more options and defaults to SSL. . surfraw || exit 1 w3_config_hook () { def SURFRAW_duckduckgo_results "$SURFRAW_results" def SURFRAW_duckduckgo_base_url "duckduckgo.com" def SURFRAW_duckduckgo_search search def SURFRAW_duckduckgo_params "&kg=g" defyn SURFRAW_duckduckgo_https_arg 0 defyn SURFRAW_duckduckgo_safe_arg 0 defyn SURFRAW_duckduckgo_redirect_arg 0 defyn SURFRAW_duckduckgo_use_javascript 0 defyn SURFRAW_duckduckgo_got_a_ducky_feeling 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using DuckDuckGo (duckduckgo.com) Local options: -d,-ducky,-l,-lucky use in case of overwhelming feeling of duckiness -j,-javascript use javascript -safe enable safe search -r,-redirect use redirection -s,-insecure disable SSL search EOF w3_global_usage } +mkopts ducky lucky javascript safe redirect insecure w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -d*|-l|-lu*) setoptyn SURFRAW_duckduckgo_got_a_ducky_feeling 1 ;; -j|-javascript*) setoptyn SURFRAW_duckduckgo_use_javascript 1 ;; -safe*) setoptyn SURFRAW_duckduckgo_safe_arg 1 ;; -r|-redirect*) setoptyn SURFRAW_duckduckgo_redirect_arg 1 ;; -s|-sec*) setoptyn SURFRAW_duckduckgo_https_arg 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ "${SURFRAW_duckduckgo_https_arg}" = 0 ] ; then SURFRAW_duckduckgo_base_url="https://${SURFRAW_duckduckgo_base_url}" else SURFRAW_duckduckgo_base_url="http://${SURFRAW_duckduckgo_base_url}" fi # need to send the user to the non-javascript version if using a non-graphical # browser if [ "$SURFRAW_duckduckgo_use_javascript" = 0 ]; then SURFRAW_duckduckgo_base_url="${SURFRAW_duckduckgo_base_url}/lite" fi if [ "$SURFRAW_duckduckgo_safe_arg" = 1 ]; then SURFRAW_duckduckgo_params="${SURFRAW_duckduckgo_params}&kp=1" fi if [ "$SURFRAW_duckduckgo_redirect_arg" = 1 ] ; then SURFRAW_duckduckgo_params="${SURFRAW_duckduckgo_params}&kd=1" fi if [ "$SURFRAW_graphical" != "yes" ] ; then SURFRAW_duckduckgo_params="${SURFRAW_duckduckgo_params}&kf=-1&kz=-1&kq=-1&kv=-1" fi escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_duckduckgo_got_a_ducky_feeling" = 1 ]; then escaped_args="! ${escaped_args}" fi w3_browse_url "${SURFRAW_duckduckgo_base_url}/?q=${escaped_args}${SURFRAW_duckduckgo_params}" diff --git a/elvi/ebay b/elvi/ebay index 6849548..c43ecec 100755 --- a/elvi/ebay +++ b/elvi/ebay @@ -1,150 +1,152 @@ #!/bin/sh # elvis: ebay -- Search the Ebay auction site # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_config_hook () { def SURFRAW_ebay_country "$SURFRAW_lang" def SURFRAW_ebay_results 50 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Ebay auction site Local options: -country= | -c= com | Main eBay site (default) ar | Argentina at | Austria au | Australia nl_BE | Belgium (Flemish) fr_BE | Belgium (French) br | Brazil ca | Canada ch | Switzerland cn | China de | Germany es | Spain fr | France hk | Hong Kong ie | Ireland kr | Korea my | Malaysia mx | Mexico nl | Netherlands nz | New Zealand ph | Philippines pl | Poland sg | Singapore se | Sweden tw | Taiwan uk UK Environment: SURFRAW_ebay_country, SURFRAW_lang -results= | -r Amount of results per page Default: 50 Environment: SURFRAW_ebay_results Examples: $w3_argv0 -c=de sauerkraut EOF w3_global_usage } +mkopts country= results= +# The values for -country= are not the same in the help and in the code. w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -country=*) setopt SURFRAW_ebay_country $optarg ;; -c=*) setopt SURFRAW_ebay_country $optarg ;; -results=*) setopt SURFRAW_ebay_results $optarg ;; -r=*) setopt SURFRAW_ebay_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_ebay_country" in com|ar|at|be|br|ca|ch|\ de|es|fr|fr_BE|\ nl_BE|ie|kr|\ mx|nl|ph|pl) TLD="${SURFRAW_ebay_country}" ;; uk) TLD="co.uk" ;; au|hk|sg|my) TLD="com.${SURFRAW_ebay_country}" ;; cn|zh|zt) TLD="cn" ;; # nz uses ebay.com, presumably using referrer to tell it is .nz # we can't affect referrer without getting browser-specific, so # just use ebay.com *) TLD="com" ;; esac mainsite_search="/sch/i.html?" case "$SURFRAW_ebay_country" in br) base_url="www.mercadolivre.com.br" search_url="lista.mercadolivre.com.br/" ;; ar|mx) base_url="www.mercadolibre.com.${TLD}" search_url="listado.mercadolibre.com.${TLD}/" ;; # Flemish and French Belgium search the same way as most other Ebay sites, but with a differently patterned base URL. fr_BE) base_url="www.befr.ebay.be" search_url="${base_url}${mainsite_search}" ;; nl_BE) base_url="www.benl.ebay.be" search_url="${base_url}${mainsite_search}" ;; cn|zh|zt) base_url="www.ebay.${TLD}" # FIXME: I can't read Chinese characters, so someone else can fix this if it doesn't work. search_url="${base_url}/newcms/search?" # The old version: #search_url="http://search.eachnet.com/search/basicsearch.do?satitle=${escaped_args}&sacat=0" ;; kr) base_url="www.auction.co.kr" search_url="browse.auction.co.kr/search?" ;; se) base_url="www.tradera.com" search_url="${base_url}/search?" ;; tw) base_url="twexport.ebay.com" # This is done by POST... # TODO: Find a way to search on the Taiwan Ebay. Use Hong Kong for now. search_url="www.ebay.com.hk${mainsite_search}" ;; *) base_url="www.ebay.${TLD}" search_url="${base_url}${mainsite_search}" ;; esac if null "$w3_args"; then url="$base_url" else escaped_args=$(w3_url_of_arg $w3_args) case "$SURFRAW_ebay_country" in # Brazil, Argentina, and Mexico searches replace spaces with hyphens ("-") rather than "%20" or "+". br|ar|mx) query="$(echo "$escaped_args" | sed 's/%20\|+/-/g')" ;; cn|zh|zt) query="q=${escaped_args}&catid=0" ;; kr) query="keyword=${escaped_args}" ;; se) query="q=${escaped_args}" ;; # `_sacat=0` appears to be the "All Categories" option. *) query="_nkw=${escaped_args}&_ipg=${SURFRAW_ebay_results}&_sacat=0" ;; esac # Avoid redundant prefixes. url="${search_url}${query}" fi case "$SURFRAW_ebay_country" in # Why? In 2021? # FYI, using HTTPS times me out. kr) url="http://$url" ;; *) url="https://$url" ;; esac w3_browse_url "$url" diff --git a/elvi/f5 b/elvi/f5 index 38cd87f..1a14f9d 100755 --- a/elvi/f5 +++ b/elvi/f5 @@ -1,56 +1,65 @@ #!/bin/sh # $Id$ # elvis: f5 -- Search F5 related information (www.f5.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_f5_dc no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search F5 related information Local options: -dc[=(yes|no)] Search F5 Devcentral Default: $SURFRAW_f5_dc Environment: SURFRAW_f5_dc Examples: $w3_argv0 Teleport to the F5 Knowledgebase $w3_argv0 -dc Teleport to the F5 Devcentral site EOF w3_global_usage } +mkopts dc dc= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -dc=*) echo yes no ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -dc) setoptyn SURFRAW_f5_dc yes ;; -dc=*) setoptyn SURFRAW_f5_dc $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments test -z "$w3_args" || escaped_args=$(w3_url_of_arg $w3_args) if ok SURFRAW_f5_dc; then if test -z "$escaped_args"; then w3_browse_url "https://devcentral.f5.com" else w3_browse_url "https://devcentral.f5.com/Default.aspx?tabid=37&cx=015798286719081439686:g38hs-tdy64&cof=FORID:11i&q=${escaped_args}" fi exit $? fi if test -z "$escaped_args"; then w3_browse_url "https://www.f5.com" else w3_browse_url "https://www.f5.com/search?q=${escaped_args}" fi exit $? diff --git a/elvi/finkpkg b/elvi/finkpkg index 01560fb..0459bb4 100755 --- a/elvi/finkpkg +++ b/elvi/finkpkg @@ -1,168 +1,181 @@ #!/bin/sh # elvis: finkpkg -- Search Fink packages (pdb.finkproject.org) # [email protected] 20091111 . surfraw || exit 1 w3_config_hook () { def SURFRAW_finkpkg_pkgname "" def SURFRAW_finkpkg_maintainer "" def SURFRAW_finkpkg_distro default def SURFRAW_finkpkg_arch any def SURFRAW_finkpkg_tree any def SURFRAW_finkpkg_section any defyn SURFRAW_finkpkg_exact no defyn SURFRAW_finkpkg_nomaint no defyn SURFRAW_finkpkg_nochildren no defyn SURFRAW_finkpkg_noshlibsdev no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search Fink packages (pdb.finkproject.org) Local options: -pkg=NAME Search by packagename for NAME -maintainer=NAME Search by maintainer for NAME -dist=DIST Specify distribution DIST default | Supported [10.5 & 10.6] (default) any | Any 10.4 | 10.4 10.5 | 10.5 10.6 | 10.6 Default: $SURFRAW_finkpkg_distro Environment: SURFRAW_finkpkg_distro -arch=ARCH Search in arch ARCH any | Any (default) i386 | i386 x86_64 | X86_64 (aka AMD64) powerpc | powerpc Default: $SURFRAW_finkpkg_arch Environment: SURFRAW_finkpkg_arch -tree=TREE Search in tree TREE any | Any (default) unstable | Unstable stable | Stable bindist | Binary Distribution testing | Packages that need testing Default: $SURFRAW_finkpkg_tree Environment: SURFRAW_finkpkg_tree -section=SEC Search in section SEC any | Any (default) base | Core packages crypto | Cryptographic software (subject to national regulations) database | SQL and other database software devel | Software for software development editors | Text editors games | Games and other fun stuff gnome | The GNOME desktop environment (version 2.26) graphics | Graphics applications and libraries kde | K Desktop Environment (version 3.5.10 and 4.2.4) languages | Programming languages (compilers, interpreters) libs | General purpose libraries libs/perlmods | Perl libraries libs/pythonmods | Python libraries libs/rubymods | Ruby libraries net | Network-related applications and libraries sci | Scientific applications shells | Shells (command line interpreters) sound | Audio software text | Text-processing software utils | Utilities that do not fit elsewhere web | Web-related software x11 | General X11 packages - toolkits and utilities x11-system | X Window System core packages x11-wm | Window managers for the X Window System Default: $SURFRAW_finkpkg_section Environment: SURFRAW_finkpkg_section -exact Exact package matches only Default: $SURFRAW_finkpkg_exact Environment: SURFRAW_finkpkg_exact -nomaint Find packages with no maintainer Default: $SURFRAW_finkpkg_nomaint Environment: SURFRAW_finkpkg_nomaint -nochildren Exclude packages with parent (includes most "-dev", "-shlibs", ... splitoffs) Default: $SURFRAW_finkpkg_nochildren Environment: SURFRAW_finkpkg_nochildren -noshlibsdev Exclude -shlibs, -dev, -bin, -common, -doc packages Default: $SURFRAW_finkpkg_noshlibsdev Environment: SURFRAW_finkpkg_noshlibsdev EOF w3_global_usage } +mkopts pkg= maintainer= dist= arch= tree= section= exact nomaint nochildren noshlibsdev +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + # Is this outdated? + -dist=*) echo default any 10.4 10.5 10.6 ;; + -arch=*) echo any i386 x86_64 powerpc ;; + -tree=*) echo any unstable stable bindist testing ;; + -section=*) echo any base crypto database devel editors games gnome graphics kde languages libs libs/perlmods libs/pythonmods libs/rubymods net sci shells sound text utils web x11 x11-system x11-wm ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -pkg*=*) setopt SURFRAW_finkpkg_pkgname $optarg ;; -maint*=*) setopt SURFRAW_finkpkg_maintainer $optarg ;; -dist*=*) setopt SURFRAW_finkpkg_distro $optarg ;; -arch=*) setopt SURFRAW_finkpkg_arch $optarg ;; -tree*=*) setopt SURFRAW_finkpkg_tree $optarg ;; -sec*=*) setopt SURFRAW_finkpkg_section $optarg ;; -ex*) setoptyn SURFRAW_finkpkg_exact yes ;; -nomaint*) setoptyn SURFRAW_finkpkg_nomaint yes ;; -noch*) setoptyn SURFRAW_finkpkg_nochildren yes ;; -noshlib*) setoptyn SURFRAW_finkpkg_noshlibsdev yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) url="http://pdb.finkproject.org/pdb/browse.php" if [ -z "$escaped_args" ] && [ -z "$SURFRAW_finkpkg_pkgname" ] && [ -z "$SURFRAW_finkpkg_maintainer" ] then w3_browse_url "$url" else if [ "$SURFRAW_finkpkg_arch" = any ] then SURFRAW_finkpkg_arch="" fi if [ "$SURFRAW_finkpkg_section" = any ] then SURFRAW_finkpkg_section="" fi url="${url}?dist_name=${SURFRAW_finkpkg_distro}" url="${url}&architecture=${SURFRAW_finkpkg_arch}" url="${url}&tree=${SURFRAW_finkpkg_tree}" url="${url}&sec=${SURFRAW_finkpkg_section}" if [ -n "$escaped_args" ] then url="${url}&summary=${escaped_args}" fi if [ -n "$SURFRAW_finkpkg_pkgname" ] then url="${url}&name=${SURFRAW_finkpkg_pkgname}" fi if [ -n "$SURFRAW_finkpkg_maintainer" ] then url="${url}&maintainer=${SURFRAW_finkpkg_maintainer}" fi if ifyes SURFRAW_finkpkg_exact then url="${url}&name_exact=on" fi if ifyes SURFRAW_finkpkg_nomaint then url="$url&nomaintainer=on" fi if ifyes SURFRAW_finkpkg_nochildren then url="$url&nochildren=on" fi if ifyes SURFRAW_finkpkg_noshlibsdev then url="$url&noshlibsdev=on" fi w3_browse_url "$url" fi diff --git a/elvi/freebsd b/elvi/freebsd index 530ca2a..31874bb 100755 --- a/elvi/freebsd +++ b/elvi/freebsd @@ -1,200 +1,212 @@ #!/bin/sh # $Id$ # elvis: freebsd -- Search FreeBSD related information (www.freebsd.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_freebsd_mail no defyn SURFRAW_freebsd_pr no defyn SURFRAW_freebsd_cvs no defyn SURFRAW_freebsd_mid no defyn SURFRAW_freebsd_gg no defyn SURFRAW_freebsd_ps no defyn SURFRAW_freebsd_prs no defyn SURFRAW_freebsd_elogs no defyn SURFRAW_freebsd_portsearch no def SURFRAW_freebsd_portsearchtype all def SURFRAW_freebsd_portsearchsec all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search FreeBSD related information Local options: -mail[=(yes|no)] Search FreeBSD mailinglists Default: $SURFRAW_freebsd_mail Environment: SURFRAW_freebsd_mail -gg[=(yes|no)] Search FreeBSD mailinglists at Google Groups Default: $SURFRAW_freebsd_mail Environment: SURFRAW_freebsd_mail -pr[=(yes|no)] Query Problem Reports Default: $SURFRAW_freebsd_pr Environment: SURFRAW_freebsd_pr -cvs[=(yes|no)] Query cvsweb Default: $SURFRAW_freebsd_cvs Environment: SURFRAW_freebsd_cvs -mid[=(yes|no)] Query mailing lists by Message-ID Default: $SURFRAW_freebsd_mid Environment: SURFRAW_freebsd_mid -ps[=(yes|no)] Teleport to the Port Survey Page Default: $SURFRAW_freebsd_ps Environment: SURFRAW_freebsd_ps -psearch[=TYPE] Search of type TYPE in ports. all | All (default) name | Package Name text | Description pkgdescr | Long Description maintainer | Maintainer requires | Requires Default: $SURFRAW_freebsd_portsearchtype Environment: SURFRAW_freebsd_portsearchtype -psection[=SEC] Section of ports to search in. all, accessibility, afterstep, arabic, archivers, astro, audio, benchmarks, biology, cad, chinese, comms, converters, databases, deskutils, devel, dns, docs, editors, elisp, emulators, finance, french, ftp, games, geography, german, gnome, gnustep, graphics, hamradio, haskell, hebrew, hungarian, ipv6, irc, japanese, java, kde, kld, korean, lang, linux, lisp, mail, math, mbone, misc, multimedia, net, net-im, net-mgmt, net-p2p, news, palm, parallel, pear, perl5, plan9, polish, ports-mgmt, portuguese, print, python, ruby, rubygems, russian, scheme, science, security, shells, spanish, sysutils, tcl, textproc, tk, ukrainian, vietnamese, windowmaker, www, x11, x11-clocks, x11-drivers, x11-fm, x11-fonts, x11-servers, x11-themes, x11-toolkits, x11-wm, xfce, zope Default: $SURFRAW_freebsd_portsearchsec Environment: SURFRAW_freebsd_portsearchsec -prs[=(yes|no)] Teleport to the Problem Report Survey Page Default: $SURFRAW_freebsd_prs Environment: SURFRAW_freebsd_prs -elogs[=(yes|no)] Teleport to the Build Error Logs Page Default: $SURFRAW_freebsd_elogs Environment: SURFRAW_freebsd_elogs Examples: $w3_argv0 Teleport to the FreeBSD website $w3_argv0 mycroft Search FreeBSD website for odeur de mycroft $w3_argv0 -mail Teleport to the mail-index Query form $w3_argv0 -mail proff Search mailing-list archives for odeur de proff $w3_argv0 -gg Teleport to FreeBSD mailinglists at Google $w3_argv0 -gg proff Search Google archives for odeur de proff $w3_argv0 -pr Query Problem Report form $w3_argv0 -pr 666 Display PR 666 $w3_argv0 -cvs Query cvsweb $w3_argv0 -cvs ports/ Display cvsweb tree for ports/ $w3_argv0 -mid Query mailing lists by Message-ID $w3_argv0 -mid <x> Display message with ID <x> $w3_argv0 -ps Teleport to the Port Survey page $w3_argv0 -prs Teleport to the Port Report Survey page $w3_argv0 -psearch surfraw Search ports for surfraw $w3_argv0 -psearch=text perl Search port descriptions for perl EOF w3_global_usage } +mkopts mail gg pr cvs mid ps psearch psection prs elogs +mkopts mail= gg= pr= cvs= mid= ps= psearch= psection= prs= elogs= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -mail=*|-gg=*|-pr=*|-cvs=*|-mid=*|-ps=*|-prs=*|-elogs=*) echo yes no ;; + -psearch=*) echo all name text pkgdescr maintainer requires ;; + -psection=*) echo all accessibility afterstep arabic archivers astro audio benchmarks biology cad chinese comms converters databases deskutils devel dns docs editors elisp emulators finance french ftp games geography german gnome gnustep graphics hamradio haskell hebrew hungarian ipv6 irc japanese java kde kld korean lang linux lisp mail math mbone misc multimedia net net-im net-mgmt net-p2p news palm parallel pear perl5 plan9 polish ports-mgmt portuguese print python ruby rubygems russian scheme science security shells spanish sysutils tcl textproc tk ukrainian vietnamese windowmaker www x11 x11-clocks x11-drivers x11-fm x11-fonts x11-servers x11-themes x11-toolkits x11-wm xfce zope ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -mail) setoptyn SURFRAW_freebsd_mail yes ;; -mail=*) setoptyn SURFRAW_freebsd_mail $optarg ;; -gg) setoptyn SURFRAW_freebsd_gg yes ;; -gg=*) setoptyn SURFRAW_freebsd_gg $optarg ;; -pr) setoptyn SURFRAW_freebsd_pr yes ;; -pr=*) setoptyn SURFRAW_freebsd_pr $optarg ;; -cvs) setoptyn SURFRAW_freebsd_cvs yes ;; -cvs=*) setoptyn SURFRAW_freebsd_cvs $optarg ;; -mid) setoptyn SURFRAW_freebsd_mid yes ;; -mid=*) setoptyn SURFRAW_freebsd_mid $optarg ;; -ps) setoptyn SURFRAW_freebsd_ps yes ;; -prs) setoptyn SURFRAW_freebsd_prs yes ;; -psea*=*) setoptyn SURFRAW_freebsd_portsearch yes; setopt SURFRAW_freebsd_portsearchtype $optarg ;; -psea*) setoptyn SURFRAW_freebsd_portsearch yes ;; -psec*=*) setoptyn SURFRAW_freebsd_portsearch yes; setopt SURFRAW_freebsd_portsec $optarg ;; -psec*) setoptyn SURFRAW_freebsd_portsearch yes ;; -elogs) setoptyn SURFRAW_freebsd_elogs yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments test -z "$w3_args" || escaped_args=$(w3_url_of_arg $w3_args) if ok SURFRAW_freebsd_portsearch; then if test -z "$escaped_args"; then w3_browse_url "https://www.freebsd.org/cgi/ports.cgi" else w3_browse_url "https://www.freebsd.org/cgi/ports.cgi?query=${escaped_args}&stype=${SURFRAW_freebsd_portsearchtype}&sektion=${SURFRAW_freebsd_portsec}" fi exit $? fi if ok SURFRAW_freebsd_pr; then if test -z "$escaped_args"; then w3_browse_url "https://www.freebsd.org/cgi/query-pr-summary.cgi?query" else w3_browse_url "https://www.freebsd.org/cgi/query-pr.cgi?pr=${escaped_args}" fi exit $? fi if ok SURFRAW_freebsd_mail; then if test -z "$escaped_args"; then w3_browse_url "https://docs.freebsd.org/mail/" else w3_browse_url "https://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&sort=score&index=recent&source=freebsd-questions" fi exit $? fi if ok SURFRAW_freebsd_gg; then if test -z "$escaped_args"; then w3_browse_url "https://groups.google.com/groups?hl=en&group=mailing.freebsd" else w3_browse_url "https://groups.google.com/groups?q=${escaped_args}&hl=en&meta=group%3Dmailing.freebsd.*" fi exit $? fi if ok SURFRAW_freebsd_cvs; then if test -z "$escaped_args"; then w3_browse_url "https://cvsweb.freebsd.org/" else w3_browse_url "https://cvsweb.freebsd.org/cgi/cvsweb.cgi?path=${escaped_args}" fi exit $? fi if ok SURFRAW_freebsd_mid; then if test -z "$escaped_args"; then w3_browse_url "https://www.freebsd.org/search/search-mid.html" else w3_browse_url "https://www.freebsd.org/cgi/mid.cgi?id=${escaped_args}&db=mid" fi exit $? fi if ok SURFRAW_freebsd_ps; then w3_browse_url "https://people.freebsd.org/~fenner/portsurvey/" exit $? fi if ok SURFRAW_freebsd_elogs; then w3_browse_url "https://people.freebsd.org/~fenner/errorlogs/" exit $? fi if ok SURFRAW_freebsd_prs; then w3_browse_url "https://people.freebsd.org/~fenner/ports-prs.html" exit $? fi if test -z "$escaped_args"; then w3_browse_url "https://www.freebsd.org/" else w3_browse_url "https://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&source=www" fi exit $? diff --git a/elvi/freedb b/elvi/freedb index 87f2a03..a2ab138 100755 --- a/elvi/freedb +++ b/elvi/freedb @@ -1,168 +1,177 @@ #!/bin/sh # $Id$ # elvis: freedb -- Search for cd track listings in FreeDB (www.freedb.org) # [email protected] 20030129 # notes at end of script . surfraw || exit 1 w3_config_hook () { # options defyn SURFRAW_freedb_artists 0 defyn SURFRAW_freedb_albums 0 defyn SURFRAW_freedb_songs 0 defyn SURFRAW_freedb_rest 0 defyn SURFRAW_freedb_all 0 defyn SURFRAW_freedb_id 0 defyn SURFRAW_freedb_allfields 0 defyn SURFRAW_freedb_allcats 1 defyn SURFRAW_freedb_bycat 0 def SURFRAW_freedb_cats "" def SURFRAW_freedb_page 1 # internal SURFRAW_freedb_default=1 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search FreeDB (www.freedb.org) for cd track listings Local options: -artists Search artists Environment: SURFRAW_cddb_artists -albums Search albums Environment: SURFRAW_cddb_albums -songs Search songs Environment: SURFRAW_cddb_songs -rest Search the rest of the data Environment: SURFRAW_cddb_rest -all Search all fields Environment: SURFRAW_cddb_all Default: search artists and albums -id Search by CDDB ID. -bycat Sort results by category -cat=CATEGORY Category to search, repeat as needed Options: all blues classical country data folk jazz misc newage reggae rock soundtrack Default: all -page=PAGENUM Start at page PAGENUM Default: 1 EOF w3_global_usage } +mkopts artists albums songs rest all id bycat cat= page= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -cat=*) echo all blues classical country data folk jazz misc newage reggae rock soundtrack ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -ar*) setopt SURFRAW_freedb_artists 1;setoptyn SURFRAW_freedb_default 0;; -alb*) setoptyn SURFRAW_freedb_albums 1;setoptyn SURFRAW_freedb_default 0;; -so*) setoptyn SURFRAW_freedb_songs 1;setoptyn SURFRAW_freedb_default 0;; -r*) setoptyn SURFRAW_freedb_rest 1;setoptyn SURFRAW_freedb_default 0;; -all) setoptyn SURFRAW_freedb_all 1;setoptyn SURFRAW_freedb_default 0;; -id) setoptyn SURFRAW_freedb_id 1;; -pag*=*) setopt SURFRAW_freedb_page $optarg ;; -bycat) setoptyn SURFRAW_freedb_bycat 1 ;; -cat*=*) if [ "$optarg" = "all" ]; then setoptyn SURFRAW_freedb_allcats 1 SURFRAW_freedb_cats="" else setoptyn SURFRAW_freedb_allcats 0 SURFRAW_freedb_cats="${SURFRAW_freedb_cats}&cats%5B%5D=$optarg" fi ;; *) return 1 ;; esac return 0 } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url http://www.freedb.org/ else escaped_args=$(w3_url_of_arg $w3_args) SURFRAW_freedb_queryopts="page=${SURFRAW_freedb_page}&" if ifyes SURFRAW_freedb_id; then w3_browse_url "http://www.freedb.org/freedb_discid_check.php?discid=${escaped_args}&${SURFRAW_freedb_queryopts}" else if [ $SURFRAW_freedb_albums -eq 1 -o \ $SURFRAW_freedb_all -eq 1 -o \ $SURFRAW_freedb_default -eq 1 ] then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}fields%5B%5D=title&" fi if [ $SURFRAW_freedb_artists -eq 1 -o \ $SURFRAW_freedb_all -eq 1 -o \ $SURFRAW_freedb_default -eq 1 ] then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}fields%5B%5D=artist&" fi if [ $SURFRAW_freedb_songs -eq 1 -o \ $SURFRAW_freedb_all -eq 1 ] then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}fields%5B%5D=track&" fi if [ $SURFRAW_freedb_rest -eq 1 -o \ $SURFRAW_freedb_all -eq 1 ] then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}fields%5B%5D=rest&" fi if [ $SURFRAW_freedb_bycat = 1 ]; then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}grouping=category&" else SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}grouping=none&" fi if [ $SURFRAW_freedb_allcats = 1 ]; then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}allcats=YES&" else SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}allcats=NO${SURFRAW_freedb_cats}" fi if [ $SURFRAW_freedb_all = 1 ]; then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}allfields=YES&" else SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}allfields=NO&" fi w3_browse_url "http://www.freedb.org/freedb_search.php?${SURFRAW_freedb_queryopts}words=${escaped_args}" fi fi #eg: http://www.freedb.org/freedb_search.php?words=swans&allfields=NO&fields=artist&fields=title&fields=track&fields=rest&allcats=NO&cats=blues&cats=classical&cats=country&cats=data&cats=folk&cats=jazz&cats=misc&cats=newage&cats=reggae&cats=rock&cats=soundtrack&grouping=cats # minimum: http://www.freedb.org/freedb_search.php?words=swans+are+dead&allfields=YES&allcats=YES&grouping=none # parameters: #words=search+words (compulsory) #allfields=YES | NO (compulsory) #fields=artist | title | track | rest (can be repeated as often as needed) #allcats=YES | NO (compulsory) #cats = blues | classical | country | data | folk | jazz | misc | newage | # reggae | rock | soundtrack (can be repeated as often as needed) #grouping=cats | none (compulsory) diff --git a/elvi/gcache b/elvi/gcache index 1e6edde..0f2360c 100755 --- a/elvi/gcache +++ b/elvi/gcache @@ -1,49 +1,50 @@ #!/bin/sh # $Id$ # elvis: gcache -- Search the web using Google cache (www.google.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_cache_graphic 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [option] [URL]... Description: Surfraw shows the cached page using Google (www.google.com) Local option: -i, -images Retrieve the stored page WITH images and media. Default: textonly. EOF w3_global_usage } +mkopts images w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -i*) setoptyn SURFRAW_cache_graphic 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if !( test -n "$SURFRAW_lang" ); then SURFRAW_lang="en"; fi if test -z "$w3_args"; then w3_browse_url "https://www.google.com/intl/$SURFRAW_lang/help/features_list.html#cached" else escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_cache_graphic" = 1 ]; then w3_browse_url "https://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang" else w3_browse_url "https://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang&strip=1" fi fi diff --git a/elvi/github b/elvi/github index 316d76a..6686ab3 100755 --- a/elvi/github +++ b/elvi/github @@ -1,67 +1,76 @@ #!/bin/sh # elvis: github -- Search GitHub (https://github.com) # Author: jason ryan • https://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_git_type "$SURFRAW_type" def SURFRAW_git_lang any } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search Github (https://github.com) Local options: -l=LANGUAGE | -lang=LANGUAGE Languages are case sensitive, eg., C, Shell, Python etc. Languages with spaces must be conjoined with a "+", eg, Common+Lisp Default: Any -type=SEARCH | -t=SEARCH every | Everything repo | Repositories user | Users code | Code Default: Everything EOF w3_global_usage } +mkopts language= type= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -type=*) echo every repo user code ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -t*=*) setopt SURFRAW_git_type $optarg ;; -l*=*) setopt SURFRAW_git_lang $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains list of arguments # type of search selected case "$SURFRAW_git_type" in every) type="Everything" ;; repo) type="Repositories" ;; user) type="Users" ;; code) type="Code" ;; *) type="Everything" ;; esac # No arguments parsed if [ -z "$w3_args" ]; then w3_browse_url "https://github.com" else # Language and/or search type selected escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://github.com/search?q=${escaped_args}&repo=&langOverride=&start_value=1&type=${type}&language=${SURFRAW_git_lang}" fi diff --git a/elvi/gmane b/elvi/gmane index c50898c..dfdea3f 100755 --- a/elvi/gmane +++ b/elvi/gmane @@ -1,85 +1,94 @@ #!/bin/sh # elvis: gmane -- Search mailing list with gmane (gmane.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_gmane_or 0 defyn SURFRAW_gmane_listsearch 0 def SURFRAW_gmane_list "" def SURFRAW_gmane_author "" def SURFRAW_gmane_sort "relevance" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search mailing lists with gmane (gmane.org) Local options: -list=LIST Search list(s) eg -l=gmane.os.openbsd.vax or -l="gmane.os.openbsd.*" -L Search by list name instead of contents -author=NAME Limit search to posts by NAME Default: $SURFRAW_gmane_results Environment: SURFRAW_gmane_results -sort= Sort by: relevance Relevance date Newest first revdate Oldest first -or OR search results instead of ANDing. EOF w3_global_usage } +mkopts list= L author= sort= or +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -sort=*) echo relevance date revdate ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -li*=*) setopt SURFRAW_gmane_group "$optarg" ;; -au*=*) setopt SURFRAW_gmane_author "$optarg" ;; -so*=*) setopt SURFRAW_gmane_sort "$optarg" ;; -L) setoptyn SURFRAW_gmane_listsearch 1 ;; -or) setoptyn SURFRAW_gmane_or 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if test -z "$w3_args" then if ifyes SURFRAW_gmane_listsearch then url=https://gmane.org/find.php else url=http://search.gmane.org/ fi else escaped_args=$(w3_url_of_arg $w3_args) if ifyes SURFRAW_gmane_listsearch then url="http://dir.gmane.org/search.php?match=${escaped_args}" else url="http://search.gmane.org/?query=${escaped_args}&sort=${SURFRAW_gmane_sort}" if [ "$SURFRAW_gmane_author" != "" ] then url="${url}&author=${SURFRAW_gmane_author}" fi if ifyes SURFRAW_gmane_or then url="${url}&DEFAULTOP=or" else url="${url}&DEFAULTOP=and" fi if [ "${SURFRAW_gmane_group}" != "" ] then url="${url}&group=${SURFRAW_gmane_group}" fi fi fi w3_browse_url "$url" diff --git a/elvi/google b/elvi/google index 0f128ba..43924e5 100755 --- a/elvi/google +++ b/elvi/google @@ -1,129 +1,139 @@ #!/bin/sh # $Id$ # elvis: google -- Search the web using Google (www.google.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_google_results "$SURFRAW_results" def SURFRAW_google_search search defyn SURFRAW_google_lucky 0 def SURFRAW_google_country us def SURFRAW_google_safe default } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Google (www.google.com) Local options: -l, -lucky Feeling lucky? Jump to first result. -results=NUM Number of search results returned Default: $SURFRAW_google_results Environment: SURFRAW_google_results -search= Specialized search on topic images | Images videos | Videos maps | Maps groups | groups news | News bsd | BSD linux | Linux mac | Apple Macintosh unclesam | U.S. Government Environment: SURFRAW_google_search -country= Select regional google site Default is us (google.com) <ISO 3166 alpha-2 code> Environment: SURFRAW_google_country -i, -images Image Search (same as -search=images) -v, -videos Video Search (same as -search=videos) -m, -maps Map Search (same as -search=maps) -n, -news News Search (same as -search=news) -G, -groups Groups Search (same as -search=groups) -safe= Safe Search level default | Default: $SURFRAW_google_safe off | Environment: SURFRAW_google_safe moderate | strict | EOF w3_global_usage } +mkopts lucky results= search= country= images videos maps news groups safe= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -search=*) echo images videos maps groups news bsd linux mac unclesam ;; + -safe=*) echo default off moderate strict ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -r*=*) setopt SURFRAW_google_results "$optarg" ;; -sa*=*) setopt SURFRAW_google_safe "$optarg" ;; -s*=*) setopt SURFRAW_google_search "$optarg" ;; -l|-lu*) setoptyn SURFRAW_google_lucky 1 ;; - -c=*) setopt SURFRAW_google_country "$optarg" ;; + -c=*|-country=*) setopt SURFRAW_google_country "$optarg" ;; -i*) setopt SURFRAW_google_search images ;; -v*) setopt SURFRAW_google_search videos ;; -m*) setopt SURFRAW_google_search maps ;; -n|-news) setopt SURFRAW_google_search news ;; -G|-gr|-groups) setopt SURFRAW_google_search groups ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments # Use SURFRAW_lang if present and the country has not been changed if test -n "$SURFRAW_lang" -a "$SURFRAW_google_country" = "us"; then SURFRAW_google_country="$SURFRAW_lang"; fi case "$SURFRAW_google_country" in af|ag|ai|ar|au|bd|bn|bo|br|bs|bw|by|bz|co|cu|do|ec|eg|et|fj|gi|gt|hk|jm|ly|mt|mx|my|na|nf|ng|ni|np|nz|om|pa|pe|ph|pk|pr|py|qa|sa|sb|sg|sv|tj|tr|tw|ua|ug|uy|vn) domain="com.${SURFRAW_google_country}" ;; cr|id|il|in|jp|ke|kh|kr|ls|ma|th|uk|uz|vc|ve|vg|vi|ck|yu|za|zm|zw) domain="co.${SURFRAW_google_country}" ;; us) domain="com";; *) domain="$SURFRAW_google_country" ;; esac safe="" case "$SURFRAW_google_safe" in strict) safe="&safe=strict" ;; moderate) safe="&safe=moderate" ;; off) safe="&safe=off" ;; esac url="https://" if test -z "$w3_args" ; then case "$SURFRAW_google_search" in i*) url="${url}images" ;; m*) url="${url}maps" ;; g*) url="${url}groups" ;; n*) url="${url}news" ;; v*) url="${url}video" ;; *) url="${url}www" ;; esac url="${url}.google.${domain}" else search="$SURFRAW_google_search" case "$SURFRAW_google_search" in v*) url="${url}www"; search="search"; extra="&tbo=p&tbm=vid";; i*) url="${url}images" ; search="images";; m*) url="${url}maps" ; search=maps ;; g*) url="${url}groups" ; search=groups ;; n*) url="${url}news" ; search=news ;; *) url="${url}www" ;; esac url="${url}.google.${domain}/${search}" escaped_args=$(w3_url_of_arg $w3_args) url="${url}?q=${escaped_args}&num=${SURFRAW_google_results}" if [ "$SURFRAW_google_lucky" = 1 ]; then button=$(w3_url_escape "I'm Feeling Lucky") url="${url}&btnI=$button" fi url="${url}${safe}${extra}" fi w3_browse_url "$url" diff --git a/elvi/gutenberg b/elvi/gutenberg index b9b26a3..4cacee1 100755 --- a/elvi/gutenberg +++ b/elvi/gutenberg @@ -1,72 +1,73 @@ #!/bin/sh # $Id$ # elvis: gutenberg -- Search for books on Project Gutenberg (gutenberg.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_gutenberg_author 0 defyn SURFRAW_gutenberg_title 0 defyn SURFRAW_gutenberg_num 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search for books on Project Gutenberg (gutenberg.org) Local options: -title Search titles (default) -author Search authors -num Search etext numbers EOF w3_global_usage } +mkopts title author num w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -a*) setoptyn SURFRAW_gutenberg_author 1 ;; -ti*) setoptyn SURFRAW_gutenberg_title 1 ;; -n*) setoptyn SURFRAW_gutenberg_num 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.gutenberg.org/" else escaped_args=$(w3_url_of_arg $w3_args) if ifno SURFRAW_gutenberg_author && ifno SURFRAW_gutenberg_title && ifno SURFRAW_gutenberg_num then SURFRAW_gutenberg_title=1 fi url="https://www.gutenberg.org/catalog/world/results?" if ifyes SURFRAW_gutenberg_author then url="$url&author=${escaped_args}" else url="$url&author=" fi if ifyes SURFRAW_gutenberg_title then url="$url&title=${escaped_args}" else url="$url&title=" fi if ifyes SURFRAW_gutenberg_num then url="$url&etextnr=${escaped_args}" else url="$url&etextnr=" fi w3_browse_url "$url" fi diff --git a/elvi/imdb b/elvi/imdb index 26ea07c..1ca0385 100755 --- a/elvi/imdb +++ b/elvi/imdb @@ -1,58 +1,67 @@ #!/bin/sh # $Id$ # elvis: imdb -- Search the Internet Movie Database (www.imdb.com) # [email protected] 20030209 . surfraw || exit 1 w3_config_hook () { def SURFRAW_imdb_category all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Internet Movie Database (www.imdb.com) Local options: -category= Category to search All | Titles | MyMovies | People | Characters | Quotes | Bios | Plots Default: $SURFRAW_imdb_category Environment: SURFRAW_imdb_category EOF w3_global_usage } +mkopts category= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -category=*) echo All Titles MyMovies People Characters Quotes Bios Plots ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -category=Titles) setopt SURFRAW_imdb_category tt ;; -category=People) setopt SURFRAW_imdb_category nm ;; -category=Characters) setopt SURFRAW_imdb_category ch ;; -category=*) setopt SURFRAW_imdb_category $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.imdb.com/" else escaped_args=$(w3_url_of_arg $w3_args) #Avoids people having to quote "My+Movies" on command line if [ $SURFRAW_imdb_category = MyMovies ]; then SURFRAW_imdb_category="My+Movies" fi w3_browse_url "http://www.imdb.com/find?s=${SURFRAW_imdb_category}&q=${escaped_args}" fi diff --git a/elvi/ixquick b/elvi/ixquick index 74d3f55..06336fc 100755 --- a/elvi/ixquick +++ b/elvi/ixquick @@ -1,97 +1,107 @@ #!/bin/sh # $Id$ # elvis: ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_ixquick_search 'do/metasearch.pl' def SURFRAW_ixquick_lang "$SURFRAW_lang" defyn SURFRAW_ixquick_ssl yes } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Ixquick metasearch [HTTPS] (www.ixquick.com) Local options: -nossl Don't use https Environment: SURFRAW_ixquick_ssl -search= Specialized search on topic web | web pics | images Environment: SURFRAW_ixquick_search -lang= Language interface of ixquick english dansk deutsch espanol francais italiano nederlands norsk polski portugues suomi svenska turkce jiantizhongwen nihongo fantizhengwen hangul Default: english Environment: SURFRAW_ixquick_lang, SURFRAW_lang EOF w3_global_usage } +mkopts nossl search= lang= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -search=*) echo web pics ;; + -lang=*) echo english dansk deutsch espanol francais italiano nederlands norsk polski portugues suomi svenska turkce jiantizhongwen nihongo fantizhengwen hangul ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -no*) setoptyn SURFRAW_ixquick_ssl no ;; -search=*) setopt SURFRAW_ixquick_search $optarg ;; -lang=*) setopt SURFRAW_ixquick_lang $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if ifyes SURFRAW_ixquick_ssl then proto="https" else proto="http" fi # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "${proto}://www.ixquick.com/" else case "$SURFRAW_ixquick_lang" in en|english) SURFRAW_ixquick_lang="english" ;; dk|dansk) SURFRAW_ixquick_lang="dansk" ;; de|deutsch) SURFRAW_ixquick_lang="deutsch" ;; es|espanol) SURFRAW_ixquick_lang="espanol" ;; fr|francais) SURFRAW_ixquick_lang="francais" ;; it|italiano) SURFRAW_ixquick_lang="italiano" ;; nl|nederlands) SURFRAW_ixquick_lang="nederlands" ;; no|nb|nn|norsk) SURFRAW_ixquick_lang="norsk" ;; pl|polski) SURFRAW_ixquick_lang="polski" ;; pt|portugues) SURFRAW_ixquick_lang="portugues" ;; fi|suomi) SURFRAW_ixquick_lang="suomi" ;; sv|svenska) SURFRAW_ixquick_lang="svenska" ;; tr|turkce) SURFRAW_ixquick_lang="turkce" ;; cn|zh|jiantizhongwen) SURFRAW_ixquick_lang="jiantizhongwen" ;; ja|jp|nihongo) SURFRAW_ixquick_lang="nihongo" ;; zt|fantizhengwen) SURFRAW_ixquick_lang="fantizhengwen" ;; ko|kr|kp|hangul) SURFRAW_ixquick_lang="hangul" ;; *) SURFRAW_ixquick_lang="english" ;; esac escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${proto}://www.ixquick.com/do/metasearch.pl?cat=${SURFRAW_ixquick_search}&cmd=process_search&language=${SURFRAW_ixquick_lang}&query=${escaped_args}" fi diff --git a/elvi/jamendo b/elvi/jamendo index 69609b6..c0c3296 100755 --- a/elvi/jamendo +++ b/elvi/jamendo @@ -1,68 +1,77 @@ #!/bin/sh # elvis: jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_jamendo_lang "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Jamendo: free music with Creative Commons licenses (www.jamendo.com) Local options: -l= | -lang= Search with this l10n en|english fr|french de|german it|italian pt|portuguese pl|polish ru|russian es|spanish Default: English Environment: SURFRAW_jamendo_lang, SURFRAW_lang EOF w3_global_usage } +mkopts lang= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -l=*|-lang=*) echo en english fr french de german it italian pt portuguese pl polish ru russian es spanish ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -l=*|-lang=*) setopt SURFRAW_jamendo_lang $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments # Use SURFRAW_lang if present if [ -z $SURFRAW_jamendo_lang ]; then SURFRAW_jamendo_lang="en"; fi if test -z "$w3_args"; then w3_browse_url "https://www.jamendo.com/${SURFRAW_jamendo_lang}/search" else case "$SURFRAW_jamendo_lang" in en|english) setopt SURFRAW_jamendo_lang en ;; fr|french) setopt SURFRAW_jamendo_lang fr ;; de|german) setopt SURFRAW_jamendo_lang de ;; it|italian) setopt SURFRAW_jamendo_lang it ;; pt|portuguese) setopt SURFRAW_jamendo_lang br;; pl|polish) setopt SURFRAW_jamendo_lang pl ;; ru|russian) setopt SURFRAW_jamendo_lang ru ;; es|spanish) setopt SURFRAW_jamendo_lang es ;; *) setopt SURFRAW_jamendo_lang en ;; esac escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.jamendo.com/${SURFRAW_jamendo_lang}/search?qs=q=${escaped_args}" fi diff --git a/elvi/javasun b/elvi/javasun index 18abc50..2638443 100755 --- a/elvi/javasun +++ b/elvi/javasun @@ -1,72 +1,83 @@ #!/bin/sh # $Id$ # elvis: javasun -- Search Java API docs (java.sun.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_java_product se def SURFRAW_java_version 6 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search Sun Java API docs (java.sun.com) Local options: -v Java API version (1.2, 1.3, 1.4, 5, 6) -p Java product (se, ee, me) EOF w3_global_usage } +# I'm guessing at the semantics :shrug: +mkopts v= p= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + # Lowercase is easier to type. + -p=*) echo se ee me ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -v*) setopt SURFRAW_java_version $optarg ;; -p*) setopt SURFRAW_java_product $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_java_product" in [sS][eE]) case "$SURFRAW_java_version" in 6) JAVA_SITE="javase/6/docs/api" ;; 5) JAVA_SITE="j2se/1.5.0/docs/api" ;; 1.4) JAVA_SITE="j2se/1.4.2/docs/api" ;; 1.3) JAVA_SITE="j2se/1.3/docs/api" ;; *) echo "Docs for J2SE $SURFRAW_java_version are not available" exit 1 ;; esac ;; [eE][eE]) case "$SURFRAW_java_version" in 6|5) JAVA_SITE="javaee/5/docs/api" ;; 1.4) JAVA_SITE="j2ee/1.4/docs/api" ;; 1.3) JAVA_SITE="j2ee/sdk_1.3/techdocs/api" ;; 1.2) JAVA_SITE="j2ee/sdk_1.2.1/techdocs/api" ;; *) echo "Docs for J2EE $SURFRAW_java_version are not available" esac ;; [mM][eE]) JAVA_SITE="j2me/docs" ;; *) echo "$SURFRAW_java_product is not a valid Java product" exit 1 ;; esac if test -z "$w3_args"; then w3_browse_url "http://download.oracle.com/${JAVA_SITE}" else button=$(w3_url_escape "I'm Feeling Lucky") escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.google.com/search?q=${escaped_args}&sitesearch=download.oracle.com/${JAVA_SITE}&btnI=${button}" fi diff --git a/elvi/lastfm b/elvi/lastfm index 57ff1a0..f091698 100755 --- a/elvi/lastfm +++ b/elvi/lastfm @@ -1,45 +1,46 @@ #!/bin/sh # $Id$ # elvis: lastfm -- Search last.fm . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_lastfm_redirect 1 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search last.fm Local options: -l Show list even if exact match. EOF w3_global_usage } +mkopts l w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -l) setoptyn SURFRAW_lastfm_redirect 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://last.fm/" else escaped_args=$(w3_url_of_arg $w3_args) url="https://last.fm/search?q=${escaped_args}" if ifno SURFRAW_lastfm_redirect then url="${url}&noredirect=1" fi w3_browse_url "${url}" fi diff --git a/elvi/leodict b/elvi/leodict index f66b240..07c9ddd 100755 --- a/elvi/leodict +++ b/elvi/leodict @@ -1,102 +1,115 @@ #!/bin/sh # elvis: leodict -- Search Leo's German <-> English dictionary (dict.leo.org) # $Id$ # surfraw plugin for the biggest English/German dictionary on # the WWW: dict.leo.org [email protected] # options added by Ian Beckwith <[email protected]> . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_leodict_link yes defyn SURFRAW_leodict_head yes defyn SURFRAW_leodict_grid yes def SURFRAW_leodict_to "either" def SURFRAW_leodict_spell "standard" def SURFRAW_leodict_tol "standard" def SURFRAW_leodict_lang "$SURFRAW_lang" } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -link*=*) setopt SURFRAW_leodict_link $optarg ;; -head*=*) setopt SURFRAW_leodict_head $optarg ;; -grid*=*) setopt SURFRAW_leodict_grid $optarg ;; -to=*) setopt SURFRAW_leodict_to $optarg ;; -spell*=*) setopt SURFRAW_leodict_spell $optarg ;; -tol*=*) setopt SURFRAW_leodict_tol $optarg ;; -lang*=*) setopt SURFRAW_leodict_lang $optarg ;; *) return 1 ;; esac return 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Surfraw search the German/English dictionary LEO (dict.leo.org) Local options: -to=de | en | either Language to translate to. Default: $SURFRAW_leodict_to Environment: SURFRAW_leodict_to -lang=en | de Language web page is in. Environment: SURFRAW_leodict_lang, SURFRAW_lang If above variables are not set, defaults to en, unless \$LANG is set and contains "de". -link=on | off Link results. Default: $SURFRAW_leodict_link Environment: SURFRAW_leodict_link -head=on | off Display headlines. Default: $SURFRAW_leodict_head Environment: SURFRAW_leodict_head -grid=on | off Show results in grid. Default: $SURFRAW_leodict_grid Environment: SURFRAW_leodict_grid -spell=off | standard | force Spelling tolerance Default: $SURFRAW_leodict_spell Environment: SURFRAW_leodict_spell -tol=off | standard | high Special characters tolerance Default: $SURFRAW_leodict_tol Environment: SURFRAW_leodict_tol EOF w3_global_usage } +mkopts to= lang= link= head= grid= spell= tol= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -to=*) echo de en either ;; + -lang=*) echo en de ;; + -link=*|-head=*|-grid=*) echo on off ;; + -spell=*) echo off standard force ;; + -tol=*) echo off standard high ;; + *) return 1 ;; + esac +} w3_config w3_parse_args "$@" if test -z "$w3_args"; then w3_browse_url "https://dict.leo.org/" else escaped_args=$(w3_url_of_arg $w3_args) url="https://dict.leo.org/?search=${escaped_args}" case "$SURFRAW_leodict_lang" in en|de) ;; *) SURFRAW_leodict_lang=$(perl -e 'if((exists($ENV{LANG})) && ($ENV{LANG}=~/de/i)) { print "de\n"; } else { print "en\n"; }') ;; esac if yesno SURFRAW_leodict_link ; then url="$url&relink=on" else url="$url&relink=off";fi if yesno SURFRAW_leodict_head ; then url="$url&sectHdr=on" else url="$url&sectHdr=off";fi if yesno SURFRAW_leodict_grid ; then url="$url&tableBorder=1" else url="$url&tableBorder=0";fi if [ "$SURFRAW_leodict_to" = "de" ] ; then url="$url&searchLoc=-1" elif [ "$SURFRAW_leodict_to" = "en" ] ; then url="$url&searchLoc=1" else url="$url&searchLoc=0" ; fi if [ "$SURFRAW_leodict_spell" = "off" ] ; then url="$url&spellToler=off" elif [ "$SURFRAW_leodict_spell" = "force" ] ; then url="$url&spellToler=on" else url="$url&spellToler=standard" ; fi if [ "$SURFRAW_leodict_tol" = "high" ] ; then url="$url&cmpType=fuzzy" elif [ "$SURFRAW_leodict_tol" = "off" ] ; then url="$url&cmpType=exact" else url="$url&cmpType=relaxed" ; fi url="$url&lang=$SURFRAW_leodict_lang" w3_browse_url "$url" fi diff --git a/elvi/lsm b/elvi/lsm index 37360cb..5f4d1a4 100755 --- a/elvi/lsm +++ b/elvi/lsm @@ -1,47 +1,56 @@ #!/bin/sh # $Id$ # elvis: lsm -- Search the Linux Software Map . surfraw || exit 1 w3_config_hook () { def SURFRAW_lsm_search title } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Linux Software Map (www.boutell.com/lsm/) Local options: -search= Specialized search on topic title | Title search (default) keyword Keyword search Environment: SURFRAW_lsm_search EOF w3_global_usage } +mkopts search= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -search=*) echo title keyword ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s*=*) setopt SURFRAW_lsm_search $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.boutell.com/lsm/" else escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_lsm_search" = "keyword" ]; then url="https://www.boutell.com/lsm/lsmbykey.cgi/submit?keyword=${escaped_args}" else url="https://www.boutell.com/lsm/lsmbytitle.cgi/submit?title=${escaped_args}" fi w3_browse_url "${url}" fi diff --git a/elvi/macports b/elvi/macports index 42ca42b..ee14cef 100755 --- a/elvi/macports +++ b/elvi/macports @@ -1,50 +1,59 @@ #!/bin/sh # elvis: macports -- Search macports packages (macports.org) # [email protected] 20091112 . surfraw || exit 1 w3_config_hook () { def SURFRAW_macports_by name } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search macports packages (macports.org) Local options: -by=TYPE Search by TYPE name | Software Title (default) category | Category maintainer | Maintainer variant | Variant platform | Platform Default: $SURFRAW_macports_by Environment: SURFRAW_macports_by EOF w3_global_usage } +mkopts by= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -by=*) echo name category maintainer variant platform ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -by*=*) setopt SURFRAW_macports_by $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) url="https://www.macports.org/ports.php" if [ -n "$escaped_args" ] then url="${url}?by=${SURFRAW_macports_by}&substr=${escaped_args}" fi w3_browse_url "$url" diff --git a/elvi/mininova b/elvi/mininova index 6899acd..67667ff 100755 --- a/elvi/mininova +++ b/elvi/mininova @@ -1,98 +1,106 @@ #!/bin/sh # # AUTHOR: S.S.R. Oemrawsingh # # DATE: Mon Oct 26 2009 # # DESC: Elvi to search the mininova bittorrent source. # elvis: mininova -- Search the mininova bittorent source. . surfraw || exit 1 w3_config_hook () { def SURFRAW_mininova_category all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search terms] Description: Surfraw the mininova bittorrent source. Local options: -category= Search for torrent in the given category all | Search all categories anime | Search anime torrents books | Search book torrents featured | Search featured torrents games | Search game torrents movies | Search movie torrents music | Search music torrents pictures | Search picture torrents software | Search software torrents tv-shows | Search tv show torrents other Search other torrents Default: $SURFRAW_mininova_category Environment: SURFRAW_mininova_category EOF w3_global_usage } - +mkopts category= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -category=*) echo all anime books featured games movies music pictures software tv-shows other ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -category=*) setopt SURFRAW_mininova_category $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if [ -z "$w3_args" ]; then url="http://www.mininova.org/" else escaped_args=$(w3_url_of_arg $w3_args) case $SURFRAW_mininova_category in all) url="http://www.mininova.org/search/?search="$escaped_args"&cat=0" ;; anime) url="http://www.mininova.org/search/?search="$escaped_args"&cat=1" ;; books) url="http://www.mininova.org/search/?search="$escaped_args"&cat=2" ;; featured) url="http://www.mininova.org/search/?search="$escaped_args"&cat=10" ;; games) url="http://www.mininova.org/search/?search="$escaped_args"&cat=3" ;; movies) url="http://www.mininova.org/search/?search="$escaped_args"&cat=4" ;; music) url="http://www.mininova.org/search/?search="$escaped_args"&cat=5" ;; pictures) url="http://www.mininova.org/search/?search="$escaped_args"&cat=6" ;; software) url="http://www.mininova.org/search/?search="$escaped_args"&cat=6" ;; tv-shows) url="http://www.mininova.org/search/?search="$escaped_args"&cat=8" ;; other) url="http://www.mininova.org/search/?search="$escaped_args"&cat=9" ;; *) return 1 ;; esac fi w3_browse_url $url diff --git a/elvi/musicbrainz b/elvi/musicbrainz index 10da0a5..2336ce6 100755 --- a/elvi/musicbrainz +++ b/elvi/musicbrainz @@ -1,165 +1,176 @@ #!/bin/sh # $Id$ # elvis: musicbrainz -- Search MusicBrainz (musicbrainz.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_musicbrainz_limit $SURFRAW_results def SURFRAW_musicbrainz_search artist def SURFRAW_musicbrainz_tagrelease "" def SURFRAW_musicbrainz_tagtrack "" def SURFRAW_musicbrainz_tagnum "" def SURFRAW_musicbrainz_taglen "" def SURFRAW_musicbrainz_tagpuid "" def SURFRAW_musicbrainz_tagfile "" defyn SURFRAW_musicbrainz_advanced 0 defyn SURFRAW_musicbrainz_direct 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search MusicBrainz (musicbrainz.org) Local options: -d Direct (old) search. -a Enable advanced query syntax. See: https://musicbrainz.org/popup/TextSearchSyntax -results=NUM Number of search results returned Default: $SURFRAW_musicbrainz_results Environment: SURFRAW_musicbrainz_results 0 means all results. -search= Search type: artist | Artist [default] <*> release | Release (album) <*> release_group | Release Group label | Label <*> annotation | Annotation barcode | Barcode catno | Catalog number cdstub | CD Stub discid | Disc ID editor | Editor freedb | FreeDB freedb | FreeDB ID isrc | ISRC iswc | ISWC mbid | MBID puid | PUID recording | Recording trmid | TRM ID work | Work tag Tag Search With Tag Search, [search words] are treated as artist name, use -tag* below to specify other fields. <*> = supported by direct search (-d) Environment: SURFRAW_musicbrainz_search -tagrelease=ALBUM Album/Release tag search (implies -search=tag) -tagnum=TRACKNUM Track number tag search (implies -search=tag) -tagtrack=SONG Track tag search (implies -search=tag) -taglen=DURATION Track length tag search (implies -search=tag) -tagfile=FILENAME Filename tag search (implies -search=tag) -tagpuid=FILENAME PUID tag search (implies -search=tag) EOF w3_global_usage } +mkopts d a results= search= +mkopts tagrelease= tagnum= tagtrack= taglen= tagfile= tagpuid= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + # "freedb" duplicated in help. Error? + -search=*) echo artist release release_group label annotation barcode catno cdstub discid editor freedb isrc iswc mbid puid recording trmid work tag ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_musicbrainz_results $optarg ;; -tagrel*=*) setopt SURFRAW_musicbrainz_tagrelease $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagnu*=*) setopt SURFRAW_musicbrainz_tagnum $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagtra*=*) setopt SURFRAW_musicbrainz_tagtrack $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagle*=*) setopt SURFRAW_musicbrainz_taglen $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagp*=*) setopt SURFRAW_musicbrainz_tagpuid $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagf*=*) setopt SURFRAW_musicbrainz_tagfile $optarg setopt SURFRAW_musicbrainz_search tag ;; -a) setoptyn SURFRAW_musicbrainz_advanced 1 ;; -d) setoptyn SURFRAW_musicbrainz_direct 1 ;; -search=*) searchtype="$optarg" case "$searchtype" in ar*) setopt SURFRAW_musicbrainz_search artist ;; release_*) setopt SURFRAW_musicbrainz_search release_group ;; release|rel|al*) setopt SURFRAW_musicbrainz_search release ;; an*) setopt SURFRAW_musicbrainz_search annotation ;; ba*) setopt SURFRAW_musicbrainz_search barcode ;; ca*) setopt SURFRAW_musicbrainz_search catno ;; cd*) setopt SURFRAW_musicbrainz_search cdstub ;; d*) setopt SURFRAW_musicbrainz_search discid ;; e*) setopt SURFRAW_musicbrainz_search editor ;; freedb|fr) setopt SURFRAW_musicbrainz_search freedb ;; freedbid) setopt SURFRAW_musicbrainz_search freedbid ;; isr*) setopt SURFRAW_musicbrainz_search isrc ;; isw*) setopt SURFRAW_musicbrainz_search iswc ;; l*) setopt SURFRAW_musicbrainz_search label ;; m*) setopt SURFRAW_musicbrainz_search mbid ;; p*) setopt SURFRAW_musicbrainz_search puid ;; rec*) setopt SURFRAW_musicbrainz_search recording ;; tr*) setopt SURFRAW_musicbrainz_search trmid ;; w*) setopt SURFRAW_musicbrainz_search work ;; ta*) setopt SURFRAW_musicbrainz_search tag ;; *) err "Search type not known" esac ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args" && test -z "$SURFRAW_musicbrainz_tagrelease" && test -z "$SURFRAW_musicbrainz_tagnum" && test -z "$SURFRAW_musicbrainz_tagtrack" && test -z "$SURFRAW_musicbrainz_taglen" && test -z "$SURFRAW_musicbrainz_tagpuid" && test -z "$SURFRAW_musicbrainz_tagfile" then w3_browse_url "https://musicbrainz.org/search.html" else escaped_args=$(w3_url_of_arg $w3_args) url="https://musicbrainz.org" if ifyes SURFRAW_musicbrainz_direct then case "$SURFRAW_musicbrainz_search" in artist|release|label) url="${url}/search/oldsearch.html?query=${escaped_args}&type=${SURFRAW_musicbrainz_search}&limit=${SURFAW_musicbrainz_results}&handlearguments=1" ;; *) err "Search type $SURFRAW_musicbrainz_search not supported by Direct Search (-d)" ;; esac else case "$SURFRAW_musicbrainz_search" in artist|release_group|release|recording|work| \ label|annotation|cdstub|editor| \ freedb) url="${url}/search?query=${escaped_args}&type=${SURFRAW_musicbrainz_search}&limit=${SURFRAW_musicbrainz_limit}" if ifyes SURFRAW_musicbrainz_advanced then url="${url}&adv=on" fi ;; catno|barcode|discid|freedbid|freedb| \ puid|trmid|isrc|iswc| \ discid) url="${url}/otherlookup?${SURFRAW_musicbrainz_search}=${escaped_args}" ;; mbid) url="${url}/release/${escaped_args}" ;; tag) url="${url}/taglookup?artist=${escaped_args}&release=${SURFRAW_musicbrainz_tagrelease}&track=${SURFRAW_musicbrainz_tagtrack}&tracknum=${SURFRAW_musicbrainz_tagnum}&duration=${SURFRAW_musicbrainz_taglen}&filename=${SURFRAW_musicbrainz_tagfile}&puid=${SURFRAW_musicbrainz_puid}" ;; *) err Unknown search type "${SURFRAW_musicbrainz_search}" ;; esac fi w3_browse_url "$url" fi diff --git a/elvi/mysqldoc b/elvi/mysqldoc index efcd6d0..1af8364 100755 --- a/elvi/mysqldoc +++ b/elvi/mysqldoc @@ -1,63 +1,64 @@ #!/bin/sh # [email protected] 20130923 # elvis: mysqldoc -- Search mysql documentation (dev.mysql.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_mysqldoc_version all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search mysql documentation (dev.mysql.com) Local options: -a Search all versions/docs -v=VERSION Search docs for mysql version VERSION Default: $SURFRAW_mysqldoc_version Environment: SURFRAW_mysqldoc_version EOF w3_custom_search_usage w3_global_usage } +mkopts a v= w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -a) setopt SURFRAW_mysqldoc_version "all" ;; -v*=*) setopt SURFRAW_mysqldoc_version "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if test -z "$w3_args" then case "$SURFRAW_mysqldoc_version" in all) inurl="/doc/" ;; *5.7*) inurl="/doc/refman/5.7/en/" ;; *5.6*) inurl="/doc/refman/5.6/en/" ;; *5.5*) inurl="/doc/refman/5.5/en/" ;; *5.0*) inurl="/doc/refman/5.0/en/" ;; *[34]*) inurl="/doc/refman/4.1/en/" ;; *) inurl="/doc/" esac w3_browse_url "https://dev.mysql.com${inurl}" else case "$SURFRAW_mysqldoc_version" in all) inurl="-u=doc" ;; *5.7*) inurl="-u=doc -u=refman -u=5.7" ;; *5.6*) inurl="-u=doc -u=refman -u=5.6" ;; *5.5*) inurl="-u=doc -u=refman -u=5.5" ;; *5.0*) inurl="-u=doc -u=refman -u=5.0" ;; *[34]*) inurl="-u=doc -u=refman -u=4.1" ;; *) inurl="-u=doc" ;; esac w3_custom_search -s=dev.mysql.com $inurl "$w3_shquoted_args" fi diff --git a/elvi/netbsd b/elvi/netbsd index e904c66..339f021 100755 --- a/elvi/netbsd +++ b/elvi/netbsd @@ -1,73 +1,82 @@ #!/bin/sh # $Id$ # elvis: netbsd -- Search NetBSD related information (www.netbsd.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_netbsd_mail no defyn SURFRAW_netbsd_pr no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search NetBSD related information Local options: -mail[=(yes|no)] Search netbsd mailinglists Default: $SURFRAW_netbsd_mail Environment: SURFRAW_netbsd_mail -pr[=(yes|no)] Query Problem Reports Default: $SURFRAW_netbsd_pr Environment: SURFRAW_netbsd_pr Examples: $w3_argv0 Teleport to the NetBSD website $w3_argv0 mycroft Search NetBSD website for odeur de mycroft $w3_argv0 -mail Teleport to the mail-index Query form $w3_argv0 -mail proff Search mailing-list archives for odeur de proff $w3_argv0 -pr Query Problem Report form $w3_argv0 -ps surfraw Search Ports for surfraw EOF w3_global_usage } +mkopts mail mail= pr pr= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -mail=*|-pr=*) echo yes no ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -mail) setoptyn SURFRAW_netbsd_mail yes ;; -mail=*) setoptyn SURFRAW_netbsd_mail $optarg ;; -pr) setoptyn SURFRAW_netbsd_pr yes ;; -pr=*) setoptyn SURFRAW_netbsd_pr $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments test -z "$w3_args" || escaped_args=$(w3_url_of_arg $w3_args) if ok SURFRAW_netbsd_pr; then if test -z "$escaped_args"; then w3_browse_url "https://www.netbsd.org/Misc/query-pr.html" else w3_browse_url "https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=${escaped_args}" fi exit $? fi if ok SURFRAW_netbsd_mail; then if test -z "$escaped_args"; then w3_browse_url "https://mail-index.netbsd.org/" else w3_custom_search -s=mail-index.netbsd.org "$w3_shquoted_args" fi exit $? fi if test -z "$escaped_args"; then w3_browse_url "https://www.netbsd.org/" else w3_custom_search -s=netbsd.org "$w3_shquoted_args" fi exit $? diff --git a/elvi/ntrs b/elvi/ntrs index 0236168..cb30376 100755 --- a/elvi/ntrs +++ b/elvi/ntrs @@ -1,86 +1,96 @@ #!/bin/sh # # author: Wim Van Hoydonck # # elvis: ntrs -- Search the NASA Technical Report Server . surfraw || exit 1 w3_config_hook () { def SURFRAW_ntrs_fields Abstract def SURFRAW_ntrs_results matchall } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search ntrs Local options: -fields=FIELD Subject field to search all | Seach all fields abstract | Words in abstract (default) accession | Accession number center | NASA Center author | Author name docID | Document ID keywords | Keywords date | Publication date title | Title -results=RESULT Find Results with all | All of the words any | At least one of the words Examples: $w3_argv0 -fields=abstract -results=all free wake EOF w3_global_usage } +mkopts fields= results= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -fields=*) echo all abstract accession center author docID keyword date title ;; + -results=*) echo all any ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -fields=*) setopt SURFRAW_ntrs_fields $optarg ;; -results=*) setopt SURFRAW_ntrs_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_ntrs_fields" in all) field=All ;; abstract) field=Abstract ;; accession) field=AccessionNum ;; center) field=ArchiveName ;; author) field=AuthorList ;; docID) field=DocumentID ;; keyword) field=Keywords ;; date) field=PublicationDate ;; title) field=Title ;; *) field=Abstract ;; esac case "$SURFRAW_ntrs_results" in all) result=matchall ;; any) result=matchany ;; *) result=matchall ;; esac if null "$w3_args"; then w3_browse_url "https://ntrs.nasa.gov/search.jsp" else # TODO: combine multiple searches, e.g. # first search the abstract for certain keywords, # then search the authors of those results # this gives urls that look like this: #https://ntrs.nasa.gov/search.jsp?N=0&Ntk=Abstract|AuthorList&Ntx=mode%20matchall|mode%20matchall&Ntt=free%20wake|wachspress escaped_args=$(w3_url_of_arg $w3_args) url="https://ntrs.nasa.gov/search.jsp?N=0&Ntk=${field}&Ntx=mode%20${result}&Ntt=${escaped_args}" w3_browse_url "${url}" fi diff --git a/elvi/pgdoc b/elvi/pgdoc index c46d633..05903ae 100755 --- a/elvi/pgdoc +++ b/elvi/pgdoc @@ -1,85 +1,86 @@ #!/bin/sh # [email protected] 20130923 # elvis: pgdoc -- Search postgres documentation (www.pgdoc.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_pgdoc_version 9.1 defyn SURFRAW_pgdoc_comments no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Postgresql documentation (www.postgresql.org) Local options: -c Search in comments too -v=VERSION Search in version VERSION Default: $SURFRAW_pgdoc_version Environment: SURFRAW_pgdoc_version EOF w3_custom_search_usage w3_global_usage } +mkopts c v= w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -c*) setoptyn SURFRAW_pgdoc_comments 1 ;; -v*=*) setopt SURFRAW_pgdoc_version "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if test -z "$w3_args" then case "$SURFRAW_pgdoc_version" in all) inurl="/docs/" ;; *9.3*) inurl="/docs/9.3/" ;; *9.2*) inurl="/docs/9.2/" ;; *9.1*) inurl="/docs/9.1/" ;; *9.0*) inurl="/docs/9.0/" ;; *8.4*) inurl="/docs/8.4/" ;; *) inurl="/docs/" ;; esac if [ "$SURFRAW_pgdoc_version" != all ] then if ifyes SURFRAW_pgdoc_comments then inurl="${inurl}interactive/" else inurl="${inurl}static/" fi fi w3_browse_url "https://www.postgresql.org${inurl}" else case "$SURFRAW_pgdoc_version" in all) inurl="-u=docs" ;; *9.3*) inurl="-u=docs -u=9.3" ;; *9.2*) inurl="-u=docs -u=9.2" ;; *9.1*) inurl="-u=docs -u=9.1" ;; *9.0*) inurl="-u=docs -u=9.0" ;; *8.4*) inurl="-u=docs -u=8.4" ;; *) inurl="-u=docs" ;; esac if [ "$SURFRAW_pgdoc_version" != all ] then if ifyes SURFRAW_pgdoc_comments then inurl="${inurl} -u=interactive" else inurl="${inurl} -u=static" fi fi w3_custom_search -s=www.postgresql.org $inurl "$w3_shquoted_args" fi diff --git a/elvi/pgpkeys b/elvi/pgpkeys index 9ee5b44..c4c5365 100755 --- a/elvi/pgpkeys +++ b/elvi/pgpkeys @@ -1,91 +1,100 @@ #!/bin/sh # elvis: pgpkeys -- Search the PGP key database # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_config_hook () { def SURFRAW_pgpkeys_sigs off defyn SURFRAW_pgpkeys_fingerprints off defyn SURFRAW_pgpkeys_exact off def SURFRAW_pgpkeys_server sks } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the PGP key database Local options: -s Displays signatures of the keys Default: $SURFRAW_pgpkeys_sigs Environment: SURFRAW_pgpkeys_sigs -f Displays fingerprints of the keys Default: $SURFRAW_pgpkeys_fingerprints Environment: SURFRAW_pgpkeys_fingerprints -e Exact matches only Default: $SURFRAW_pgpkeys_exact Environment: SURFRAW_pgpkeys_exact -k= Keyserver to query. Supported: sks | www.sks-keyservers.net (default) gnupg | www-keys.gnupg.net pgp | www.uk.pgp.net mit | pgp.mit.edu Default: $SURFRAW_pgpkeys_server Environment: SURFRAW_pgpkeys_server Examples: $w3_argv0 -s [email protected] EOF w3_global_usage } +mkopts s f e k= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -k=*) echo sks gnupg pgp mit ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s*) setopt SURFRAW_pgpkeys_sigs on ;; -f*) setoptyn SURFRAW_pgpkeys_fingerprints on ;; -e*) setoptyn SURFRAW_pgpkeys_exact on ;; -k*=*) setopt SURFRAW_pgpkeys_server "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_pgpkeys_server" in mit) base="http://pgp.mit.edu" prefix="http://pgp.mit.edu:11371/pks/lookup?search=" ;; sks) base="http://www.sks-keyservers.net/i/" prefix="http://pool.sks-keyservers.net:11371/pks/lookup?search=" ;; gnupg) base="http://http-keys.gnupg.net" prefix="http://http-keys.gnupg.net/pks/lookup?search=" ;; pgp) base="http://www.uk.pgp.net/pgpnet/wwwkeys.html" prefix="http://wwwkeys.uk.pgp.net:11371/pks/lookup?search=" ;; *) err "Server \"$SURFRAW_pgpkeys_server\" not supported" ;; esac suffix="&op=index" if [ $SURFRAW_pgpkeys_sigs = on ]; then suffix="&op=vindex" fi if ifyes SURFRAW_pgpkeys_fingerprints ;then suffix="$suffix&fingerprint=on" fi if ifyes SURFRAW_pgpkeys_exact ;then suffix="$suffix&exact=on" fi if null "$w3_args"; then w3_browse_url "$base" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${prefix}${escaped_args}${suffix}" fi diff --git a/elvi/phpdoc b/elvi/phpdoc index 5db3cd4..d14916e 100644 --- a/elvi/phpdoc +++ b/elvi/phpdoc @@ -1,129 +1,140 @@ #!/bin/sh # elvis: phpdoc -- Search PHP documentation (php.net) # Author: http://jonyamo.net . surfraw || exit 1 w3_config_hook () { def SURFRAW_php_language "$SURFRAW_lang" def SURFRAW_php_search "functions" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Surfraw search PHP documentation (php.net) Local options: -l, -language= Two letter language code (resembles ISO country codes) en | English (default) pt | Brazilian Portuguese zh | Chinese (Simplified) fr | French de | German ja | Japanese pl | Polish ro | Romanian fa | Persian es | Spanish tr | Turkish Environment: SURFRAW_php_language, SURFRAW_lang Default: en -s, -search= Specialized search on topic all | All php.net sites functions | Function search manual | Online documentation bugs | Bug database news | News archive changelogs | Changelogs pear | Just pear.php.net pecl | Just pecl.php.net talks | Just talks.php.net maillist | General mailing list devlist | Developer mailing list phpdoc | Documentation mailing list Environment: SURFRAW_php_search Default: functions -a, -all alias of -search=all -f, -functions alias of -search=functions -m, -manual alias of -search=manual -b, -bugs alias of -search=bugs -n, -news alias of -search=news -c, -changelogs alias of -search=changelogs -t, -talks alias of -search=talks -maillist alias of -search=maillist -devlist alias of -search=devlist -phpdoc alias of -search=phpdoc EOF w3_global_usage } +mkopts language= search= +mkopts all functions manual bugs news changelogs talks maillist devlist phpdoc +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -l=*|-language=*) echo en pt zh fr de ja pl ro fa es tr ;; + -s=*|-search=*) echo all functions manual bugs news changelogs pear pecl talks maillist devlist phpdoc ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_php_language "$optarg" ;; -l=*) setopt SURFRAW_php_language "$optarg" ;; -search=*) setopt SURFRAW_php_search "$optarg" ;; -s=*) setopt SURFRAW_php_search "$optarg" ;; -a|-all) setopt SURFRAW_php_search "all" ;; -f|-functions) setopt SURFRAW_php_search "functions" ;; -m|-manual) setopt SURFRAW_php_search "manual" ;; -b|-bugs) setopt SURFRAW_php_search "bugs" ;; -n|-news) setopt SURFRAW_php_search "news" ;; -c|-changelogs) setopt SURFRAW_php_search "changelogs" ;; -t|-talks) setopt SURFRAW_php_search "talks" ;; -maillist) setopt SURFRAW_php_search "maillist" ;; -devlist) setopt SURFRAW_php_search "devlist" ;; -phpdoc) setopt SURFRAW_php_search "phpdoc" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments url="https://php.net/" case "$SURFRAW_php_language" in en) lang="en" ;; pt) lang="pt_BR" ;; zh) lang="zh" ;; fr) lang="fr" ;; de) lang="de" ;; ja) lang="ja" ;; pl) lang="pl" ;; ro) lang="ro" ;; fa) lang="fa" ;; es) lang="es" ;; tr) lang="tr" ;; *) lang="en" ;; esac case "$SURFRAW_php_search" in all) search="all" ;; functions) search="quickref" ;; manual) search="manual" ;; bugs) search="bugdb" ;; news) search="news_archive" ;; changelogs) search="changelogs" ;; pear) search="pear" ;; pecl) search="pecl" ;; talks) search="talks" ;; maillist) search="maillist" ;; devlist) search="devlist" ;; phpdoc) search="phpdoc" ;; *) search="functions" ;; esac if [ -n "$w3_args" ]; then escaped_args=$(w3_url_of_arg $w3_args) url="${url}search.php?lang=${lang}&show=${search}&pattern=${escaped_args}" fi w3_browse_url "$url" diff --git a/elvi/pin b/elvi/pin index 8978180..7f18f40 100755 --- a/elvi/pin +++ b/elvi/pin @@ -1,93 +1,94 @@ #!/bin/sh # elvis: pin -- Search Pinboard bookmarks (https://pinboard.in) # author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_pinboard_tags "$SURFRAW_tags" def SURFRAW_pinboard_user "$SURFRAW_user" def SURFRAW_pinboard_new 0 def SURFRAW_pinboard_popular 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Pinboard bookmarks (http://pinboard.in) Local options: Default search (without any options) includes tags, titles and descriptions and is not limited to a specific number of search terms. -popular | -p Search popular tags -recent | -r Search recent tags -tags=TAGS | -t=TAGS Only search tags (separate a maximum of 3 TAGS with a "+" eg., unix+linux) -user=NAME | -u=NAME Search a user's bookmarks EOF w3_global_usage } +mkopts popular recent tags= user= w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -p* ) setoptyn SURFRAW_pinboard_popular 1 ;; -r* ) setoptyn SURFRAW_pinboard_new 1 ;; -t=*) setopt SURFRAW_pinboard_tags $optarg ;; -u=*) setopt SURFRAW_pinboard_user $optarg ;; *) return 1 ;; esac return 0 } # create tag string tags () { local IFS=+ for tag in $SURFRAW_pinboard_tags; do printf "%s" "t:$tag/" done } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) base_url="https://pinboard.in/" # check for recent & popular if [ "$SURFRAW_pinboard_new" = 1 ]; then suffix="recent/" elif [ "$SURFRAW_pinboard_popular" = 1 ]; then suffix="popular" fi # Run through the other possibilities... if [ -z "$w3_args" ]; then if [ -n "$SURFRAW_pinboard_user" ] && [ -n "$SURFRAW_pinboard_tags" ]; then w3_browse_url "${base_url}u:$SURFRAW_pinboard_user/$(tags)" elif [ -n "$SURFRAW_pinboard_tags" ]; then w3_browse_url "${base_url}$(tags)" elif [ -n "$SURFRAW_pinboard_user" ]; then w3_browse_url "${base_url}u:$SURFRAW_pinboard_user" else w3_browse_url "$base_url${suffix}" fi elif [ -n "$w3_args" ]; then w3_browse_url "${base_url}search/?query=${escaped_args}&all=Search+All" else w3_browse_url "${base_url}" fi diff --git a/elvi/piratebay b/elvi/piratebay index 0777cbe..118483c 100755 --- a/elvi/piratebay +++ b/elvi/piratebay @@ -1,88 +1,97 @@ #!/bin/sh # elvis: piratebay -- Search The Pirate Bay (https://thepiratebay.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_bay_categories "$SURFRAW_categories" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search thepiratebay.org for torrents -sort=CATEGORIES | -s=CATEGORIES Local options: all | search all categories (default) apps | search applications games | search games music | search music tv | search TV shows movies | search movies Default: All Subcategories: flac | flac audio files books | audio books dvd | DVD rips hrm | High-res movies hrt | High-res TV EOF w3_global_usage } +mkopts sort= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -sort=*) echo all apps games music tv movies flac books dvd hrm hrt ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s*=*) setopt SURFRAW_bay_categories $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_bay_categories" in al*) category="0" ;; ap*) category="300" ;; ga*) category="400" ;; mu*) category="100" ;; tv*) category="205" ;; mo*) category="201" ;; fl*) category="104" ;; bo*) category="102" ;; dv*) category="202" ;; hrm) category="207" ;; hrt) category="208" ;; *) category="0" ;; esac # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) # just browsing category if [ -n "$SURFRAW_bay_categories" ] && [ -z "$w3_args" ]; then w3_browse_url "https://thepiratebay.org/browse/${category}" # searching category for string elif [ -n "$SURFRAW_bay_categories" ] && [ -n "$w3_args" ]; then w3_browse_url "https://thepiratebay.org/search/${escaped_args}/0/99/${category}" # no arguments passed elif [ -z "$w3_args" ]; then w3_browse_url "https://thepiratebay.org/" # no category specified else w3_browse_url "https://thepiratebay.org/search/${escaped_args}" fi diff --git a/elvi/pubmed b/elvi/pubmed index 445ec85..6614a3f 100755 --- a/elvi/pubmed +++ b/elvi/pubmed @@ -1,48 +1,57 @@ #!/bin/sh # $Id$ # elvis: pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) . surfraw || exit 1 w3_config_hook () { def SURFRAW_pubmed_database PubMed } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search PubMed medical/molbio databases (www.ncbi.nlm.nih.gov) Local options: -db= Database to search PubMed | Nucleotide | Protein | Genome | Structure | Popset Default: $SURFRAW_pubmed_database Environment: SURFRAW_pubmed_database EOF w3_global_usage } +mkopts db= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -db=*) echo PubMed Nucleotide Protein Genome Structure Popset ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -db=PubMed | -db=Nucleotide | -db=Protein | -db=Genome | -db=Structure | -db=Popset) setopt SURFRAW_pubmed_database $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.ncbi.nlm.nih.gov/entrez/query.fcgi" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?SUBMIT=y&term=${escaped_args}&db=${SURFRAW_pubmed_database}&orig_db=PubMed&cmd=" fi diff --git a/elvi/rfc b/elvi/rfc index 6a5ecf3..6a0d1fc 100755 --- a/elvi/rfc +++ b/elvi/rfc @@ -1,194 +1,204 @@ #!/bin/sh # $Id$ # elvis: rfc -- Search RFCs (internet standards documents) # [email protected] 20031220 . surfraw || exit 1 w3_config_hook () { def SURFRAW_rfc_search all def SURFRAW_rfc_field all def SURFRAW_rfc_results $SURFRAW_results def SURFRAW_rfc_output txt defyn SURFRAW_rfc_matchexact no defyn SURFRAW_rfc_showabs no defyn SURFRAW_rfc_showkw no defyn SURFRAW_rfc_reverse no defyn SURFRAW_rfc_ftp no defyn SURFRAW_rfc_nodirect no searchset=0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the RFC (Request For Comments) internet standards. Local options: -results=NUM Number of search results returned Default: $SURFRAW_rfc_results Environment: SURFRAW_rfc_results -pdf Return files as PDF (Default: text) -rev Reverse order of results -exact Match exact words (instead of prefixes) -abs Show abstracts -keywords Show keywords -nodirect Don't try and go direct to RFC (Tries when arg is numeric and -search/-field not used) -ftp Retrieve RFCs via FTP instead of HTTP -field= Which field to search all | All fields number | title | author | keyword Default: if args are numeric, "number", else "all" Environment: SURFRAW_rfc_field -search= Collection to search all | All rfc | Requests For Comments std | Standards bcp | Best Current Practices fyi Informational (For Your Information) Default: $SURFRAW_rfc_search Environment: SURFRAW_rfc_search EOF w3_global_usage } +mkopts results= pdf rev exact abs keyword nodirect ftp field= search= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -field=*) echo all number title author keyword ;; + -search=*) echo all rfc std bcp fyi ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -res*=*) setopt SURFRAW_rfc_results $optarg ;; -pdf*) setopt SURFRAW_rfc_output pdf ;; -rev*) setoptyn SURFRAW_rfc_reverse yes ;; -ex*) setoptyn SURFRAW_rfc_matchexact yes ;; -abs*) setoptyn SURFRAW_rfc_showabs yes ;; -k*) setoptyn SURFRAW_rfc_showkw yes ;; -ftp*) setoptyn SURFRAW_rfc_ftp yes ;; -no*) setoptyn SURFRAW_rfc_nodirect yes ;; -se*=*) setopt SURFRAW_rfc_search $optarg ;; -fi*=*) setopt SURFRAW_rfc_field $optarg ; searchset=1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.rfc-editor.org/rfcsearch.html" else escaped_args=$(w3_url_of_arg $w3_args) # Is cmdline numeric? nodirect=0 if echo "$escaped_args" |grep '^[0-9]*$' >/dev/null 2>&1 then isnum=1 if ifyes SURFRAW_rfc_nodirect then nodirect=1 fi else isnum=0 fi # Do we want to go direct to rfc? if [ $isnum -eq 1 -a $searchset -eq 0 -a $nodirect -eq 0 ] then # do we want txt if [ "$SURFRAW_rfc_output" = "txt" ] then subdir="" case "$SURFRAW_rfc_search" in all) fileprefix="rfc";; rfc) fileprefix="rfc";; std) fileprefix="std"; subdir="/std";; bcp) fileprefix="bcp"; subdir="/bcp";; fyi) fileprefix="fyi"; subdir="/fyi";; *) echo "Unknown search: $SURFRAW_rfc_search"; exit;; esac if ifyes SURFRAW_rfc_ftp then url="ftp://ftp.rfc-editor.org/in-notes${subdir}/${fileprefix}${escaped_args}.txt" elif [ $fileprefix = rfc ] || [ $fileprefix = bcp ]; then url="https://tools.ietf.org/html/${fileprefix}${escaped_args}" else url="https://www.rfc-editor.org/rfc${subdir}/${fileprefix}${escaped_args}.txt" fi else # godless PDFs case "$SURFRAW_rfc_search" in all) ;; rfc) ;; *) echo "Only RFCs available as PDF files, not STDs, BCPs or FYIs. Try without -pdf"; exit 1;; esac # pdfs only available through ftp url="ftp://ftp.rfc-editor.org/in-notes/pdfrfc/rfc${escaped_args}.txt.pdf" fi else # not direct to rfc, construct url from options url="https://www.rfc-editor.org/cgi-bin/rfcsearch.pl?searchwords=${escaped_args}" if [ $isnum -eq 1 -a $searchset -eq 0 ] then url="$url&opt=Number" else case "$SURFRAW_rfc_field" in all*) url="$url&opt=All+Fields";; num*) url="$url&opt=Number";; tit*) url="$url&opt=Title";; auth*) url="$url&opt=Author";; key*) url="$url&opt=Keywords";; kw*) url="$url&opt=Keywords";; *) url="$url&opt=All+Fields";; esac fi url="$url&num=$SURFRAW_rfc_results" url="$url&filefmt=$SURFRAW_rfc_output" url="$url&search_doc=search_$SURFRAW_rfc_search" if ifyes SURFRAW_rfc_matchexact then url="$url&match_method=entire" else url="$url&match_method=prefix" fi if ifyes SURFRAW_rfc_showabs then url="$url&abstract=abson" else url="$url&abstract=absoff" fi if ifyes SURFRAW_rfc_showkw then url="$url&keywords=keyon" else url="$url&keywords=keyoff" fi if ifyes SURFRAW_rfc_reverse then url="$url&sort_method=older" else url="$url&sort_method=newer" fi if ifyes SURFRAW_rfc_ftp then url="$url&format=ftp" else url="$url&format=http" fi fi w3_browse_url "$url" fi diff --git a/elvi/scpan b/elvi/scpan index fef967d..a88da22 100755 --- a/elvi/scpan +++ b/elvi/scpan @@ -1,52 +1,61 @@ #!/bin/sh # $Id$ # elvis: scpan -- Search the Comprehensive Perl Archive Network (metacpan.org) # [email protected] 20030918 . surfraw || exit 1 w3_config_hook () { def SURFRAW_scpan_search "$SURFRAW_scpan_opts" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Comprehensive Perl Archive Network (metacpan.org) Local options: -search= Search Type module | Modules dist | Distributions author | Authors Default: All EOF w3_global_usage } +mkopts search= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -search=*) echo module dist author all ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -search=*) setopt SURFRAW_scpan_search $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_scpan_search" in module) searchopts="modules::" ;; dist) searchopts="dist::" ;; author) searchopts="author::" ;; all|*) searchopts="" ;; esac if test -z "$w3_args"; then w3_browse_url "https://metacpan.org/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://metacpan.org/search?q=${searchopts}${escaped_args}" fi diff --git a/elvi/searx b/elvi/searx index 01b535f..5bb4937 100755 --- a/elvi/searx +++ b/elvi/searx @@ -1,87 +1,97 @@ #!/bin/sh # elvis: searx -- Search using searx metasearch engine instances (https://searx.me and others) # author: ng0 -- contact: [email protected] # 2016-08-14 . surfraw || exit 1 w3_config_hook () { def SURFRAW_searx_categories "$SURFRAW_categories" def SURFRAW_searx_base_url "$SURFRAW_url" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Use the searx metasearch engine -category,c=CATEGORIES Local options: default | search category "general" (default) vid | search category "videos" socialm | search category "social+media" news | search category "news" music | search category "music" map | search category "map" it | search category "it" img | search category "images" files | search category "files" Default: general -url,u=URL Local options: 1 | https://searx.me 2 | https://searx.laquadrature.net 3 | https://www.privatesearch.io o1 | http://searchb5a7tmimez.onion (laquadrature) o2 | http://ulrn6sryqaifefld.onion (searx.me) cjdns | fc00:59dd:3bb2:d592:4083:c138:5489:560a Default: https://searx.me EOF w3_global_usage } +mkopts category= url= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -c=*|-category=*) echo default vid socialm news music map it img files ;; + -u=*|-url=*) echo 1 2 3 o1 o2 cjdns ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -c*=*) setopt SURFRAW_searx_categories $optarg ;; -u*=*) setopt SURFRAW_searx_base_url $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_searx_categories" in default*) category="general" ;; vid*) category="videos" ;; socialm*) category="social+media" ;; news*) category="news" ;; music*) category="music" ;; map*) category="map" ;; it*) category="it" ;; img*) category="images" ;; files*) category="files" ;; *) category="general" ;; esac case "$SURFRAW_searx_base_url" in 1*) searx_url="https://searx.me" ;; 2*) searx_url="https://searx.laquadrature.net" ;; 3*) searx_url="https://www.privatesearch.io" ;; o1*) searx_url="http://searchb5a7tmimez.onion" ;; o2*) searx_url="http://ulrn6sryqaifefld.onion" ;; cjdns*) searx_url="fc00:59dd:3bb2:d592:4083:c138:5489:560a" ;; *) searx_url="https://searx.me" ;; esac # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${searx_url}/?q=${escaped_args}&categories=${category}" diff --git a/elvi/sourceforge b/elvi/sourceforge index b6dbf9c..77587ef 100755 --- a/elvi/sourceforge +++ b/elvi/sourceforge @@ -1,63 +1,73 @@ #!/bin/sh # elvis: sourceforge -- Search SourceForge (www.sourceforge.net) # $Id$ . surfraw || exit 1 # version 0.2 [email protected] 20030910 # added -exact and -type # version 0.1 # this great work has been achieved by Caiaphas Pechorin ([email protected]) w3_config_hook () { defyn SURFRAW_sourceforge_exact no def SURFRAW_sourceforge_searchtype soft } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search SourceForge (www.sourceforge.net) Local options: -exact=yes|no Require all words Default: $SURFRAW_sourceforge_exact Environment: SURFRAW_sourceforge_exact -type= soft | Software / Group people | People freshmeat Freshmeat Default: $SURFRAW_sourceforge_searchtype Environment: SURFRAW_sourceforge_searchtype EOF w3_global_usage } +mkopts exact exact= type= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -exact=*) echo yes no ;; + -type=*) echo soft people freshmeat ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -e*=*) setoptyn SURFRAW_sourceforge_exact $optarg ;; -e*) setoptyn SURFRAW_sourceforge_exact yes ;; -t*=*) setopt SURFRAW_sourceforge_searchtype $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.sourceforge.net/" else escaped_args=$(w3_url_of_arg $w3_args) if $(yesno SURFRAW_sourceforge_exact) then isexact=1 else isexact=0 fi w3_browse_url "https://sourceforge.net/search/?words=${escaped_args}&exact=$isexact&typeofsearch=$SURFRAW_sourceforge_searchtype" fi diff --git a/elvi/springer b/elvi/springer index 5f737c9..20dfda7 100755 --- a/elvi/springer +++ b/elvi/springer @@ -1,62 +1,71 @@ #!/bin/sh # # author: Wim Van Hoydonck # # elvis: springer -- Search Springer for Books and Articles . surfraw || exit 1 w3_config_hook () { def SURFRAW_spinger_fields All } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search springer Local options: -fields=FIELD Subject field to search all | Seach all fields (default) author | Author name title | Title series | Series isbn | ISBN/ISSN Examples: $w3_argv0 -fields=author featherstone EOF w3_global_usage } +mkopts fields= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -fields=*) echo all author title series isbn ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -fields=*) setopt SURFRAW_springer_fields $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_springer_fields" in all) field=all ;; author) field=authorEditor ;; title) field=title ;; series) field=bookSeries ;; isbn) field=all ;; *) field=all ;; esac if null "$w3_args"; then w3_browse_url "https://www.springer.com" else escaped_args=$(w3_url_of_arg $w3_args) url="https://www.springer.com/?searchKey=easySearchKey&searchType=easy&visited=true&propagate=false&resultStart=1&resultCount=10&SGWID=5-102-14-0-0&queryText=${escaped_args}&easySearchOption=${field}&go.x=8&go.y=7" w3_browse_url "${url}" fi diff --git a/elvi/stack b/elvi/stack index 036a65e..13b4c3d 100755 --- a/elvi/stack +++ b/elvi/stack @@ -1,85 +1,94 @@ #!/bin/sh # elvis: stack -- Search Stack Overflow # Author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_stack_categories "$SURFRAW_categories" def SURFRAW_stack_unix 0 def SURFRAW_stack_results 25 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search Stack Overflow (https://stackoverflow.com) Combine search terms (tags) with a "+" eg., "bash+script" Local options: -sort=CATEGORIES -s=CATEGORIES new | Most recently asked (default) feat | Questions with open bounties vote | Questions with most votes active | Recently active null | No upvoted answers faq | Questions with the most links Default: new -u | Search Unix & Linux Exchange Default: no -num=NUMBER | Number of results per page Default: $SURFRAW_stack_results EOF w3_global_usage } +mkopts sort= u num= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -s=*|-sort=*) echo new feat vote active null faq ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -sort=*) setopt SURFRAW_stack_categories $optarg ;; -s=*) setopt SURFRAW_stack_categories $optarg ;; -num=*) setopt SURFRAW_stack_results $optarg ;; -u) setoptyn SURFRAW_stack_unix 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains list of arguments case "$SURFRAW_stack_categories" in new) category="newest" ;; feat) category="featured" ;; vote) category="votes" ;; active) category="active" ;; null) category="unanswered" ;; faq) category="faq" ;; *) category="newest" ;; esac # Check for Unix & Linux Exchange if [ "$SURFRAW_stack_unix" = 1 ]; then url="https://unix.stackexchange.com" else url="https://stackoverflow.com" fi # No arguments passed if [ -z "$w3_args" ]; then w3_browse_url "$url" else escaped_args=$(w3_url_of_arg $w3_args) if [ -n "$SURFRAW_stack_categories" ]; then w3_browse_url "${url}/questions/tagged/${escaped_args}?sort=${category}&pagesize=${SURFRAW_stack_results}" else w3_browse_url "${url}/questions/tagged/${escaped_args}" fi fi diff --git a/elvi/stockquote b/elvi/stockquote index b48195b..1766185 100755 --- a/elvi/stockquote +++ b/elvi/stockquote @@ -1,66 +1,75 @@ #!/bin/sh # $Id$ # elvis: stockquote -- Get a single stock quote (multiple providers) . surfraw || exit 1 w3_config_hook () { def SURFRAW_stockquote_provider yahoo } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] STOCK Description: Surfraw fetch a single stock quote Local options: -provider= Quote provider to use yahoo quote.yahoo.com nasdaq nasdaq.com (InfoQuote) quote quote.com Default: $SURFRAW_stockquote_provider Environment: SURFRAW_stockquote_provider Examples: $w3_argv0 Provider's standard quote page $w3_argv0 -provider=nasdaq Use NASDAQ for quote $w3_argv0 BLDP Obtain quote for 'Ballard Power' EOF w3_global_usage } +mkopts provider= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -provider=*) echo yahoo nasdaq quote ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -provider=*) setopt SURFRAW_stockquote_provider $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test "$SURFRAW_stockquote_provider" = "yahoo"; then if test -z "$w3_args"; then w3_browse_url "https://quote.yahoo.com/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://quote.yahoo.com/q?s=${escaped_args}" fi elif test "$SURFRAW_stockquote_provider" = "nasdaq"; then if test -z "$w3_args"; then w3_browse_url "https://www.nasdaq.com/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://quotes.nasdaq.com/Quote.dll?mode=Stock&symbol=${escaped_args}&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&multi.x=44&multi.y=12" fi elif test "$SURFRAW_stockquote_provider" = "quote"; then if test -z "$w3_args"; then w3_browse_url "https://www.quote.com/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.quote.com/quotecom/stocks/quotes.asp?symbols=${escaped_args}" fi else err "-provider ${SURFRAW_stockquote_provider} unsupported" fi diff --git a/elvi/translate b/elvi/translate index 8729299..5bce582 100755 --- a/elvi/translate +++ b/elvi/translate @@ -1,154 +1,167 @@ #!/bin/sh # $Id$ # elvis: translate -- Translate human languages . surfraw || exit 1 w3_config_hook () { def SURFRAW_translate_from "$SURFRAW_lang" def SURFRAW_translate_to "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [words|URI]... Description: Surfraw translate human language Local options: -from=LANGUAGE Source language Environment: SURFRAW_translate_from, SURFRAW_lang -to=LANGUAGE Destination language Environment: SURFRAW_translate_to, SURFRAW_lang Languages (any provider): nl Dutch en English fr French de German el Greek it Italian ja Japanese ko Korean pt Portuguese ru Russian es Spanish Languages (Systrans only): zh Chinese (Simplified) zt Chinese (Traditional) Languages (Google only): auto Automatically detect language af Afrikaans sq Albanian ar Arabic hy Armenian az Azerbaijani eu Basque be Belarusian bg Bulgarian ca Catalan zh-CN Chinese (Simplified) zh-TW Chinese (Traditional) hr Croatian cs Czech da Danish et Estonian tl Filipino fi Finnish gl Galician ka Georgian ht Hatian Creole iw Hebrew hi Hindi hu Hungarian is Icelandic id Indonesian ga Irish la Latin lv Latvian lt Lithuanian mk Macedonian ms Malay mt Maltese no Norwegian fa Persian pl Polish ro Romanian sr Serbian sk Slovak sl Slovenian sw Swahili sv Swedish th Thai tr Turkish uk Ukrainian ur Urdu vi Vietnamese cy Welsh yi Yiddish Examples: $w3_argv0 Provider's standard translation page $w3_argv0 -from=fr -to=en la verite vous liberera $w3_argv0 -from=en -to=es https://tashian.com/multibabel Translate the given Web page Bugs: Systrans derived providers only support the following translation combinations: English to Chinese English to French English to German English to Italian English to Japanese English to Korean English to Portuguese English to Spanish Chinese to English French to English French to German German to English German to French Italian to English Japanese to English Korean to English Portuguese to English Russian to English Spanish to English EOF w3_global_usage } +mkopts from= to= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -from=*|-to=*) + echo nl en fr de el it ja + echo zh zt + echo auto af sq ar hy az eu be bg ca zh-CN zh-TW hr cs da et tl fi gl ka ht iw hi hu is id ga la lv lt mk ms mt no fa pl ro sr sk sl sw sv th tr uk ur vi cy yi + ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -from=*) setopt SURFRAW_translate_from $optarg ;; -to=*) setopt SURFRAW_translate_to $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args" then w3_browse_url "https://translate.google.com/" else if [ -z "$SURFRAW_translate_to" ]; then SURFRAW_translate_to="en" fi if [ -z "$SURFRAW_translate_from" ]; then SURFRAW_translate_from="fr" fi escaped_args=$(w3_url_of_arg $w3_args) case "$escaped_args" in http*) w3_browse_url "https://translate.google.com/translate?&sl=${SURFRAW_translate_from}&tl=${SURFRAW_translate_to}&u=${escaped_args}" ;; *) w3_browse_url "https://translate.google.com/?&sl=${SURFRAW_translate_from}&tl=${SURFRAW_translate_to}&q=${escaped_args}" ;; esac fi exit $? diff --git a/elvi/w3css b/elvi/w3css index e484569..e9cd825 100755 --- a/elvi/w3css +++ b/elvi/w3css @@ -1,66 +1,77 @@ #!/bin/sh # $Id$ # elvis: w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) # [email protected] 20040909 . surfraw || exit 1 w3_config_hook () { def SURFRAW_w3css_warnings "1" def SURFRAW_w3css_profile "css2" def SURFRAW_w3css_medium "all" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [URL] Description: Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator/) Local options: -warnings=LEVEL Level of warnings displayed. Default: normal Values: all, normal, important, none Environment: SURFRAW_w3css_warnings -profile=PROFILE CSS Profile. Default: $SURFRAW_w3css_profile Values: none, css1, css2, css3, svg, svgbasic, svgtiny, mobile, atsv-tv, tv Environment: SURFRAW_w3css_profile -medium=MEDIUM User Medium Default: $SURFRAW_w3css_medium Values: all, aural, braille, embossed, handheld, print, projection, screen, tty, tv, presentation Environment: SURFRAW_w3css_medium EOF w3_global_usage } +mkopts warnings= profile= medium= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -warnings=*) echo all normal important none ;; + -profile=*) echo none css1 css2 css3 svg svgbasic svgtiny mobile atsv-tv tv ;; + -medium=*) echo all aural braille embossed handheld print projection screen tty tv presentation ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -prof*=*) setopt SURFRAW_w3css_profile "$optarg" ;; -med*=*) setopt SURFRAW_w3css_medium "$optarg" ;; -warn*=*) case "$optarg" in [Aa]*) setopt SURFRAW_w3css_warnings "2" ;; [Nn][Oo][Rr]*) setopt SURFRAW_w3css_warnings "1" ;; [Ii]*) setopt SURFRAW_w3css_warnings "0" ;; [Nn][Oo][Nn]*) setopt SURFRAW_w3css_warnings "no" ;; *) echo "Invalid value $optarg"; exit 1 ;; esac ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://jigsaw.w3.org/css-validator/" else escaped_args=$(w3_url_of_arg $w3_args) url="https://jigsaw.w3.org/css-validator/validator?uri=${escaped_args}&warning=${SURFRAW_w3css_warnings}&profile=${SURFRAW_w3css_profile}&usermedium=${SURFRAW_w3css_medium}" w3_browse_url "${url}" fi diff --git a/elvi/w3html b/elvi/w3html index 18f6992..53b42ff 100755 --- a/elvi/w3html +++ b/elvi/w3html @@ -1,117 +1,118 @@ #!/bin/sh # $Id$ # elvis: w3html -- Validate a web page URL with the w3c validator (validator.w3.org) # [email protected] 20040906 . surfraw || exit 1 w3_config_hook () { def SURFRAW_w3html_encoding "%28detect+automatically%29" def SURFRAW_w3html_doctype "Inline" defyn SURFRAW_w3html_verbose 1 defyn SURFRAW_w3html_encodingfallback 0 defyn SURFRAW_w3html_doctypefallback 0 defyn SURFRAW_w3html_showsource 0 defyn SURFRAW_w3html_showparsetree 0 defyn SURFRAW_w3html_showoutline 0 defyn SURFRAW_w3html_excludeattributes 0 defyn SURFRAW_w3html_validateerror 0 defyn SURFRAW_w3html_usage 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [URL] Description: Validate a web page URL with the w3c validator (validator.w3.org) Local options: -usage Go to help page for validator. -encoding=ENCODING Set page encoding. Default: autodetect Environment: SURFRAW_w3html_encoding -encfb Fall back to encoding rather than override. Environment: SURFRAW_w3html_encodingfallback -doctype="DOCTYPE" Set page doctype. Default: SURFRAW_w3html_doctype -docfb Fall back to doctype rather than override. Environment: SURFRAW_w3html_doctypefallback -nv Be less verbose. Environment: SURFRAW_w3html_verbose -showsource Show page source. Environment: SURFRAW_w3html_showsource -showoutline Show page outline (headings) Environment: SURFRAW_w3html_showoutline -showparsetree Show parse tree. Environment: SURFRAW_w3html_showparsetree -excludeatt Exclude attributes from parse tree. Environment: SURFRAW_w3html_excludeattributes -err Validate Error (404) pages. Environment: SURFRAW_w3html_validateerror EOF w3_global_usage } +mkopts usage encoding= encfb doctype= docfb nv showsource showoutline showparsetree excludeatt err w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -enco*=*) setopt SURFRAW_w3html_encoding $(w3_url_escape "$optarg") ;; -docty*=*) setopt SURFRAW_w3html_doctype $(w3_url_escape "$optarg") ;; -encfb) setoptyn SURFRAW_w3html_encodingfallback 1 ;; -docfb) setoptyn SURFRAW_w3html_doctypefallback 1 ;; -shows*) setoptyn SURFRAW_w3html_showsource 1 ;; -showp*) setoptyn SURFRAW_w3html_showparsetree 1 ;; -showo*) setoptyn SURFRAW_w3html_showoutline 1 ;; -exc*) setoptyn SURFRAW_w3html_excludeattributes 1 ;; -err*) setoptyn SURFRAW_w3html_validateerror 1 ;; -nv*) setoptyn SURFRAW_w3html_verbose 0 ;; -us*) setoptyn SURFRAW_w3html_usage 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ $SURFRAW_w3html_usage -eq 1 ]; then w3_browse_url "https://validator.w3.org/docs/users.html#Options" elif test -z "$w3_args"; then w3_browse_url "https://validator.w3.org/" else escaped_args=$(w3_url_of_arg $w3_args) url="https://validator.w3.org/check?uri=${escaped_args}&charset=${SURFRAW_w3html_encoding}&doctype=${SURFRAW_w3html_doctype}" if [ $SURFRAW_w3html_encodingfallback -eq 1 ] then url="${url}&fbc=1" fi if [ $SURFRAW_w3html_doctypefallback -eq 1 ] then url="${url}&fbd=1" fi if [ $SURFRAW_w3html_showsource -eq 1 ] then url="${url}&ss=1" fi if [ $SURFRAW_w3html_showparsetree -eq 1 ] then url="${url}&sp=1" fi if [ $SURFRAW_w3html_showoutline -eq 1 ] then url="${url}&outline=1" fi if [ $SURFRAW_w3html_excludeattributes -eq 1 ] then url="${url}&noatt=1" fi if [ $SURFRAW_w3html_validateerror -eq 1 ] then url="${url}&No200=1" fi if [ $SURFRAW_w3html_verbose -eq 1 ] then url="${url}&verbose=1" fi w3_browse_url "${url}" fi diff --git a/elvi/w3link b/elvi/w3link index d633f4a..0a63abc 100755 --- a/elvi/w3link +++ b/elvi/w3link @@ -1,88 +1,89 @@ #!/bin/sh # $Id$ # elvis: w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) # [email protected] 20040908 . surfraw || exit 1 w3_config_hook () { def SURFRAW_w3link_depth -1 defyn SURFRAW_w3link_summary 1 defyn SURFRAW_w3link_hiderd 0 defyn SURFRAW_w3link_dhiderd 0 defyn SURFRAW_w3link_noacceptlanguage 0 defyn SURFRAW_w3link_recurse 0 defyn SURFRAW_w3link_cookie 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [URL] Description: Check web page links with the w3c linkchecker (validator.w3.org/checklink) Local options: -r Check linked documents recursively. Environment: SURFRAW_w3link_recurse -d=DEPTH Recursion depth. Default: unlimited (-1) Environment: SURFRAW_w3link_depth -s Summary only. Environment: SURFRAW_w3link_summary -hiderd Hide Redirects. Environment: SURFRAW_w3link_hiderd -dhiderd Hide Redirects for directories only. Environment: SURFRAW_w3link_dhidedrd -nolang Don't send the Accept-Language: header. Environment: SURFRAW_w3link_noacceptlanguage -cookie Save options in a cookie. Environment: SURFRAW_w3link_cookie EOF w3_global_usage } +mkopts r d= s hiderd dhiderd nolang cookie w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -d*=*) setopt SURFRAW_w3link_depth "$optarg" ;; -r) setoptyn SURFRAW_w3link_recurse 1 ;; -s) setoptyn SURFRAW_w3link_summary 1 ;; -hiderd) setoptyn SURFRAW_w3link_hiderd 1 ;; -dhiderd) setoptyn SURFRAW_w3link_dhiderd 1 ;; -nolang) setoptyn SURFRAW_w3link_noacceptlanguage 1 ;; -cookie) setoptyn SURFRAW_w3link_cookie 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://validator.w3.org/checklink" else escaped_args=$(w3_url_of_arg $w3_args) url="https://validator.w3.org/checklink?uri=${escaped_args}&depth=${SURFRAW_w3link_depth}" if [ $SURFRAW_w3link_recurse -eq 1 -o $SURFRAW_w3link_depth -ge 0 ] then url="${url}&recursive=on" fi if [ $SURFRAW_w3link_summary -eq 1 ] then url="${url}&summary=on" fi if [ $SURFRAW_w3link_noacceptlanguage -eq 1 ] then url="${url}&no_accept_language=on" fi if [ $SURFRAW_w3link_hiderd -eq 1 ] then url="${url}&hide_redirects=on&hide_type=all" elif [ $SURFRAW_w3link_dhiderd -eq 1 ] then url="${url}&hide_redirects=on&hide_type=dir" fi w3_browse_url "${url}" fi diff --git a/elvi/w3rdf b/elvi/w3rdf index 775ec42..e919a07 100755 --- a/elvi/w3rdf +++ b/elvi/w3rdf @@ -1,133 +1,146 @@ #!/bin/sh # $Id$ # elvis: w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) # [email protected] 20040909 . surfraw || exit 1 w3_config_hook () { def SURFRAW_w3rdf_output "PRINT_TRIPLES" def SURFRAW_w3rdf_format "PNG_EMBEDDED" defyn SURFRAW_w3rdf_savedot 0 defyn SURFRAW_w3rdf_ntriples 0 defyn SURFRAW_w3rdf_embedded 0 defyn SURFRAW_w3rdf_useme 0 defyn SURFRAW_w3rdf_anon 0 def SURFRAW_w3rdf_node "Black" def SURFRAW_w3rdf_nodetext "Blue" def SURFRAW_w3rdf_arc "Darkgreen" def SURFRAW_w3rdf_arctext "Red" def SURFRAW_w3rdf_fontsize 10 def SURFRAW_w3rdf_orientation "LR" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [URL] Description: Validate a RDF URL with the w3c RDF validator (www.w3.org/RDF/Validator) Local options: -output=TYPE Type of output displayed. Values: Triples, Graphs, Both Default: Triples Environment: SURFRAW_w3rdf_output -format=TYPE Graph Format Values: PNG_EMBED, PNG_LINK, SVG_LINK, SVG_EMBED, GIF_EMBED, GIF_LINK, PS_LINK, HP_PCL_LINK, HP_GL_LINK, ISV_ZVTM Default: $SURFRAW_w3rdf_format Environment: SURFRAW_w3rdf_format -savedot Save GraphViz DOT file. Environment: SURFRAW_w3rdf_savedot -ntriples Display triples in N-Triples format Environment: SURFRAW_w3rdf_ntriples -embedded RDF is NOT enclosed in <RDF>..</RDF> tags. Environment: SURFRAW_w3rdf_embedded -useme I grant w3c permission to save the RDF for developing test cases. Environment: SURFRAW_w3rdf_useme -anon Make anonymous nodes unlabelled. Environment: SURFRAW_w3rdf_anon -fontsize=SIZE Font Size. Values: 10, 12, 14, 16, 20 Default: $SURFRAW_w3rdf_fontsize Environment: SURFRAW_w3rdf_fontsize -orient=ORIENTATION Orientation Values: TB (Top to Bottom), LR (Left to Right) Default: $SURFRAW_w3rdf_orientation Environment: SURFRAW_w3rdf_orientation -node=COLOUR Node Colour. Environment: SURFRAW_w3rdf_node Default: $SURFRAW_w3rdf_node -nodetext=COLOUR Node Text Colour. Environment: SURFRAW_w3rdf_nodetext Default: $SURFRAW_w3rdf_nodetext -arc=COLOUR Arc Colour. Environment: SURFRAW_w3rdf_arc Default: $SURFRAW_w3rdf_arc -arctext=COLOUR Arc Text Colour. Environment: SURFRAW_w3rdf_arctext Default: $SURFRAW_w3rdf_arctext Valid Colours: Black, Blue, Darkgreen, Red EOF w3_global_usage } +mkopts output= format= savedot ntriples embedded useme anon fontsize= orient= node= nodetext= arc= arctext= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -output=*) echo Triples Graphs Both ;; + -format=*) echo PNG_EMBED PNG_LINK SVG_LINK SVG_EMBED GIF_EMBED GIF_LINK PS_LINK HP_PCL_LINK HP_GL_LINK ISV_ZVTM ;; + -fontsize=*) echo 10 12 14 16 20;; + -orient=*) echo TB LR ;; + -arctext=*) echo Black Blue Darkgreen Red ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -out*=*) case "$optarg" in [Tt]*) setopt SURFRAW_w3rdf_output "PRINT_TRIPLES" ;; [Gg]*) setopt SURFRAW_w3rdf_output "PRINT_GRAPH" ;; [Bb]*) setopt SURFRAW_w3rdf_output "PRINT_GRAPH" ;; *) echo "Invalid value $optarg"; exit 1 ;; esac ;; -for*=*) setopt SURFRAW_w3rdf_format "$optarg" ;; -sav*) setoptyn SURFRAW_w3rdf_savedot 1 ;; -nt*) setoptyn SURFRAW_w3rdf_ntriples 1 ;; -em*) setoptyn SURFRAW_w3rdf_embedded 1 ;; -use*) setoptyn SURFRAW_w3rdf_useme 1 ;; -anon*) setoptyn SURFRAW_w3rdf_anon 1 ;; -font*=*) setopt SURFRAW_w3rdf_fontsize "$optarg" ;; -or*=*) setopt SURFRAW_w3rdf_orientation "$optarg" ;; -node=*) setopt SURFRAW_w3rdf_node "$optarg" ;; -nodet*) setopt SURFRAW_w3rdf_nodetext "$optarg" ;; -arc=*) setopt SURFRAW_w3rdf_arc "$optarg" ;; -arct*=*) setopt SURFRAW_w3rdf_arctext "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.w3.org/RDF/Validator/" else escaped_args=$(w3_url_of_arg $w3_args) url="https://www.w3.org/RDF/Validator/ARPServlet?PARSE=PARSE_URI&URI=${escaped_args}&TRIPLES_AND_GRAPH=${SURFRAW_w3rdf_output}&FORMAT=${SURFRAW_w3rdf_format}&NODE_COLOR=${SURFRAW_w3rdf_node}&NODE_TEXT_COLOR=${SURFRAW_w3rdf_nodetext}&EDGE_COLOR=${SURFRAW_w3rdf_arc}&EDGE_TEXT_COLOR=${SURFRAW_w3rdf_arctext}&FONT_SIZE=${SURFRAW_w3rdf_fontsize}&ORIENTATION=${SURFRAW_w3rdf_orientation}" if [ $SURFRAW_w3rdf_savedot -eq 1 ] then url="${url}&SAVE_DOT_FILE=on" fi if [ $SURFRAW_w3rdf_ntriples -eq 1 ] then url="${url}&NTRIPLES=on" fi if [ $SURFRAW_w3rdf_embedded -eq 1 ] then url="${url}&EMBEDDED_RDF=on" fi if [ $SURFRAW_w3rdf_useme -eq 1 ] then url="${url}&SAVE_RDF=on" fi if [ $SURFRAW_w3rdf_anon -eq 1 ] then url="${url}&ANON_NODES_EMPTY=on" fi w3_browse_url "${url}" fi diff --git a/elvi/webster b/elvi/webster index d9e7d64..5e848b5 100755 --- a/elvi/webster +++ b/elvi/webster @@ -1,42 +1,43 @@ #!/bin/sh # $Id$ # elvis: webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_webster_book dictionary } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Look up word in Merriam-Webster's Dictionary (www.m-w.com) Local options: -t Search in Thesaurus EOF w3_global_usage } +mkopts t w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -t*) setopt SURFRAW_webster_book thesaurus ;; *) return 1 ;; esac return 0 } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.merriam-webster.com/dictionary.htm" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.merriam-webster.com/${SURFRAW_webster_book}/${escaped_args}" fi diff --git a/elvi/wikipedia b/elvi/wikipedia index 2525a11..2023d95 100755 --- a/elvi/wikipedia +++ b/elvi/wikipedia @@ -1,57 +1,58 @@ #!/bin/sh # elvis: wikipedia -- Search the free encyclopedia wikipedia # $Id$ # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_config_hook () { def SURFRAW_wikipedia_language "$SURFRAW_lang" defyn SURFRAW_wikipedia_deletionpedia no def SURFRAW_wikipedia_fallback wikipedia } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Wikipedia online encyclopedia Local options: -language=ISOCODE | -l=ISOCODE Two letter language code (resembles ISO country codes) Default: en Environment: SURFRAW_wikipedia_language, SURFRAW_lang Examples: $w3_argv0 -language=de Richard Stallman EOF w3_global_usage } +mkopts language= w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_wikipedia_language $optarg ;; -l=*) setopt SURFRAW_wikipedia_language $optarg ;; *) return 1 ;; esac return 0 } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" if [ -z "$SURFRAW_wikipedia_language" ]; then SURFRAW_wikipedia_language="en" fi prefix="https://${SURFRAW_wikipedia_language}.wikipedia.org/w/index.php?search=" if null "$w3_args"; then w3_browse_url "https://${SURFRAW_wikipedia_language}.wikipedia.org/wiki/Main_Page" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${prefix}${escaped_args}" fi diff --git a/elvi/wiktionary b/elvi/wiktionary index a852603..1819bbd 100755 --- a/elvi/wiktionary +++ b/elvi/wiktionary @@ -1,54 +1,55 @@ #!/bin/sh # elvis: wiktionary -- Search the free dictionary wiktionary # $Id$ # Author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_wiktionary_language "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Wiktionary online dictionary -language=ISOCODE | -l=ISOCODE Two letter language code (resembles ISO country codes) Default: en Environment: SURFRAW_wiktionary_language, SURFRAW_lang Examples: $w3_argv0 -language=de synecdoche EOF w3_global_usage } +mkopts language= w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_wiktionary_language $optarg ;; -l=*) setopt SURFRAW_wiktionary_language $optarg ;; *) return 1 ;; esac return 0 } w3_config # disable requoting, doesn't work with this elvi. #SURFRAW_quote_ifs=0 w3_parse_args "$@" if [ -z "$SURFRAW_wiktionary_language" ]; then SURFRAW_wiktionary_language="en" fi prefix="${SURFRAW_wiktionary_language}" if null "$w3_args"; then w3_browse_url "https://${SURFRAW_wiktionary_language}.wiktionary.org" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://${prefix}.wiktionary.org/wiki/${escaped_args}" fi diff --git a/elvi/woffle b/elvi/woffle index 1c15c85..dfde865 100755 --- a/elvi/woffle +++ b/elvi/woffle @@ -1,67 +1,78 @@ #!/bin/sh # $Id$ # elvis: woffle -- Search the web using Woffle (localhost:8080) . surfraw || exit 1 w3_config_hook () { def SURFRAW_woffle_search search/htdig/htsearch def SURFRAW_woffle_format 'builtin-long' def SURFRAW_woffle_method and def SURFRAW_woffle_sort score } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Woffle (localhost:8080/) Local options: -method= Method used for searching... and | ALL or | ANY bool | BOOLEAN -format= Format of results short | just a link and title long | description please -sort= Sort method score | best result revscore | worst result! time | newest revtime | oldest title | abc by title revtitle | zyx by title EOF w3_global_usage } +mkopts method= format= sort= +w3_complete_hook_opt () +{ + local opt="$1" + case "$opt" in + -method=*) echo and or bool ;; + -format=*) echo short long ;; + -sort=*) echo score revscore time revtime title revtitle ;; + *) return 1 ;; + esac +} w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -format=*) if [ "$optarg" = "short" ] ; then optarg="builtin-short" else optarg="builtin-long" fi setopt SURFRAW_woffle_format $optarg ;; -method=*) if [ "$optarg" = "bool" ] ; then optarg="boolean" fi setopt SURFRAW_woffle_method $optarg ;; -sort=*) setopt SURFRAW_woffle_sort $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://localhost:8080/search/htdig/search.html" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://localhost:8080/${SURFRAW_woffle_search}?words=${escaped_args}&method=${SURFRAW_woffle_method}&format=${SURFRAW_woffle_format}&sort=${SURFRAW_woffle_sort}" fi diff --git a/elvi/yahoo b/elvi/yahoo index b1fef3e..865f686 100755 --- a/elvi/yahoo +++ b/elvi/yahoo @@ -1,41 +1,42 @@ #!/bin/sh # $Id$ # elvis: yahoo -- Search Yahoo categories (www.yahoo.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_yahoo_results $SURFRAW_results } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Yahoo categories (www.yahoo.com) Local options: -results=NUM Number of search results returned Default: $SURFRAW_yahoo_results Environment: SURFRAW_yahoo_results EOF w3_global_usage } +mkopts results= w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_yahoo_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.yahoo.com/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://search.yahoo.com/search?p=${escaped_args}&n=${SURFRAW_yahoo_results}" fi diff --git a/elvi/yandex b/elvi/yandex index b10d0e3..3d6b099 100755 --- a/elvi/yandex +++ b/elvi/yandex @@ -1,50 +1,51 @@ #!/bin/sh # $Id$ # elvis: yandex -- Search the web using Yandex (yandex.ru) . surfraw || exit 1 w3_config_hook () { def SURFRAW_yandex_search "${search:-yandsearch?}text" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Yandex (yandex.ru) Local options: Specialized search on topic -dict | Slovari -news | News -images | Images -market | Market -maps | Maps EOF w3_global_usage } +mkopts dict news images market maps w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -dict) search="search.xml?" opt=slovari ;; -news) search="yandsearch?rpt=nnews2\&" ;; -market) search="search.xml?" ;; -images) search="search?" ;; -maps) search="?" ;; *) return 1 esac setopt SURFRAW_yandex_domain "${opt:+${opt#-}.}" [ -n $search ] && setopt SURFRAW_yandex_search "${search}text" return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://${SURFRAW_yandex_domain}yandex.ru/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://${SURFRAW_yandex_domain}yandex.ru/${SURFRAW_yandex_search}=${escaped_args}" fi
JNRowe/surfraw
297f10e4932578710a8e732accb8ae0401bbeac1
Provide richer completions
diff --git a/surfraw-bash-completion.IN b/surfraw-bash-completion.IN index 9ec53cc..05d911c 100644 --- a/surfraw-bash-completion.IN +++ b/surfraw-bash-completion.IN @@ -1,35 +1,100 @@ # -*- sh -*- bash programmable completion for Surfraw, v2.2 -# This is for people who wish to use surfraw completion, without -# installing the bash-completion package which sets this explicitly. -shopt -s extglob - -_surfraw() -{ COMPREPLY=() - local cur=${COMP_WORDS[COMP_CWORD]} - local prev=${COMP_WORDS[COMP_CWORD-1]} - local opts='-browser -elvi -escape-url-args -graphical \ - -help -q -quote -text -version' - local elvi="$(source surfraw - cut -f1 @sysconfdir@/surfraw.bookmarks ~/.surfraw.bookmarks "$(find_local_conf bookmarks)" "$(find_global_conf bookmarks)" 2>&- - cd @ELVIDIR@ && echo * 2>&- - [ -d ~/.surfraw.d ] && cd ~/.surfraw.d && echo * 2>&- - cd $(get_local_elvi_dir) && echo * 2>&-)" - if [[ $cur == -* ]] - then COMPREPLY=( $( compgen -W "$opts" -- $cur ) ) - # I can't see a way to get the =yes/=no parts to work... - elif [[ $COMP_CWORD -eq 1 ]] - then COMPREPLY=( $( compgen -W "$elvi" -- $cur ) ) - # "sr go<tab>" for google - elif [[ $prev == @(alioth|deb@(bugs|contents|packages|pts|sec)|freshmeat|fsfdir|sourceforge) ]] - then COMPREPLY=( $(apt-cache --generate pkgnames $cur) ) - # "sr debbugs 4<tab>" to check 44bsd-rdist bugs... - elif [[ -x /usr/bin/look ]] # in bsdmainutils, "important" - then COMPREPLY=( $(/usr/bin/look ${cur:-''}) ) - # "sr l<tab> vy<tab>" to find the German for "vying" - else COMPREPLY=( $( compgen -o default -- $cur) ) # copout +__surfraw_validate_elvis_exists () +{ + # Allow global surfraw completions + [[ -z "$1" ]] && return 0 + grep -xF "$(__surfraw_get_elvi | tr ' ' '\n' | tr -s '\n')" <<< "$1" &>/dev/null +} + +__surfraw_complete_arg () +{ + __surfraw_validate_elvis_exists "$1" || return 1 + local completions; declare -a completions + mapfile -t completions < <(surfraw "$1" --complete-arg="$2") + # We want to complete *something* for non-option, non-elvis arguments + if [[ "${#completions[@]}" -eq 0 ]] + then + COMPREPLY=( $(compgen -o default -- "$2") ) + else + # Quote if needed: https://stackoverflow.com/a/40944195 + mapfile -t COMPREPLY < <(compgen -W "$(printf '%q ' "${completions[@]}")" -- "$2" | awk '/[[:space:]]/ { print "\"" $0 "\""; next } { print $0 }') + fi +} + +__surfraw_complete_optname () +{ + __surfraw_validate_elvis_exists "$1" || return 1 + # Appended spaces after completing options with arguments is annoying + compopt -o nospace + COMPREPLY=( + $(compgen -W "$(surfraw "$1" --complete="$2")" -- "$2") + ) +} + +__surfraw_complete_optarg () +{ + __surfraw_validate_elvis_exists "$1" || return 1 + # Match argument + local arg="$(echo "$2" | sed 's/[-_a-zA-Z0-9]*=//')" + COMPREPLY=( + $(compgen -W "$(surfraw "$1" --complete="$2")" -- "$arg") + ) +} + +__surfraw_get_elvi () +( + source surfraw + cd "$(get_local_elvi_dir)" 2>/dev/null && echo * + cd "$elvidir" 2>/dev/null && echo * + cut -f1 "$(find_local_conf bookmarks)" "$(find_global_conf bookmarks)" 2>/dev/null +) + +_surfraw () +{ + local cur words=() cword + _get_comp_words_by_ref -n = cur words cword + + # Determine end of args and current elvis + local i=1 + local end_of_args=no + local elvis elvis_index + # Skip "surfraw" or "sr" at start of command + for word in "${words[@]:1}" + do + case "$word" in + --) [[ $cword -ge $i ]] && end_of_args=yes ;; + -*) : ignore options ;; + *) [[ -z "$elvis" ]] && elvis="$word" elvis_index="$i" ;; + esac + [[ $end_of_args = yes && -n "$elvis" ]] && break + i="$(( i + 1 ))" + done + + if [[ $elvis_index -eq $cword ]] # complete partial elvis names + then + # $elvis == $cur + COMPREPLY=( $(compgen -W "$(__surfraw_get_elvi)" -- "$cur") ) + elif [[ -z "$elvis" ]] # complete global options or elvis names + then + case "$cur" in + # Global options + -*=*) __surfraw_complete_optarg '' "$cur" ;; + -*) __surfraw_complete_optname '' "$cur" ;; + # Match empty elvis names (the partial name branch would have been executed if this *wasn't* empty) + # Regardless, surfraw accepts the elvis name after the "--" argument + '') COMPREPLY=( $(compgen -W "$(__surfraw_get_elvi)") ) ;; + esac + elif [[ $end_of_args = yes ]] # elvis is defined, so it's safe to complete args + then + __surfraw_complete_arg "$elvis" "$cur" + else # now, complete elvi-specific options and arguments + case "$cur" in + -*=*) __surfraw_complete_optarg "$elvis" "$cur" ;; + -*) __surfraw_complete_optname "$elvis" "$cur" ;; + *) __surfraw_complete_arg "$elvis" "$cur" ;; + esac fi - return 0 } # test first in case removed-but-unpurged type -p surfraw >/dev/null 2>&1 && complete -F _surfraw surfraw sr diff --git a/surfraw.IN b/surfraw.IN index da01945..d7435b6 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,694 +1,794 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 -w3_argv0=$(basename "$0") +# $0 can be -bash when sourced for tab completions. +# POSIX seems to assume `--` support. +w3_argv0=$(basename -- "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default conf="@sysconfdir@/xdg/surfraw/$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value="\"\$${1}\"" case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value="\"\$${1}\"" # Do nothing if already have a value. test -z "$value" && eval ${1}="\"$2\"" return 0 } defyn () { def "$@" yesno "$1" } setopt () { eval value="\"\$${1}\"" eval ${1}="\"$2\"" } setoptyn () { setopt "$@" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } +# Should only complete for specific options +# Called before declared-options completions +w3_complete_hook_opt () +{ + return 1 +} +# Completions for main surfraw script +w3_complete_hook_opt_global () +{ + local opt="$1" + case "$opt" in + -bookmark-search-elvis=*) + cd "$(get_local_elvi_dir)" 2>/dev/null && echo * + cd "$elvidir" && echo * + ;; + # -browser=* can be anything + -custom-search=*) echo google duckduckgo ;; + -escape-url-args=*) echo yes no ;; + # -o=* can be anything + -new=*|-ns=*|-newscreen=*) echo yes no ;; + *) return 1 ;; + esac +} +# Allowed to use a plain '*' in case statements +# Called before declared-options completions +# These must print newline-delimited completion alternatives (if any are defined for the argument) +w3_complete_hook_arg_default () +{ + local arg="$1" + if command -v look >/dev/null 2>&1 + then + look -- "${arg:-''}" + else + return 1 + fi +} +w3_complete_hook_arg () +{ + w3_complete_hook_arg_default "$@" +} + +w3_complete () +{ + local arg="$1" + + w3_complete_hook_opt "$arg" && return 0 + w3_complete_hook_opt_global "$arg" && return 0 + # At this point, `arg` is either: + # 1. an option that takes an argument BUT doesn't define completions for it; + # 2. a flag; + # 3. an incomplete option name; or + # 4. a non-option argument. + case "$arg" in + # Avoid completing options that don't define completions for the optarg + -*=*) return 0 ;; + # Complete options + -*) + # Remove ' ' "options" + echo "$SURFRAW__complete_flags $SURFRAW__complete_options" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -s '[:space:]' + return 0 + ;; + esac + + w3_complete_hook_arg "$arg" + return 0 +} +# Properly complete calls like "sr fooelvis -- -notanoption" +w3_complete_arg () +{ + local arg="$1" + w3_complete_hook_arg "$arg" + return 0 +} + +# Declare options (and valid arguments, TODO) +# Does not need leading hyphen +# Example use: +# mkopts flag optwithvar= +mkopts () +{ + for opt in "$@" + do + case "$opt" in + *=*) SURFRAW__complete_options="$SURFRAW__complete_options -$(echo $opt | sed 's/^\([^=]*=\).*/\1/')" ;; + *) SURFRAW__complete_flags="$SURFRAW__complete_flags -$opt" ;; + esac + done +} + +# Options with arguments +mkopts bookmark-search-elvis= browser= escape-url-args= new= ns= newscreen= custom-search= o= +# Flags +mkopts elvi graphical help local-help quote new ns newscreen o text version print + w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi*) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh|-\? ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; + --complete=* | \ + -complete=*) w3_complete "$optarg"; exit 0 ;; + --complete-arg=* | \ + -complete-arg=*) w3_complete_arg "$optarg"; exit 0 ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then w3_parse_option "$arg" fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="$(quote "$arg")" unquoted_opts="$arg" else opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then exec sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then exec sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=$(bookmark_lookup $elvi) if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else - echo "$(basename $0): $elvi: No elvis or bookmark with that name" + echo "$w3_argv0: $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
f5f14053bedce13e2e394b465ffa8de6846b0eda
add Local option for archlinux.jp.
diff --git a/elvi/archwiki b/elvi/archwiki index ad5fef8..557c150 100755 --- a/elvi/archwiki +++ b/elvi/archwiki @@ -1,76 +1,78 @@ #!/bin/sh # elvis: archwiki -- Search the Arch Linux Wiki # Author: http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_archwiki_language "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Arch Linux Wiki (wiki.archlinux.org) Local options -language=ISOCODE Two letter language code (resembles ISO country codes) -l=ISOCODE en | Main Arch Wiki site (default) fr | French de | German he | Hebrew + jp | Japan pl | Polish pt | Portugese ro | Romanian es | Spanish sv | Swedish uk | Ukranian Environment: SURFRAW_archwiki_language, SURFRAW_lang Default: en EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_archwiki_language $optarg ;; -l=*) setopt SURFRAW_archwiki_language $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains list of arguments case "$SURFRAW_archwiki_language" in en) domain=".org" ;; fr) domain=".fr" ;; de) domain=".de" ;; he) domain=".il" ;; + jp) domain=".jp" ;; pl) domain=".pl" ;; pt) domain="-br.org" ;; ro) domain=".ro" ;; es) domain=".cl" ;; sv) domain=".sv" ;; uk) domain=".ua" ;; *) domain=".org" ;; esac # handle ssl if [ $domain = ".org" -o $domain = ".de" ]; then protocol="https://"; else protocol="http://"; fi if [ -z "$w3_args" ]; then w3_browse_url "${protocol}wiki.archlinux${domain}/" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${protocol}wiki.archlinux${domain}/index.php?search=${escaped_args}" fi
JNRowe/surfraw
60c16c6390762691a7ceac848cc5dccdec7277f4
Wikipedia search string updated, addressing issue #11
diff --git a/elvi/wikipedia b/elvi/wikipedia index 3db5e4d..2525a11 100755 --- a/elvi/wikipedia +++ b/elvi/wikipedia @@ -1,58 +1,57 @@ #!/bin/sh # elvis: wikipedia -- Search the free encyclopedia wikipedia # $Id$ # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_config_hook () { def SURFRAW_wikipedia_language "$SURFRAW_lang" defyn SURFRAW_wikipedia_deletionpedia no def SURFRAW_wikipedia_fallback wikipedia } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Wikipedia online encyclopedia Local options: -language=ISOCODE | -l=ISOCODE Two letter language code (resembles ISO country codes) Default: en Environment: SURFRAW_wikipedia_language, SURFRAW_lang Examples: $w3_argv0 -language=de Richard Stallman EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_wikipedia_language $optarg ;; -l=*) setopt SURFRAW_wikipedia_language $optarg ;; *) return 1 ;; esac return 0 } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" if [ -z "$SURFRAW_wikipedia_language" ]; then SURFRAW_wikipedia_language="en" fi -prefix="https://${SURFRAW_wikipedia_language}.wikipedia.org/wiki/index.php?search=" -suffix="&go=Go" +prefix="https://${SURFRAW_wikipedia_language}.wikipedia.org/w/index.php?search=" if null "$w3_args"; then w3_browse_url "https://${SURFRAW_wikipedia_language}.wikipedia.org/wiki/Main_Page" else escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${prefix}${escaped_args}" fi
JNRowe/surfraw
c692a688c9091238e3a44e7890be24ed540b083e
Use HTTPS for etym elvis
diff --git a/elvi/etym b/elvi/etym index b4f80c9..cb7a340 100755 --- a/elvi/etym +++ b/elvi/etym @@ -1,26 +1,26 @@ #!/bin/sh # jbr20050112 # elvis: etym -- Look up word origins at www.etymonline.com . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Look up word origins at www.etymonline.com Example: etym surf '1685, probably from earlier suffe (1599), of uncertain origin...' EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.etymonline.com/" + w3_browse_url "https://www.etymonline.com/" else escaped_args=$(w3_url_of_arg $w3_args) - w3_browse_url "http://www.etymonline.com/?search=${escaped_args}" + w3_browse_url "https://www.etymonline.com/search?q=${escaped_args}" fi
JNRowe/surfraw
29556dbb527e390923169966c85b6f26917d1d6c
Support HTTPS in OpenSearch helpers
diff --git a/opensearch-discover b/opensearch-discover index 95e071e..737fe29 100755 --- a/opensearch-discover +++ b/opensearch-discover @@ -1,256 +1,274 @@ #!/usr/bin/perl -w # $Id$ # Ian Beckwith <[email protected]> # 20060830 use strict; use vars qw($me $url $title $all $verbose $found $foundnonmatching); $me=($0=~/(?:.*\/)?(.*)/)[0]; use Getopt::Long; $found=0; $foundnonmatching=0; $all=0; $verbose=0; $title=undef; my $quiet=0; my $help=0; GetOptions('quiet' => \$quiet, 'verbose' => \$verbose, 'title=s' => \$title, 'all' => \$all, '1|first' => sub { $all=0; }, 'help' => \$help); if ($help || ($#ARGV!=0)) { usage(); } unless (eval { require LWP::UserAgent; require HTTP::Request; require HTTP::Response; require HTML::Parser; }) { unless($quiet) { print STDERR "$me: Cannot find required modules, are libwww-perl and HTML::Parser installed?\n"; } exit 3; } +# If no protocol, try HTTPS, then HTTP if the first one fails. my $urlstr=shift; -unless($urlstr=~/^http\:\/\//i) -{ - $urlstr="http://".$urlstr; -} - -$url=URI->new($urlstr); - my $ua=LWP::UserAgent->new; +my ($url, $response); +unless($urlstr=~/^https?\:\/\//i) +{ + print STDERR "$me: No protocol in URL, trying HTTPS and then HTTP\n" unless $quiet; + my @testurls=("https://".$urlstr, "http://".$urlstr); + for (@testurls) + { + $url=URI->new($_); + # FIXME: utf8 problem with weblabor.hu on next line + # looks like a LWP::UserAgent problem, reported + # as a comment to existing debian bug #296832 + # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=296832 + $response=$ua->get("$url"); + unless($response->is_success) + { + print STDERR "$me: Error retrieving $url: ",$response->status_line,"\n" unless $quiet; + } + else + { + last; + } + } + exit 1 if not $response->is_success; -# FIXME: utf8 problem with weblabor.hu on next line -# looks like a LWP::UserAgent problem, reported -# as a comment to existing debian bug #296832 -# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=296832 -my $response=$ua->get("$url"); - -unless($response->is_success) +} +else { - unless($quiet) + $url=URI->new($urlstr); + # FIXME: utf8 problem with weblabor.hu on next line + # looks like a LWP::UserAgent problem, reported + # as a comment to existing debian bug #296832 + # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=296832 + $response=$ua->get("$url"); + unless($response->is_success) { - print STDERR "$me: Error retriving $url: ",$response->status_line,"\n"; + print STDERR "$me: Error retrieving $url: ",$response->status_line,"\n" unless $quiet; + exit 1; } - exit 1; } my $parser=HTML::Parser->new(api_version => 3, start_h => [ \&start_handler, "self,tagname,attr" ], end_h => [ \&end_handler, "self,tagname" ], report_tags => [qw(head link)]); $parser->parse($response->decoded_content); unless($found) { unless($quiet) { print STDERR "$me: $url: No "; if($foundnonmatching) { print STDERR "matching "; } print STDERR "OpenSearch link found\n"; } exit 2; } exit 0; sub start_handler { my($self,$tag,$attr)=@_; if(($tag eq 'link') && (exists($attr->{rel})) && (defined($attr->{rel})) && ($attr->{rel} =~/^search$/i) && (exists($attr->{type})) && (defined($attr->{type})) && ($attr->{type} eq 'application/opensearchdescription+xml') && (exists($attr->{href})) && (defined($attr->{href}))) { my $href=URI->new($attr->{href}); my $link=$href->abs($url)->canonical; if(defined($title)) { if((exists($attr->{title})) && (defined($attr->{title}))) { unless($attr->{title} =~/$title/i) { $foundnonmatching=1; return; } } else { # title doesnt exist so can't match $foundnonmatching=1; return; } } $found=1; if(($verbose) && (exists($attr->{title})) && (defined($attr->{title}))) { print $attr->{title},": "; } print $link,"\n"; unless($all) { exit 0; } } } sub end_handler { my($self,$tag)=@_; # stop parsing at </head> if($tag eq 'head') { $self->eof(); } } sub usage { die("Usage: $me [-q] [-v] [-1|-a] [-t TITLE] [-h] URL\n". "Finds and displays OpenSearch links at a given URL.\n". "Options:\n". " -q\t\tQuiet: Don't display errors.\n". " -v\t\tVerbose: display titles with links.\n". " -t TITLE\tOnly display links matching TITLE, a case-insensitive perl regex.\n". " -1\t\tOnly display first (matching) link (default).\n". " -a\t\tDisplay all (matching) links.\n". " -h\t\tThis help.\n". "Return codes:\n". " 0 - Success.\n". " 1 - Cannot load URL.\n". " 2 - Cannot find (matching) OpenSearch link at URL.\n". " 3 - Cannot find required perl modules.\n"); } __END__ =head1 NAME opensearch-discover - Find an OpenSearch link from a given URL. =head1 SYNOPSIS B<opensearch-discover> [B<-q>] [B<-v>] S<[B<-t TITLE>]> S<[B<-1>|B<-a>]> [B<-h>] [I<URL>] =head1 DESCRIPTION Loads the given URL, searches it for a link to an OpenSearch description URL, and prints that URL. =head1 OPTIONS =over 4 =item B<-q>, B<--quiet> Give no output on errors. In this case, consult the exit code to determine errors (See L</DIAGNOSTICS>). =item B<-v>, B<--verbose> Verbose: display titles with links. Combine with B<-a> to see all available searches =item S<B<-t> I<TITLE>>, S<B<--title>=I<TITLE>> Only display links matching B<TITLE>, a case-insensitive perl regular expression. For example, B<-t book> would match I<Book Search>, and B<-t b.*k> would match I<Book Search> or I<Baby Springbok>. =item B<-1>, B<--first> Only display first (matching) link. This is the default. =item B<-a>, B<--all> Display all (matching) links. =item B<-h>, B<--help> Display a short help message. =back =head1 DIAGNOSTICS On success, prints the address of the OpenSearch description file and returns 0. If it cannot load the given URL, it returns 1. If the given URL does not contain a link to an OpenSearch description file, it returns 2. If required perl modules are missing, it returns 3. =head1 DEPENDENCIES Requires modules from libwww-perl and HTML::Parser (Debian package libhtml-parser-perl). =head1 BUGS None known. Please report any found to [email protected] =head1 SEE ALSO L<opensearch(1)>, L<opensearch-genquery(1)>, L<surfraw(1)>, L<WWW::OpenSearch(3pm)>, L<http://www.opensearch.org/> =head1 AUTHOR Ian Beckwith <[email protected]> =head1 COPYRIGHT AND LICENSE Copyright 2006 Ian Beckwith <[email protected]> Licensed under the same terms as surfraw. =cut diff --git a/opensearch-genquery b/opensearch-genquery index 9e0f145..d123c5c 100755 --- a/opensearch-genquery +++ b/opensearch-genquery @@ -1,328 +1,336 @@ #!/usr/bin/perl -w # $Id$ # Ian Beckwith <[email protected]> # 20060830 use Getopt::Long; use strict; use vars qw($me); $me=($0=~/(?:.*\/)?(.*)/)[0]; use vars qw(@wantedtypes $htmlmime $atommime $rssmime); @wantedtypes=(); $htmlmime="text/html"; $atommime="application/atom+xml"; $rssmime ="application/rss+xml"; my $quiet=0; my $count=undef; my $startindex=undef; my $startpage=undef; my $language=undef; my $inputencoding=undef; my $outputencoding=undef; my $help=0; Getopt::Long::Configure("no_ignore_case"); GetOptions("quiet" => \$quiet, "H|html" => sub { push(@wantedtypes,$htmlmime); }, "A|atom" => sub { push(@wantedtypes,$atommime); }, "R|rss" => sub { push(@wantedtypes,$rssmime); }, "count=i" => \$count, "language=s" => \$language, "i|startindex=i" => \$startindex, "p|startpage=i" => \$startpage, "O|outputencoding=s" => \$outputencoding, "I|inputencoding=s" => \$inputencoding, "h|help" => \$help); if ($help || ($#ARGV<1)) { usage(); } -my $url=shift; -my $searchterms=join(' ',@ARGV); - -unless($url=~/^http\:\/\//i) -{ - $url="http://".$url; -} - unless (eval { require WWW::OpenSearch; }) { unless($quiet) { print STDERR "$me: Cannot find WWW::OpenSearch, is it installed?\n"; } exit 4; } +my $url=shift; +my $searchterms=join(' ',@ARGV); + my $engine; -eval { $engine=WWW::OpenSearch->new($url); }; -if($@) +unless($url=~/^https?\:\/\//i) { + print STDERR "$me: No protocol in URL, trying HTTPS and then HTTP\n" unless $quiet; + my @testurls=("https://".$url, "http://".$url); + for my $curr_url (@testurls) + { + eval { $engine=WWW::OpenSearch->new($curr_url); }; + check_engine($curr_url, $curr_url eq $testurls[1]) if $@; + } +} +else +{ + eval { $engine=WWW::OpenSearch->new($url); }; + check_engine($url, 1) if $@; +} +sub check_engine +{ + my ($url, $do_exit)=@_; my $errstr=""; my $exitcode=0; if($@ =~/fetching/i) { $errstr="Error fetching $url"; $exitcode=1; } elsif(($@ =~/parsing/i) || ($@ =~/node\s+should/i)) { $errstr="Error parsing OpenSearch Description at $url"; $exitcode=2; } else { # Some other error, probably because WWW::OpenSearch has changed $errstr=$@; $exitcode=5; } - unless($quiet) - { - print STDERR "$me: $errstr\n"; - } - exit $exitcode; + + print STDERR "$me: $errstr\n" unless $quiet; + exit $exitcode if $do_exit; } my $desc=$engine->description(); # copy options to hash, translating from option name to OpenSearch param my %options=(); $options{searchTerms} = $searchterms; if(defined($count)) { $options{count} = $count; } if(defined($startindex)) { $options{startIndex} = $startindex; } if(defined($startpage)) { $options{startPage} = $startpage; } if(defined($language)) { $options{language} = $language; } if(defined($inputencoding)) { $options{inputEncoding} = $inputencoding; } if(defined($outputencoding)) { $options{outputEncoding} = $outputencoding; } my @urls=(); for (@{$desc->url()}) { if($_->method() =~ /^get$/i) { push(@urls,$_); } } my $besturl=undef; # if no preferred type specified use first Url. if($#wantedtypes<0) { $besturl=$urls[0]; } else # find best match against @wantedtypes { my $bestindex=undef; for my $urlindex (0..$#urls) { for(my $typeindex=0;$typeindex<=$#wantedtypes;$typeindex++) { if($urls[$urlindex]->type() eq $wantedtypes[$typeindex]) { if((!defined($bestindex)) || ($typeindex < $bestindex)) { $bestindex=$typeindex; $besturl=$urls[$urlindex]; } } } } } if(!defined($besturl)) { unless($quiet) { print STDERR "$me: No matching search type found\n"; } exit 3; } print $besturl->prepare_query(\%options),"\n"; exit 0; sub usage { die("Usage: $me [OPTIONS] URL SEARCH TERMS...\n". " Outputs the url of a query generated from an OpenSearch Description\n". " at URL with SEARCH TERMS filled in.\n". "Options:\n". " -q\t\tQuiet: Don't display errors.\n". " -H, -A, -R can be ordered to express response type priority.\n". " -H\t\tRequest HTML response.\n". " -A\t\tRequest Atom response.\n". " -R\t\tRequest RSS response.\n". " Not all sites implement all (or any) of the following options.\n". " Unimplemented options will be silently ignored.\n". " -c COUNT\tRequest COUNT results (OpenSearch param: count).\n". " -i INDEX\tRequest results start at NUM (OpenSearch param: startIndex).\n". " -p PAGENUM\tRequest results page PAGENUM (OpenSearch param: pageIndex).\n". " -l LANG\tRequest results in LANG (2-letter ISO country code) (OpenSearch param: language).\n". " -I ENC\t\tSpecify search terms are encoded in ENC (OpenSearch param: inputEncoding).\n". " -O ENC\t\tRequest results encoded in ENC (OpenSearch param: outputEncoding).\n". "Return codes:\n". " 0 - Success.\n". " 1 - Error fetching OpenSearch Description URL.\n". " 2 - Error parsing OpenSearch Description.\n". " 3 - No matching search type found.\n". " 4 - Cannot find perl module WWW::OpenSearch.\n". " 5 - Unhandled error from WWW::OpenSearch.\n"); } __END__ =head1 NAME opensearch-genquery - Output the URL of a query generated from an OpenSearch Description =head1 SYNOPSIS B<opensearch-genquery> [B<-q>] [B<-H>] [B<-A>] [B<-R>] S<[B<-c> I<COUNT>]> S<[B<-i> I<INDEX>]> S<[B<-p> I<PAGENUM>]> S<[B<-l> I<LANG>]> S<[B<-O> I<ENC>]> S<[B<-I> I<ENC>]> I<URL> S<I<SEARCH TERMS...>> =head1 DESCRIPTION Output the URL of a query generated from an OpenSearch Description file at I<URL>, with the specified S<I<SEARCH TERMS>> and other options filled in. If multiple search types are available, B<-H>, B<-A> and B<-R> can be used to specify which type is wanted. For example, S<B<-A -R>> can be used to request an Atom response, or failing that fall back to RSS. By default the first URL found in the description file is used. Not all web sites implement all (or any) of the optional OpenSearch parameters. When used with those sites, the corresponding options will be silently ignored. =head1 OPTIONS =over 4 =item B<-q> Give no output on errors. In this case, consult the exit code to determine errors (See L</DIAGNOSTICS>). =item B<-H> Request HTML response. =item B<-A> Request Atom response. =item B<-R> Request RSS response. B<-H>, B<-A>, and B<-R> can be combined to express response type priority and specify fallback types. =item B<-c COUNT>, B<--count=COUNT> Request COUNT results. OpenSearch parameter: I<count>. =item B<-i INDEX>, B<--startindex=INDEX> Request results start at offset NUM. OpenSearch parameter: I<startIndex>. =item B<-p PAGENUM>, B<--startpage=PAGENUM> Request results page PAGENUM. OpenSearch parameter: I<pageIndex>. =item B<-l LANG>, B<--language=LANG> Request results in LANG. LANG should be a 2-letter ISO country code (e.g. B<en> or B<de>). OpenSearch parameter: I<language>. =item B<-O ENC>, B<--outputencoding=ENC> Request results encoded in ENC (default: UTF-8). OpenSearch parameter: I<outputEncoding>. =item B<-I ENC>, B<--inputencoding=ENC> Specify search terms are encoded in ENC (default: UTF-8). OpenSearch parameter: I<inputEncoding>. =item B<-h>, B<--help> Show a short help message. =item B<--> End of options. =back =head1 DIAGNOSTICS The exit code can be consulted to determine errors, as follows: =over 4 =item B<0> - Success. =item B<1> - Error fetching OpenSearch Description URL. =item B<2> - Error parsing OpenSearch Description. =item B<3> - No matching search type found. =item B<4> - Cannot find perl module WWW::OpenSearch. =item B<5> - Unhandled error from WWW::OpenSearch. =back =head1 DEPENDENCIES Requires the module WWW::OpenSearch (Debian package libwww-opensearch-perl). =head1 BUGS Only supports GET queries. Please report any bugs found to [email protected] =head1 SEE ALSO L<opensearch(1)>, L<opensearch-discover(1)>, L<surfraw(1)>, L<WWW::OpenSearch(3pm)>, L<http://www.opensearch.org/> =head1 AUTHOR Ian Beckwith <[email protected]> =head1 COPYRIGHT AND LICENSE Copyright 2006 Ian Beckwith <[email protected]> Licensed under the same terms as surfraw. =cut
JNRowe/surfraw
1ff34153d221e006ce85a53e301db1f72d39cf89
Fix - test: too many arguments
diff --git a/AUTHORS b/AUTHORS index d2f7ceb..a8d2213 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,171 +1,174 @@ AUTHORS Julian Assange <[email protected]> original author Christian Surchi <[email protected]> original debian maintainer elvi: debcontents, debbugs, debpackages Ian Beckwith <[email protected]> current debian maintainer elvi: alioth, bbcnews, bugzilla, deblists, freedb, imdb, scpan, codesearch, debwiki, lastfm, musicbrainz, opensearch, scholar, ctan, fsfdir, gutenberg, wayback, dmoz, w3html, w3link, w3css, w3rdf, debpts, rfc, lsm, finkpkg, rpmsearch, macports, debpkghome, debvcsbrowse, scroogle, scirus, scitopia, worldwidescience, debcodesearch, jquery, mdn, mysqldoc, pgdoc, oraclesearch, S, yacy, gmane plus various tweaks/bugfixes/features. Moritz Muehlenhoff <[email protected]> elvi: debsec, ebay, leodict, wikipedia, sharereactor, pgpkeys, happypenguin plus various patches/maintenance. Thomas Smith <[email protected]> Bugfixes, uploading. Stephen Stafford <[email protected]> Bug fixes Kevin Kreamer <[email protected]> Bug fixes Christian Weisgerber <[email protected]> elvi: fast, thesaurus, webster Jason Harris <[email protected]> elvi: freebsd, openbsd, filesearching, ftpfind Ruben Pollan <[email protected]> elvi: rae Ian Broadfoot <[email protected]> elvi: yubnub James Rowe <[email protected]> plus useful patches/maintenance. Aparna Jaitly <[email protected]> elvi: ixquick Justin B. Rye <[email protected]> elvi: cia, deblogs, etym, foldoc plus useful patches. Patroklos Argyroudis <[email protected]> elvi: discogs Simon Ernst <[email protected]> elvi: archpkg Ivy Foster <[email protected]> elvi: bookfinder, bugmenot plus various patches/maintenance Sumant Oemrawsingh <[email protected]> elvi: cliki, l1sp, mathworth, mininova, youtube plus patches, including the uzbl examples. Sadako <[email protected]> imdb fixes tczy <[email protected]> elvi: bing Simone Fittabile <[email protected]> elvi: acronym, gcache, jamendo plus patches. Micah Anderson <[email protected]> various patches René Reigel <[email protected]> elvi: aur J.R. Mauro <[email protected]> elvi: urban, piratebay, genportage Wim van Hoydonck <[email protected]> elvi: ntrs, springer, sc John Briggs <[email protected]> patch to google John Gruenenfelder <[email protected]> elvi: arxiv csh patch James TD Smith <[email protected]> elvi: javasun google country-specific options Charles Twardy <[email protected]> fixed cia Uspenskiy Andrey <[email protected]> elvi: yandex Jameson Rollins <[email protected]> elvi: ads plus tweaks. Jakob <[email protected]> elvi: pasearch Kyle Isom <[email protected]> elvi: cablesearch, duckduckgo, openports, wolfram plus various fixes/maintenance. Jason Ryan <[email protected]> elvi: archwiki, deli, github, stack, pin plus various fixes/maintenance Sara Fauzia <[email protected]> archpkg fix. Thomas Zervogiannis <[email protected]> Searchable bookmarks. Paulo Almeida <[email protected]> elvi: priberam Shain Singh <[email protected]> elvi: cisco, f5 Manolo Martínez <[email protected]> examples: elinks integration (hooks.lua) Jon Yamokoski <[email protected]> elvi: phpdoc Lucas Hoffmann <l-m-h at web.de> elvi: commandlinefu ng0 <[email protected]> elvi: searx +Sascha <[email protected]> + Bug fixes + THANKS TO Brian Nelson <[email protected]> Christian Garbs <[email protected]> Hector Blanco <[email protected]> Jeff Bailey <[email protected]> Mark W. Eichin <[email protected]> Teófilo Ruiz Suárez <[email protected]> Maru Dubshinki <[email protected]> Matt Kraai <[email protected]> Brian Mcdonald <[email protected]> Carl Fredrik Hammar <[email protected]> Andy Valencia <[email protected]> Philip Armstrong <[email protected]> Dan Jacobson <[email protected]> Sunil Nimmagadda <[email protected]> Michel <[email protected]> Nikos Apostolakis <[email protected]> Facundo Aguirre <[email protected]> Raphael Geissert <[email protected]> If we've missed anyone, let us know. diff --git a/ChangeLog b/ChangeLog index 794c030..0d0eaf6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,512 +1,516 @@ +2020-12-23 Sascha <[email protected]> + + * Fix - test: too many arguments + 2018-10-09 Dmitry Bogatov <[email protected]> * new elvi: dockerhub 2018-01-13 Jason Ryan <[email protected]> * Bump version to 2.3.0 * Select Perl version at buildtime (Mark Meyer) * Remove lynx-cur (closes #882286) * Packages the https elvi 2017-06-07 Jason Ryan <[email protected]> * new elvi: wiktionary 2017-07-14 Jason Ryan <[email protected]> * Moved all elvi to https * Removed elvi that don't support https: - cablesearch - dmoz - openports - opensearch - pasearch - rhyme - rpmsearch - scicom - scirus - wetandwild - yacy - yubnub 2015-09-13 Kyle Isom <[email protected]> * use awk instead of sed for listing elvi This provides better cross-platform behaviour. 2015-08-23 Jason Ryan <[email protected]> * new elvi: searx 2014-09-20 Lucas Hoffmann <l-m-h at web.de> * new elvi: commandlinefu 2104-06-04 Jason Ryan <[email protected]> * new elvi: nlab 2013-12-10 Ian Beckwith <[email protected]> * yandex: disabled test: redirects to captcha when used with LWP. * Fix make distcheck: remove last traces of codesearch and scitopia. 2013-12-09 Ian Beckwith <[email protected]> * deja: disable tests, google groups now requires javascript. * gmane: fix test. * codesearch: removed, service shut down. * scitopia: removed, service shut down. * scicom: down, status unknown, made note in NEWS. 2013-12-08 Ian Beckwith <[email protected]> * new elvi: gmane * openbsd -mail: use gmane (directly, not via gmane elvi) * fix tests: ads, pgdoc, pin, yacy 2013-10-27 Ian Beckwith <[email protected]> * surfraw.IN: w3_custom_search_google: don't give full path to surfraw. * pgdoc, wayback: fixed tests. 2013-10-20 Ian Beckwith <[email protected]> * new elvi: yacy: search using yacy p2p search. -S searches ScienceNet, a yacy-based science search engine. * rae: fix url, remove -tipo option (no longer supported), disable test as there is now gratuitous javascript. 2013-10-06 Ian Beckwith <[email protected]> * Replaced phpdoc with version posted back in 2011 by Jon Yamokoski <[email protected]> Thanks, and apologies for missing it! * S: add test. * Include debian packaging in upstream tarball. 2013-10-05 Ian Beckwith <[email protected]> * ask, cisco: fix elvi. * new elvi: + oraclesearch - Replaces removed sunonesearch <sigh>. + S - search using w3_custom_search. * google: -g for groups clashed with -g for graphical browser. Invoke groups with -G, -gr, -groups or -search=groups. * mdn: site invokes google custom search via gratuitous javascript, so switch to w3_custom_search. * alioth: changed test to SKIP:, works OK but won't talk to LWP, hence test breaks. * discogs, openbsd: fixed tests. * mdn, mysqldoc, pgdoc, phpdoc: added tests. * w3_custom_search: + document in README. + remove documentation for ixquick support. It still works(ish), but doesn't support enough features to support (eg) mysqldoc -v=. + add -custom-search= commandline option. * updated copyright years to 2013. 2013-09-30 Ian Beckwith <[email protected]> * new elvi: mdn, mysqldoc, pgdoc, phpdoc * new function: w3_custom_search Is used by elvi that use a generic search engine with (eg) site: or inurl: to narrow down the search. Pass it -s=site -u=url for site: and inurl: args plus the quoted search args * new environment variable: SURFRAW_customsearch_provider to set provider used by w3_custom_search can be set to: google, duckduckgo or ixquick. Currently affects: mysqldoc, netbsd(*), openbsd(*), pgdoc, phpdoc, mysqldoc. (*) = only used by some options of elvi. * new internal variable w3_shquoted_args, contains arguments 'quoted' 'like this' for passing to w3_custom_search * Fixed url-encoding for '\' 2013-05-07 Ian Beckwith <[email protected]> * new elvi: jquery 2013-05-04 Ian Beckwith <[email protected]> * bump version to 2.2.9 * rae: fixed, at least as far as the test passing. Could really do with some love from someone who actually speaks spanish. * ctan: fixed search, updated options. Note command-line options have changed. * genportage: switch to gpo.zugaina.org * debcodesearch: new (trivial) elvi for codesearch.debian.net * jamendo: fix url, disable test (search now javascript) * deli: fix url; remove options; disable test (search now javascript) 2013-04-28 Ian Beckwith <[email protected]> * musicbrainz: fixed mbid search. * springer: fixed test. 2013-04-27 Ian Beckwith <[email protected]> * javasun: fixed test. 2013-04-24 Ian Beckwith <[email protected]> * Rewrote deblists for new xapian search. + -author, -lists, -lang no longer supported. + added -ml and -mv to show message id links and list view. * Removed happypenguin. Currently defunct and they are talking about a rewrite, so when it is back it will need fixing anyway. 2012-10-22 Ian Beckwith <[email protected]> * Fixed elvi: cisco, slashdot, slinuxdoc. * Removed elvi: scroogle (site gone). * Fixed tests: acronym, bbcnews, bugzilla, cisco, cite[1], currency, discogs, excite, fsfdir, gcache, github, imdb, ixquick, lastfm, leodict, openbsd[2], scholar. * test/Makefile.am: Added missing tests to EXTRA_DIST 2012-06-28 Manolo Martínez <[email protected]> * examples/hooks.lua: Added elinks integration script 2012-06-28 Ivy Foster <[email protected]> * Further simplified searchable bookmarks 2012-06-28 Thomas Zervogiannis <[email protected]> * Simplified searchable bookmarks 2012-06-27 Ivy Foster <[email protected]> * Fixed arg parsing in searchable bookmarks * New variable: SURFRAW_bookmark_search_elvis + When using searchable bookmarks, if all else fails run this elvis. Defaults to google * Updated manual to reflect changes to bookmarks * duckduckgo: Removed -p option. -safe still works. + Prevents clobbering global option -p[rint]. 2012-06-27 Thomas Zervogiannis <[email protected]> * Added searchable bookmarks + Bookmarks can now be searchable by adding '%s' to the url string. 2012-06-01 Jason Ryan <[email protected]> * New elvi: github (search github.com) 2012-03-17 Ivy Foster <[email protected]> * Fix a typo in duckduckgo code. 2012-03-17 Ivy Foster <[email protected]> * Keep duckduckgo's -l[ucky] from clobbering -lh 2012-01-10 Ivy Foster <[email protected]> * aur: now uses HTTPS by default + On the AUR, connecting via HTTP disables login. + Added switch -no-https to enable connection via plain HTTP 2011-10-10 Ian Beckwith <[email protected]> * surfraw.IN: test_elvi(): tweak sed regex * add tests for f5, cisco and pin. 2011-10-10 Shain Singh <[email protected]> * New elvi: f5, cisco 2011-10-10 Jason Ryan <[email protected]> * New elvi: pin (search pinboard.in). 2011-09-09 Kyle Isom <[email protected]> * New elvi: wolfram - query Wolfram Alpha * Author: Kyle Isom <[email protected]> * Added test for wolfram. 2011-08-09 Ian Beckwith <[email protected]> * New elvi: priberam - search Portuguese dictionary. Author: Paulo Almeida <[email protected]> * Added test for priberam. 2011-07-11 Ian Beckwith <[email protected]> * netbsd: fix normal & mail search. google custom searches were complaining I was a bot, so I switched to normal google searches with site:{mail-index,}.netbsd.org. * cia: fix search URL 2011-06-17 Ian Beckwith <[email protected]> * arxiv: fix -scope=author with single-word queries. Thanks to Nikos Apostolakis. * btw, note about entry below, netbsd make *does* support '$<', but only in suffix rules. 2011-06-16 Ian Beckwith <[email protected]> * Fix more make(1) portability problems. Either I am horribly confused or netbsd make (or at least pmake in debian) doesn't support '$<'. Switched to '$?'. * Also switched submit-lsm rule to '$?'. Thanks to Kyle Isom. * Removed long-obsolete commented-out sourceforge upload rules. 2011-06-15 Ian Beckwith <[email protected]> * scitopia, worldwidescience: fixed URLs. * Fixed make portability problems. We cannot portably combine single suffix rules (foo.IN->foo) and separated dependencies so we have to explicitly specify all the .IN rules. The solution we used for this until now was specific to GNU make. * Removed Makefile.include, no longer used. * './configure --enable-opensearch' now only controls installation of the (direct) dependencies for opensearch, not opensearch itself, as opensearch now falls back to using a remote reflector if opensearch-discover(1) and opensearch-genquery(1) aren't found. * yandex: fix test. 2011-06-14 Ian Beckwith <[email protected]> * musicbrainz, codesearch, rpmsearch: Fixed URLs, options and tests. The sites have all changed significantly which means both new options and no-longer-supported options. Codesearch has gone all ajaxy, so I've implemented the options via the search string, e.g. adding " package:foo". Disabled codesearch.test, as it now needs javascript. Codesearch on both google.com and google.co.uk was acting up, so I've pointed it at google.fr. * Removed filesearching elvi, it now requires a 'Referer:' header to work. There is no browser-portable way to specify a 'Refer[r]er:' header, plus we should probably take it as a hint. * Tweaked debian packaging. * Updated NEWS. 2011-06-13 Ian Beckwith <[email protected]> * w3link: fixed URLs. 2011-06-10 Ian Beckwith <[email protected]> * Fixed ctan. Option -doc has been replaced by -id. Options are no longer mutually exclusive, you can now do (eg) ctan -d -i -n texlive. 2011-06-09 Ian Beckwith <[email protected]> * fixed tests: debwiki, ntrs, wayback. 2011-06-07 Ian Beckwith <[email protected]> * Default to surfraw_graphical_remote=no, as chromium doesn't support "-remote openURL". 2011-05-31 Jason Ryan <[email protected]> * Add options to archpkg. 2011-05-12 Sara Fauzia <[email protected]> * Fix archpkg URL. 2011-05-12 Ian Beckwith <[email protected]> * surfraw.IN: + if elvi doesn't exist, send usage to stderr not stdout. + bookmark names: do exact match not substring match. * Added tests for archwiki, deli & stack. * README: + added INTEGRATION section on uzbl and pentadactyl. + upcased section headings for clarity. 2011-05-12 Jason Ryan <[email protected]> * New elvi: + archwiki: search the arch wiki. + deli: search delicious.com. + stack: search stackoverflow.com and friends. 2011-03-21 Ian Beckwith <[email protected]> * google: Added -safe=default|off|moderate|strict option for Safe Search. 2011-03-21 Ivy Foster <[email protected]> * Added Google Translate to elvi/translate. 2011-03-03 Ian Beckwith <[email protected]> * opensearch: new option -r, uses redirector at http://erislabs.net/ianb/webtools/opensearch/ instead of calling opensearch-discover and opensearch-genquery. -r is selected automatically if those tools are not installed. This enables us to ship opensearch in the main surfraw package and it still functions if the dependencies are not installed. See debian/changelog. * wikipedia: new options: + -d, uses a redirector at http://erislabs.net/ianb/webtools/wpdp/ This redirector searches for a page with that name at wikipedia. If not found, it searches deletionpedia, if not found there it falls back to a normal wikipedia search. + -f=w|d, -fallback=wikipedia|deletionpedia Implies -d. If page not found at either wikipedia or deletionpedia, whether to fallback to wikipedia search or deletionpedia search. * google: + support video, maps and news. + new options -i, -v, -m, -n, shortcuts for -search={images,videos,maps,news}. * debcontents, debpackages: update docs for new arches and distributions. * bugzilla: + fix url so it works with redhat & eclipse bugzillas too. + enable -s=redhat. * ixquick, w3css: fix tests. * opensearch, wikipedia: add redirector tests. 2011-02-20 Ian Beckwith <[email protected]> * New elvi: bugzilla - searches various bugzillas, defaults to kernel. * pgpkeys: add more options, support more keyservers, default to sks-keyservers.net. * bump version to 2.2.8. * test/Makefile.am: add cablesearch.test. 2011-02-19 Ian Beckwith <[email protected]> * lastfm: fix url to avoid a redirect that mangled args with spaces. * debbugs: add -s as an alias for -search=src. * surfraw.IN: (finally) update copyright year to 2011. * remove traces of port elvi from build system. 2011-02-09 Kyle Isom <[email protected]> * fix a number of tests to match current site formats 2011-01-12 Kyle Isom <[email protected]> * New elvi: + cablesearch - search wikileaks cables + duckduckgo - replace with better implementation + openports - search openbsd ports 2010-12-04 Jakob <[email protected]> * new elvis: pasearch. 2010-12-08 Ian Beckwith <[email protected]> * arxiv: Thanks to MT <[email protected]> for patch that fixes: 1. Search queries with more than two terms would fail, e.g. 'supermassive black hole'. 2. Full text search was broken, it works now. 3. Enhancement: quoting the query now does an exact string match. 2010-10-29 Ian Beckwith <[email protected]> * wayback: advanced search is broken, rip out all options and use basic search. * w3_url_escape: add /g to '/'->'%2F' replacement. * uzbl_load_url_from_surfraw: use @AWK@ to pick up ./configure's choice of awk implementation. 2010-10-28 Ian Beckwith <[email protected]> * Support -local-help, --local-help or -lh to get elvi-specific help without displaying the global options. This works for all elvi and the main surfraw script. * google, duckduckgo, opensearch, wayback: tweak overbroad option parsing so it doesn't interfere with -lh. * Support -h as a synonym for -help. 2010-10-25 Ian Beckwith <[email protected]> * new elvi: scirus, scitopia, worldwidescience. * yahoo: reduced query string to just p and n options. * openbsd: support -misc and -tech. Thanks to Sunil Nimmagadda for the patch. * removed cddb: gracenote made the "hard decision" to remove the website search. sigh. * removed altavista: is now just a front-end to yahoo. * removed fast: another yahoo front-end. * imdb: fix test. * javasun: oracleized URLs. * w3link: fixed URL. 2010-08-22 Jameson Rollins <[email protected]> * surfraw.IN: Improve listing of elvi. 2010-08-20 James Rowe <[email protected]> * new elvi: ads. Thanks to Jameson Rollins. 2010-07-02 Ian Beckwith <[email protected]> * new elvi: yandex. Thanks to Uspenskiy Andrey. 2010-05-06 Ian Beckwith <[email protected]> * uzbl_load_url_from_surfraw: fix menu. Thanks to Sumant Oemrawsingh. * Fixed tests: deblists google openbsd. 2010-04-28 Ian Beckwith <[email protected]> * configure.in: test for google-chrome, opera and links2. 2010-04-22 Ian Beckwith <[email protected]> * debwiki: remove -w, Debian Women wiki is now being merged into main wiki. Thanks to Simone Fittabile. * debwiki.test: stop testing -w option. * surfraw.IN: change an awk to @AWK@. 2010-04-21 Ian Beckwith <[email protected]> * New elvi: jamendo - Search Jamendo: free music with Creative Commons licenses (www.jamendo.com). Thanks to Simone Fittabile. * wikipedia, ixquick: Support https. Thanks to Simone Fittabile. * wikipedia: tweak Simone's patch to support https for start page and document the SURFRAW_wikipedia_ssl variable. * ixquick: add -nossl option. * javasun.test: revert to previous test, works again. 2010-04-19 James Rowe <[email protected]> * genpkg: removed, use genportage. 2010-04-16 Ian Beckwith <[email protected]> * New elvi: + scroogle: Search Google anonymously via www.scroogle.org. + duckduckgo: Search the web via duckduckgo.com. * Fix tests: excite, javasun, musicbrainz, yahoo. 2010-03-03 James Rowe <[email protected]> * bookfinder: fix ISBN search test. 2010-03-01 Ian Beckwith <[email protected]> * Removed autotools-generated files from git repo diff --git a/surfraw.IN b/surfraw.IN index 8569e1a..da01945 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,694 +1,694 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=$(basename "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default conf="@sysconfdir@/xdg/surfraw/$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value="\"\$${1}\"" case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value="\"\$${1}\"" # Do nothing if already have a value. test -z "$value" && eval ${1}="\"$2\"" return 0 } defyn () { def "$@" yesno "$1" } setopt () { eval value="\"\$${1}\"" eval ${1}="\"$2\"" } setoptyn () { setopt "$@" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi*) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh|-\? ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else - if test $SURFRAW_browser_args = "none"; then + if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi - if test $SURFRAW_browser_args = "none"; then + if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else - if test $SURFRAW_browser_args = "none"; then + if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then w3_parse_option "$arg" fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="$(quote "$arg")" unquoted_opts="$arg" else opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then exec sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then exec sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=$(bookmark_lookup $elvi) if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else echo "$(basename $0): $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
b914831a85034501b096c384ef5db4edf667c829
Add test to Yahoo Finance elvi
diff --git a/test/yahoofinance.test b/test/yahoofinance.test new file mode 100644 index 0000000..6917d89 --- /dev/null +++ b/test/yahoofinance.test @@ -0,0 +1,2 @@ +yahoofinance spy +SPDR S&P 500 ETF Trust (SPY)
JNRowe/surfraw
f2b499eba6eb37d40db580bd3ea1ae513cb0dba6
Add elvi for Yahoo Finance
diff --git a/elvi/Makefile.am b/elvi/Makefile.am index a0a9bda..95e244c 100644 --- a/elvi/Makefile.am +++ b/elvi/Makefile.am @@ -1,121 +1,122 @@ # $Id$ elvidir=$(ELVIDIR) dist_elvi_SCRIPTS = \ S \ W \ acronym \ ads \ alioth \ amazon \ archpkg \ archwiki \ arxiv \ ask \ aur \ austlii \ bing \ bbcnews \ bookfinder \ bugmenot \ bugzilla \ cia \ cisco \ cite \ cliki \ cnn \ comlaw \ commandlinefu \ ctan \ currency \ cve \ debbugs \ debcodesearch \ debcontents \ deblists \ deblogs \ debpackages \ debpkghome \ debpts \ debsec \ debvcsbrowse \ debwiki \ deja \ discogs \ dockerhub \ duckduckgo \ ebay \ etym \ excite \ f5 \ foldoc \ finkpkg \ freebsd \ freedb \ freshmeat \ fsfdir \ gcache \ genbugs \ genportage \ github \ gmane \ google \ gutenberg \ imdb \ ixquick \ jamendo \ javasun \ jquery \ l1sp \ lastfm \ leodict \ lsm \ macports \ mathworld \ mdn \ mininova \ musicbrainz \ mysqldoc \ netbsd \ nlab \ ntrs \ openbsd \ oraclesearch \ pgdoc \ pgpkeys \ phpdoc \ pin \ piratebay \ priberam \ pubmed \ rae \ rfc \ scholar \ scpan \ searx \ slashdot \ slinuxdoc \ sourceforge \ springer \ stack \ stockquote \ thesaurus \ translate \ urban \ w3css \ w3html \ w3link \ w3rdf \ wayback \ webster \ wikipedia \ wiktionary \ woffle \ wolfram \ worldwidescience \ yahoo \ + yahoofinance \ yandex \ youtube uninstall-local: -rmdir $(DESTDIR)$(PREFIX)/$(ELVIDIR) diff --git a/elvi/yahoofinance b/elvi/yahoofinance new file mode 100644 index 0000000..ef0e34a --- /dev/null +++ b/elvi/yahoofinance @@ -0,0 +1,38 @@ +#!/bin/sh +# $Id$ +# elvis: yahoofinance -- Search Yahoo Finance (www.finance.yahoo.com) +. surfraw || exit 1 + +w3_config_hook () { +def SURFRAW_yahoofinance_results $SURFRAW_results +} + +w3_usage_hook () { + cat <<EOF +Usage: $w3_argv0 [options] [search words]... +Description: + Surfraw search Yahoo Finance data (www.finance.yahoo.com) + Environment: SURFRAW_yahoofinance_results +EOF + w3_global_usage +} + +w3_parse_option_hook () { + opt="$1" + optarg="$2" + case "$opt" in + -results=*) setopt SURFRAW_yahoofinance_results $optarg ;; + *) return 1 ;; + esac + return 0 +} + +w3_config +w3_parse_args "$@" +# w3_args now contains a list of arguments +if test -z "$w3_args"; then + w3_browse_url "https://www.finance.yahoo.com/" +else + escaped_args=$(w3_url_of_arg $w3_args) + w3_browse_ul "https://finance.yahoo.com/quote/${escaped_args}" +fi
JNRowe/surfraw
469f342dd93f5ae75b4b7b2b317d66ee8fbb3bb9
Extraneous 'to'
diff --git a/README b/README index 07c73dc..ba842b3 100644 --- a/README +++ b/README @@ -1,346 +1,346 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Home Page: https://gitlab.com/surfraw/Surfraw ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web New: https://gitlab.com/surfraw/Surfraw Old: http://surfraw.alioth.debian.org Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS - Surfraw now supports bookmarks. To add a bookmark, add it to to the + Surfraw now supports bookmarks. To add a bookmark, add it to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/stack -u -s=vote shell OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) discogs -- Search the Discogs database of music information (www.discogs.com) dockerhub -- Search for Docker images (https://hub.docker.com) duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) oraclesearch -- Search an OpenSearch-enabled website pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) scholar -- Search Google Scholar (scholar.google.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) wikipedia -- Search the free encyclopedia wikipedia wiktionary -- Search the free multilingual dictionary (wiktionary.org) woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) All elvi have useful low calorie help, for example: sr bbcnews -help Usage: bbcnews [options] [search words]... Description: Surfraw search BBC News (news.bbc.co.uk) Local options: -scope=world | uk Search world or uk news Default: world Environment: SURFRAW_bbcnews_scope If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________
JNRowe/surfraw
291b476598e90be3b21effd12a34556b199f81f4
Use datadir and `sr` when installing bash completions
diff --git a/Makefile.am b/Makefile.am index 7754cd1..2db60e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,140 +1,146 @@ SUBDIRS = elvi test examples bin_SCRIPTS = surfraw surfraw-update-path if OPENSEARCH dist_bin_SCRIPTS = opensearch-discover opensearch-genquery endif devel_extra = banner prebuild if BASHCOMPLETIONS noinst_DATA = surfraw.bookmarks else noinst_DATA = surfraw.bookmarks surfraw-bash-completion endif man_MANS = surfraw-update-path.1 surfraw.1 elvi.1sr if OPENSEARCH man_MANS += opensearch-discover.1 opensearch-genquery.1 endif debian_extra = debian/NEWS debian/README.Debian debian/changelog debian/compat debian/control \ debian/copyright debian/docs debian/postrm debian/rules debian/source/format \ debian/surfraw-extra.files debian/surfraw-extra.install debian/watch EXTRA_DIST = surfraw.lsm.in surfraw.IN surfraw-update-path.IN\ surfraw.spec.in aclocal.m4 HACKING STYLE \ surfraw.1.IN elvi.1sr.IN surfraw.bookmarks links.IN \ surfraw-bash-completion.IN surfraw.conf.IN \ $(devel_extra) $(debian_extra) CLEANFILES = surfraw surfraw-update-path surfraw-update-path.1 surfraw.spec surfraw.lsm \ surfraw.1 elvi.1sr links surfraw-bash-completion surfraw.conf surfraw.1 \ elvi.1sr opensearch-discover.1 opensearch-genquery.1 BUILT_SOURCES = surfraw.conf # we cannot portably combine single suffix rules and separated dependencies # so we have to explicitly specify all the .IN rules surfraw: surfraw.IN -rm -f $@ [email protected] sed -e 's,@VERSION\@,${VERSION},g; '\ -e 's,@ELVIDIR\@,${ELVIDIR},g; '\ -e 's,@AWK\@,${AWK},g; '\ -e 's,@PERL\@,${PERL},g; '\ -e 's,@sysconfdir\@,${sysconfdir},g ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw.conf: surfraw.conf.IN -rm -f $@ [email protected] sed -e 's,@prefix\@,${prefix},g; '\ -e 's,@TEXTBROWSER\@,${TEXTBROWSER},g; '\ -e 's,@GRAPHICALBROWSER\@,${GRAPHICALBROWSER},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-update-path: surfraw-update-path.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-bash-completion: surfraw-bash-completion.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ elvi.1sr: elvi.1sr.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw.1: surfraw.1.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; '\ -e 's,@sysconfdir\@,${sysconfdir},g' $? > [email protected] chmod +x [email protected] mv [email protected] $@ links: links.IN -rm -f $@ [email protected] sed -e 's,@mandir\@,${mandir},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-update-path.1: surfraw-update-path -rm -f $@ pod2man $? > $@ opensearch-discover.1: opensearch-discover -rm -f $@ pod2man $? > $@ opensearch-genquery.1: opensearch-genquery -rm -f $@ pod2man $? > $@ install-data-hook: links surfraw-bash-completion chmod -x surfraw.conf elvi.1sr surfraw.1 mkdir -p $(DESTDIR)@sysconfdir@/xdg/surfraw cp surfraw.conf $(DESTDIR)@sysconfdir@/xdg/surfraw/conf cp $(top_srcdir)/surfraw.bookmarks $(DESTDIR)@sysconfdir@/xdg/surfraw/bookmarks while read target link ;\ do \ ln -sf $$target $(DESTDIR)/$$link ;\ done < links if INSTALLSR ln -sf surfraw $(DESTDIR)/@bindir@/sr ln -sf surfraw.1.gz $(DESTDIR)/@mandir@/man1/sr.1.gz endif if BASHCOMPLETIONS - mkdir -p $(DESTDIR)@sysconfdir@/bash_completion.d - @cp $(top_srcdir)/surfraw-bash-completion $(DESTDIR)@sysconfdir@/bash_completion.d/surfraw -endif + mkdir -p $(DESTDIR)@datadir@/bash-completion/completions + @cp $(top_srcdir)/surfraw-bash-completion $(DESTDIR)@datadir@/bash-completion/completions/surfraw +if INSTALLSR + @ln -sf $(DESTDIR)@datadir@/bash-completion/completions/surfraw $(DESTDIR)@datadir@/bash-completion/completions/sr +endif # INSTALLSR +endif # BASHCOMPLETIONS uninstall-local: links -rm -f $(DESTDIR)@sysconfdir@/xdg/surfraw/conf -rm -f $(DESTDIR)@sysconfdir@/xdg/surfraw/bookmarks rmdir $(DESTDIR)@sysconfdir@/xdg/surfraw 2>/dev/null rmdir $(DESTDIR)@sysconfdir@/xdg 2>/dev/null while read target link ;\ do \ rm -f $(DESTDIR)/$$link ;\ done < links if INSTALLSR rm -f $(DESTDIR)/@bindir@/sr rm -f $(DESTDIR)/@mandir@/man1/sr.1.gz endif if BASHCOMPLETIONS - -rm -f $(DESTDIR)@sysconfdir@/bash_completion.d/surfraw -endif + -rm -f $(DESTDIR)@datadir@/bash-completion/completions/surfraw +if INSTALLSR + -rm -f $(DESTDIR)@datadir@/bash-completion/completions/sr +endif # INSTALLSR +endif # BASHCOMPLETIONS submit-lsm: surfraw.lsm mail -s add [email protected] < $? test: all surfraw.conf make -C test test .PHONY: test
JNRowe/surfraw
459f222d4eb225fef90babfb2986915f164fc088
Reinstate bash completion
diff --git a/Makefile.am b/Makefile.am index 0141193..7754cd1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,129 +1,140 @@ SUBDIRS = elvi test examples bin_SCRIPTS = surfraw surfraw-update-path if OPENSEARCH dist_bin_SCRIPTS = opensearch-discover opensearch-genquery endif devel_extra = banner prebuild -noinst_DATA = surfraw-bash-completion surfraw.bookmarks +if BASHCOMPLETIONS +noinst_DATA = surfraw.bookmarks +else +noinst_DATA = surfraw.bookmarks surfraw-bash-completion +endif man_MANS = surfraw-update-path.1 surfraw.1 elvi.1sr if OPENSEARCH man_MANS += opensearch-discover.1 opensearch-genquery.1 endif debian_extra = debian/NEWS debian/README.Debian debian/changelog debian/compat debian/control \ debian/copyright debian/docs debian/postrm debian/rules debian/source/format \ debian/surfraw-extra.files debian/surfraw-extra.install debian/watch EXTRA_DIST = surfraw.lsm.in surfraw.IN surfraw-update-path.IN\ surfraw.spec.in aclocal.m4 HACKING STYLE \ surfraw.1.IN elvi.1sr.IN surfraw.bookmarks links.IN \ surfraw-bash-completion.IN surfraw.conf.IN \ $(devel_extra) $(debian_extra) CLEANFILES = surfraw surfraw-update-path surfraw-update-path.1 surfraw.spec surfraw.lsm \ surfraw.1 elvi.1sr links surfraw-bash-completion surfraw.conf surfraw.1 \ elvi.1sr opensearch-discover.1 opensearch-genquery.1 BUILT_SOURCES = surfraw.conf # we cannot portably combine single suffix rules and separated dependencies # so we have to explicitly specify all the .IN rules surfraw: surfraw.IN -rm -f $@ [email protected] sed -e 's,@VERSION\@,${VERSION},g; '\ -e 's,@ELVIDIR\@,${ELVIDIR},g; '\ -e 's,@AWK\@,${AWK},g; '\ -e 's,@PERL\@,${PERL},g; '\ -e 's,@sysconfdir\@,${sysconfdir},g ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw.conf: surfraw.conf.IN -rm -f $@ [email protected] sed -e 's,@prefix\@,${prefix},g; '\ -e 's,@TEXTBROWSER\@,${TEXTBROWSER},g; '\ -e 's,@GRAPHICALBROWSER\@,${GRAPHICALBROWSER},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-update-path: surfraw-update-path.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-bash-completion: surfraw-bash-completion.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ elvi.1sr: elvi.1sr.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw.1: surfraw.1.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; '\ -e 's,@sysconfdir\@,${sysconfdir},g' $? > [email protected] chmod +x [email protected] mv [email protected] $@ links: links.IN -rm -f $@ [email protected] sed -e 's,@mandir\@,${mandir},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-update-path.1: surfraw-update-path -rm -f $@ pod2man $? > $@ opensearch-discover.1: opensearch-discover -rm -f $@ pod2man $? > $@ opensearch-genquery.1: opensearch-genquery -rm -f $@ pod2man $? > $@ -install-data-hook: links +install-data-hook: links surfraw-bash-completion chmod -x surfraw.conf elvi.1sr surfraw.1 mkdir -p $(DESTDIR)@sysconfdir@/xdg/surfraw cp surfraw.conf $(DESTDIR)@sysconfdir@/xdg/surfraw/conf cp $(top_srcdir)/surfraw.bookmarks $(DESTDIR)@sysconfdir@/xdg/surfraw/bookmarks while read target link ;\ do \ ln -sf $$target $(DESTDIR)/$$link ;\ done < links if INSTALLSR ln -sf surfraw $(DESTDIR)/@bindir@/sr ln -sf surfraw.1.gz $(DESTDIR)/@mandir@/man1/sr.1.gz endif +if BASHCOMPLETIONS + mkdir -p $(DESTDIR)@sysconfdir@/bash_completion.d + @cp $(top_srcdir)/surfraw-bash-completion $(DESTDIR)@sysconfdir@/bash_completion.d/surfraw +endif uninstall-local: links -rm -f $(DESTDIR)@sysconfdir@/xdg/surfraw/conf -rm -f $(DESTDIR)@sysconfdir@/xdg/surfraw/bookmarks rmdir $(DESTDIR)@sysconfdir@/xdg/surfraw 2>/dev/null rmdir $(DESTDIR)@sysconfdir@/xdg 2>/dev/null while read target link ;\ do \ rm -f $(DESTDIR)/$$link ;\ done < links if INSTALLSR rm -f $(DESTDIR)/@bindir@/sr rm -f $(DESTDIR)/@mandir@/man1/sr.1.gz endif +if BASHCOMPLETIONS + -rm -f $(DESTDIR)@sysconfdir@/bash_completion.d/surfraw +endif submit-lsm: surfraw.lsm mail -s add [email protected] < $? test: all surfraw.conf make -C test test .PHONY: test diff --git a/configure.in b/configure.in index 806ff5c..9c070e6 100644 --- a/configure.in +++ b/configure.in @@ -1,60 +1,67 @@ dnl $Id$ dnl Process this file with autoconf to produce a configure script. dnl This is the only place where the package version appears dnl (apart from changelogs & NEWS) AC_INIT(surfraw, 2.3.0) AC_PREREQ(2.54) AC_CONFIG_SRCDIR([surfraw.IN]) dnl minimum automake version, not surfraw version AM_INIT_AUTOMAKE([1.10]) AC_MSG_CHECKING([whether to enable local OpenSearch support]) AC_ARG_ENABLE([opensearch], [AS_HELP_STRING([--disable-opensearch], [disable local OpenSearch support])],, [enable_opensearch=yes]) AC_MSG_RESULT([$enable_opensearch]) AM_CONDITIONAL(OPENSEARCH, test "$enable_opensearch" = "yes") +AC_MSG_CHECKING([wether to install Bash completions]) +AC_ARG_ENABLE([bash-completions], + [AS_HELP_STRING([--disable-bash-completions], [disable Bash completions support])],, + [enable_bashcompletions=yes]) +AC_MSG_RESULT([$enable_bashcompletions]) +AM_CONDITIONAL(BASHCOMPLETIONS, test "$enable_bashcompletions" = "yes") + AC_MSG_CHECKING([whether to install sr alias]) AC_ARG_ENABLE([sr], [AS_HELP_STRING([--disable-sr], [disable sr alias])],, [enable_sr=yes]) AC_MSG_RESULT([$enable_sr]) AM_CONDITIONAL(INSTALLSR, test "$enable_sr" = "yes") ELVIDIR="\$(libdir)/surfraw" AC_CHECK_PROGS(TEXTBROWSER, lynx links2 links elinks w3m netrik) AC_CHECK_PROGS(GRAPHICALBROWSER, iceweasel firefox google-chrome opera mozilla \ xombrero luakit safari epiphany-browser konqueror galeon kazenhakase \ conkeror dillo netscape chromium chrome) AC_ARG_WITH([elvidir], [AS_HELP_STRING([--with-elvidir=ELVIDIR], [specify location of elvi])], [if test -n "$withval" && test "$withval" != "no" ; then ELVIDIR="$withval";fi]) AC_ARG_WITH([text-browser], [AS_HELP_STRING([--with-text-browser=BROWSER], [specify default text browser])], [if test -n "$withval" && test "$withval" != "no" ; then TEXTBROWSER="$withval";fi]) AC_ARG_WITH([graphical-browser], [AS_HELP_STRING([--with-graphical-browser=BROWSER], [specify default graphical browser])], [if test -n "$withval" && test "$withval" != "no" ; then GRAPHICALBROWSER="$withval";fi]) AC_SUBST(ELVIDIR) AC_SUBST(VERSION) AC_SUBST(TEXTBROWSER) AC_SUBST(GRAPHICALBROWSER) ISODATE=`date -u -r ChangeLog +%Y-%m-%d` AC_SUBST(ISODATE) dnl Checks for programs. AC_PROG_INSTALL AC_PROG_AWK AC_PATH_PROG([PERL], [perl], [perl]) AC_SUBST(PERL) AC_CONFIG_FILES([Makefile surfraw.lsm surfraw.spec elvi/Makefile test/Makefile examples/Makefile]) AC_OUTPUT
JNRowe/surfraw
612162113280e7c1d194170dfd5cb2b77fc72a7c
Bash-complete all bookmarks in one command
diff --git a/surfraw-bash-completion.IN b/surfraw-bash-completion.IN index 381634a..9ec53cc 100644 --- a/surfraw-bash-completion.IN +++ b/surfraw-bash-completion.IN @@ -1,35 +1,35 @@ # -*- sh -*- bash programmable completion for Surfraw, v2.2 # This is for people who wish to use surfraw completion, without # installing the bash-completion package which sets this explicitly. shopt -s extglob _surfraw() { COMPREPLY=() local cur=${COMP_WORDS[COMP_CWORD]} local prev=${COMP_WORDS[COMP_CWORD-1]} local opts='-browser -elvi -escape-url-args -graphical \ -help -q -quote -text -version' - local elvi="$(cut -f1 @sysconfdir@/surfraw.bookmarks ~/.surfraw.bookmarks 2>&- - source surfraw && awk '{print $1}' "$(find_local_conf bookmarks)" "$(find_global_conf bookmarks)" + local elvi="$(source surfraw + cut -f1 @sysconfdir@/surfraw.bookmarks ~/.surfraw.bookmarks "$(find_local_conf bookmarks)" "$(find_global_conf bookmarks)" 2>&- cd @ELVIDIR@ && echo * 2>&- [ -d ~/.surfraw.d ] && cd ~/.surfraw.d && echo * 2>&- - source surfraw && cd $(get_local_elvi_dir) && echo * 2>&-)" + cd $(get_local_elvi_dir) && echo * 2>&-)" if [[ $cur == -* ]] then COMPREPLY=( $( compgen -W "$opts" -- $cur ) ) # I can't see a way to get the =yes/=no parts to work... elif [[ $COMP_CWORD -eq 1 ]] then COMPREPLY=( $( compgen -W "$elvi" -- $cur ) ) # "sr go<tab>" for google elif [[ $prev == @(alioth|deb@(bugs|contents|packages|pts|sec)|freshmeat|fsfdir|sourceforge) ]] then COMPREPLY=( $(apt-cache --generate pkgnames $cur) ) # "sr debbugs 4<tab>" to check 44bsd-rdist bugs... elif [[ -x /usr/bin/look ]] # in bsdmainutils, "important" then COMPREPLY=( $(/usr/bin/look ${cur:-''}) ) # "sr l<tab> vy<tab>" to find the German for "vying" else COMPREPLY=( $( compgen -o default -- $cur) ) # copout fi return 0 } # test first in case removed-but-unpurged type -p surfraw >/dev/null 2>&1 && complete -F _surfraw surfraw sr
JNRowe/surfraw
dac305dd8f4faaf91b5cca0ab55fbbc86c1404ef
Launch SURFRAW_browser and BROWSER using `exec` call
diff --git a/surfraw.IN b/surfraw.IN index 1d738f8..37da223 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,696 +1,696 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=$(basename "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default conf="@sysconfdir@/xdg/surfraw/$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value=\$${1} case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value=\$${1} test -z "$value" || return 0 eval ${1}="$2" return 0 } defyn () { eval value=\$${1} test -z "$value" && eval ${1}="$2" yesno "$1" } setopt () { eval value=\$${1} eval ${1}="$2" } setoptyn () { eval value=\$${1} eval ${1}="$2" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi*) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh|-\? ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then - $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & + exec $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else - $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & + exec $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test $SURFRAW_browser_args = "none"; then - $SURFRAW_browser "$@" + exec $SURFRAW_browser "$@" else - $SURFRAW_browser $SURFRAW_browser_args "$@" + exec $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then w3_parse_option "$arg" fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="$(quote "$arg")" unquoted_opts="$arg" else opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then exec sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then exec sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=$(bookmark_lookup $elvi) if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else echo "$(basename $0): $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." - $BROWSER "$elvi $opts $unquoted_searchterms" + exec $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
cc6b0d0980407b2631b10de6bc787647ff97db4f
Uniformly handle options before and after elvis determined
diff --git a/surfraw.IN b/surfraw.IN index 8ae595e..1d738f8 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,702 +1,696 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=$(basename "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default conf="@sysconfdir@/xdg/surfraw/$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value=\$${1} case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value=\$${1} test -z "$value" || return 0 eval ${1}="$2" return 0 } defyn () { eval value=\$${1} test -z "$value" && eval ${1}="$2" yesno "$1" } setopt () { eval value=\$${1} eval ${1}="$2" } setoptyn () { eval value=\$${1} eval ${1}="$2" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; - -elvi) echo " GLOBAL ELVI:" + -elvi*) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ - --local-help |-lh ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; + --local-help |-lh|-\? ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then - case "$arg" in - -help | --help |-h) do_help=1 ;; - -local-help | \ - --local-help | \ - -lh | -\? ) do_help=1 ; setoptyn SURFRAW_local_help yes ;; - -elvi*) w3_parse_option -elvi; exit 0 ;; - esac + w3_parse_option "$arg" fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="$(quote "$arg")" unquoted_opts="$arg" else opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then exec sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then exec sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=$(bookmark_lookup $elvi) if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else echo "$(basename $0): $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
faf29f9fc2204422d806c3c8c2c687cca7281a46
Allow spaces in second arg for {setopt,def}{yn,}
diff --git a/surfraw.IN b/surfraw.IN index 8ae595e..4946540 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,677 +1,675 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=$(basename "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { local base="${1}" local conf set -- if [ "${XDG_CONFIG_DIRS}" ] ; then local OIFS="${IFS}" IFS=":" set -- ${XDG_CONFIG_DIRS} IFS="$OIFS" fi set -- "$@" "@sysconfdir@/xdg" for dir ; do conf="${dir}/surfraw/${base}" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi done # old surfraw default conf="@sysconfdir@/xdg/surfraw/$base" if [ -r "${conf}" ] ; then printf "%s" "${conf}" return 0 fi return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { - eval value=\$${1} + eval value="\"\$${1}\"" case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { - eval value=\$${1} - test -z "$value" || return 0 - eval ${1}="$2" + eval value="\"\$${1}\"" + # Do nothing if already have a value. + test -z "$value" && eval ${1}="\"$2\"" return 0 } defyn () { - eval value=\$${1} - test -z "$value" && eval ${1}="$2" + def "$@" yesno "$1" } setopt () { - eval value=\$${1} - eval ${1}="$2" + eval value="\"\$${1}\"" + eval ${1}="\"$2\"" } setoptyn () { - eval value=\$${1} - eval ${1}="$2" + setopt "$@" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="$(quote "$arg")" else w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then case "$arg" in -help | --help |-h) do_help=1 ;; -local-help | \ --local-help | \ -lh | -\? ) do_help=1 ; setoptyn SURFRAW_local_help yes ;; -elvi*) w3_parse_option -elvi; exit 0 ;; esac fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="$(quote "$arg")" unquoted_opts="$arg" else opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0
JNRowe/surfraw
34f3148733803ccf1237bd4a174de19b8b157b4b
Complete local and global bookmarks
diff --git a/surfraw-bash-completion.IN b/surfraw-bash-completion.IN index 3dad5ab..381634a 100644 --- a/surfraw-bash-completion.IN +++ b/surfraw-bash-completion.IN @@ -1,34 +1,35 @@ # -*- sh -*- bash programmable completion for Surfraw, v2.2 # This is for people who wish to use surfraw completion, without # installing the bash-completion package which sets this explicitly. shopt -s extglob _surfraw() { COMPREPLY=() local cur=${COMP_WORDS[COMP_CWORD]} local prev=${COMP_WORDS[COMP_CWORD-1]} local opts='-browser -elvi -escape-url-args -graphical \ -help -q -quote -text -version' local elvi="$(cut -f1 @sysconfdir@/surfraw.bookmarks ~/.surfraw.bookmarks 2>&- + source surfraw && awk '{print $1}' "$(find_local_conf bookmarks)" "$(find_global_conf bookmarks)" cd @ELVIDIR@ && echo * 2>&- [ -d ~/.surfraw.d ] && cd ~/.surfraw.d && echo * 2>&- source surfraw && cd $(get_local_elvi_dir) && echo * 2>&-)" if [[ $cur == -* ]] then COMPREPLY=( $( compgen -W "$opts" -- $cur ) ) # I can't see a way to get the =yes/=no parts to work... elif [[ $COMP_CWORD -eq 1 ]] then COMPREPLY=( $( compgen -W "$elvi" -- $cur ) ) # "sr go<tab>" for google elif [[ $prev == @(alioth|deb@(bugs|contents|packages|pts|sec)|freshmeat|fsfdir|sourceforge) ]] then COMPREPLY=( $(apt-cache --generate pkgnames $cur) ) # "sr debbugs 4<tab>" to check 44bsd-rdist bugs... elif [[ -x /usr/bin/look ]] # in bsdmainutils, "important" then COMPREPLY=( $(/usr/bin/look ${cur:-''}) ) # "sr l<tab> vy<tab>" to find the German for "vying" else COMPREPLY=( $( compgen -o default -- $cur) ) # copout fi return 0 } # test first in case removed-but-unpurged type -p surfraw >/dev/null 2>&1 && complete -F _surfraw surfraw sr
JNRowe/surfraw
1aebb41925715d9402e1a6396268c6faaeab5168
Complete local elvi names
diff --git a/surfraw-bash-completion.IN b/surfraw-bash-completion.IN index 5a7024e..3dad5ab 100644 --- a/surfraw-bash-completion.IN +++ b/surfraw-bash-completion.IN @@ -1,33 +1,34 @@ # -*- sh -*- bash programmable completion for Surfraw, v2.2 # This is for people who wish to use surfraw completion, without # installing the bash-completion package which sets this explicitly. shopt -s extglob _surfraw() { COMPREPLY=() local cur=${COMP_WORDS[COMP_CWORD]} local prev=${COMP_WORDS[COMP_CWORD-1]} local opts='-browser -elvi -escape-url-args -graphical \ -help -q -quote -text -version' local elvi="$(cut -f1 @sysconfdir@/surfraw.bookmarks ~/.surfraw.bookmarks 2>&- cd @ELVIDIR@ && echo * 2>&- - [ -d ~/.surfraw.d ] && cd ~/.surfraw.d && echo * 2>&-)" + [ -d ~/.surfraw.d ] && cd ~/.surfraw.d && echo * 2>&- + source surfraw && cd $(get_local_elvi_dir) && echo * 2>&-)" if [[ $cur == -* ]] then COMPREPLY=( $( compgen -W "$opts" -- $cur ) ) # I can't see a way to get the =yes/=no parts to work... elif [[ $COMP_CWORD -eq 1 ]] then COMPREPLY=( $( compgen -W "$elvi" -- $cur ) ) # "sr go<tab>" for google elif [[ $prev == @(alioth|deb@(bugs|contents|packages|pts|sec)|freshmeat|fsfdir|sourceforge) ]] then COMPREPLY=( $(apt-cache --generate pkgnames $cur) ) # "sr debbugs 4<tab>" to check 44bsd-rdist bugs... elif [[ -x /usr/bin/look ]] # in bsdmainutils, "important" then COMPREPLY=( $(/usr/bin/look ${cur:-''}) ) # "sr l<tab> vy<tab>" to find the German for "vying" else COMPREPLY=( $( compgen -o default -- $cur) ) # copout fi return 0 } # test first in case removed-but-unpurged type -p surfraw >/dev/null 2>&1 && complete -F _surfraw surfraw sr
JNRowe/surfraw
4f804f736074b41269b2a88477d1b4f29a3b6f7b
debbugs: add support for usertags search
diff --git a/elvi/debbugs b/elvi/debbugs index f5d930e..51a9d19 100755 --- a/elvi/debbugs +++ b/elvi/debbugs @@ -1,235 +1,294 @@ #!/bin/sh # $Id$ # elvis: debbugs -- Search the debian BTS (bugs.debian.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debbugs_search pkg def SURFRAW_debbugs_version "" def SURFRAW_debbugs_dist "" +def SURFRAW_debbugs_user "" defyn SURFRAW_debbugs_archive 0 defyn SURFRAW_debbugs_merge 0 defyn SURFRAW_debbugs_statussort 1 defyn SURFRAW_debbugs_head 1 defyn SURFRAW_debbugs_foot 1 def SURFRAW_debbugs_incstatus "" def SURFRAW_debbugs_excstatus "" def SURFRAW_debbugs_incsev "" def SURFRAW_debbugs_excsev "" def SURFRAW_debbugs_inctag "" def SURFRAW_debbugs_exctag "" defyn SURFRAW_debbugs_asmbox 0 defyn SURFRAW_debbugs_headers 0 defyn SURFRAW_debbugs_boring 0 defyn SURFRAW_debbugs_revstat 0 defyn SURFRAW_debbugs_revsev 0 defyn SURFRAW_debbugs_revbugs 0 defyn setsearch 0 +defyn search_usertag 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [package | bug number | maintainer email] Description: Surfraw search debian BTS (bugs.debian.org) Examples: debbugs 20000 | show report for bug #20000 debbugs [email protected] | show bugs for csurchi debbugs surfraw | show bugs for surfraw package debbugs -raw -rb surfraw | show surfraw bugs newest first Defaults if -search is not supplied: If arg is numeric, searches by bug number, If it contains '@', searches by maintainer, Otherwise, searches by package. Local options: -search= pkg | Search type. src | bug | (bug number) maint | tag | submitter | severity | - tag + tag | + usertag -s Alias for -search=src + -user=EMAIL User for usertag search, defaults to value + of \$DEBEMAIL environment. Ignored if + search type is not "usertag". -version=VERSION Package version. -dist=oldstable | Distribution stable | proposed-updates | testing | unstable | experimental | testing-proposed-updates -arc Show archived bugs. -raw Do not sort by status or severity. -rb Reverse order of bugs shown. -rst Reverse order of statuses shown. -rse Reverse order of severities shown. -merge Display merged bugs only once. -nohead Do not show table of contents header. -nofoot Do not show statistics in the footer. -mbox View results in mbox format. * -sh Show headers. * -boring Show boring messages. * (* = only when searching by bug number.) -incstat=stat1,stat2 Include given status list. -exstat=stat3,stat4 Exclude given status list. Available statuses: open, forwarded, pending, fixed, done. -incsev=sev1,sev2 Include given severities. -exsev=sev3,sev4 Exclude given severities. Available severities: critical, grave, serious, important, normal, minor, wishlist, fixed. -inctag=tag1,tag2 Include given tags. -extag=tag3,tag4 Exclude given tags. Available tags: potato, woody, sarge, sarge-ignore, etch, etch-ignore, sid, experimental, confirmed, d-i, fixed, fixed-in-experimental, fixed-upstream, help, l10n, moreinfo, patch, pending, security, unreproducible, upstream, wontfix, ipv6, lfs EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s) setopt SURFRAW_debbugs_search src ; setoptyn setsearch 1 ;; -se*=*) setopt SURFRAW_debbugs_search $optarg; setoptyn setsearch 1 ;; -ve*=*) setopt SURFRAW_debbugs_version $optarg ;; -dis*=*) setopt SURFRAW_debbugs_dist $optarg ;; -arc*) setoptyn SURFRAW_debbugs_archive 1;; -mer*) setoptyn SURFRAW_debbugs_merge 1;; -raw*) setoptyn SURFRAW_debbugs_statussort 0;; -noh*) setoptyn SURFRAW_debbugs_head 0;; -nof*) setoptyn SURFRAW_debbugs_foot 0;; -in*stat*=*) setopt SURFRAW_debbugs_incstatus $optarg;; -ex*stat*=*) setopt SURFRAW_debbugs_excstatus $optarg;; -in*sev*=*) setopt SURFRAW_debbugs_incsev $optarg;; -ex*sev*=*) setopt SURFRAW_debbugs_excsev $optarg;; -in*tag*=*) setopt SURFRAW_debbugs_inctag $optarg;; -ex*tag*=*) setopt SURFRAW_debbugs_exctag $optarg;; + -u*=*) setopt SURFRAW_debbugs_user $optarg;; -rb*) setoptyn SURFRAW_debbugs_revbugs 1;; -rst*) setoptyn SURFRAW_debbugs_revstat 1;; -rse*) setoptyn SURFRAW_debbugs_revsev 1;; -mb*) setoptyn SURFRAW_debbugs_asmbox 1;; -sh*) setoptyn SURFRAW_debbugs_headers 1;; -bo*) setoptyn SURFRAW_debbugs_boring 1;; *) return 1 ;; esac return 0 } +# Email normalization +# ~~~~~~~~~~~~~~~~~~~ +# +# Debbugs search have bug: even if email have upper-case letters, it +# must be lower-cased when writing search request, or nothing will be +# found. +# +# For example, to search bugs in packages, maintained by +# J. Random Hacker <[email protected]> one have to request following url: +# +# https://bugs.debian.org/[email protected] +# +# No search results will be returned at this requst: +# +# https://bugs.debian.org/[email protected] +# +# Environment variable $DEBEMAIL is used by many developer tools, +# maintainers tend to place their email in preferred capitalization. +# +# When using this variable as fallback for -user option, it is lowercased +# to work-around described beviour (reported as #921970). +# +# Strictly speaking, local part of email address must be considered +# opaque, having meaning only to receiving email server. + w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.debian.org/Bugs" else escaped_args=$(w3_url_of_arg $w3_args) setoptyn donum 0 setoptyn domaint 0 + setoptyn dousertag 0 case "$SURFRAW_debbugs_search" in bug*) setoptyn donum 1;; + user*) setopt SURFRAW_debbugs_search tag + setoptyn dousertag 1;; esac # default search unless searchtype set on cmdline if ifno setsearch then export escaped_args if perl -e 'if($ENV{escaped_args} =~/^((\#|\%23)(\s|\%20)*)?\d+$/) { exit 0; } exit 1;' then # %23 = uri escaped '#', %20=' ' setoptyn donum 1 elif perl -e 'if($ENV{escaped_args} =~/\%40|@/) { exit 0; } exit 1;' then # %40 = uri escaped '@' setopt SURFRAW_debbugs_search "maint" fi fi if ifyes donum then url="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${escaped_args}" if yesno SURFRAW_debbugs_asmbox then url="$url&mbox=yes" fi if yesno SURFRAW_debbugs_headers then url="$url&trim=no" fi if yesno SURFRAW_debbugs_boring then url="$url&boring=yes" fi else url="https://bugs.debian.org/cgi-bin/pkgreport.cgi?which=${SURFRAW_debbugs_search}&version=${SURFRAW_debbugs_version}&dist=${SURFRAW_debbugs_dist}&data=${escaped_args}" + + if ifyes dousertag + then + user=${SURFRAW_debbugs_user} + if null "${user}" + then + user="${DEBEMAIL:-}" + if null "${user}" + then + cat <<EOF >&2 +$w3_argv0 ERROR: can not do usertag search -- user is unknown. + + * option -user is not provided + * environment variable "SURFRAW_debbugs_user" is not set + * environment variable "DEBEMAIL" is not set +EOF + exit 1 + fi + # See [Email normalization] + user=$(printf '%s' "${user}" | tr '[:upper:]' '[:lower:]') + fi + url="$url&users=$user" + fi + if yesno SURFRAW_debbugs_archive then url="$url&archive=yes" else url="$url&archive=no" fi if ifyes SURFRAW_debbugs_merge then url="$url&repeatmerged=no" fi if ifno SURFRAW_debbugs_statussort then url="$url&raw=yes" fi if ifno SURFRAW_debbugs_head then url="$url&show_list_header=no" fi if ifno SURFRAW_debbugs_foot then url="$url&show_list_footer=no" fi if ifyes SURFRAW_debbugs_revstat then url="$url&pend-rev=yes" fi if ifyes SURFRAW_debbugs_revsev then url="$url&sev-rev=yes" fi if ifyes SURFRAW_debbugs_revbugs then url="$url&bug-rev=yes" fi if [ "$SURFRAW_debbugs_incstatus" != "" ] then add=$(echo "$SURFRAW_debbugs_incstatus"|perl -ne 's/pending/pending-fixed/g;s/open/pending/g;print(join("&pend-inc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_excstatus" != "" ] then add=$(echo "$SURFRAW_debbugs_excstatus"|perl -ne 'print(join("&pend-exc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_incsev" != "" ] then add=$(echo "$SURFRAW_debbugs_incsev"|perl -ne 'print(join("&sev-inc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_excsev" != "" ] then add=$(echo "$SURFRAW_debbugs_excsev"|perl -ne 'print(join("&sev-exc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_inctag" != "" ] then add=$(echo "$SURFRAW_debbugs_inctag"|perl -ne 'print(join("&include=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_exctag" != "" ] then add=$(echo "$SURFRAW_debbugs_exctag"|perl -ne 'print(join("&exclude=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi fi w3_browse_url "$url" fi
JNRowe/surfraw
8924dfeee31f66c48342dd68a038e85117f09926
Avoid useless /bin/sh hanging in memory
diff --git a/surfraw.IN b/surfraw.IN index bc01e86..0405ed0 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -170,533 +170,533 @@ quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=`echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//'` esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="`quote "$arg"`" else w3_shquoted_args="$w3_shquoted_args `quote "$arg"`" fi if ok SURFRAW_quote_ifs then arg=`quote_ifs "$arg"` fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test `echo $TERM | cut -c 1-6` = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=`echo "$1"|sed "s/'/'\\\\\''/g"` echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then case "$arg" in -help | --help |-h) do_help=1 ;; -local-help | \ --local-help | \ -lh | -\? ) do_help=1 ; setoptyn SURFRAW_local_help yes ;; -elvi*) w3_parse_option -elvi; exit 0 ;; esac fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="`quote "$arg"`" unquoted_opts="$arg" else opts="$opts `quote "$arg"`" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="`quote "$arg"`" unquoted_searchterms="$arg" else searchterms="$searchterms `quote "$arg"`" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then - sh -c "$localelvidir/$elvi $opts $searchterms" + exec sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then - sh -c "$elvidir/$elvi $opts $searchterms" + exec sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=`bookmark_lookup $elvi` if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else echo "`basename $0`: $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
3c0f8ade64fa0dc9e695b66d64d5a6123bff67d3
Simplify `find_global_conf' function in surfraw(1)
diff --git a/surfraw.IN b/surfraw.IN index 1e2db3b..bc01e86 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,560 +1,564 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=`basename "$0"` elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { - base="$1" - local conf OIFS - conf="" - if test -n "$XDG_CONFIG_DIRS"; then - OIFS="$IFS" - IFS=: - set $XDG_CONFIG_DIRS - IFS="$OIFS" - for i in "$@"; do - if test -r "$i/surfraw/$base"; then - conf="$i/surfraw/$base" - break - fi - done + local base="${1}" + local conf + set -- + + if [ "${XDG_CONFIG_DIRS}" ] ; then + local OIFS="${IFS}" + IFS=":" + set -- ${XDG_CONFIG_DIRS} + IFS="$OIFS" fi + set -- "$@" "@sysconfdir@/xdg" - if test -n "$conf"; then - if test -r "@sysconfdir@/xdg/surfraw/$base"; then # XDG default - conf="@sysconfdir@/xdg/surfraw/$base" - elif test -r "@sysconfdir@/surfraw.$base"; then # old surfraw default - conf="@sysconfdir@/surfraw.$base" - fi + for dir ; do + conf="${dir}/surfraw/${base}" + if [ -r "${conf}" ] ; then + printf "%s" "${conf}" + return 0 + fi + done + + # old surfraw default + conf="@sysconfdir@/xdg/surfraw/$base" + if [ -r "${conf}" ] ; then + printf "%s" "${conf}" + return 0 fi - echo "$conf" + + return 1 } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value=\$${1} case `echo "$value" | tr A-Z a-z` in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value=\$${1} test -z "$value" || return 0 eval ${1}="$2" return 0 } defyn () { eval value=\$${1} test -z "$value" && eval ${1}="$2" yesno "$1" } setopt () { eval value=\$${1} eval ${1}="$2" } setoptyn () { eval value=\$${1} eval ${1}="$2" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=`echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//'` esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="`quote "$arg"`" else w3_shquoted_args="$w3_shquoted_args `quote "$arg"`" fi if ok SURFRAW_quote_ifs then arg=`quote_ifs "$arg"` fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test `echo $TERM | cut -c 1-6` = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done
JNRowe/surfraw
7b9162e8f1f1c1b0ac7d6f8659d91822f9316761
Make style of output capture uniform
diff --git a/HACKING b/HACKING index c397b21..78ff5af 100644 --- a/HACKING +++ b/HACKING @@ -1,198 +1,198 @@ ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! H A C K I N G Or... How to Eat The CHEESE 1) First, find a front end (`an elvi, types of elvis -- makes evil nice') in the elvi/ directory that does something similar to what you want. In this example we shall use the `google' elvis. 2) Copy the `google' elvis to the name of your new elvis. In this example we shall create an elvis for the Peoples' Front Against Forum Stealing Dogs http://www.pfafsd.org/ mailing-list search service 3) At the top of the file, you will see something like: # elvis: google -- Search the web using Google (http://www.google.com) Keep the "elvis:" take and change the rest of the line. This description is used at Surfraw installation time to generate a list of Surfraw clients Immediately after we see: . surfraw || exit 1 Which pulls in the Surfraw functions. Keep it. 4) Next we (optionally) define w3_config_hook(). It is called by w3_config and is used to define default configuration variables. It is called after the global configuration file is interpreted, but before ~/.surfraw. You will notice the use of: def -- define configuration variable unless already defined (i.e by the environment) defyn -- define boolean configuration variable unless already defined Which are pre-defined surfraw functions, but you can of course use your own arbitrary broken shell code instead. 5) Any non-trivial program will then define w3_usage_hook(). $w3_argv0 is set to contain $0, otherwise usage is self explanatory. You must call w3_global_usage at the end of this function and follow the surfraw usage style least you be marked a quiche eater. 6) Next define w3_parse_option_hook(). This is called at w3_config() time, and takes two arguments. The first is the current option being examined, the second is only present if the option was of the form `-foo=bar'. It's the `bar'. w3_parse_option_hook() is called before Surfraw global options are parsed and so you can selectively over-ride them. Return value: 0 if the option was recognised, 1 otherwise. 7) After this, w3_config() and w3_parse_args "$@" are called. w3_config() scans the configuration files and calls w3_config_hook(). w3_parse_args "$@" processes options, called w3_parse_option_hook() as needed and builds $w3_args -- the list non-option arguments. This ends the regular initialisation code. 7.5)Note that surfraw now supports quoting arguments, eg with: sr google foo "bar baz" bam it adds the quotes back. Not all sites support arguments in double quotes. If you want to disable it for your elvis, add SURFRAW_quote_ifs=0 in between the calls to w3_config and w3_parse_args. 8) What happens next depends on the type of evil we are dealing with. In the Peoples' Front Against Forum Stealing Dogs case, we have previously performed a search on the http://www.pfafsd.org search service, and noted (with the '=' key in lynx, links) the url returned. We then analyse this url to work out which CGI variable is being used to convey search the search string, number of results et al. Q: What about those proslytizers of iniquity that worship idols like method=POST? A: Most sites will take GETs in the place of POSTs, even if they preach method=POST in forms. For those that don't? Walking with the devil should not be a an exercise in relaxed discourse. The problem is getting the browser to automatically submit the data using POST as a method. One partial solution is to have surfraw generate a pre-filled method=POST form as a local file and have the browser read it. Exploration of other ideas is encouraged. w3_url_of_arg() is then used to escape the command line search string argument into something that can be seen in a URL without embarrassment. - i.e escaped_args=`w3_url_of_arg $w3_args` + i.e escaped_args=$(w3_url_of_arg $w3_args) In our last exhilarating moments we then build the final URL and pass it onto the currently selected browser with w3_browse_url, proud in the knowledge that the Shell Users' Revolutionary Front Against the WWW has brought the holy word of the command line to yet another heathen land. -Julian Assange <[email protected]> APPENDIX 1 Adding an elvi to the distribution: 1: write it (see above) 2: copy elviname to the elvi directory 3: make the elvi executable (chmod 755 elvipath) so the test suite can run it directly. 4: add elviname to the elvi_SCRIPTS list in elvi/Makefile.am 5: add a link for the manpage in links.IN 6: update the elvi list in README 7: add an entry to the ChangeLog and NEWS 8: add yourself or the author to AUTHORS 9: test 10: add tests to test suite, see test/README 11: if the elvi has heavy dependencies, consider moving it to the surfraw-extra package by adding its files to debian/surfraw-extra.files 12: if using git, 'git add elvi/elviname' then commit and push. APPENDIX 2 Preparing a release of surfraw: 1: git clone git://git.debian.org/surfraw/surfraw 2: git clone git://git.debian.org/surfraw/web 3: cd surfraw 4: git tag surfraw-versionnumber-debianversion 5: git push --tags 6: mkdir -p ../release/upload ; cd ../release 7: git clone git://git.debian.org/surfraw/surfraw 8: cd surfraw 9: git checkout surfraw-versionnumber-debianversion 10: rm -rf .git 11: ./prebuild && ./configure && make distcheck 12: # test surfraw-version.tar.gz 13: cp surfraw-version.tar.gz ../surfraw_version.orig.tar.gz 14: mv surfraw-version.tar.gz ../upload 15: pdebuild --buildresult ../upload --auto-debsign --logfile ../pbuilder.log 16: cd ../upload 17: # test and upload the debian packages 18: cp * ../../web/dist 19: cd ../../web 20: make install # see README.WEB for more info diff --git a/elvi/acronym b/elvi/acronym index 04d719a..9aa0d8a 100755 --- a/elvi/acronym +++ b/elvi/acronym @@ -1,168 +1,168 @@ #!/bin/sh # $Id$ # elvis: acronym -- Look for acronyms definitions (www.acronymfinder.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_acronym_ict 0 defyn SURFRAW_acronym_sci 0 defyn SURFRAW_acronym_gov 0 defyn SURFRAW_acronym_org 0 defyn SURFRAW_acronym_biz 0 defyn SURFRAW_acronym_pop 0 defyn SURFRAW_acronym_exa 1 defyn SURFRAW_acronym_wim 0 defyn SURFRAW_acronym_zip 0 defyn SURFRAW_acronym_ran 0 defyn SURFRAW_acronym_gen 0 defyn SURFRAW_acronym_alpha 0 defyn SURFRAW_acronym_attic 0 def SURFRAW_acronym_path def SURFRAW_acronym_par } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [option] [keyword] Description: Surfraw searches for possible definitions of acronyms using acronymfinder.com Local option: -i -ict List all acronyms matching in Information Technology category -s -sci List all acronyms matching in Science & Medicine category -g -gov List all acronyms matching in Government & Military category -o -org List all acronyms matching in Organizations & Schools category -b -biz List all acronyms matching in Business & Finance category -c -common List all acronyms matching in Slang & Pop Culture category -e -exact List all acronyms matching with exact match (Default when keyword specified) -w -wim List all acronyms matching with Word(s) in meaning match -z -zip List all acronyms matching with Location (postal code, name) match -r -random List a random acronym (Default when no keyword specified) -f -fake List a fake acronym generated with the Acronym Finder Random Systematic Buzz Phrase Projector (AFRSBPP) -a -alphabetic List all acronyms matching sorted alphabetically instead of by rank -u -unverified List all acronyms matching, included those unverified by men and potentially misleading (Acronym Attic) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in #Information Technology category -i*) setoptyn SURFRAW_acronym_ict 1 setoptyn SURFRAW_acronym_sci 0 setoptyn SURFRAW_acronym_gov 0 setoptyn SURFRAW_acronym_org 0 setoptyn SURFRAW_acronym_biz 0 setoptyn SURFRAW_acronym_pop 0 ;; #Science & Medicine category -s*) setoptyn SURFRAW_acronym_sci 1 setoptyn SURFRAW_acronym_ict 0 setoptyn SURFRAW_acronym_gov 0 setoptyn SURFRAW_acronym_org 0 setoptyn SURFRAW_acronym_biz 0 setoptyn SURFRAW_acronym_pop 0 ;; #Government & Military category -g*) setoptyn SURFRAW_acronym_gov 1 setoptyn SURFRAW_acronym_sci 0 setoptyn SURFRAW_acronym_ict 0 setoptyn SURFRAW_acronym_org 0 setoptyn SURFRAW_acronym_biz 0 setoptyn SURFRAW_acronym_pop 0 ;; #Organizations & Schools category -o*) setoptyn SURFRAW_acronym_org 1 setoptyn SURFRAW_acronym_sci 0 setoptyn SURFRAW_acronym_gov 0 setoptyn SURFRAW_acronym_ict 0 setoptyn SURFRAW_acronym_biz 0 setoptyn SURFRAW_acronym_pop 0 ;; #Business & Finance category -b*) setoptyn SURFRAW_acronym_biz 1 setoptyn SURFRAW_acronym_sci 0 setoptyn SURFRAW_acronym_gov 0 setoptyn SURFRAW_acronym_org 0 setoptyn SURFRAW_acronym_ict 0 setoptyn SURFRAW_acronym_pop 0 ;; #Slang & Pop Culture category -c*) setoptyn SURFRAW_acronym_pop 1 setoptyn SURFRAW_acronym_sci 0 setoptyn SURFRAW_acronym_gov 0 setoptyn SURFRAW_acronym_org 0 setoptyn SURFRAW_acronym_biz 0 setoptyn SURFRAW_acronym_ict 0 ;; #exact match -e*) setoptyn SURFRAW_acronym_exa 1 setoptyn SURFRAW_acronym_wim 0 setoptyn SURFRAW_acronym_zip 0 ;; #Word(s) in meaning match -w*) setoptyn SURFRAW_acronym_wim 1 setoptyn SURFRAW_acronym_exa 0 setoptyn SURFRAW_acronym_zip 0 ;; #Location (postal code, name) match -z*) setoptyn SURFRAW_acronym_zip 1 setoptyn SURFRAW_acronym_wim 0 setoptyn SURFRAW_acronym_exa 0 ;; #Random acronym -r*) setoptyn SURFRAW_acronym_ran 1 setoptyn SURFRAW_acronym_gen 0 ;; #Fake acronym -f*) setoptyn SURFRAW_acronym_gen 1 setoptyn SURFRAW_acronym_ran 0 ;; #Sort alphabetically -a*) setoptyn SURFRAW_acronym_alpha 1 ;; #Match from Acronym Attic -u*) setoptyn SURFRAW_acronym_attic 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then if [ "$SURFRAW_acronym_gen" = 1 ]; then SURFRAW_acronym_path="http://www.acronymfinder.com/buzzgen.asp" # Fake Acronym else SURFRAW_acronym_path="http://www.acronymfinder.com/random.aspx" # Random Acronym fi else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_acronym_attic" = 1 ]; then SURFRAW_acronym_path="http://www.acronymattic.com/~/search/aa.aspx?Acronym=" # Acronym Attic else SURFRAW_acronym_path="http://www.acronymfinder.com/~/search/af.aspx?Acronym=" # Acronym Finder if [ "$SURFRAW_acronym_exa" = 1 ]; then par="exact" elif [ "$SURFRAW_acronym_wim" = 1 ]; then par="on" elif [ "$SURFRAW_acronym_zip" = 1 ]; then par="zip" fi SURFRAW_acronym_par="&Find=find&string=$par&Page=1" if [ "$SURFRAW_acronym_ict" = 1 ]; then par="IT" elif [ "$SURFRAW_acronym_sci" = 1 ]; then par="SciMed" elif [ "$SURFRAW_acronym_gov" = 1 ]; then par="MilGov" elif [ "$SURFRAW_acronym_org" = 1 ]; then par="Org" elif [ "$SURFRAW_acronym_biz" = 1 ]; then par="Business" elif [ "$SURFRAW_acronym_pop" = 1 ]; then par="Slang" fi SURFRAW_acronym_par="$SURFRAW_acronym_par&Category=$par" fi if [ "$SURFRAW_acronym_alpha" = 1 ]; then SURFRAW_acronym_par="$SURFRAW_acronym_par&s=a" fi fi w3_browse_url "$SURFRAW_acronym_path${escaped_args}$SURFRAW_acronym_par" diff --git a/elvi/ads b/elvi/ads index 2419898..6c1d32b 100755 --- a/elvi/ads +++ b/elvi/ads @@ -1,27 +1,27 @@ #!/bin/sh # elvis: ads -- Search SAO/NASA Astrophysics Data System # [email protected] 20100819 . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the SAO/NASA Astrophysics Data System EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://adsabs.harvard.edu/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) # not direct to ads, construct url from options url="http://adsabs.harvard.edu/cgi-bin/nph-basic_connect?qsearch=${escaped_args}&version=1" w3_browse_url "$url" fi diff --git a/elvi/alioth b/elvi/alioth index 2a9f438..c6abcdf 100755 --- a/elvi/alioth +++ b/elvi/alioth @@ -1,48 +1,48 @@ #!/bin/sh # $Id$ # elvis: alioth -- Search Alioth (alioth.debian.org) # [email protected] 20030910 # adapted from sourceforge elvi . surfraw || exit 1 w3_config_hook () { def SURFRAW_alioth_searchtype soft } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Alioth (alioth.debian.org) Local options: -type= soft | Software / Group skill | Skills people People Default: $SURFRAW_alioth_searchtype Environment: SURFRAW_alioth_searchtype EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -t*=*) setopt SURFRAW_alioth_searchtype $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://alioth.debian.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://alioth.debian.org/search/?words=${escaped_args}&type_of_search=$SURFRAW_alioth_searchtype" fi diff --git a/elvi/amazon b/elvi/amazon index be7ad96..cc20cdb 100755 --- a/elvi/amazon +++ b/elvi/amazon @@ -1,244 +1,244 @@ #!/bin/sh # $Id$ # elvis: amazon -- Search the amazon.com bookstore . surfraw || exit 1 w3_config_hook () { def SURFRAW_amazon_country "$SURFRAW_lang" def SURFRAW_amazon_search all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search amazon Local options: -country=COUNTRY Two letter domain-style country code com | Main amazon.com site (default) ca | Canada cn | China de | Germany fr | France jp | Japan uk UK Environment: SURFRAW_amazon_country, SURFRAW_lang Default: $SURFRAW_amazon_country -search= Specialised search on topic all All Departments. amazon.com: apparel Apparel & Accessories automotive Automotive baby-products Baby beauty Beauty books Books wireless-aps Cell Phones & Service electronics Electronics misc Everything Else gourmet Gourmet Food grocery Grocery hpc Health & Personal Care garden Home & Garden tools Home Improvement industrial Industrial & Scientific jewelry Jewelry digital-text Kindle Store magazines Magazines dvd Movies & TV digital-music MP3 Downloads popular Music mi Musical Instruments office-products Office Products & Supplies shoes Shoes software Software sporting Sports & Outdoors toys-and-games Toys & Games vhs VHS videogames Video Games amazontv Video On Demand watches Watches uk: books Books electronics Electronics popular Music classical Classical Music digital-music MP3 Downloads dvd DVD vhs VHS software Software videogames Video Games software-videogames Software & Games diy DIY & Tools outdoor Garden & Outdoors kitchen Kitchen & Home drugstore Health & Beauty beauty Beauty toys Toys & Games sports Sports & Leisure jewelry-watches Jewellery & Watches clothing Clothing shoes Shoes & Accessories baby Baby fr: books Livres en français english-books Livres en anglais electronics High-tech popular Musique classical Musique classique dvd DVD & Vidéo blu-ray Blu-ray software Logiciels videogames Jeux vidéo toys Jeux et Jouets kitchen Cuisine & Maison jewelry-watches Montres & Bijoux de: books Bücher english-books Englische Bücher magazines Zeitschriften popular Musik classical Klassische Musik dvd DVD blu-ray Blu-ray electronics Elektronik & Foto computer Computer photo Kamera & Foto kitchen Küche & Haushalt diy Baumarkt automotive Auto & Motorrad outdoor Garten & Freizeit drugstore Drogerie & Bad beauty Parfümerie & Kosmetik software Software videogames Games toys Spielzeug sports Sport & Freizeit jewelry-watches Uhren & Schmuck baby Babyausstattung clothing Bekleidung shoes Schuhe & Handtaschen ca: books Books popular Music classical Classical Music dvd DVD vhs VHS electronics Electronics software Software videogames Video Games jp: books a書 english-books m酪 electronics 痩d&塔Jメラ kitchen zメ[ム&Lャb\`ャ popular 塔~ュ[<WbャN classical Nャ宴VbャN音y dvd DVD software PC潟\tャg videogames Qメ[ム toys おもちゃ&zャr[ sporting <X|メ[c&ャAEャghャA hpc wャ泣X&rャ[eャB[ beauty <RXャ food-beverage $Hi&譜料 watch 時v baby 激xrメ[&}ャ^jャeB apparel ャApャ激&æ³£t@ャbVャ梼G貨 cn: 1 图书 2 音乐 3 影视 5 手机 6 家电 7 化妆 8 厨具 9 家居 10 运动健康 11 玩具 12 钟表首饰 14 个人护理 15 软件 16 游戏/娱乐 17 礼品箱包 20 摄影摄像 21 Mp3/Mp4 22 视听设备 23 电脑配件 25 教育音像 Default: $SURFRAW_amazon_search Environment: SURFRAW_amazon_search Examples: $w3_argv0 -search=books -country=uk -q The Lotus and The Robot EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -search=*) setopt SURFRAW_amazon_search $optarg ;; -country=*) setopt SURFRAW_amazon_country $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_amazon_country" in uk) host=www.amazon.co.uk ;; de) host=www.amazon.de ;; fr) host=www.amazon.fr ;; jp) host=www.amazon.co.jp ;; ca) host=www.amazon.ca ;; cn|zh|zt) host=www.amazon.cn ;; *) host=www.amazon.com ;; esac if null "$w3_args"; then w3_browse_url "https://${host}/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_amazon_search" = books ] ; then SURFRAW_amazon_search=stripbooks elif [ "$SURFRAW_amazon_search" = all ] ; then SURFRAW_amazon_search=aps fi case "$host" in www.amazon.cn) path="mn/searchApp" if [ "$SURFRAW_amazon_search" = "aps" ] ;then SURFRAW_amazon_search="" fi args="ix=sunray&pageletid=headsearch&searchType=${SURFRAW_amazon_search}&keywords=${escaped_args}&Go.x=0&Go.y=0&bestSaleNum=0" break;; www.amazon.co.jp) path="s/ref=nb_ss_gw" args="__mk_ja_JP=%83J%83%5E%83J%83i&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.co.uk) path="s/ref=nb_ss_w_h_" args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.fr) path="s/ref=nb_ss_w" args="__mk_fr_FR=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.de) path="s/ref=nb_ss_w" args="__mk_de_DE=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.ca) path="s/ref=nb_ss_gw" args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; *) path="s/ref=nb_ss_gw" args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" esac w3_browse_url "https://${host}/${path}?${args}" fi diff --git a/elvi/arxiv b/elvi/arxiv index 0fa54af..3c64609 100755 --- a/elvi/arxiv +++ b/elvi/arxiv @@ -1,141 +1,141 @@ #!/bin/sh # # $Id$ # # elvis: arxiv -- Search arXiv E-Print Archive for articles # # 2008-June-03 - By John Gruenenfelder ([email protected]) # Rewrote 'xxx' script to allow searching arXiv site by various # means. # . surfraw || exit 1 w3_config_hook () { def SURFRAW_arxiv_scope all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search terms] Description: Surfraw the Los Alamos Science E-Print Archive (arXiv) Local options: -scope= Limit scope of arXiv search all | Search all fields title | Search article titles author | Search article authors abstract | Search article abstracts fulltext Search the full text of articles Default: $SURFRAW_arxiv_scope Environment: SURFRAW_arxiv_scope EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -scope=*) setopt SURFRAW_arxiv_scope $optarg ;; *) return 1 ;; esac return 0 } # Parse config w3_config # Parse search terms SURFRAW_escape_url_args=no w3_parse_args "$@" # Mangle search terms into something useable terms="" cnt=0 if [ ! -z "$w3_args" ]; then case $SURFRAW_arxiv_scope in all | title | abstract) - if [ `w3_url_of_arg $w3_args | cut -c1` = \" ]; then - terms="+EXACT+"`echo $w3_args | sed -e 's/ /_/g'` + if [ $(w3_url_of_arg $w3_args | cut -c1) = \" ]; then + terms="+EXACT+"$(echo $w3_args | sed -e 's/ /_/g') else for w in $w3_args ; do - terms="+"`w3_url_of_arg $w`$terms + terms="+"$(w3_url_of_arg $w)$terms cnt=$((cnt + 1)) if [ $cnt -gt 1 ]; then terms="+AND"$terms fi done fi - terms=`echo $terms | sed -e 's/"//g'` + terms=$(echo $terms | sed -e 's/"//g') ;; author) # Names without commas need to be reversed echo "$w3_args" | grep -q "," if [ $? -eq 0 ]; then # Name already in last, first format. - terms=`echo "$w3_args" | sed -e "s/,/_/g" -e "s/ //g"` - terms="+"`w3_url_of_arg $terms` + terms=$(echo "$w3_args" | sed -e "s/,/_/g" -e "s/ //g") + terms="+"$(w3_url_of_arg $terms) else # Name in first last format. Need to reverse. first="" last="" for n in $w3_args ; do if [ -z $first ]; then first=$n elif [ -z $last ]; then last=$n fi done terms="" if [ -n "$last" ]; then terms="${last}_" fi terms="$terms$first" - terms="+"`w3_url_of_arg $terms` + terms="+"$(w3_url_of_arg $terms) fi ;; fulltext) - terms=`w3_url_escape $w3_args` + terms=$(w3_url_escape $w3_args) ;; *) return 1 ;; esac fi # Form URL if [ -z "$w3_args" ]; then url="https://arXiv.org/" else case $SURFRAW_arxiv_scope in all) url="https://arXiv.org/find/all/1/all:"$terms"/0/1/0/all/0/1" ;; title) url="https://arXiv.org/find/all/1/ti:"$terms"/0/1/0/all/0/1" ;; abstract) url="https://arXiv.org/find/all/1/abs:"$terms"/0/1/0/all/0/1" ;; author) url="https://arXiv.org/find/all/1/au:"$terms"/0/1/0/all/0/1" ;; fulltext) url="https://search.arXiv.org:8081/?query="$terms"&in=" ;; *) return 1 ;; esac fi w3_browse_url $url diff --git a/elvi/ask b/elvi/ask index f890e78..321c74a 100755 --- a/elvi/ask +++ b/elvi/ask @@ -1,25 +1,25 @@ #!/bin/sh # $Id$ # elvis: ask -- Question the web using Ask Jeeves (www.ask.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Question the web using Ask Jeeves (www.ask.com) Example: ask is jeeves gay? EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.ask.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.ask.com/web?q=${escaped_args}" fi diff --git a/elvi/aur b/elvi/aur index b51c4c9..a8a21a3 100755 --- a/elvi/aur +++ b/elvi/aur @@ -1,146 +1,146 @@ #!/bin/sh # # AUTHOR: René Reigel based on piratebay by J.R. Mauro # Ivy Foster added additional search options # # DESC: Search the Arch User Repository # $ID$ # elvis: aur -- Search aur.archlinux.org for PKGBUILDs . surfraw || exit 1 w3_config_hook () { def SURFRAW_aur_action "Search=Go" def SURFRAW_aur_category "any" def SURFRAW_aur_order "a" def SURFRAW_aur_language en defyn SURFRAW_aur_outdated 0 def SURFRAW_aur_protocol "https" def SURFRAW_aur_results "$SURFRAW_results" def SURFRAW_aur_search name def SURFRAW_aur_sort name } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search aur.archlinux.org for PKGBUILDS Local options -category Search the given AUR category Consult aur.archlinux.org/packages.php for a complete list. Default: any -language Search in your your language See aur.archlinux.org for available languages Default: en -no-https Connect using HTTP, rather than HTTPS. This disables logging in. Default: use $SURFRAW_aur_protocol -order=ascending|descending Organize in ascending or descending order Default: ascending -orphans Search orphaned packages -outdated Search for out-of-date packages -results=NUM Number of search results returned Default: $SURFRAW_aur_results Must be in range 25-100 -search= Search for one of... name | Package name maintainer | Maintainer submitter | Submitter Default: name -sort= Sort by... name | Package name category | Package category location | Package location votes | Number of votes maintainer | Package maintainer age | Package age Default: name EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -category=*) setopt SURFRAW_aur_category "$optarg" ;; -language=*) setopt SURFRAW_aur_language "$optarg" ;; -no-https) setopt SURFRAW_aur_protocol "http" ;; -orphans*) setopt SURFRAW_aur_action "Orphans=Orphans" ;; -order=d*) setopt SURFRAW_aur_order d ;; -order=*) setopt SURFRAW_aur_order a ;; -outdated*) setoptyn SURFRAW_aur_outdated 1 ;; -results=*) setopt SURFRAW_aur_results "$optarg" ;; -search=*) setopt SURFRAW_aur_search "$optarg" ;; -sort=*) setopt SURFRAW_aur_sort "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_aur_category" in a*) aur_category=0 ;; da*) aur_category=2 ;; de*) aur_category=3 ;; ed*) aur_category=4 ;; em*) aur_category=5 ;; ga*) aur_category=6 ;; gn*) aur_category=7 ;; i*) aur_category=8 ;; kd*) aur_category=9 ;; ke*) aur_category=19 ;; l*) aur_category=10 ;; mo*) aur_category=11 ;; mu*) aur_category=12 ;; n*) aur_category=13 ;; o*) aur_category=14 ;; sc*) aur_category=15 ;; sy*) aur_category=16 ;; x1*) aur_category=17 ;; xf*) aur_category=18 ;; *) aur_category=0 ;; esac case "$SURFRAW_aur_search" in n*) aur_search_by=nd ;; m*) aur_search_by=m ;; s*) aur_search_by=s ;; *) aur_search_by=nd ;; esac case "$SURFRAW_aur_sort" in n*) aur_sort_by=n ;; c*) aur_sort_by=c ;; l*) aur_sort_by=l ;; v*) aur_sort_by=v ;; m*) aur_sort_by=m ;; a*) aur_sort_by=a ;; *) aur_sort_by=n ;; esac # Use SURFRAW_lang if present and the country has not been changed # More or less verbatim from the google elvis if test -n "$SURFRAW_lang" -a "$SURFRAW_aur_language" = "en"; then SURFRAW_aur_language="$SURFRAW_lang"; fi case "$SURFRAW_aur_language" in ca|cs|de|en|es|fr|hr|hu|it|nb_no|nb_NO|pl|pt|ro|ru|sr|tr|uk|zh_cn|zh_CN) aur_lang="$SURFRAW_aur_language" ;; *) aur_lang=en ;; esac # w3_args now contains a list of arguments if test -z "$w3_args" && test "$SURFRAW_aur_action" = "Search=Go"; then w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?setlang=${aur_lang}" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_aur_outdated" = 1 ]; then w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?O=0&L=0&detail=1&C=${aur_category}&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&do_${SURFRAW_aur_action}&outdated=on&setlang=${aur_lang}" else w3_browse_url "${SURFRAW_aur_protocol}://aur.archlinux.org/packages.php?O=0&L=0&detail=1&C=${aur_category}&K=${escaped_args}&SeB=${aur_search_by}&SB=${aur_sort_by}&SO=${SURFRAW_aur_order}&PP=${SURFRAW_aur_results}&do_${SURFRAW_aur_action}&setlang=${aur_lang}" fi fi diff --git a/elvi/austlii b/elvi/austlii index 59f2a6b..c66e0d4 100755 --- a/elvi/austlii +++ b/elvi/austlii @@ -1,54 +1,54 @@ #!/bin/sh # $Id$ # elvis: austlii -- Search Australian Law docs (www.austlii.edu.au) . surfraw || exit 1 w3_config_hook () { def SURFRAW_austlii_results $SURFRAW_results def SURFRAW_austlii_method auto } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Australian & world case law, legislation and policy documents at Austlii (www.austlii.edu.au), the Australian Legal Information Institute Local options: -method=auto | boolean | any | all | phrase | legis | title Define search method Default: $SURFRAW_austlii_method Environment: SURFRAW_austlii_method -results=NUM Number of search results returned Default: $SURFRAW_austlii_results Environment: SURFRAW_austlii_results EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -method=*) setopt SURFRAW_austlii_method $optarg ;; -results=*) setopt SURFRAW_austlii_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.austlii.edu.au/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.austlii.edu.au/cgi-bin/sinosrch.cgi?method=${SURFRAW_austlii_method}&meta=%2Fau&query=${escaped_args}&results=${SURFRAW_austlii_results}&submit=Search&callback=on&mask_world=&mask_path=" fi diff --git a/elvi/bbcnews b/elvi/bbcnews index da47705..19141b1 100755 --- a/elvi/bbcnews +++ b/elvi/bbcnews @@ -1,53 +1,53 @@ #!/bin/sh # $Id$ # elvis: bbcnews -- Search BBC News (news.bbc.co.uk) # [email protected] 20030209 . surfraw || exit 1 w3_config_hook () { if [ "$SURFRAW_lang" = "uk" ]; then def SURFRAW_bbcnews_scope uk else def SURFRAW_bbcnews_scope world fi } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search BBC News (news.bbc.co.uk) Local options: -scope=world | uk Search world or uk news Default: $SURFRAW_bbcnews_scope Environment: SURFRAW_bbcnews_scope EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -scope=*) setopt SURFRAW_bbcnews_scope $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://news.bbc.co.uk/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if [ $SURFRAW_bbcnews_scope = uk ]; then w3_browse_url "http://search.bbc.co.uk/search?scope=uk&tab=ns&q=${escaped_args}" else w3_browse_url "http://search.bbc.co.uk/search?scope=all&tab=ns&q=${escaped_args}" fi fi diff --git a/elvi/bing b/elvi/bing index cd2173a..0e84c30 100755 --- a/elvi/bing +++ b/elvi/bing @@ -1,28 +1,28 @@ #!/bin/sh # # AUTHOR: tczy, based on piratebay by J.R. Mauro # # DATE: Mon, 18 Jan 2010 13:37:00 +0100 # # DESC: Elvi to search the web using Microsoft's Bing # elvis: bing -- Search the web using Microsoft's Bing (www.bing.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the web using Microsoft's Bing (www.bing.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.bing.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.bing.com/search?q=${escaped_args}&go=&form=QBLH&filt=all" fi diff --git a/elvi/bookfinder b/elvi/bookfinder index c762248..d33fda5 100755 --- a/elvi/bookfinder +++ b/elvi/bookfinder @@ -1,131 +1,131 @@ #!/bin/sh # $Id$ # elvis: bookfinder -- Search for books using www.bookfinder.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_bookfinder_binding "any" defyn SURFRAW_bookfinder_classic 0 def SURFRAW_bookfinder_currency "USD" def SURFRAW_bookfinder_destination "us" defyn SURFRAW_bookfinder_first 0 def SURFRAW_bookfinder_language "en" def SURFRAW_bookfinder_search "title" defyn SURFRAW_bookfinder_signed 0 def SURFRAW_bookfinder_type "any" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search terms]... Description: Surfraw: Search for books using www.bookfinder.com Example: Local Options: -author="..." Search for an author. Complements -search=title -binding= Search for copies with a particular binding any | Any hard | Hardbacks only soft | Softcovers/paperbacks only Default: $SURFRAW_bookfinder_binding Environment: SURFRAW_bookfinder_binding -classic Use classic search display Default: no Environment: SURFRAW_bookfinder_classic -currency= Display prices in the given currency (ISO currency code) Default: $SURFRAW_bookfinder_currency Environment: SURFRAW_bookfinder_destination -destination= Shipping destination (Two-digit ISO country code) Default: $SURFRAW_bookfinder_destination Environment: SURFRAW_bookfinder_destination -first Search first editions -keywords="..." Search for keywords -language= Search for books in... de | German en | English es | Spanish fr | French it | Italian nl | Dutch Default: $SURFRAW_bookfinder_language Environment: SURFRAW_bookfinder_language -maxprice= Set the maximum acceptable price -minprice= Set the minimum acceptable price -search= Search by... title author isbn Default: $SURFRAW_bookfinder_search Environment: SURFRAW_bookfinder_search -signed Search for signed copies -title="..." Search for a title. Complements -search=author -type= Search books that are... any | Any new | New used | Used and/or out of print Default: $SURFRAW_bookfinder_type Environment: SURFRAW_bookfinder_type EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -author=*) - setopt SURFRAW_bookfinder_author `w3_url_of_arg "$optarg"` ;; + setopt SURFRAW_bookfinder_author $(w3_url_of_arg "$optarg") ;; -binding=any) setopt SURFRAW_bookfinder_binding '*' ;; -binding=*) setopt SURFRAW_bookfinder_binding "$optarg" ;; -classic) setoptyn SURFRAW_bookfinder_classic 1 ;; -currency=*) setopt SURFRAW_bookfinder_currency "$optarg" ;; -destination=*) setopt SURFRAW_bookfinder_destination "$optarg" ;; -first) setoptyn SURFRAW_bookfinder_first 1 ;; -keywords=*) - setopt SURFRAW_bookfinder_keywords `w3_url_of_arg "$optarg"` ;; + setopt SURFRAW_bookfinder_keywords $(w3_url_of_arg "$optarg") ;; -language=*) setopt SURFRAW_bookfinder_language "$optarg" ;; -maxprice=*) setopt SURFRAW_bookfinder_maxprice "$optarg" ;; -minprice=*) setopt SURFRAW_bookfinder_minprice "$optarg" ;; -search=*) setopt SURFRAW_bookfinder_search "$optarg" ;; -signed) setoptyn SURFRAW_bookfinder_signed 1 ;; -title=*) - setopt SURFRAW_bookfinder_title `w3_url_of_arg "$optarg"` ;; + setopt SURFRAW_bookfinder_title $(w3_url_of_arg "$optarg") ;; -type=any) setopt SURFRAW_bookfinder_type '*' ;; -type=*) setopt SURFRAW_bookfinder_type "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then url="http://www.bookfinder.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) case "$SURFRAW_bookfinder_search" in author) setopt SURFRAW_bookfinder_author "$escaped_args" ;; isbn) setopt SURFRAW_bookfinder_isbn "$escaped_args" ;; title) setopt SURFRAW_bookfinder_title "$escaped_args" ;; *) return 1 ;; esac url="http://www.bookfinder.com/search/?author=${SURFRAW_bookfinder_author}&title=${SURFRAW_bookfinder_title}&lang=${SURFRAW_bookfinder_language}&submit=Begin%20search&new_used=${SURFRAW_bookfinder_type}&destination=${SURFRAW_bookfinder_destination}&currency=${SURFRAW_bookfinder_currency}&binding=${SURFRAW_bookfinder_binding}&isbn=${SURFRAW_bookfinder_isbn}&keywords=${SURFRAW_bookfinder_keywords}&minprice=${SURFRAW_bookfinder_minprice}&maxprice=${SURFRAW_bookfinder_maxprice}&mode=advanced&st=sr&ac=qr" if [ "$SURFRAW_bookfinder_classic" = 1 ]; then url="${url}&classic=on" fi if [ "$SURFRAW_bookfinder_first" = 1 ]; then url="${url}&first=on" fi if [ "$SURFRAW_bookfinder_signed" = 1 ]; then url="${url}&signed=on" fi fi w3_browse_url "$url" # End of file diff --git a/elvi/bugmenot b/elvi/bugmenot index a1544c3..1769d8d 100755 --- a/elvi/bugmenot +++ b/elvi/bugmenot @@ -1,25 +1,25 @@ #!/bin/sh # $Id$ # elvis: bugmenot -- Bypass compulsory web registration with bugmenot.com . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [URL]... Description: Surfraw: Bypass compulsory web registration using www.bugmenot.com EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.bugmenot.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.bugmenot.com/view/${escaped_args}" fi diff --git a/elvi/bugzilla b/elvi/bugzilla index 7a4692b..070587b 100755 --- a/elvi/bugzilla +++ b/elvi/bugzilla @@ -1,87 +1,87 @@ #!/bin/sh # elvis: bugzilla -- Search for bugs on Bugzilla bugtrackers . surfraw || exit 1 w3_config_hook () { def SURFRAW_bugzilla_site kernel def SURFRAW_bugzilla_status open def SURFRAW_bugzilla_product all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search for bugs on Bugzilla bugtrackers Local options: -site=URL Bugzilla site to search The site URL can be specified, or the following aliases can be used: kernel, mozilla, gnome, kde, apache, freedesktop, eclipse, redhat, mandriva, gentoo, novell Default: $SURFRAW_bugzilla_site Environment: SURFRAW_bugzilla_site Examples: bugzilla -s=https://bugs.kde.org ipv6 bugzilla -s=kde ipv6 -status=open | Bug status closed | all Default: $SURFRAW_bugzilla_status Environment: SURFRAW_bugzilla_status -product=all | Product to search for bugs in. <product name> Default: $SURFRAW_bugzilla_product Environment: SURFRAW_bugzilla_product EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -st*=*) setopt SURFRAW_bugzilla_status "$optarg" ;; -s*=*) setopt SURFRAW_bugzilla_site "$optarg" ;; -p*=*) setopt SURFRAW_bugzilla_product "$(w3_url_of_arg "$optarg")" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ "$SURFRAW_bugzilla_product" = all ] ; then setopt SURFRAW_bugzilla_product "" fi case "$SURFRAW_bugzilla_status" in open) setopt SURFRAW_bugzilla_status "__open__" ;; closed) setopt SURFRAW_bugzilla_status "__closed__" ;; all) setopt SURFRAW_bugzilla_status "__all__" ;; esac case "$SURFRAW_bugzilla_site" in kernel) setopt SURFRAW_bugzilla_site "https://bugzilla.kernel.org" ;; mozilla) setopt SURFRAW_bugzilla_site "https://bugzilla.mozilla.org" ;; gnome) setopt SURFRAW_bugzilla_site "https://bugzilla.gnome.org" ;; kde) setopt SURFRAW_bugzilla_site "https://bugs.kde.org" ;; apache) setopt SURFRAW_bugzilla_site "https://issues.apache.org/bugzilla" ;; freedesktop) setopt SURFRAW_bugzilla_site "https://bugs.freedesktop.org" ;; eclipse) setopt SURFRAW_bugzilla_site "https://bugs.eclipse.org/bugs" ;; redhat) setopt SURFRAW_bugzilla_site "https://bugzilla.redhat.com/" ;; gentoo) setopt SURFRAW_bugzilla_site "https://bugs.gentoo.org" ;; novell) setopt SURFRAW_bugzilla_site "https://bugzilla.novell.com" ;; esac if test -z "$w3_args"; then w3_browse_url "${SURFRAW_bugzilla_site}/query.cgi?format=advanced" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) # params="short_desc_type=allwordssubstr&short_desc=${escaped_args}&bug_status=${SURFRAW_bugzilla_status}" params="content=${escaped_args}&bug_status=${SURFRAW_bugzilla_status}" params="${params}&product=${SURFRAW_bugzilla_product}" w3_browse_url "${SURFRAW_bugzilla_site}/buglist.cgi?${params}" fi diff --git a/elvi/cia b/elvi/cia index 1c24a7f..d2eed58 100755 --- a/elvi/cia +++ b/elvi/cia @@ -1,27 +1,27 @@ #!/bin/sh # jbr20050112 # elvis: cia -- Search CIA documents at www.cia.gov . surfraw || exit 1 # could have -worldfactbook etc, but I always use Entire Site w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search CIA documents at www.cia.gov Example: cia WDM EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.cia.gov/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.cia.gov/search?q=${escaped_args}&site=CIA&client=CIA&proxystylesheet=CIA&output=xml_no_dtd&myAction=%2Fsearch&submitMethod=get" fi diff --git a/elvi/cisco b/elvi/cisco index 024d9b1..bd301f1 100755 --- a/elvi/cisco +++ b/elvi/cisco @@ -1,25 +1,25 @@ #!/bin/sh # $Id$ # elvis: cisco -- Search Cisco documentation (www.cisco.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Cisco documentation (www.cisco.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://tools.cisco.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) # w3_browse_url "https://tools.cisco.com/search/JSP/search-results.get?strQueryText=${escaped_args}&Search+All+cisco.com=cisco.com" w3_browse_url "https://tools.cisco.com/search/results/en/us/get?q=${escaped_args}&js=0" fi diff --git a/elvi/cite b/elvi/cite index 3fca772..dcf6a99 100755 --- a/elvi/cite +++ b/elvi/cite @@ -1,54 +1,54 @@ #!/bin/sh # $Id$ # elvis: cite -- Search computer science papers (citeseerx.ist.psu.edu) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_cite_citations 0 defyn SURFRAW_cite_authors 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search CiteSeer^X (citeseerx.ist.psu.edu) CiteSeer is a scientific literature digital library that indexes the full text of spidered PDF and PS documents and performes sophisticated clustering and citation analysis on the results. Local options: -cite Include citations. -author Search authors instead of documents. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -cit*) setoptyn SURFRAW_cite_citations 1 ;; -auth*) setoptyn SURFRAW_cite_authors 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://citeseerx.ist.psu.edu/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="http://citeseerx.ist.psu.edu/search?q=${escaped_args}&submit=Search" if ifyes SURFRAW_cite_citations; then url="${url}&ic=1" fi if ifyes SURFRAW_cite_authors; then url="${url}&uauth=1" fi w3_browse_url "$url" fi diff --git a/elvi/cliki b/elvi/cliki index 3df514c..94d8e38 100755 --- a/elvi/cliki +++ b/elvi/cliki @@ -1,27 +1,27 @@ #!/bin/sh # # AUTHOR: S.S.R. Oemrawsingh # # DATE: Mon Oct 26 2009 # # DESC: Elvi to search cliki.net # elvis: cliki -- Search the common lisp wiki . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the common lisp wiki EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then w3_browse_url "http://www.cliki.net/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.cliki.net/site/search?query=${escaped_args}" fi diff --git a/elvi/cnn b/elvi/cnn index 6b25ef1..d1fc868 100755 --- a/elvi/cnn +++ b/elvi/cnn @@ -1,25 +1,25 @@ #!/bin/sh # $Id$ # elvis: cnn -- Search on CNN (cnn.com) # version 0.1 by Ross Campbell [email protected] # version 0.2 updated url . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search on CNN (search.cnn.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://cnn.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.cnn.com/search/?query=${escaped_args}&x=0&y=0&primaryType=mixed" fi diff --git a/elvi/comlaw b/elvi/comlaw index 3a052f3..0457aea 100755 --- a/elvi/comlaw +++ b/elvi/comlaw @@ -1,23 +1,23 @@ #!/bin/sh # $Id$ # elvis: comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Australian Law using Comlaw (www.comlaw.gov.au) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.legislation.gov.au/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.legislation.gov.au/Search/${escaped_args}" fi diff --git a/elvi/commandlinefu b/elvi/commandlinefu index e981b2c..56b7f3a 100755 --- a/elvi/commandlinefu +++ b/elvi/commandlinefu @@ -1,65 +1,65 @@ #!/bin/sh # $Id$ # elvis: commandlinefu -- search on www.commandlinefu.com # The API of the site is described at http://www.commandlinefu.com/site/api. . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_commandlinefu_votes 1 def SURFRAW_commandlinefu_format html } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search www.commandlinefu.com Local options: -html get results as html -txt get results as plain text -json get results as json -rss get results as rss data Default: $SURFRAW_commandlinefu_format -v, -s, -votes, -sort sort results by votes -u, -n, -unsort, -nosort do not sort results Default: $SURFRAW_commandlinefu_votes EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -json) setopt SURFRAW_commandlinefu_format json ;; -html) setopt SURFRAW_commandlinefu_format html ;; -rss) setopt SURFRAW_commandlinefu_format rss ;; -txt) setopt SURFRAW_commandlinefu_format plaintext ;; -v|-votes|-s|-sort) setoptyn SURFRAW_commandlinefu_votes 1 ;; -u|-unsort|-n|-nosort) setoptyn SURFRAW_commandlinefu_votes 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments url=https://www.commandlinefu.com/commands/matching # The next part of the url is a normalized plaintext version of the search # query. It seems to be unused by the CGI but it needs to be present. So we # normalize to "x". url=$url/x # What is really used is the base64 encoded query. (echo -n is not portable) -url=$url/"`printf %s "$w3_args" | base64`" +url=$url/"$(printf %s "$w3_args" | base64)" # possibly add the sorting option if test $SURFRAW_commandlinefu_votes -eq 1; then url="$url/sort-by-votes" fi # add the output format option if test $SURFRAW_commandlinefu_format != html; then url="$url/$SURFRAW_commandlinefu_format" fi w3_browse_url "$url" diff --git a/elvi/ctan b/elvi/ctan index 72ed27b..64a0b28 100755 --- a/elvi/ctan +++ b/elvi/ctan @@ -1,70 +1,70 @@ #!/bin/sh # $Id$ # elvis: ctan -- Search the Comprehensive TeX Archive Network (ctan.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_ctan_topics 0 defyn SURFRAW_ctan_desc 0 defyn SURFRAW_ctan_authors 0 def SURFRAW_ctan_results $SURFRAW_results } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Comprehensive TeX Archive Network (ctan.org) Local options: -desc Search descriptions (default) -topics Search by filename -authors Search package identifiers Options can be combined to search multiple types at once. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -top*) setoptyn SURFRAW_ctan_topics 1 ;; -d*) setoptyn SURFRAW_ctan_desc 1 ;; -au*) setoptyn SURFRAW_ctan_authors 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.ctan.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if ifno SURFRAW_ctan_topics && ifno SURFRAW_ctan_desc && ifno SURFRAW_ctan_authors then SURFRAW_ctan_desc=1 fi url="https://www.ctan.org/search/?x=1&PORTAL=on" url="${url}&phrase=${escaped_args}&max=${SURFRAW_results}" if ifyes SURFRAW_ctan_topics then url="${url}&TOPICS=on" fi if ifyes SURFRAW_ctan_desc then url="${url}&PKG=on" fi if ifyes SURFRAW_ctan_authors then url="${url}&AUTHORS=on" fi w3_browse_url "$url" fi diff --git a/elvi/currency b/elvi/currency index 4787780..2efa44a 100755 --- a/elvi/currency +++ b/elvi/currency @@ -1,382 +1,382 @@ #!/bin/sh # $Id$ # elvis: currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) . surfraw || exit 1 list_currency_symbols () { cat <<EOT Symbol Country and Currency AFA Afghanistan, Afghani ALL Albania, Lek DZD Algeria, Dinar USD America (United States), Dollar USD American Samoa, United States Dollar EUR Andorra, Euro AOA Angola, Kwanza XCD Anguilla, East Caribbean Dollar XCD Antigua and Barbuda, East Caribbean Dollar ARS Argentina, Peso AMD Armenia, Dram AWG Aruba, Guilder AUD Ashmore and Cartier Islands, Australia Dollar AUD Australia, Dollar EUR Austria, Euro ATS Austria, Schilling [obsolete] AZM Azerbaijan, Manat EUR Azores, Euro BSD Bahamas, Dollar BHD Bahrain, Dinar BBD Bajan (Barbados), Dollar EUR Balearic Islands, Euro BDT Bangladesh, Taka BBD Barbados, Dollar BYR Belarus, Ruble EUR Belgium, Euro BEF Belgium, Franc [obsolete] BZD Belize, Dollar XOF Benin, CFA Franc BCEAO BMD Bermuda, Dollar INR Bhutan, India Rupee BTN Bhutan, Ngultrum BOB Bolivia, Boliviano ANG Bonaire, Netherlands Antilles Guilder BAM Bosnia and Herzegovina, Convertible Marka BWP Botswana, Pula BRL Brazil, Real GBP Britain (United Kingdom), Pound GBP British Indian Ocean Territory, United Kingdom Pound USD British Indian Ocean Territory, United States Dollar USD British Virgin Islands, United States Dollar BND Brunei, Dollar SGD Brunei, Singapore Dollar BGN Bulgaria, Lev XOF Burkina Faso, CFA Franc BCEAO MMK Burma (Myanmar), Kyat BIF Burundi, Franc KHR Cambodia, Riel XAF Cameroon, CFA Franc BEAC CAD Canada, Dollar EUR Canary Islands, Euro CVE Cape Verde, Escudo KYD Cayman Islands, Dollar XAF Central African Republic, CFA Franc BEAC XAF CFA Communauté Financière Africaine BEAC Franc XOF CFA Communauté Financière Africaine BCEAO Franc XAF Chad, CFA Franc BEAC CLP Chile, Peso CNY China, Yuan Renminbi AUD Christmas Island, Australia Dollar AUD Cocos (Keeling Islands, Australia Dollar COP Colombia, Peso XAF Communauté Financière Africaine BEAC Franc XOF Communauté Financière Africaine BCEAO Franc KMF Comoros, Franc XPF Comptoirs Français du Pacifique Franc XAF Congo/Brazzaville, CFA Franc BEAC CDF Congo/Kinshasa, Franc NZD Cook Islands, New Zealand Dollar AUD Coral Sea Islands, Australia Dollar CRC Costa Rica, Colon XOF Côte d'Ivoire, CFA Franc BCEAO HRK Croatia, Kuna CUC Cuba, Convertible Peso CUP Cuba, Peso ANG Curaço, Netherlands Antilles Guilder CYP Cyprus, Pound CZK Czech Republic, Koruna DKK Denmark, Krone DJF Djibouti, Franc XCD Dominica, East Caribbean Dollar DOP Dominican Republic, Peso EUR Dutch (Netherlands), Euro NLG Dutch (Netherlands), Guilder [obsolete] XCD East Caribbean Dollar USD East Timor, United States Dollar USD Ecuador, United States Dollar EGP Egypt, Pound SVC El Salvador, Colon GBP England (United Kingdom), Pound XAF Equatorial Guinea, CFA Franc BEAC ERN Eritrea, Nakfa EEK Estonia, Kroon ETB Ethiopia, Birr EUR Euro EUR Europa Island, Euro FKP Falkland Islands, Pound DKK Faroe Islands, Denmark Krone FJD Fiji, Dollar EUR Finland, Euro FIM Finland, Markka [obsolete] EUR France, Euro FRF France, Franc [obsolete] EUR French Guiana, Euro XPF French Polynesia, Comptoirs Français du Pacifique Franc EUR French Polynesia, Euro EUR French Southern and Antarctic Lands, Euro XAF Gabon, CFA Franc BEAC GMD Gambia, Dalasi ILS Gaza Strip, Israel New Shekel GEL Georgia, Lari DEM Germany, Deutsche Mark [obsolete] EUR Germany, Euro GHC Ghana, Cedi GIP Gibraltar, Pound XAU Gold Ounce GBP Great Britain (United Kingdom), Pound EUR Greece, Euro GRD Greece, Drachma [obsolete] DKK Greenland, Denmark Krone XCD Grenada, East Caribbean Dollar EUR Guadeloupe, Euro USD Guam, United States Dollar GTQ Guatemala, Quetzal GGP Guernsey, Pound GNF Guinea, Franc XOF Guinea-Bissau, CFA Franc BCEAO GYD Guyana, Dollar HTG Haiti, Gourde EUR Holland (Netherlands), Euro NLG Holland (Netherlands), Guilder [obsolete] EUR Holy See (Vatican City), Euro VAL Holy See (Vatican City), Lira [obsolete] HNL Honduras, Lempira HKD Hong Kong, Dollar HUF Hungary, Forint ISK Iceland, Krona INR India, Rupee IDR Indonesia, Rupiah XDR International Monetary Fund Special Drawing Right IRR Iran, Rial IQD Iraq, Dinar EUR Ireland, Euro IEP Ireland, Pound [obsolete] FKP Islas Malvinas (Falkland Islands), Pound IMP Isle of Man, Pound ILS Israel, New Shekel EUR Italy, Euro ITL Italy, Lira [obsolete] XOF Ivory Coast (Côte d'Ivoire), CFA Franc BCEAO JMD Jamaica, Dollar JPY Japan, Yen JEP Jersey, Pound USD Johnson, United States Dollar JOD Jordan, Dinar EUR Juan de Nova, Euro KZT Kazakhstan, Tenge KES Kenya, Shilling AUD Kiribati, Australia Dollar KWD Kuwait, Dinar KGS Kyrgyzstan, Som LAK Laos, Kip LVL Latvia, Lat LBP Lebanon, Pound LSL Lesotho, Loti LRD Liberia, Dollar LYD Libya, Dinar CHF Liechtenstein, Switzerland Franc LTL Lithuania, Litas EUR Luxembourg, Euro LUF Luxembourg, Franc [obsolete] MOP Macau, Pataca MKD Macedonia, Denar MGA Madagascar, Ariary MGF Madagascar, Franc [obsolete] EUR Madeira Islands, Euro MWK Malawi, Kwacha MYR Malaysia, Ringgit MVR Maldives, Rufiyaa XOF Mali, CFA Franc BCEAO MTL Malta, Lira FKP Malvinas (Falkland Islands), Pound USD Marshall Islands, United States Dollar EUR Martinique, Euro MRO Mauritania, Ouguiya MUR Mauritius, Rupee EUR Mayotte, Euro MXN Mexico, Peso USD Micronesia, United States Dollar USD Midway Islands, United States Dollar MDL Moldova, Leu EUR Monaco, Euro MNT Mongolia, Tughrik EUR Montenegro, Euro XCD Montserrat, East Caribbean Dollar MAD Morocco, Dirham MZM Mozambique, Metical MMK Myanmar (Burma), Kyat NAD Namibia, Dollar AUD Nauru, Australia Dollar HTG Navassa, Haiti Gourde USD Navassa, United States Dollar CNY Nepal, China Yuan Renminbi NPR Nepal, Rupee ANG Netherlands Antilles, Guilder EUR Netherlands, Euro NLG Netherlands, Guilder [obsolete] XPF New Caledonia, Comptoirs Français du Pacifique Franc NZD New Zealand, Dollar NIO Nicaragua, Cordoba XOF Niger, CFA Franc BCEAO NGN Nigeria, Naira NZD Niue, New Zealand Dollar AUD Norfolk Island, Australia Dollar KPW North Korea, Won USD Northern Mariana Islands, United States Dollar NOK Norway, Krone OMR Oman, Rial PKR Pakistan, Rupee USD Palau, United States Dollar XPD Palladium Ounce PAB Panama, Balboa USD Panama, United States Dollar PGK Papua New Guinea, Kina CNY Paracel Islands, China Yuan Renminbi VND Paracel Islands, Vietnam Dong PYG Paraguay, Guarani PEN Peru, Nuevo Sol PHP Philippines, Peso NZD Pitcairn, New Zealand Dollar XPT Platinum Ounce PLN Poland, Zloty EUR Portugal, Euro PTE Portugal, Escudo [obsolete] USD Puerto Rico, United States Dollar QAR Qatar, Riyal EUR Reunion, Euro ROL Romania, Leu RUB Russia, Ruble RWF Rwanda, Franc ANG Saba, Netherlands Antilles Guilder SHP Saint Helena, Pound XCD Saint Kitts and Nevis, East Caribbean Dollar XCD Saint Lucia, East Caribbean Dollar EUR Saint Pierre and Miquelon, Euro XCD Saint Vincent and The Grenadines, East Caribbean Dollar EUR Saint-Martin, Euro WST Samoa, Tala EUR San Marino, Euro STD São Tome and Principe, Dobra SAR Saudi Arabia, Riyal GBP Scotland (United Kingdom), Pound SPL Seborga, Luigino XOF Senegal, CFA Franc BCEAO CSD Serbia, Dinar SCR Seychelles, Rupee SLL Sierra Leone, Leone XAG Silver Ounce SGD Singapore, Dollar ANG Sint Eustatius, Netherlands Antilles Guilder ANG Sint Maarten, Netherlands Antilles Guilder SKK Slovakia, Koruna SIT Slovenia, Tolar SBD Solomon Islands, Dollar SOS Somalia, Shilling ZAR South Africa, Rand GBP South Georgia, United Kingdom Pound KRW South Korea, Won GBP South Sandwich Islands, United Kingdom Pound EUR Spain, Euro ESP Spain, Peseta [obsolete] LKR Sri Lanka, Rupee SDD Sudan, Dinar SRD Suriname, Dollar SRG Suriname, Guilder NOK Svalbard and Jan Mayen, Norway Krone SZL Swaziland, Lilangeni ZAR Swaziland, South Africa Rand SEK Sweden, Krona CHF Switzerland, Franc SYP Syria, Pound TWD Taiwan, New Dollar TJS Tajikistan, Somoni RUB Tajikistan, Russia Ruble TZS Tanzania, Shilling THB Thailand, Baht XOF Togo, CFA Franc BCEAO NZD Tokelau, New Zealand Dollar TOP Tonga, Pa'anga MDL Transnistria, Moldova Leu TTD Trinidad and Tobago, Dollar TND Tunisia, Dinar TRY Turkey, New Lira TRL Turkey, Lira TMM Turkmenistan, Manat USD Turks and Caicos Islands, United States Dollar AUD Tuvalu, Australia Dollar TVD Tuvalu, Dollar UGX Uganda, Shilling UAH Ukraine, Hryvna AED United Arab Emirates, Dirham GBP United Kingdom, Pound USD United States, Dollar UYU Uruguay, Peso UZS Uzbekistan, Som VUV Vanuatu, Vatu EUR Vatican City, Euro VAL Vatican City, Lira [obsolete] VEB Venezuela, Bolivar VND Vietnam, Dong USD Virgin Islands, United States Dollar USD Wake Island, United States Dollar XPF Wallis and Futuna Islands, Comptoirs Français du Pacifique Franc ILS West Bank, Israel New Shekel JOD West Bank, Jordan Dinar MAD Western Sahara, Morocco Dirham WST Western Samoa (Samoa), Tala YER Yemen, Rial ZMK Zambia, Kwacha ZWD Zimbabwe, Dollar EOT } w3_config_hook () { def SURFRAW_currency_from USD def SURFRAW_currency_to EUR } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Convert currencies with the Universal Currency Converter (www.xe.net/ucc) Local options: -l List all known currency symbols. -from=SYM Symbol for currency to convert from. Default: $SURFRAW_currency_from Environment: SURFRAW_currency_from -to=SYM Symbol for currency to convert to. Default: $SURFRAW_currency_to Environment: SURFRAW_currency_to Example currency symbols: EUR (Euro), USD (US Dollars), GBP (UK Pounds), CAD (Canada Dollars), AUD (Australia Dollars), JPY (Japan Yen), INR (India Rupees), NZD (New Zealand Dollars), CHF (Switzerland Francs), ZAR (South Africa Rand) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -from=*) setopt SURFRAW_currency_from $optarg ;; -to=*) setopt SURFRAW_currency_to $optarg ;; -l) list_currency_symbols; exit 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.xe.com/currencyconverter/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.xe.com/currencyconverter/Amount=${escaped_args}&From=${SURFRAW_currency_from}&To=${SURFRAW_currency_to}&submit=Perform+Currency+Conversion" fi diff --git a/elvi/cve b/elvi/cve index a796782..7561949 100755 --- a/elvi/cve +++ b/elvi/cve @@ -1,25 +1,25 @@ #!/bin/sh # Moritz Muehlenhoff <[email protected]> # elvis: cve -- Search for CAN assignments in CVE . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search for CAN assignments in the CVE dictionary Example: cve CAN-2005-0666 EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://cve.mitre.org" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://cve.mitre.org/cgi-bin/cvename.cgi?name=${escaped_args}" fi diff --git a/elvi/debbugs b/elvi/debbugs index 6ac05aa..f5d930e 100755 --- a/elvi/debbugs +++ b/elvi/debbugs @@ -1,235 +1,235 @@ #!/bin/sh # $Id$ # elvis: debbugs -- Search the debian BTS (bugs.debian.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debbugs_search pkg def SURFRAW_debbugs_version "" def SURFRAW_debbugs_dist "" defyn SURFRAW_debbugs_archive 0 defyn SURFRAW_debbugs_merge 0 defyn SURFRAW_debbugs_statussort 1 defyn SURFRAW_debbugs_head 1 defyn SURFRAW_debbugs_foot 1 def SURFRAW_debbugs_incstatus "" def SURFRAW_debbugs_excstatus "" def SURFRAW_debbugs_incsev "" def SURFRAW_debbugs_excsev "" def SURFRAW_debbugs_inctag "" def SURFRAW_debbugs_exctag "" defyn SURFRAW_debbugs_asmbox 0 defyn SURFRAW_debbugs_headers 0 defyn SURFRAW_debbugs_boring 0 defyn SURFRAW_debbugs_revstat 0 defyn SURFRAW_debbugs_revsev 0 defyn SURFRAW_debbugs_revbugs 0 defyn setsearch 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [package | bug number | maintainer email] Description: Surfraw search debian BTS (bugs.debian.org) Examples: debbugs 20000 | show report for bug #20000 debbugs [email protected] | show bugs for csurchi debbugs surfraw | show bugs for surfraw package debbugs -raw -rb surfraw | show surfraw bugs newest first Defaults if -search is not supplied: If arg is numeric, searches by bug number, If it contains '@', searches by maintainer, Otherwise, searches by package. Local options: -search= pkg | Search type. src | bug | (bug number) maint | tag | submitter | severity | tag -s Alias for -search=src -version=VERSION Package version. -dist=oldstable | Distribution stable | proposed-updates | testing | unstable | experimental | testing-proposed-updates -arc Show archived bugs. -raw Do not sort by status or severity. -rb Reverse order of bugs shown. -rst Reverse order of statuses shown. -rse Reverse order of severities shown. -merge Display merged bugs only once. -nohead Do not show table of contents header. -nofoot Do not show statistics in the footer. -mbox View results in mbox format. * -sh Show headers. * -boring Show boring messages. * (* = only when searching by bug number.) -incstat=stat1,stat2 Include given status list. -exstat=stat3,stat4 Exclude given status list. Available statuses: open, forwarded, pending, fixed, done. -incsev=sev1,sev2 Include given severities. -exsev=sev3,sev4 Exclude given severities. Available severities: critical, grave, serious, important, normal, minor, wishlist, fixed. -inctag=tag1,tag2 Include given tags. -extag=tag3,tag4 Exclude given tags. Available tags: potato, woody, sarge, sarge-ignore, etch, etch-ignore, sid, experimental, confirmed, d-i, fixed, fixed-in-experimental, fixed-upstream, help, l10n, moreinfo, patch, pending, security, unreproducible, upstream, wontfix, ipv6, lfs EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s) setopt SURFRAW_debbugs_search src ; setoptyn setsearch 1 ;; -se*=*) setopt SURFRAW_debbugs_search $optarg; setoptyn setsearch 1 ;; -ve*=*) setopt SURFRAW_debbugs_version $optarg ;; -dis*=*) setopt SURFRAW_debbugs_dist $optarg ;; -arc*) setoptyn SURFRAW_debbugs_archive 1;; -mer*) setoptyn SURFRAW_debbugs_merge 1;; -raw*) setoptyn SURFRAW_debbugs_statussort 0;; -noh*) setoptyn SURFRAW_debbugs_head 0;; -nof*) setoptyn SURFRAW_debbugs_foot 0;; -in*stat*=*) setopt SURFRAW_debbugs_incstatus $optarg;; -ex*stat*=*) setopt SURFRAW_debbugs_excstatus $optarg;; -in*sev*=*) setopt SURFRAW_debbugs_incsev $optarg;; -ex*sev*=*) setopt SURFRAW_debbugs_excsev $optarg;; -in*tag*=*) setopt SURFRAW_debbugs_inctag $optarg;; -ex*tag*=*) setopt SURFRAW_debbugs_exctag $optarg;; -rb*) setoptyn SURFRAW_debbugs_revbugs 1;; -rst*) setoptyn SURFRAW_debbugs_revstat 1;; -rse*) setoptyn SURFRAW_debbugs_revsev 1;; -mb*) setoptyn SURFRAW_debbugs_asmbox 1;; -sh*) setoptyn SURFRAW_debbugs_headers 1;; -bo*) setoptyn SURFRAW_debbugs_boring 1;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.debian.org/Bugs" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) setoptyn donum 0 setoptyn domaint 0 case "$SURFRAW_debbugs_search" in bug*) setoptyn donum 1;; esac # default search unless searchtype set on cmdline if ifno setsearch then export escaped_args if perl -e 'if($ENV{escaped_args} =~/^((\#|\%23)(\s|\%20)*)?\d+$/) { exit 0; } exit 1;' then # %23 = uri escaped '#', %20=' ' setoptyn donum 1 elif perl -e 'if($ENV{escaped_args} =~/\%40|@/) { exit 0; } exit 1;' then # %40 = uri escaped '@' setopt SURFRAW_debbugs_search "maint" fi fi if ifyes donum then url="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${escaped_args}" if yesno SURFRAW_debbugs_asmbox then url="$url&mbox=yes" fi if yesno SURFRAW_debbugs_headers then url="$url&trim=no" fi if yesno SURFRAW_debbugs_boring then url="$url&boring=yes" fi else url="https://bugs.debian.org/cgi-bin/pkgreport.cgi?which=${SURFRAW_debbugs_search}&version=${SURFRAW_debbugs_version}&dist=${SURFRAW_debbugs_dist}&data=${escaped_args}" if yesno SURFRAW_debbugs_archive then url="$url&archive=yes" else url="$url&archive=no" fi if ifyes SURFRAW_debbugs_merge then url="$url&repeatmerged=no" fi if ifno SURFRAW_debbugs_statussort then url="$url&raw=yes" fi if ifno SURFRAW_debbugs_head then url="$url&show_list_header=no" fi if ifno SURFRAW_debbugs_foot then url="$url&show_list_footer=no" fi if ifyes SURFRAW_debbugs_revstat then url="$url&pend-rev=yes" fi if ifyes SURFRAW_debbugs_revsev then url="$url&sev-rev=yes" fi if ifyes SURFRAW_debbugs_revbugs then url="$url&bug-rev=yes" fi if [ "$SURFRAW_debbugs_incstatus" != "" ] then - add=`echo "$SURFRAW_debbugs_incstatus"|perl -ne 's/pending/pending-fixed/g;s/open/pending/g;print(join("&pend-inc=","",split(/\s*,\s*/,$_)));'` + add=$(echo "$SURFRAW_debbugs_incstatus"|perl -ne 's/pending/pending-fixed/g;s/open/pending/g;print(join("&pend-inc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_excstatus" != "" ] then - add=`echo "$SURFRAW_debbugs_excstatus"|perl -ne 'print(join("&pend-exc=","",split(/\s*,\s*/,$_)));'` + add=$(echo "$SURFRAW_debbugs_excstatus"|perl -ne 'print(join("&pend-exc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_incsev" != "" ] then - add=`echo "$SURFRAW_debbugs_incsev"|perl -ne 'print(join("&sev-inc=","",split(/\s*,\s*/,$_)));'` + add=$(echo "$SURFRAW_debbugs_incsev"|perl -ne 'print(join("&sev-inc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_excsev" != "" ] then - add=`echo "$SURFRAW_debbugs_excsev"|perl -ne 'print(join("&sev-exc=","",split(/\s*,\s*/,$_)));'` + add=$(echo "$SURFRAW_debbugs_excsev"|perl -ne 'print(join("&sev-exc=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_inctag" != "" ] then - add=`echo "$SURFRAW_debbugs_inctag"|perl -ne 'print(join("&include=","",split(/\s*,\s*/,$_)));'` + add=$(echo "$SURFRAW_debbugs_inctag"|perl -ne 'print(join("&include=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi if [ "$SURFRAW_debbugs_exctag" != "" ] then - add=`echo "$SURFRAW_debbugs_exctag"|perl -ne 'print(join("&exclude=","",split(/\s*,\s*/,$_)));'` + add=$(echo "$SURFRAW_debbugs_exctag"|perl -ne 'print(join("&exclude=","",split(/\s*,\s*/,$_)));') url="${url}${add}" fi fi w3_browse_url "$url" fi diff --git a/elvi/debcodesearch b/elvi/debcodesearch index 4805e82..ab6f44d 100755 --- a/elvi/debcodesearch +++ b/elvi/debcodesearch @@ -1,23 +1,23 @@ #!/bin/sh # [email protected] 20130504 # elvis: debcodesearch -- Search debian source code . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search source code of debian packages EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://codesearch.debian.net" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://codesearch.debian.net/search?q=${escaped_args}" fi diff --git a/elvi/debcontents b/elvi/debcontents index 3dc65c3..8e3c762 100755 --- a/elvi/debcontents +++ b/elvi/debcontents @@ -1,155 +1,155 @@ #!/bin/sh # $Id$ # elvis: debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debcontents_arch i386 def SURFRAW_debcontents_distro stable def SURFRAW_debcontents_search "files" defyn SURFRAW_debcontents_ubuntu no defyn SURFRAW_debcontents_archive no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) Local options: -a Search archived debian releases -u Search ubuntu packages instead of debian -search= Type of search files | Packages that contain files named like this path | Paths ending with the keyword word | Packages that contain files or directories whose names contain the keyword Default: $SURFRAW_debcontents_search Environment: SURFRAW_debcontents_search -arch= Specialized search on architecture i386 | Intel x86 (all) powerpc | PowerPC (all) amd64 | AMD64 (all) m68k | Motorola 680x0 (debian, archive.debian) alpha | Alpha (debian, archive.debian) sparc | SPARC (debian, archive.debian) arm | ARM (debian, archive.debian) hppa | HP PA/RISC (debian, archive.debian) ia64 | Intel IA-64 (debian, archive.debian) mips | MIPS (debian, archive.debian) mipsel | MIPS (DEC) (debian, archive.debian) s390 | IBM S/390 (debian, archive.debian) hurd-i386 | Hurd (i386) (debian) kfreebsd-amd64 | kFreeBSD (amd64) (debian) kfreebsd-i386 kFreeBSD (i386) (debian) Default: $SURFRAW_debcontents_arch Environment: SURFRAW_debcontents_arch -distro= Specific distribution Debian: stable | Stable testing | Testing unstable | Unstable oldstable | Old Stable Archived Debian (-a): bo | 1.3.1 hamm | 2.0 slink | 2.1 potato | 2.2 woody | 3.0 sarge | 3.1 etch | 4.0 Ubuntu (-u): dapper | Dapper dapper-updates | Dapper Updates dapper-backports | Dapper Backports hardy | Hardy hardy-updates | Hardy Updates hardy-backports | Hardy Backports intrepid | Intrepid intrepid-updates | Intrepid Updates intrepid-backports| Intrepid Backports jaunty | Jaunty jaunty-updates | Jaunty Updates jaunty-backports | Jaunty Backports karmic | Karmic karmic-updates | Karmic Updates karmic-backports | Karmic Backports lucid | Lucid lucid-updates | Lucid Updates lucid-backports | Lucid Backports maverick | Maverick maverick-updates | Maverick Updates maverick-backports| Maverick Backports natty | Natty natty-updates | Natty Updates natty-backports | Natty Backports Default: $SURFRAW_debcontents_distro Environment: SURFRAW_debcontents_distro EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -arch=*) setopt SURFRAW_debcontents_arch $optarg ;; -distro=*) setopt SURFRAW_debcontents_distro $optarg ;; -search=*) setopt SURFRAW_debcontents_search $optarg ;; -u*) setoptyn SURFRAW_debcontents_ubuntu yes ;; -a*) setoptyn SURFRAW_debcontents_archive yes ;; -ca*) setoptyn SURFRAW_debcontents_usecase yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if ifyes SURFRAW_debcontents_ubuntu then searchpage="http://packages.ubuntu.com/#search_contents" searchurl="http://packages.ubuntu.com/search" elif ifyes SURFRAW_debcontents_archive then searchpage="https://archive.debian.net/#search_contents" searchurl="https://archive.debian.net/search" else searchpage="https://packages.debian.org/#search_contents" searchurl="https://packages.debian.org/search" fi if test -z "$w3_args"; then w3_browse_url "$searchpage" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if ifyes SURFRAW_debcontents_ubuntu then if [ "$SURFRAW_debcontents_distro" = "stable" ] then SURFRAW_debcontents_distro=raring fi fi url="$searchurl?keywords=${escaped_args}&searchon=contents" url="$url&arch=${SURFRAW_debcontents_arch}" url="$url&suite=${SURFRAW_debcontents_distro}" case "$SURFRAW_debcontents_search" in p*) if ifyes SURFRAW_debcontents_ubuntu || ifyes SURFRAW_debcontents_archive then searchmode="" else searchmode=path fi;; f*) searchmode=exactfilename ;; w*) searchmode=filename ;; *) err "Unknown search type" ;; esac url="${url}&mode=${searchmode}" w3_browse_url "$url" fi diff --git a/elvi/deblists b/elvi/deblists index 12a0243..f7297b4 100755 --- a/elvi/deblists +++ b/elvi/deblists @@ -1,104 +1,104 @@ #!/bin/sh # elvis: deblists -- Search debian mailing lists (lists.debian.org/search.html) # [email protected] 2003919 . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_deblists_matchany no defyn SURFRAW_deblists_searchmsgid no def SURFRAW_deblists_msgidsearchtype direct def SURFRAW_deblists_sort relevance def SURFRAW_deblists_results $SURFRAW_results } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search patterns]... Description: Surfraw search debian mailing lists (lists.debian.org/search.html) Local options: -results=NUM Number of search results returned Default: $SURFRAW_deblists_results Environment: SURFRAW_deblists_results -m|-msgid Search by message-id, jump to result -mv Search by message-id and show matches -ml Search by message-id and show links -any Match any word in search rather than all words -sort=relevance | How to sort the results date | revdate Default: $SURFRAW_deblists_sort Environment: SURFRAW_deblists_sort EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -result*=*) setopt SURFRAW_deblists_results $optarg ;; -mv) setoptyn SURFRAW_deblists_searchmsgid yes ; setopt SURFRAW_deblists_msgidsearchtype view ;; -ml) setoptyn SURFRAW_deblists_searchmsgid yes ; setopt SURFRAW_deblists_msgidsearchtype links ;; -m|-msg*) setoptyn SURFRAW_deblists_searchmsgid yes ;; -any) setoptyn SURFRAW_deblists_matchany yes ;; -sort*=*) setopt SURFRAW_deblists_sort $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then if ifyes SURFRAW_deblists_searchmsgid then w3_browse_url "https://lists.debian.org/msgid-search" else w3_browse_url "https://lists.debian.org/search.html" fi elif ifyes SURFRAW_deblists_searchmsgid then if [ "$SURFRAW_deblists_msgidsearchtype" = links ] then searchtype="&links=Query" elif [ "$SURFRAW_deblists_msgidsearchtype" = view ] then searchtype="" else searchtype="&firsthit=I%27m+feeling+lucky" fi - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://lists.debian.org/msgid-search/?m=${escaped_args}${searchtype}" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://lists.debian.org/cgi-bin/search?P=${escaped_args}" if ifyes SURFRAW_deblists_matchany then url="$url&DEFAULTOP=or" else url="$url&DEFAULTOP=and" fi case "$SURFRAW_deblists_sort" in rel*) SURFRAW_deblists_sort="relevance" ;; rev*) SURFRAW_deblists_sort="revdate" ;; d*) SURFRAW_deblists_sort="date" ;; *) err "Unknown sort method: $SURFRAW_deblists_sort" esac url="$url&sort=${SURFRAW_deblists_sort}" if [ "$SURFRAW_deblists_results" = "" ] then SURFRAW_deblists_results=10 fi url="$url&HITSPERPAGE=${SURFRAW_deblists_results}" w3_browse_url "$url" fi diff --git a/elvi/deblogs b/elvi/deblogs index c804b99..6daea70 100755 --- a/elvi/deblogs +++ b/elvi/deblogs @@ -1,24 +1,24 @@ #!/bin/sh # jbr20050112 # elvis: deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Show changelogs for a package in Debian main (changelogs.debian.net) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://changelogs.debian.net/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://changelogs.debian.net/${escaped_args}" fi diff --git a/elvi/debpackages b/elvi/debpackages index e08e84f..8201f29 100755 --- a/elvi/debpackages +++ b/elvi/debpackages @@ -1,148 +1,148 @@ #!/bin/sh # $Id$ # elvis: debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debian_release any def SURFRAW_debian_distro any def SURFRAW_debian_search pkg defyn SURFRAW_debian_ubuntu no defyn SURFRAW_debian_subwords yes defyn SURFRAW_debian_archive no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) Local options: -a Search archived debian distributions -u Search ubuntu packages instead of debian -release= Specialized search on release Debian: any | all releases main | main release contrib | contrib non-free | packages not meeting DFSG Ubuntu (-u): any | all releases main | restricted | universe | multiverse | Default: $SURFRAW_debian_release Environment: SURFRAW_debian_release -distro= Specific distribution Debian: any | All distributions stable | Stable testing | Testing unstable | Unstable oldstable | Old Stable experimental | Experimental Archived Debian (-a): bo | 1.3.1 hamm | 2.0 slink | 2.1 potato | 2.2 woody | 3.0 sarge | 3.1 etch | 4.0 Ubuntu (-u): any | All distributions dapper | dapper-updates | dapper-backports | hardy | hardy-updates | hardy-backports | intrepid | intrepid-updates | intrepid-backports| jaunty | jaunty-updates | jaunty-backports | karmic | karmic-updates | karmic-backports | lucid | lucid-updates | lucid-backports | maverick | maverick-updates | maverick-backports| natty | natty-updates | natty-backports Default: $SURFRAW_debian_distro Environment: SURFRAW_debian_distro -search= Field to search pkg | Package names only desc | Descriptions src | Source package names -nosub Don't allow subword matches (exact matches only) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -release=*) setopt SURFRAW_debian_release $optarg ;; -distro=*) setopt SURFRAW_debian_distro $optarg ;; -search=*) setopt SURFRAW_debian_search $optarg ;; -a*) setoptyn SURFRAW_debian_archive yes ;; -u*) setoptyn SURFRAW_debian_ubuntu yes ;; -nos*) setoptyn SURFRAW_debian_subwords no ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if ifyes SURFRAW_debian_ubuntu then searchpage="http://packages.ubuntu.com/" searchurl="http://packages.ubuntu.com/search" elif ifyes SURFRAW_debian_archive then searchpage="http://archive.debian.net/" searchurl="http://archive.debian.net/search" else searchpage="https://packages.debian.org/#search_packages" searchurl="https://packages.debian.org/search" fi if test -z "$w3_args"; then w3_browse_url "$searchpage" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if [ "${SURFRAW_debian_distro}" = "any" ]; then SURFRAW_debian_distro="all" fi if [ "${SURFRAW_debian_release}" = "any" ]; then SURFRAW_debian_release="all" fi url="$searchurl?keywords=${escaped_args}&suite=${SURFRAW_debian_distro}&section=${SURFRAW_debian_release}" case "$SURFRAW_debian_search" in pkg*) url="$url&searchon=names" ;; src*) url="$url&searchon=sourcenames" ;; desc*) url="$url&searchon=all" ;; *) err "Unknown search type" ;; esac if ifno SURFRAW_debian_subwords then url="$url&exact=1" fi w3_browse_url "$url" fi diff --git a/elvi/debpkghome b/elvi/debpkghome index 1f19ab7..cfc0003 100755 --- a/elvi/debpkghome +++ b/elvi/debpkghome @@ -1,76 +1,76 @@ #!/bin/sh # elvis: debpkghome -- Visit the home page for a Debian package . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [package|file.dsc|controlfile] Description: Visit the home page for a Debian package EOF w3_global_usage } extract_home_page () { # sed /I is a gnu extension grep -i '^homepage:' | head -1 | \ sed 's/^[Hh][Oo][Mm][Ee][Pp][Aa][Gg][Ee]: *//;' } do_control() { if [ ! -f $1 ] then err $1": file not found" return fi OUT="$(cat $1 | extract_home_page)" if [ -z "$OUT" ] then err $1": no Homepage field" else echo "$OUT" fi } do_package() { - if [ ! -x "`which apt-cache`" ] + if [ ! -x "$(which apt-cache)" ] then err "apt-cache not installed. Try finding the homepage via debpts instead" return fi OUT="$(apt-cache showsrc $1)" if [ -z "$OUT" ] then err $1": package not found" return fi OUT="$(echo "$OUT" | extract_home_page)" if [ -z "$OUT" ] then err $1": no Homepage field" else echo "$OUT" fi } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_usage_hook exit fi case "$w3_args" in *.dsc|*control) url="$(do_control "$w3_args")" ;; *) url="$(do_package "$w3_args")" ;; esac if [ -n "$url" ] then w3_browse_url "$url" fi diff --git a/elvi/debpts b/elvi/debpts index 5321758..479870d 100755 --- a/elvi/debpts +++ b/elvi/debpts @@ -1,43 +1,43 @@ #!/bin/sh # $Id$ # elvis: debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) # [email protected] 20040729 . surfraw || exit 1 w3_config_hook () { def SURFRAW_debpts_viewdocs 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Debian Package Tracking System (packages.qa.debian.org) Local options: -doc View PTS documentation EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -d*) setopt SURFRAW_debpts_viewdocs 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ $SURFRAW_debpts_viewdocs -eq 1 ]; then w3_browse_url "https://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system" elif test -z "$w3_args"; then w3_browse_url "https://packages.qa.debian.org/common/index.html" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://packages.qa.debian.org/common/index.html?src=${escaped_args}" fi diff --git a/elvi/debsec b/elvi/debsec index 2489d61..9797314 100755 --- a/elvi/debsec +++ b/elvi/debsec @@ -1,23 +1,23 @@ #!/bin/sh # elvis: debsec -- Search the Debian Security Tracker for CVE ids or package names # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Search the Debian Security Tracker for CVE ids or package names EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then w3_browse_url "https://security-tracker.debian.org/tracker" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://security-tracker.debian.org/tracker/${escaped_args}" fi diff --git a/elvi/debvcsbrowse b/elvi/debvcsbrowse index 2be27cb..f00f631 100755 --- a/elvi/debvcsbrowse +++ b/elvi/debvcsbrowse @@ -1,76 +1,76 @@ #!/bin/sh # elvis: debvcsbrowse -- Browse the VCS repository for a Debian package . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [package|file.dsc|controlfile] Description: Browse the VCS repository for a Debian package EOF w3_global_usage } extract_vcs_browser () { # sed /I is a gnu extension grep -i '^vcs-browser:' | head -1 | \ sed 's/^[Vv][Cc][Ss]-[Bb][Rr][Oo][Ww][Ss][Ee][Rr]: *//;' } do_control() { if [ ! -f $1 ] then err $1": file not found" return fi OUT="$(cat $1 | extract_vcs_browser)" if [ -z "$OUT" ] then err $1": no Vcs-Browser field" else echo "$OUT" fi } do_package() { - if [ ! -x "`which apt-cache`" ] + if [ ! -x "$(which apt-cache)" ] then err "apt-cache not installed. Try finding the vcs via debpts instead" return fi OUT="$(apt-cache showsrc $1)" if [ -z "$OUT" ] then err $1": package not found" return fi OUT="$(echo "$OUT" | extract_vcs_browser)" if [ -z "$OUT" ] then err $1": no Vcs-Browser field" else echo "$OUT" fi } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_usage_hook exit fi case "$w3_args" in *.dsc|*control) url="$(do_control "$w3_args")" ;; *) url="$(do_package "$w3_args")" ;; esac if [ -n "$url" ] then w3_browse_url "$url" fi diff --git a/elvi/debwiki b/elvi/debwiki index 10778ef..9f6ffca 100755 --- a/elvi/debwiki +++ b/elvi/debwiki @@ -1,71 +1,71 @@ #!/bin/sh # $Id$ # elvis: debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) # by Ian Beckwith <[email protected]> . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_debwiki_title 0 defyn SURFRAW_debwiki_context 1 defyn SURFRAW_debwiki_case 0 defyn SURFRAW_debwiki_direct 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Debian Wiki (wiki.debian.org) Local options: -c Make search case-sensitive. -n Don't show context of search result. -t Limit search to title. -d Go direct to page (or create it). EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -c) setoptyn SURFRAW_debwiki_case 1 ;; -n) setoptyn SURFRAW_debwiki_context 0 ;; -d) setoptyn SURFRAW_debwiki_direct 1 ;; -t) setoptyn SURFRAW_debwiki_title 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments url="https://wiki.debian.org" if test -z "$w3_args" then w3_browse_url "$url" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="${url}/FindPage?" if ifyes SURFRAW_debwiki_direct then url="${url}goto=${escaped_args}&submit=Go+To+Page" elif ifyes SURFRAW_debwiki_title then url="${url}action=fullsearch&titlesearch=1&value=${escaped_args}&submit=Search+Titles" else url="${url}action=fullsearch&titlesearch=0&value=${escaped_args}&submit=Search+Text" if ifyes SURFRAW_debwiki_context then url="${url}&context=160" fi if ifyes SURFRAW_debwiki_case then url="${url}&case=1" fi fi w3_browse_url "$url" fi diff --git a/elvi/deja b/elvi/deja index a83f95d..90c6ac4 100755 --- a/elvi/deja +++ b/elvi/deja @@ -1,48 +1,48 @@ #!/bin/sh # $Id$ # elvis: deja -- Search usenet using Google Groups (groups.google.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_deja_results $SURFRAW_results def SURFRAW_deja_style "normal" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search usenet using Google Groups (groups.google.com) Local options: -results=NUM Number of search results returned Default: $SURFRAW_deja_results Environment: SURFRAW_deja_results -m Search for Message-ID EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_deja_results $optarg ;; -m*) setopt SURFRAW_deja_style "message-id" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://groups.google.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if test "${SURFRAW_deja_style}" = "normal"; then w3_browse_url "https://groups.google.com/groups?q=${escaped_args}&num=${SURFRAW_deja_results}" else w3_browse_url "https://groups.google.com/groups?as_umsgid=${escaped_args}&num=${SURFRAW_deja_results}" fi fi diff --git a/elvi/discogs b/elvi/discogs index cef65be..7757397 100755 --- a/elvi/discogs +++ b/elvi/discogs @@ -1,53 +1,53 @@ #!/bin/sh # elvis: discogs -- Search the Discogs database of music information (www.discogs.com) # Patroklos Argyroudis, argp at domain cs.tcd.ie, 20060823 . surfraw || exit 1 w3_config_hook() { def SURFRAW_discogs_category all } w3_usage_hook() { cat << EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Discogs database of music information (www.discogs.com) Local options: -category= Category to search all | artists | labels | releases | catno Default: $SURFRAW_discogs_category Environment: SURFRAW_discogs_category EOF w3_global_usage } w3_parse_option_hook() { opt="$1" optarg="$2" case "$opt" in -category=*) setopt SURFRAW_discogs_category $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.discogs.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.discogs.com/search?type=${SURFRAW_discogs_category}&q=${escaped_args}&btn=Search" fi # EOF diff --git a/elvi/duckduckgo b/elvi/duckduckgo index 1695cf2..af96401 100755 --- a/elvi/duckduckgo +++ b/elvi/duckduckgo @@ -1,82 +1,82 @@ #!/bin/sh # elvis: duckduckgo -- Securely search the web using duckduckgo (duckduckgo.com) # [email protected] 20110105 # relevant: https://duckduckgo.com/params.html # similar to duckduckgo elvi, adds more options and defaults to SSL. . surfraw || exit 1 w3_config_hook () { def SURFRAW_duckduckgo_results "$SURFRAW_results" def SURFRAW_duckduckgo_base_url "duckduckgo.com" def SURFRAW_duckduckgo_search search def SURFRAW_duckduckgo_params "&kg=g" defyn SURFRAW_duckduckgo_https_arg 0 defyn SURFRAW_duckduckgo_safe_arg 0 defyn SURFRAW_duckduckgo_redirect_arg 0 defyn SURFRAW_duckduckgo_use_javascript 0 defyn SURFRAW_duckduckgo_got_a_ducky_feeling 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using DuckDuckGo (duckduckgo.com) Local options: -d,-ducky,-l,-lucky use in case of overwhelming feeling of duckiness -j,-javascript use javascript -safe enable safe search -r,-redirect use redirection -s,-insecure disable SSL search EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -d*|-l|-lu*) setoptyn SURFRAW_duckduckgo_got_a_ducky_feeling 1 ;; -j|-javascript*) setoptyn SURFRAW_duckduckgo_use_javascript 1 ;; -safe*) setoptyn SURFRAW_duckduckgo_safe_arg 1 ;; -r|-redirect*) setoptyn SURFRAW_duckduckgo_redirect_arg 1 ;; -s|-sec*) setoptyn SURFRAW_duckduckgo_https_arg 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ "${SURFRAW_duckduckgo_https_arg}" = 0 ] ; then SURFRAW_duckduckgo_base_url="https://${SURFRAW_duckduckgo_base_url}" else SURFRAW_duckduckgo_base_url="http://${SURFRAW_duckduckgo_base_url}" fi # need to send the user to the non-javascript version if using a non-graphical # browser if [ "$SURFRAW_duckduckgo_use_javascript" = 0 ]; then SURFRAW_duckduckgo_base_url="${SURFRAW_duckduckgo_base_url}/lite" fi if [ "$SURFRAW_duckduckgo_safe_arg" = 1 ]; then SURFRAW_duckduckgo_params="${SURFRAW_duckduckgo_params}&kp=1" fi if [ "$SURFRAW_duckduckgo_redirect_arg" = 1 ] ; then SURFRAW_duckduckgo_params="${SURFRAW_duckduckgo_params}&kd=1" fi if [ "$SURFRAW_graphical" != "yes" ] ; then SURFRAW_duckduckgo_params="${SURFRAW_duckduckgo_params}&kf=-1&kz=-1&kq=-1&kv=-1" fi -escaped_args=`w3_url_of_arg $w3_args` +escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_duckduckgo_got_a_ducky_feeling" = 1 ]; then escaped_args="! ${escaped_args}" fi w3_browse_url "${SURFRAW_duckduckgo_base_url}/?q=${escaped_args}${SURFRAW_duckduckgo_params}" diff --git a/elvi/ebay b/elvi/ebay index 75dcab1..85ca9d6 100755 --- a/elvi/ebay +++ b/elvi/ebay @@ -1,122 +1,122 @@ #!/bin/sh # elvis: ebay -- Search the Ebay auction site # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_config_hook () { def SURFRAW_ebay_country "$SURFRAW_lang" def SURFRAW_ebay_results 50 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Ebay auction site Local options: -country= | -c= com | Main eBay site (default) ar | Argentina at | Austria au | Australia nl_BE | Belgium (Flemish) fr_BE | Belgium (French) br | Brazil ca | Canada ch | Switzerland cn | China de | Germany es | Spain fr | France hk | Hong Kong ie | Ireland in | India kr | Korea my | Malaysia mx | Mexico nl | Netherlands nz | New Zealand ph | Philippines pl | Poland sg | Singapore se | Sweden tw | Taiwan uk UK Environment: SURFRAW_ebay_country, SURFRAW_lang -results= | -r Amount of results per page Default: 50 Environment: SURFRAW_ebay_results Examples: $w3_argv0 -c=de sauerkraut EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -country=*) setopt SURFRAW_ebay_country $optarg ;; -c=*) setopt SURFRAW_ebay_country $optarg ;; -results=*) setopt SURFRAW_ebay_results $optarg ;; -r=*) setopt SURFRAW_ebay_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_ebay_country" in com|ar|at|be|br|ca|ch|\ de|es|fr|fr_BE|\ nl_BE|ie|in|kr|\ mx|nl|ph|pl) TLD="${SURFRAW_ebay_country}" ;; uk|nz) TLD="co.${SURFRAW_ebay_country}" ;; au|hk|sg|my) TLD="com.${SURFRAW_ebay_country}" ;; cn|zh|zt) TLD="com.cn" ;; # tw uses hk for searches tw) TLD="com.hk" ;; *) TLD="com" ;; esac if null "$w3_args"; then case "$SURFRAW_ebay_country" in br) url="http://www.mercadolivre.com.${TLD}" ;; ar|mx) url="http://www.mercadolibre.com.${TLD}" ;; kr) url="http://www.auction.co.kr" ;; fr_BE) url="http://www.befr.ebay.be" ;; nl_BE) url="http://www.benl.ebay.be" ;; se|sv) url="http://www.tradera.com" ;; tw) url="http://twexport.ebay.com" ;; *) url="https://www.ebay.${TLD}" ;; esac w3_browse_url "$url" else if [ "$SURFRAW_ebay_country" = "nz" ] ; then # nz uses ebay.com, presumably using referrer to tell it is .nz # we can't affect referrer without getting browser-specific, so # just use ebay.com TLD=com fi - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) host="http://ebay.${TLD}" pathstart="search/search.dll?MfcISAPICommand=GetResult&krd=1&ht=1&shortcut=4&SoftProperty=MetaEndSort&cgiurl=http%3A%2F%2Fcgi" pathend="%2Fws%2F&maxRecordsPerPage=$SURFRAW_ebay_results&st=2&ebaytag1code=77&query=${escaped_args}" case "$SURFRAW_ebay_country" in cn|zh|zt) url="http://search.eachnet.com/search/basicsearch.do?satitle=${escaped_args}&sacat=0" ;; br) url="http://www.mercadolivre.com.${TLD}/jm/search?as_pr_categ_id=&as_word=${escaped_args}" ;; ar|mx) url="http://www.mercadolibre.com.${TLD}/jm/search?as_pr_categ_id=&as_word=${escaped_args}" ;; kr) url="http://search.auction.co.kr/search/search.aspx?keyword=${escaped_args}&itemno=&seller=&dom=auction&isSuggestion=No&optSection=%C5%EB%C7%D5%B0%CB%BB%F6&txtKeyword=${escaped_args}&x=0&y=0" ;; se|sv) url="http://www.tradera.com/search/search_firstpage.aspx?search=${escaped_args}&search_category=-1" ;; nl_BE) url="http://search.benl.ebay.be/${pathstart}.benl.ebay.be${pathend}" ;; be|fr_BE) url="http://search.befr.ebay.be/${pathstart}.befr.ebay.be${pathend}" ;; *) url="${host}/${pathstart}.ebay.${TLD}${pathend}" ;; esac w3_browse_url "${url}" fi diff --git a/elvi/etym b/elvi/etym index 761cecd..b4f80c9 100755 --- a/elvi/etym +++ b/elvi/etym @@ -1,26 +1,26 @@ #!/bin/sh # jbr20050112 # elvis: etym -- Look up word origins at www.etymonline.com . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Look up word origins at www.etymonline.com Example: etym surf '1685, probably from earlier suffe (1599), of uncertain origin...' EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.etymonline.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.etymonline.com/?search=${escaped_args}" fi diff --git a/elvi/excite b/elvi/excite index 559eccb..0d5f8b9 100755 --- a/elvi/excite +++ b/elvi/excite @@ -1,23 +1,23 @@ #!/bin/sh # $Id$ # elvis: excite -- Search on Excite (www.excite.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search on Excite (www.excite.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.excite.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://msxml.excite.com/excite/ws/results/Web/${escaped_args}/1/417/TopNavigation/Relevance/iq=true/zoom=off/_iceUrlFlag=7?_IceUrl=true" fi diff --git a/elvi/f5 b/elvi/f5 index 65d0cb6..38cd87f 100755 --- a/elvi/f5 +++ b/elvi/f5 @@ -1,56 +1,56 @@ #!/bin/sh # $Id$ # elvis: f5 -- Search F5 related information (www.f5.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_f5_dc no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search F5 related information Local options: -dc[=(yes|no)] Search F5 Devcentral Default: $SURFRAW_f5_dc Environment: SURFRAW_f5_dc Examples: $w3_argv0 Teleport to the F5 Knowledgebase $w3_argv0 -dc Teleport to the F5 Devcentral site EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -dc) setoptyn SURFRAW_f5_dc yes ;; -dc=*) setoptyn SURFRAW_f5_dc $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments -test -z "$w3_args" || escaped_args=`w3_url_of_arg $w3_args` +test -z "$w3_args" || escaped_args=$(w3_url_of_arg $w3_args) if ok SURFRAW_f5_dc; then if test -z "$escaped_args"; then w3_browse_url "https://devcentral.f5.com" else w3_browse_url "https://devcentral.f5.com/Default.aspx?tabid=37&cx=015798286719081439686:g38hs-tdy64&cof=FORID:11i&q=${escaped_args}" fi exit $? fi if test -z "$escaped_args"; then w3_browse_url "https://www.f5.com" else w3_browse_url "https://www.f5.com/search?q=${escaped_args}" fi exit $? diff --git a/elvi/foldoc b/elvi/foldoc index 1813e01..5cca137 100755 --- a/elvi/foldoc +++ b/elvi/foldoc @@ -1,27 +1,27 @@ #!/bin/sh # jbr20050112 # elvis: foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: The Free On-Line Dictionary Of Computing (foldoc.org) Example: foldoc pcmcia "Personal Computer Memory Card International Association(*). (Or People Can't Memorise Computer Industry Acronyms)." EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://foldoc.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://foldoc.org/${escaped_args}" fi diff --git a/elvi/freebsd b/elvi/freebsd index 4833917..530ca2a 100755 --- a/elvi/freebsd +++ b/elvi/freebsd @@ -1,200 +1,200 @@ #!/bin/sh # $Id$ # elvis: freebsd -- Search FreeBSD related information (www.freebsd.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_freebsd_mail no defyn SURFRAW_freebsd_pr no defyn SURFRAW_freebsd_cvs no defyn SURFRAW_freebsd_mid no defyn SURFRAW_freebsd_gg no defyn SURFRAW_freebsd_ps no defyn SURFRAW_freebsd_prs no defyn SURFRAW_freebsd_elogs no defyn SURFRAW_freebsd_portsearch no def SURFRAW_freebsd_portsearchtype all def SURFRAW_freebsd_portsearchsec all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search FreeBSD related information Local options: -mail[=(yes|no)] Search FreeBSD mailinglists Default: $SURFRAW_freebsd_mail Environment: SURFRAW_freebsd_mail -gg[=(yes|no)] Search FreeBSD mailinglists at Google Groups Default: $SURFRAW_freebsd_mail Environment: SURFRAW_freebsd_mail -pr[=(yes|no)] Query Problem Reports Default: $SURFRAW_freebsd_pr Environment: SURFRAW_freebsd_pr -cvs[=(yes|no)] Query cvsweb Default: $SURFRAW_freebsd_cvs Environment: SURFRAW_freebsd_cvs -mid[=(yes|no)] Query mailing lists by Message-ID Default: $SURFRAW_freebsd_mid Environment: SURFRAW_freebsd_mid -ps[=(yes|no)] Teleport to the Port Survey Page Default: $SURFRAW_freebsd_ps Environment: SURFRAW_freebsd_ps -psearch[=TYPE] Search of type TYPE in ports. all | All (default) name | Package Name text | Description pkgdescr | Long Description maintainer | Maintainer requires | Requires Default: $SURFRAW_freebsd_portsearchtype Environment: SURFRAW_freebsd_portsearchtype -psection[=SEC] Section of ports to search in. all, accessibility, afterstep, arabic, archivers, astro, audio, benchmarks, biology, cad, chinese, comms, converters, databases, deskutils, devel, dns, docs, editors, elisp, emulators, finance, french, ftp, games, geography, german, gnome, gnustep, graphics, hamradio, haskell, hebrew, hungarian, ipv6, irc, japanese, java, kde, kld, korean, lang, linux, lisp, mail, math, mbone, misc, multimedia, net, net-im, net-mgmt, net-p2p, news, palm, parallel, pear, perl5, plan9, polish, ports-mgmt, portuguese, print, python, ruby, rubygems, russian, scheme, science, security, shells, spanish, sysutils, tcl, textproc, tk, ukrainian, vietnamese, windowmaker, www, x11, x11-clocks, x11-drivers, x11-fm, x11-fonts, x11-servers, x11-themes, x11-toolkits, x11-wm, xfce, zope Default: $SURFRAW_freebsd_portsearchsec Environment: SURFRAW_freebsd_portsearchsec -prs[=(yes|no)] Teleport to the Problem Report Survey Page Default: $SURFRAW_freebsd_prs Environment: SURFRAW_freebsd_prs -elogs[=(yes|no)] Teleport to the Build Error Logs Page Default: $SURFRAW_freebsd_elogs Environment: SURFRAW_freebsd_elogs Examples: $w3_argv0 Teleport to the FreeBSD website $w3_argv0 mycroft Search FreeBSD website for odeur de mycroft $w3_argv0 -mail Teleport to the mail-index Query form $w3_argv0 -mail proff Search mailing-list archives for odeur de proff $w3_argv0 -gg Teleport to FreeBSD mailinglists at Google $w3_argv0 -gg proff Search Google archives for odeur de proff $w3_argv0 -pr Query Problem Report form $w3_argv0 -pr 666 Display PR 666 $w3_argv0 -cvs Query cvsweb $w3_argv0 -cvs ports/ Display cvsweb tree for ports/ $w3_argv0 -mid Query mailing lists by Message-ID $w3_argv0 -mid <x> Display message with ID <x> $w3_argv0 -ps Teleport to the Port Survey page $w3_argv0 -prs Teleport to the Port Report Survey page $w3_argv0 -psearch surfraw Search ports for surfraw $w3_argv0 -psearch=text perl Search port descriptions for perl EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -mail) setoptyn SURFRAW_freebsd_mail yes ;; -mail=*) setoptyn SURFRAW_freebsd_mail $optarg ;; -gg) setoptyn SURFRAW_freebsd_gg yes ;; -gg=*) setoptyn SURFRAW_freebsd_gg $optarg ;; -pr) setoptyn SURFRAW_freebsd_pr yes ;; -pr=*) setoptyn SURFRAW_freebsd_pr $optarg ;; -cvs) setoptyn SURFRAW_freebsd_cvs yes ;; -cvs=*) setoptyn SURFRAW_freebsd_cvs $optarg ;; -mid) setoptyn SURFRAW_freebsd_mid yes ;; -mid=*) setoptyn SURFRAW_freebsd_mid $optarg ;; -ps) setoptyn SURFRAW_freebsd_ps yes ;; -prs) setoptyn SURFRAW_freebsd_prs yes ;; -psea*=*) setoptyn SURFRAW_freebsd_portsearch yes; setopt SURFRAW_freebsd_portsearchtype $optarg ;; -psea*) setoptyn SURFRAW_freebsd_portsearch yes ;; -psec*=*) setoptyn SURFRAW_freebsd_portsearch yes; setopt SURFRAW_freebsd_portsec $optarg ;; -psec*) setoptyn SURFRAW_freebsd_portsearch yes ;; -elogs) setoptyn SURFRAW_freebsd_elogs yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments -test -z "$w3_args" || escaped_args=`w3_url_of_arg $w3_args` +test -z "$w3_args" || escaped_args=$(w3_url_of_arg $w3_args) if ok SURFRAW_freebsd_portsearch; then if test -z "$escaped_args"; then w3_browse_url "https://www.freebsd.org/cgi/ports.cgi" else w3_browse_url "https://www.freebsd.org/cgi/ports.cgi?query=${escaped_args}&stype=${SURFRAW_freebsd_portsearchtype}&sektion=${SURFRAW_freebsd_portsec}" fi exit $? fi if ok SURFRAW_freebsd_pr; then if test -z "$escaped_args"; then w3_browse_url "https://www.freebsd.org/cgi/query-pr-summary.cgi?query" else w3_browse_url "https://www.freebsd.org/cgi/query-pr.cgi?pr=${escaped_args}" fi exit $? fi if ok SURFRAW_freebsd_mail; then if test -z "$escaped_args"; then w3_browse_url "https://docs.freebsd.org/mail/" else w3_browse_url "https://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&sort=score&index=recent&source=freebsd-questions" fi exit $? fi if ok SURFRAW_freebsd_gg; then if test -z "$escaped_args"; then w3_browse_url "https://groups.google.com/groups?hl=en&group=mailing.freebsd" else w3_browse_url "https://groups.google.com/groups?q=${escaped_args}&hl=en&meta=group%3Dmailing.freebsd.*" fi exit $? fi if ok SURFRAW_freebsd_cvs; then if test -z "$escaped_args"; then w3_browse_url "https://cvsweb.freebsd.org/" else w3_browse_url "https://cvsweb.freebsd.org/cgi/cvsweb.cgi?path=${escaped_args}" fi exit $? fi if ok SURFRAW_freebsd_mid; then if test -z "$escaped_args"; then w3_browse_url "https://www.freebsd.org/search/search-mid.html" else w3_browse_url "https://www.freebsd.org/cgi/mid.cgi?id=${escaped_args}&db=mid" fi exit $? fi if ok SURFRAW_freebsd_ps; then w3_browse_url "https://people.freebsd.org/~fenner/portsurvey/" exit $? fi if ok SURFRAW_freebsd_elogs; then w3_browse_url "https://people.freebsd.org/~fenner/errorlogs/" exit $? fi if ok SURFRAW_freebsd_prs; then w3_browse_url "https://people.freebsd.org/~fenner/ports-prs.html" exit $? fi if test -z "$escaped_args"; then w3_browse_url "https://www.freebsd.org/" else w3_browse_url "https://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&source=www" fi exit $? diff --git a/elvi/freedb b/elvi/freedb index 5e0e603..87f2a03 100755 --- a/elvi/freedb +++ b/elvi/freedb @@ -1,168 +1,168 @@ #!/bin/sh # $Id$ # elvis: freedb -- Search for cd track listings in FreeDB (www.freedb.org) # [email protected] 20030129 # notes at end of script . surfraw || exit 1 w3_config_hook () { # options defyn SURFRAW_freedb_artists 0 defyn SURFRAW_freedb_albums 0 defyn SURFRAW_freedb_songs 0 defyn SURFRAW_freedb_rest 0 defyn SURFRAW_freedb_all 0 defyn SURFRAW_freedb_id 0 defyn SURFRAW_freedb_allfields 0 defyn SURFRAW_freedb_allcats 1 defyn SURFRAW_freedb_bycat 0 def SURFRAW_freedb_cats "" def SURFRAW_freedb_page 1 # internal SURFRAW_freedb_default=1 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search FreeDB (www.freedb.org) for cd track listings Local options: -artists Search artists Environment: SURFRAW_cddb_artists -albums Search albums Environment: SURFRAW_cddb_albums -songs Search songs Environment: SURFRAW_cddb_songs -rest Search the rest of the data Environment: SURFRAW_cddb_rest -all Search all fields Environment: SURFRAW_cddb_all Default: search artists and albums -id Search by CDDB ID. -bycat Sort results by category -cat=CATEGORY Category to search, repeat as needed Options: all blues classical country data folk jazz misc newage reggae rock soundtrack Default: all -page=PAGENUM Start at page PAGENUM Default: 1 EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -ar*) setopt SURFRAW_freedb_artists 1;setoptyn SURFRAW_freedb_default 0;; -alb*) setoptyn SURFRAW_freedb_albums 1;setoptyn SURFRAW_freedb_default 0;; -so*) setoptyn SURFRAW_freedb_songs 1;setoptyn SURFRAW_freedb_default 0;; -r*) setoptyn SURFRAW_freedb_rest 1;setoptyn SURFRAW_freedb_default 0;; -all) setoptyn SURFRAW_freedb_all 1;setoptyn SURFRAW_freedb_default 0;; -id) setoptyn SURFRAW_freedb_id 1;; -pag*=*) setopt SURFRAW_freedb_page $optarg ;; -bycat) setoptyn SURFRAW_freedb_bycat 1 ;; -cat*=*) if [ "$optarg" = "all" ]; then setoptyn SURFRAW_freedb_allcats 1 SURFRAW_freedb_cats="" else setoptyn SURFRAW_freedb_allcats 0 SURFRAW_freedb_cats="${SURFRAW_freedb_cats}&cats%5B%5D=$optarg" fi ;; *) return 1 ;; esac return 0 } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url http://www.freedb.org/ else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) SURFRAW_freedb_queryopts="page=${SURFRAW_freedb_page}&" if ifyes SURFRAW_freedb_id; then w3_browse_url "http://www.freedb.org/freedb_discid_check.php?discid=${escaped_args}&${SURFRAW_freedb_queryopts}" else if [ $SURFRAW_freedb_albums -eq 1 -o \ $SURFRAW_freedb_all -eq 1 -o \ $SURFRAW_freedb_default -eq 1 ] then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}fields%5B%5D=title&" fi if [ $SURFRAW_freedb_artists -eq 1 -o \ $SURFRAW_freedb_all -eq 1 -o \ $SURFRAW_freedb_default -eq 1 ] then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}fields%5B%5D=artist&" fi if [ $SURFRAW_freedb_songs -eq 1 -o \ $SURFRAW_freedb_all -eq 1 ] then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}fields%5B%5D=track&" fi if [ $SURFRAW_freedb_rest -eq 1 -o \ $SURFRAW_freedb_all -eq 1 ] then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}fields%5B%5D=rest&" fi if [ $SURFRAW_freedb_bycat = 1 ]; then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}grouping=category&" else SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}grouping=none&" fi if [ $SURFRAW_freedb_allcats = 1 ]; then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}allcats=YES&" else SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}allcats=NO${SURFRAW_freedb_cats}" fi if [ $SURFRAW_freedb_all = 1 ]; then SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}allfields=YES&" else SURFRAW_freedb_queryopts="${SURFRAW_freedb_queryopts}allfields=NO&" fi w3_browse_url "http://www.freedb.org/freedb_search.php?${SURFRAW_freedb_queryopts}words=${escaped_args}" fi fi #eg: http://www.freedb.org/freedb_search.php?words=swans&allfields=NO&fields=artist&fields=title&fields=track&fields=rest&allcats=NO&cats=blues&cats=classical&cats=country&cats=data&cats=folk&cats=jazz&cats=misc&cats=newage&cats=reggae&cats=rock&cats=soundtrack&grouping=cats # minimum: http://www.freedb.org/freedb_search.php?words=swans+are+dead&allfields=YES&allcats=YES&grouping=none # parameters: #words=search+words (compulsory) #allfields=YES | NO (compulsory) #fields=artist | title | track | rest (can be repeated as often as needed) #allcats=YES | NO (compulsory) #cats = blues | classical | country | data | folk | jazz | misc | newage | # reggae | rock | soundtrack (can be repeated as often as needed) #grouping=cats | none (compulsory) diff --git a/elvi/freshmeat b/elvi/freshmeat index 9302f99..f897557 100755 --- a/elvi/freshmeat +++ b/elvi/freshmeat @@ -1,23 +1,23 @@ #!/bin/sh # $Id$ # elvis: freshmeat -- Search Freshmeat (www.freshmeat.net) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Freshmeat (www.freshmeat.net) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.freecode.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.freecode.com/search?q=${escaped_args}" fi diff --git a/elvi/fsfdir b/elvi/fsfdir index 7c6b99d..90b29f7 100755 --- a/elvi/fsfdir +++ b/elvi/fsfdir @@ -1,24 +1,24 @@ #!/bin/sh # $Id$ # elvis: fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the FSF/UNESCO Free Software Directory (directory.fsf.org) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://directory.fsf.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://directory.fsf.org/search/?query=${escaped_args}" fi diff --git a/elvi/gcache b/elvi/gcache index 6c4a428..1e6edde 100755 --- a/elvi/gcache +++ b/elvi/gcache @@ -1,49 +1,49 @@ #!/bin/sh # $Id$ # elvis: gcache -- Search the web using Google cache (www.google.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_cache_graphic 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [option] [URL]... Description: Surfraw shows the cached page using Google (www.google.com) Local option: -i, -images Retrieve the stored page WITH images and media. Default: textonly. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -i*) setoptyn SURFRAW_cache_graphic 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if !( test -n "$SURFRAW_lang" ); then SURFRAW_lang="en"; fi if test -z "$w3_args"; then w3_browse_url "https://www.google.com/intl/$SURFRAW_lang/help/features_list.html#cached" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_cache_graphic" = 1 ]; then w3_browse_url "https://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang" else w3_browse_url "https://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang&strip=1" fi fi diff --git a/elvi/genbugs b/elvi/genbugs index 457a128..f6b2737 100755 --- a/elvi/genbugs +++ b/elvi/genbugs @@ -1,24 +1,24 @@ #!/bin/sh # elvis: genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Surfraw search the Gentoo bug tracker (bugs.gentoo.org) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://bugs.gentoo.org/" else - escaped_args=`w3_url_of_arg $w3_args` - terms=`echo $escaped_args | sed 's/%20/+/g'` + escaped_args=$(w3_url_of_arg $w3_args) + terms=$(echo $escaped_args | sed 's/%20/+/g') w3_browse_url "https://bugs.gentoo.org/buglist.cgi?quicksearch=${terms}" fi diff --git a/elvi/genportage b/elvi/genportage index 9e73f1c..fb7bf41 100755 --- a/elvi/genportage +++ b/elvi/genportage @@ -1,28 +1,28 @@ #!/bin/sh # # Original Author: J.R. Mauro # # Modified to use Gentoo Portage Overlays # as gentoo-portage.com has gone -- ianb # # elvis: genportage -- Search gentoo-portage.com for packages . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search gentoo portage overlays for packages EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://gpo.zugaina.org" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://gpo.zugaina.org/Search?search=${escaped_args}" fi diff --git a/elvi/gmane b/elvi/gmane index a556d2a..c50898c 100755 --- a/elvi/gmane +++ b/elvi/gmane @@ -1,85 +1,85 @@ #!/bin/sh # elvis: gmane -- Search mailing list with gmane (gmane.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_gmane_or 0 defyn SURFRAW_gmane_listsearch 0 def SURFRAW_gmane_list "" def SURFRAW_gmane_author "" def SURFRAW_gmane_sort "relevance" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search mailing lists with gmane (gmane.org) Local options: -list=LIST Search list(s) eg -l=gmane.os.openbsd.vax or -l="gmane.os.openbsd.*" -L Search by list name instead of contents -author=NAME Limit search to posts by NAME Default: $SURFRAW_gmane_results Environment: SURFRAW_gmane_results -sort= Sort by: relevance Relevance date Newest first revdate Oldest first -or OR search results instead of ANDing. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -li*=*) setopt SURFRAW_gmane_group "$optarg" ;; -au*=*) setopt SURFRAW_gmane_author "$optarg" ;; -so*=*) setopt SURFRAW_gmane_sort "$optarg" ;; -L) setoptyn SURFRAW_gmane_listsearch 1 ;; -or) setoptyn SURFRAW_gmane_or 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if test -z "$w3_args" then if ifyes SURFRAW_gmane_listsearch then url=https://gmane.org/find.php else url=http://search.gmane.org/ fi else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if ifyes SURFRAW_gmane_listsearch then url="http://dir.gmane.org/search.php?match=${escaped_args}" else url="http://search.gmane.org/?query=${escaped_args}&sort=${SURFRAW_gmane_sort}" if [ "$SURFRAW_gmane_author" != "" ] then url="${url}&author=${SURFRAW_gmane_author}" fi if ifyes SURFRAW_gmane_or then url="${url}&DEFAULTOP=or" else url="${url}&DEFAULTOP=and" fi if [ "${SURFRAW_gmane_group}" != "" ] then url="${url}&group=${SURFRAW_gmane_group}" fi fi fi w3_browse_url "$url" diff --git a/elvi/google b/elvi/google index d2bba19..0f128ba 100755 --- a/elvi/google +++ b/elvi/google @@ -1,129 +1,129 @@ #!/bin/sh # $Id$ # elvis: google -- Search the web using Google (www.google.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_google_results "$SURFRAW_results" def SURFRAW_google_search search defyn SURFRAW_google_lucky 0 def SURFRAW_google_country us def SURFRAW_google_safe default } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Google (www.google.com) Local options: -l, -lucky Feeling lucky? Jump to first result. -results=NUM Number of search results returned Default: $SURFRAW_google_results Environment: SURFRAW_google_results -search= Specialized search on topic images | Images videos | Videos maps | Maps groups | groups news | News bsd | BSD linux | Linux mac | Apple Macintosh unclesam | U.S. Government Environment: SURFRAW_google_search -country= Select regional google site Default is us (google.com) <ISO 3166 alpha-2 code> Environment: SURFRAW_google_country -i, -images Image Search (same as -search=images) -v, -videos Video Search (same as -search=videos) -m, -maps Map Search (same as -search=maps) -n, -news News Search (same as -search=news) -G, -groups Groups Search (same as -search=groups) -safe= Safe Search level default | Default: $SURFRAW_google_safe off | Environment: SURFRAW_google_safe moderate | strict | EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -r*=*) setopt SURFRAW_google_results "$optarg" ;; -sa*=*) setopt SURFRAW_google_safe "$optarg" ;; -s*=*) setopt SURFRAW_google_search "$optarg" ;; -l|-lu*) setoptyn SURFRAW_google_lucky 1 ;; -c=*) setopt SURFRAW_google_country "$optarg" ;; -i*) setopt SURFRAW_google_search images ;; -v*) setopt SURFRAW_google_search videos ;; -m*) setopt SURFRAW_google_search maps ;; -n|-news) setopt SURFRAW_google_search news ;; -G|-gr|-groups) setopt SURFRAW_google_search groups ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments # Use SURFRAW_lang if present and the country has not been changed if test -n "$SURFRAW_lang" -a "$SURFRAW_google_country" = "us"; then SURFRAW_google_country="$SURFRAW_lang"; fi case "$SURFRAW_google_country" in af|ag|ai|ar|au|bd|bn|bo|br|bs|bw|by|bz|co|cu|do|ec|eg|et|fj|gi|gt|hk|jm|ly|mt|mx|my|na|nf|ng|ni|np|nz|om|pa|pe|ph|pk|pr|py|qa|sa|sb|sg|sv|tj|tr|tw|ua|ug|uy|vn) domain="com.${SURFRAW_google_country}" ;; cr|id|il|in|jp|ke|kh|kr|ls|ma|th|uk|uz|vc|ve|vg|vi|ck|yu|za|zm|zw) domain="co.${SURFRAW_google_country}" ;; us) domain="com";; *) domain="$SURFRAW_google_country" ;; esac safe="" case "$SURFRAW_google_safe" in strict) safe="&safe=strict" ;; moderate) safe="&safe=moderate" ;; off) safe="&safe=off" ;; esac url="https://" if test -z "$w3_args" ; then case "$SURFRAW_google_search" in i*) url="${url}images" ;; m*) url="${url}maps" ;; g*) url="${url}groups" ;; n*) url="${url}news" ;; v*) url="${url}video" ;; *) url="${url}www" ;; esac url="${url}.google.${domain}" else search="$SURFRAW_google_search" case "$SURFRAW_google_search" in v*) url="${url}www"; search="search"; extra="&tbo=p&tbm=vid";; i*) url="${url}images" ; search="images";; m*) url="${url}maps" ; search=maps ;; g*) url="${url}groups" ; search=groups ;; n*) url="${url}news" ; search=news ;; *) url="${url}www" ;; esac url="${url}.google.${domain}/${search}" - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="${url}?q=${escaped_args}&num=${SURFRAW_google_results}" if [ "$SURFRAW_google_lucky" = 1 ]; then - button=`w3_url_escape "I'm Feeling Lucky"` + button=$(w3_url_escape "I'm Feeling Lucky") url="${url}&btnI=$button" fi url="${url}${safe}${extra}" fi w3_browse_url "$url" diff --git a/elvi/gutenberg b/elvi/gutenberg index d51e269..b9b26a3 100755 --- a/elvi/gutenberg +++ b/elvi/gutenberg @@ -1,72 +1,72 @@ #!/bin/sh # $Id$ # elvis: gutenberg -- Search for books on Project Gutenberg (gutenberg.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_gutenberg_author 0 defyn SURFRAW_gutenberg_title 0 defyn SURFRAW_gutenberg_num 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search for books on Project Gutenberg (gutenberg.org) Local options: -title Search titles (default) -author Search authors -num Search etext numbers EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -a*) setoptyn SURFRAW_gutenberg_author 1 ;; -ti*) setoptyn SURFRAW_gutenberg_title 1 ;; -n*) setoptyn SURFRAW_gutenberg_num 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.gutenberg.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if ifno SURFRAW_gutenberg_author && ifno SURFRAW_gutenberg_title && ifno SURFRAW_gutenberg_num then SURFRAW_gutenberg_title=1 fi url="https://www.gutenberg.org/catalog/world/results?" if ifyes SURFRAW_gutenberg_author then url="$url&author=${escaped_args}" else url="$url&author=" fi if ifyes SURFRAW_gutenberg_title then url="$url&title=${escaped_args}" else url="$url&title=" fi if ifyes SURFRAW_gutenberg_num then url="$url&etextnr=${escaped_args}" else url="$url&etextnr=" fi w3_browse_url "$url" fi diff --git a/elvi/imdb b/elvi/imdb index 6a40d0c..26ea07c 100755 --- a/elvi/imdb +++ b/elvi/imdb @@ -1,58 +1,58 @@ #!/bin/sh # $Id$ # elvis: imdb -- Search the Internet Movie Database (www.imdb.com) # [email protected] 20030209 . surfraw || exit 1 w3_config_hook () { def SURFRAW_imdb_category all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Internet Movie Database (www.imdb.com) Local options: -category= Category to search All | Titles | MyMovies | People | Characters | Quotes | Bios | Plots Default: $SURFRAW_imdb_category Environment: SURFRAW_imdb_category EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -category=Titles) setopt SURFRAW_imdb_category tt ;; -category=People) setopt SURFRAW_imdb_category nm ;; -category=Characters) setopt SURFRAW_imdb_category ch ;; -category=*) setopt SURFRAW_imdb_category $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://www.imdb.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) #Avoids people having to quote "My+Movies" on command line if [ $SURFRAW_imdb_category = MyMovies ]; then SURFRAW_imdb_category="My+Movies" fi w3_browse_url "http://www.imdb.com/find?s=${SURFRAW_imdb_category}&q=${escaped_args}" fi diff --git a/elvi/ixquick b/elvi/ixquick index 758afdf..74d3f55 100755 --- a/elvi/ixquick +++ b/elvi/ixquick @@ -1,97 +1,97 @@ #!/bin/sh # $Id$ # elvis: ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_ixquick_search 'do/metasearch.pl' def SURFRAW_ixquick_lang "$SURFRAW_lang" defyn SURFRAW_ixquick_ssl yes } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Ixquick metasearch [HTTPS] (www.ixquick.com) Local options: -nossl Don't use https Environment: SURFRAW_ixquick_ssl -search= Specialized search on topic web | web pics | images Environment: SURFRAW_ixquick_search -lang= Language interface of ixquick english dansk deutsch espanol francais italiano nederlands norsk polski portugues suomi svenska turkce jiantizhongwen nihongo fantizhengwen hangul Default: english Environment: SURFRAW_ixquick_lang, SURFRAW_lang EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -no*) setoptyn SURFRAW_ixquick_ssl no ;; -search=*) setopt SURFRAW_ixquick_search $optarg ;; -lang=*) setopt SURFRAW_ixquick_lang $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if ifyes SURFRAW_ixquick_ssl then proto="https" else proto="http" fi # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "${proto}://www.ixquick.com/" else case "$SURFRAW_ixquick_lang" in en|english) SURFRAW_ixquick_lang="english" ;; dk|dansk) SURFRAW_ixquick_lang="dansk" ;; de|deutsch) SURFRAW_ixquick_lang="deutsch" ;; es|espanol) SURFRAW_ixquick_lang="espanol" ;; fr|francais) SURFRAW_ixquick_lang="francais" ;; it|italiano) SURFRAW_ixquick_lang="italiano" ;; nl|nederlands) SURFRAW_ixquick_lang="nederlands" ;; no|nb|nn|norsk) SURFRAW_ixquick_lang="norsk" ;; pl|polski) SURFRAW_ixquick_lang="polski" ;; pt|portugues) SURFRAW_ixquick_lang="portugues" ;; fi|suomi) SURFRAW_ixquick_lang="suomi" ;; sv|svenska) SURFRAW_ixquick_lang="svenska" ;; tr|turkce) SURFRAW_ixquick_lang="turkce" ;; cn|zh|jiantizhongwen) SURFRAW_ixquick_lang="jiantizhongwen" ;; ja|jp|nihongo) SURFRAW_ixquick_lang="nihongo" ;; zt|fantizhengwen) SURFRAW_ixquick_lang="fantizhengwen" ;; ko|kr|kp|hangul) SURFRAW_ixquick_lang="hangul" ;; *) SURFRAW_ixquick_lang="english" ;; esac - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${proto}://www.ixquick.com/do/metasearch.pl?cat=${SURFRAW_ixquick_search}&cmd=process_search&language=${SURFRAW_ixquick_lang}&query=${escaped_args}" fi diff --git a/elvi/jamendo b/elvi/jamendo index b2b2904..69609b6 100755 --- a/elvi/jamendo +++ b/elvi/jamendo @@ -1,68 +1,68 @@ #!/bin/sh # elvis: jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_jamendo_lang "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Jamendo: free music with Creative Commons licenses (www.jamendo.com) Local options: -l= | -lang= Search with this l10n en|english fr|french de|german it|italian pt|portuguese pl|polish ru|russian es|spanish Default: English Environment: SURFRAW_jamendo_lang, SURFRAW_lang EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -l=*|-lang=*) setopt SURFRAW_jamendo_lang $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments # Use SURFRAW_lang if present if [ -z $SURFRAW_jamendo_lang ]; then SURFRAW_jamendo_lang="en"; fi if test -z "$w3_args"; then w3_browse_url "https://www.jamendo.com/${SURFRAW_jamendo_lang}/search" else case "$SURFRAW_jamendo_lang" in en|english) setopt SURFRAW_jamendo_lang en ;; fr|french) setopt SURFRAW_jamendo_lang fr ;; de|german) setopt SURFRAW_jamendo_lang de ;; it|italian) setopt SURFRAW_jamendo_lang it ;; pt|portuguese) setopt SURFRAW_jamendo_lang br;; pl|polish) setopt SURFRAW_jamendo_lang pl ;; ru|russian) setopt SURFRAW_jamendo_lang ru ;; es|spanish) setopt SURFRAW_jamendo_lang es ;; *) setopt SURFRAW_jamendo_lang en ;; esac - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.jamendo.com/${SURFRAW_jamendo_lang}/search?qs=q=${escaped_args}" fi diff --git a/elvi/javasun b/elvi/javasun index 8bbaa7c..18abc50 100755 --- a/elvi/javasun +++ b/elvi/javasun @@ -1,72 +1,72 @@ #!/bin/sh # $Id$ # elvis: javasun -- Search Java API docs (java.sun.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_java_product se def SURFRAW_java_version 6 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search Sun Java API docs (java.sun.com) Local options: -v Java API version (1.2, 1.3, 1.4, 5, 6) -p Java product (se, ee, me) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -v*) setopt SURFRAW_java_version $optarg ;; -p*) setopt SURFRAW_java_product $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_java_product" in [sS][eE]) case "$SURFRAW_java_version" in 6) JAVA_SITE="javase/6/docs/api" ;; 5) JAVA_SITE="j2se/1.5.0/docs/api" ;; 1.4) JAVA_SITE="j2se/1.4.2/docs/api" ;; 1.3) JAVA_SITE="j2se/1.3/docs/api" ;; *) echo "Docs for J2SE $SURFRAW_java_version are not available" exit 1 ;; esac ;; [eE][eE]) case "$SURFRAW_java_version" in 6|5) JAVA_SITE="javaee/5/docs/api" ;; 1.4) JAVA_SITE="j2ee/1.4/docs/api" ;; 1.3) JAVA_SITE="j2ee/sdk_1.3/techdocs/api" ;; 1.2) JAVA_SITE="j2ee/sdk_1.2.1/techdocs/api" ;; *) echo "Docs for J2EE $SURFRAW_java_version are not available" esac ;; [mM][eE]) JAVA_SITE="j2me/docs" ;; *) echo "$SURFRAW_java_product is not a valid Java product" exit 1 ;; esac if test -z "$w3_args"; then w3_browse_url "http://download.oracle.com/${JAVA_SITE}" else - button=`w3_url_escape "I'm Feeling Lucky"` - escaped_args=`w3_url_of_arg $w3_args` + button=$(w3_url_escape "I'm Feeling Lucky") + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://www.google.com/search?q=${escaped_args}&sitesearch=download.oracle.com/${JAVA_SITE}&btnI=${button}" fi diff --git a/elvi/jquery b/elvi/jquery index b36111d..62837d3 100755 --- a/elvi/jquery +++ b/elvi/jquery @@ -1,24 +1,24 @@ #!/bin/sh # elvis: jquery -- Search the jQuery documentation (api.jquery.com) # [email protected] 20130507 . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the jQuery documentation (api.jquery.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://api.jquery.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://api.jquery.com?s=${escaped_args}" fi diff --git a/elvi/l1sp b/elvi/l1sp index b6419b3..591b7d2 100755 --- a/elvi/l1sp +++ b/elvi/l1sp @@ -1,27 +1,27 @@ #!/bin/sh # # AUTHOR: S.S.R. Oemrawsingh # # DATE: Sun Nov 1 2009 # # DESC: Elvi to search l1sp.org # elvis: l1sp -- Search lisp documentation . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search lisp documentation using l1sp.org EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then w3_browse_url "http://l1sp.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://l1sp.org/search?q=${escaped_args}" fi diff --git a/elvi/lastfm b/elvi/lastfm index 6296426..57ff1a0 100755 --- a/elvi/lastfm +++ b/elvi/lastfm @@ -1,45 +1,45 @@ #!/bin/sh # $Id$ # elvis: lastfm -- Search last.fm . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_lastfm_redirect 1 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search last.fm Local options: -l Show list even if exact match. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -l) setoptyn SURFRAW_lastfm_redirect 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://last.fm/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://last.fm/search?q=${escaped_args}" if ifno SURFRAW_lastfm_redirect then url="${url}&noredirect=1" fi w3_browse_url "${url}" fi diff --git a/elvi/leodict b/elvi/leodict index 3f0c237..f66b240 100755 --- a/elvi/leodict +++ b/elvi/leodict @@ -1,102 +1,102 @@ #!/bin/sh # elvis: leodict -- Search Leo's German <-> English dictionary (dict.leo.org) # $Id$ # surfraw plugin for the biggest English/German dictionary on # the WWW: dict.leo.org [email protected] # options added by Ian Beckwith <[email protected]> . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_leodict_link yes defyn SURFRAW_leodict_head yes defyn SURFRAW_leodict_grid yes def SURFRAW_leodict_to "either" def SURFRAW_leodict_spell "standard" def SURFRAW_leodict_tol "standard" def SURFRAW_leodict_lang "$SURFRAW_lang" } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -link*=*) setopt SURFRAW_leodict_link $optarg ;; -head*=*) setopt SURFRAW_leodict_head $optarg ;; -grid*=*) setopt SURFRAW_leodict_grid $optarg ;; -to=*) setopt SURFRAW_leodict_to $optarg ;; -spell*=*) setopt SURFRAW_leodict_spell $optarg ;; -tol*=*) setopt SURFRAW_leodict_tol $optarg ;; -lang*=*) setopt SURFRAW_leodict_lang $optarg ;; *) return 1 ;; esac return 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Surfraw search the German/English dictionary LEO (dict.leo.org) Local options: -to=de | en | either Language to translate to. Default: $SURFRAW_leodict_to Environment: SURFRAW_leodict_to -lang=en | de Language web page is in. Environment: SURFRAW_leodict_lang, SURFRAW_lang If above variables are not set, defaults to en, unless \$LANG is set and contains "de". -link=on | off Link results. Default: $SURFRAW_leodict_link Environment: SURFRAW_leodict_link -head=on | off Display headlines. Default: $SURFRAW_leodict_head Environment: SURFRAW_leodict_head -grid=on | off Show results in grid. Default: $SURFRAW_leodict_grid Environment: SURFRAW_leodict_grid -spell=off | standard | force Spelling tolerance Default: $SURFRAW_leodict_spell Environment: SURFRAW_leodict_spell -tol=off | standard | high Special characters tolerance Default: $SURFRAW_leodict_tol Environment: SURFRAW_leodict_tol EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then w3_browse_url "https://dict.leo.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://dict.leo.org/?search=${escaped_args}" case "$SURFRAW_leodict_lang" in en|de) ;; - *) SURFRAW_leodict_lang=`perl -e 'if((exists($ENV{LANG})) && ($ENV{LANG}=~/de/i)) { print "de\n"; } else { print "en\n"; }'` ;; + *) SURFRAW_leodict_lang=$(perl -e 'if((exists($ENV{LANG})) && ($ENV{LANG}=~/de/i)) { print "de\n"; } else { print "en\n"; }') ;; esac if yesno SURFRAW_leodict_link ; then url="$url&relink=on" else url="$url&relink=off";fi if yesno SURFRAW_leodict_head ; then url="$url&sectHdr=on" else url="$url&sectHdr=off";fi if yesno SURFRAW_leodict_grid ; then url="$url&tableBorder=1" else url="$url&tableBorder=0";fi if [ "$SURFRAW_leodict_to" = "de" ] ; then url="$url&searchLoc=-1" elif [ "$SURFRAW_leodict_to" = "en" ] ; then url="$url&searchLoc=1" else url="$url&searchLoc=0" ; fi if [ "$SURFRAW_leodict_spell" = "off" ] ; then url="$url&spellToler=off" elif [ "$SURFRAW_leodict_spell" = "force" ] ; then url="$url&spellToler=on" else url="$url&spellToler=standard" ; fi if [ "$SURFRAW_leodict_tol" = "high" ] ; then url="$url&cmpType=fuzzy" elif [ "$SURFRAW_leodict_tol" = "off" ] ; then url="$url&cmpType=exact" else url="$url&cmpType=relaxed" ; fi url="$url&lang=$SURFRAW_leodict_lang" w3_browse_url "$url" fi diff --git a/elvi/lsm b/elvi/lsm index 927a4a0..37360cb 100755 --- a/elvi/lsm +++ b/elvi/lsm @@ -1,47 +1,47 @@ #!/bin/sh # $Id$ # elvis: lsm -- Search the Linux Software Map . surfraw || exit 1 w3_config_hook () { def SURFRAW_lsm_search title } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Linux Software Map (www.boutell.com/lsm/) Local options: -search= Specialized search on topic title | Title search (default) keyword Keyword search Environment: SURFRAW_lsm_search EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s*=*) setopt SURFRAW_lsm_search $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.boutell.com/lsm/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) if [ "$SURFRAW_lsm_search" = "keyword" ]; then url="https://www.boutell.com/lsm/lsmbykey.cgi/submit?keyword=${escaped_args}" else url="https://www.boutell.com/lsm/lsmbytitle.cgi/submit?title=${escaped_args}" fi w3_browse_url "${url}" fi diff --git a/elvi/mathworld b/elvi/mathworld index 9b53c83..0c4be65 100755 --- a/elvi/mathworld +++ b/elvi/mathworld @@ -1,27 +1,27 @@ #!/bin/sh # # AUTHOR: S.S.R. Oemrawsingh # # DATE: Mon Nov 4 2009 # # DESC: Elvi to search Wolfram MathWorld # elvis: mathworld -- Search Wolfram MathWorld . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search Wolfram MathWorld EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then w3_browse_url "http://mathworld.wolfram.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://mathworld.wolfram.com/search/?query=${escaped_args}&x=0&y=0" fi diff --git a/elvi/mininova b/elvi/mininova index a3fcc53..6899acd 100755 --- a/elvi/mininova +++ b/elvi/mininova @@ -1,98 +1,98 @@ #!/bin/sh # # AUTHOR: S.S.R. Oemrawsingh # # DATE: Mon Oct 26 2009 # # DESC: Elvi to search the mininova bittorrent source. # elvis: mininova -- Search the mininova bittorent source. . surfraw || exit 1 w3_config_hook () { def SURFRAW_mininova_category all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search terms] Description: Surfraw the mininova bittorrent source. Local options: -category= Search for torrent in the given category all | Search all categories anime | Search anime torrents books | Search book torrents featured | Search featured torrents games | Search game torrents movies | Search movie torrents music | Search music torrents pictures | Search picture torrents software | Search software torrents tv-shows | Search tv show torrents other Search other torrents Default: $SURFRAW_mininova_category Environment: SURFRAW_mininova_category EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -category=*) setopt SURFRAW_mininova_category $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if [ -z "$w3_args" ]; then url="http://www.mininova.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) case $SURFRAW_mininova_category in all) url="http://www.mininova.org/search/?search="$escaped_args"&cat=0" ;; anime) url="http://www.mininova.org/search/?search="$escaped_args"&cat=1" ;; books) url="http://www.mininova.org/search/?search="$escaped_args"&cat=2" ;; featured) url="http://www.mininova.org/search/?search="$escaped_args"&cat=10" ;; games) url="http://www.mininova.org/search/?search="$escaped_args"&cat=3" ;; movies) url="http://www.mininova.org/search/?search="$escaped_args"&cat=4" ;; music) url="http://www.mininova.org/search/?search="$escaped_args"&cat=5" ;; pictures) url="http://www.mininova.org/search/?search="$escaped_args"&cat=6" ;; software) url="http://www.mininova.org/search/?search="$escaped_args"&cat=6" ;; tv-shows) url="http://www.mininova.org/search/?search="$escaped_args"&cat=8" ;; other) url="http://www.mininova.org/search/?search="$escaped_args"&cat=9" ;; *) return 1 ;; esac fi w3_browse_url $url diff --git a/elvi/musicbrainz b/elvi/musicbrainz index 84b1fd0..10da0a5 100755 --- a/elvi/musicbrainz +++ b/elvi/musicbrainz @@ -1,165 +1,165 @@ #!/bin/sh # $Id$ # elvis: musicbrainz -- Search MusicBrainz (musicbrainz.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_musicbrainz_limit $SURFRAW_results def SURFRAW_musicbrainz_search artist def SURFRAW_musicbrainz_tagrelease "" def SURFRAW_musicbrainz_tagtrack "" def SURFRAW_musicbrainz_tagnum "" def SURFRAW_musicbrainz_taglen "" def SURFRAW_musicbrainz_tagpuid "" def SURFRAW_musicbrainz_tagfile "" defyn SURFRAW_musicbrainz_advanced 0 defyn SURFRAW_musicbrainz_direct 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search MusicBrainz (musicbrainz.org) Local options: -d Direct (old) search. -a Enable advanced query syntax. See: https://musicbrainz.org/popup/TextSearchSyntax -results=NUM Number of search results returned Default: $SURFRAW_musicbrainz_results Environment: SURFRAW_musicbrainz_results 0 means all results. -search= Search type: artist | Artist [default] <*> release | Release (album) <*> release_group | Release Group label | Label <*> annotation | Annotation barcode | Barcode catno | Catalog number cdstub | CD Stub discid | Disc ID editor | Editor freedb | FreeDB freedb | FreeDB ID isrc | ISRC iswc | ISWC mbid | MBID puid | PUID recording | Recording trmid | TRM ID work | Work tag Tag Search With Tag Search, [search words] are treated as artist name, use -tag* below to specify other fields. <*> = supported by direct search (-d) Environment: SURFRAW_musicbrainz_search -tagrelease=ALBUM Album/Release tag search (implies -search=tag) -tagnum=TRACKNUM Track number tag search (implies -search=tag) -tagtrack=SONG Track tag search (implies -search=tag) -taglen=DURATION Track length tag search (implies -search=tag) -tagfile=FILENAME Filename tag search (implies -search=tag) -tagpuid=FILENAME PUID tag search (implies -search=tag) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_musicbrainz_results $optarg ;; -tagrel*=*) setopt SURFRAW_musicbrainz_tagrelease $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagnu*=*) setopt SURFRAW_musicbrainz_tagnum $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagtra*=*) setopt SURFRAW_musicbrainz_tagtrack $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagle*=*) setopt SURFRAW_musicbrainz_taglen $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagp*=*) setopt SURFRAW_musicbrainz_tagpuid $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagf*=*) setopt SURFRAW_musicbrainz_tagfile $optarg setopt SURFRAW_musicbrainz_search tag ;; -a) setoptyn SURFRAW_musicbrainz_advanced 1 ;; -d) setoptyn SURFRAW_musicbrainz_direct 1 ;; -search=*) searchtype="$optarg" case "$searchtype" in ar*) setopt SURFRAW_musicbrainz_search artist ;; release_*) setopt SURFRAW_musicbrainz_search release_group ;; release|rel|al*) setopt SURFRAW_musicbrainz_search release ;; an*) setopt SURFRAW_musicbrainz_search annotation ;; ba*) setopt SURFRAW_musicbrainz_search barcode ;; ca*) setopt SURFRAW_musicbrainz_search catno ;; cd*) setopt SURFRAW_musicbrainz_search cdstub ;; d*) setopt SURFRAW_musicbrainz_search discid ;; e*) setopt SURFRAW_musicbrainz_search editor ;; freedb|fr) setopt SURFRAW_musicbrainz_search freedb ;; freedbid) setopt SURFRAW_musicbrainz_search freedbid ;; isr*) setopt SURFRAW_musicbrainz_search isrc ;; isw*) setopt SURFRAW_musicbrainz_search iswc ;; l*) setopt SURFRAW_musicbrainz_search label ;; m*) setopt SURFRAW_musicbrainz_search mbid ;; p*) setopt SURFRAW_musicbrainz_search puid ;; rec*) setopt SURFRAW_musicbrainz_search recording ;; tr*) setopt SURFRAW_musicbrainz_search trmid ;; w*) setopt SURFRAW_musicbrainz_search work ;; ta*) setopt SURFRAW_musicbrainz_search tag ;; *) err "Search type not known" esac ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args" && test -z "$SURFRAW_musicbrainz_tagrelease" && test -z "$SURFRAW_musicbrainz_tagnum" && test -z "$SURFRAW_musicbrainz_tagtrack" && test -z "$SURFRAW_musicbrainz_taglen" && test -z "$SURFRAW_musicbrainz_tagpuid" && test -z "$SURFRAW_musicbrainz_tagfile" then w3_browse_url "https://musicbrainz.org/search.html" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://musicbrainz.org" if ifyes SURFRAW_musicbrainz_direct then case "$SURFRAW_musicbrainz_search" in artist|release|label) url="${url}/search/oldsearch.html?query=${escaped_args}&type=${SURFRAW_musicbrainz_search}&limit=${SURFAW_musicbrainz_results}&handlearguments=1" ;; *) err "Search type $SURFRAW_musicbrainz_search not supported by Direct Search (-d)" ;; esac else case "$SURFRAW_musicbrainz_search" in artist|release_group|release|recording|work| \ label|annotation|cdstub|editor| \ freedb) url="${url}/search?query=${escaped_args}&type=${SURFRAW_musicbrainz_search}&limit=${SURFRAW_musicbrainz_limit}" if ifyes SURFRAW_musicbrainz_advanced then url="${url}&adv=on" fi ;; catno|barcode|discid|freedbid|freedb| \ puid|trmid|isrc|iswc| \ discid) url="${url}/otherlookup?${SURFRAW_musicbrainz_search}=${escaped_args}" ;; mbid) url="${url}/release/${escaped_args}" ;; tag) url="${url}/taglookup?artist=${escaped_args}&release=${SURFRAW_musicbrainz_tagrelease}&track=${SURFRAW_musicbrainz_tagtrack}&tracknum=${SURFRAW_musicbrainz_tagnum}&duration=${SURFRAW_musicbrainz_taglen}&filename=${SURFRAW_musicbrainz_tagfile}&puid=${SURFRAW_musicbrainz_puid}" ;; *) err Unknown search type "${SURFRAW_musicbrainz_search}" ;; esac fi w3_browse_url "$url" fi diff --git a/elvi/netbsd b/elvi/netbsd index 1c37363..e904c66 100755 --- a/elvi/netbsd +++ b/elvi/netbsd @@ -1,73 +1,73 @@ #!/bin/sh # $Id$ # elvis: netbsd -- Search NetBSD related information (www.netbsd.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_netbsd_mail no defyn SURFRAW_netbsd_pr no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search NetBSD related information Local options: -mail[=(yes|no)] Search netbsd mailinglists Default: $SURFRAW_netbsd_mail Environment: SURFRAW_netbsd_mail -pr[=(yes|no)] Query Problem Reports Default: $SURFRAW_netbsd_pr Environment: SURFRAW_netbsd_pr Examples: $w3_argv0 Teleport to the NetBSD website $w3_argv0 mycroft Search NetBSD website for odeur de mycroft $w3_argv0 -mail Teleport to the mail-index Query form $w3_argv0 -mail proff Search mailing-list archives for odeur de proff $w3_argv0 -pr Query Problem Report form $w3_argv0 -ps surfraw Search Ports for surfraw EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -mail) setoptyn SURFRAW_netbsd_mail yes ;; -mail=*) setoptyn SURFRAW_netbsd_mail $optarg ;; -pr) setoptyn SURFRAW_netbsd_pr yes ;; -pr=*) setoptyn SURFRAW_netbsd_pr $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments -test -z "$w3_args" || escaped_args=`w3_url_of_arg $w3_args` +test -z "$w3_args" || escaped_args=$(w3_url_of_arg $w3_args) if ok SURFRAW_netbsd_pr; then if test -z "$escaped_args"; then w3_browse_url "https://www.netbsd.org/Misc/query-pr.html" else w3_browse_url "https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=${escaped_args}" fi exit $? fi if ok SURFRAW_netbsd_mail; then if test -z "$escaped_args"; then w3_browse_url "https://mail-index.netbsd.org/" else w3_custom_search -s=mail-index.netbsd.org "$w3_shquoted_args" fi exit $? fi if test -z "$escaped_args"; then w3_browse_url "https://www.netbsd.org/" else w3_custom_search -s=netbsd.org "$w3_shquoted_args" fi exit $? diff --git a/elvi/ntrs b/elvi/ntrs index 4402c3f..0236168 100755 --- a/elvi/ntrs +++ b/elvi/ntrs @@ -1,86 +1,86 @@ #!/bin/sh # # author: Wim Van Hoydonck # # elvis: ntrs -- Search the NASA Technical Report Server . surfraw || exit 1 w3_config_hook () { def SURFRAW_ntrs_fields Abstract def SURFRAW_ntrs_results matchall } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search ntrs Local options: -fields=FIELD Subject field to search all | Seach all fields abstract | Words in abstract (default) accession | Accession number center | NASA Center author | Author name docID | Document ID keywords | Keywords date | Publication date title | Title -results=RESULT Find Results with all | All of the words any | At least one of the words Examples: $w3_argv0 -fields=abstract -results=all free wake EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -fields=*) setopt SURFRAW_ntrs_fields $optarg ;; -results=*) setopt SURFRAW_ntrs_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_ntrs_fields" in all) field=All ;; abstract) field=Abstract ;; accession) field=AccessionNum ;; center) field=ArchiveName ;; author) field=AuthorList ;; docID) field=DocumentID ;; keyword) field=Keywords ;; date) field=PublicationDate ;; title) field=Title ;; *) field=Abstract ;; esac case "$SURFRAW_ntrs_results" in all) result=matchall ;; any) result=matchany ;; *) result=matchall ;; esac if null "$w3_args"; then w3_browse_url "https://ntrs.nasa.gov/search.jsp" else # TODO: combine multiple searches, e.g. # first search the abstract for certain keywords, # then search the authors of those results # this gives urls that look like this: #https://ntrs.nasa.gov/search.jsp?N=0&Ntk=Abstract|AuthorList&Ntx=mode%20matchall|mode%20matchall&Ntt=free%20wake|wachspress - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://ntrs.nasa.gov/search.jsp?N=0&Ntk=${field}&Ntx=mode%20${result}&Ntt=${escaped_args}" w3_browse_url "${url}" fi diff --git a/elvi/openbsd b/elvi/openbsd index cc2cdcf..6b3644c 100755 --- a/elvi/openbsd +++ b/elvi/openbsd @@ -1,28 +1,28 @@ #!/bin/sh # $Id$ # elvis: openbsd -- Search OpenBSD related information (www.openbsd.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search-string] Description: Surfraw search OpenBSD related information Examples: $w3_argv0 Teleport to the OpenBSD website EOF w3_custom_search_usage w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments -test -z "$w3_args" || escaped_args=`w3_url_of_arg $w3_args` +test -z "$w3_args" || escaped_args=$(w3_url_of_arg $w3_args) if test -z "$escaped_args"; then w3_browse_url "https://www.openbsd.org/" else w3_custom_search -s=openbsd.org "$w3_shquoted_args" fi exit $? diff --git a/elvi/oraclesearch b/elvi/oraclesearch index c472348..c53ef2b 100755 --- a/elvi/oraclesearch +++ b/elvi/oraclesearch @@ -1,24 +1,24 @@ #!/bin/sh # elvis: oraclesearch -- Search Oracle (search.oracle.com) # [email protected] 20131005 . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Oracle (search.oracle.com) EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then w3_browse_url "http://search.oracle.com/search/search" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.oracle.com/search/results?Ntt=${escaped_args}&Dy=1&Nty=1&Ntk=S3" fi diff --git a/elvi/pgpkeys b/elvi/pgpkeys index f4eb02a..9ee5b44 100755 --- a/elvi/pgpkeys +++ b/elvi/pgpkeys @@ -1,91 +1,91 @@ #!/bin/sh # elvis: pgpkeys -- Search the PGP key database # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_config_hook () { def SURFRAW_pgpkeys_sigs off defyn SURFRAW_pgpkeys_fingerprints off defyn SURFRAW_pgpkeys_exact off def SURFRAW_pgpkeys_server sks } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the PGP key database Local options: -s Displays signatures of the keys Default: $SURFRAW_pgpkeys_sigs Environment: SURFRAW_pgpkeys_sigs -f Displays fingerprints of the keys Default: $SURFRAW_pgpkeys_fingerprints Environment: SURFRAW_pgpkeys_fingerprints -e Exact matches only Default: $SURFRAW_pgpkeys_exact Environment: SURFRAW_pgpkeys_exact -k= Keyserver to query. Supported: sks | www.sks-keyservers.net (default) gnupg | www-keys.gnupg.net pgp | www.uk.pgp.net mit | pgp.mit.edu Default: $SURFRAW_pgpkeys_server Environment: SURFRAW_pgpkeys_server Examples: $w3_argv0 -s [email protected] EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s*) setopt SURFRAW_pgpkeys_sigs on ;; -f*) setoptyn SURFRAW_pgpkeys_fingerprints on ;; -e*) setoptyn SURFRAW_pgpkeys_exact on ;; -k*=*) setopt SURFRAW_pgpkeys_server "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_pgpkeys_server" in mit) base="http://pgp.mit.edu" prefix="http://pgp.mit.edu:11371/pks/lookup?search=" ;; sks) base="http://www.sks-keyservers.net/i/" prefix="http://pool.sks-keyservers.net:11371/pks/lookup?search=" ;; gnupg) base="http://http-keys.gnupg.net" prefix="http://http-keys.gnupg.net/pks/lookup?search=" ;; pgp) base="http://www.uk.pgp.net/pgpnet/wwwkeys.html" prefix="http://wwwkeys.uk.pgp.net:11371/pks/lookup?search=" ;; *) err "Server \"$SURFRAW_pgpkeys_server\" not supported" ;; esac suffix="&op=index" if [ $SURFRAW_pgpkeys_sigs = on ]; then suffix="&op=vindex" fi if ifyes SURFRAW_pgpkeys_fingerprints ;then suffix="$suffix&fingerprint=on" fi if ifyes SURFRAW_pgpkeys_exact ;then suffix="$suffix&exact=on" fi if null "$w3_args"; then w3_browse_url "$base" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${prefix}${escaped_args}${suffix}" fi diff --git a/elvi/priberam b/elvi/priberam index 52f6d41..ab9fa44 100755 --- a/elvi/priberam +++ b/elvi/priberam @@ -1,29 +1,29 @@ #!/bin/sh # $Id$ # elvis: priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) . surfraw || exit 1 w3_config_hook () { def SURFRAW_priberam dictionary } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Look up word in Priberam online dictionary (www.priberam.pt/dlpo) EOF w3_global_usage } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.priberam.pt/dlpo/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.priberam.pt/dlpo/default.aspx?pal=${escaped_args}" fi diff --git a/elvi/pubmed b/elvi/pubmed index 5ba82a3..445ec85 100755 --- a/elvi/pubmed +++ b/elvi/pubmed @@ -1,48 +1,48 @@ #!/bin/sh # $Id$ # elvis: pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) . surfraw || exit 1 w3_config_hook () { def SURFRAW_pubmed_database PubMed } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search PubMed medical/molbio databases (www.ncbi.nlm.nih.gov) Local options: -db= Database to search PubMed | Nucleotide | Protein | Genome | Structure | Popset Default: $SURFRAW_pubmed_database Environment: SURFRAW_pubmed_database EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -db=PubMed | -db=Nucleotide | -db=Protein | -db=Genome | -db=Structure | -db=Popset) setopt SURFRAW_pubmed_database $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.ncbi.nlm.nih.gov/entrez/query.fcgi" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?SUBMIT=y&term=${escaped_args}&db=${SURFRAW_pubmed_database}&orig_db=PubMed&cmd=" fi diff --git a/elvi/rae b/elvi/rae index 6109637..8ab42d0 100755 --- a/elvi/rae +++ b/elvi/rae @@ -1,26 +1,26 @@ #!/bin/sh # $Id$ # elvis: rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) # Author: Ruben Pollan <[email protected]> . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if null "$w3_args"; then w3_browse_url "https://lema.rae.es/drae/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://lema.rae.es/drae/?val=${escaped_args}" fi diff --git a/elvi/rfc b/elvi/rfc index f93dd71..6a5ecf3 100755 --- a/elvi/rfc +++ b/elvi/rfc @@ -1,194 +1,194 @@ #!/bin/sh # $Id$ # elvis: rfc -- Search RFCs (internet standards documents) # [email protected] 20031220 . surfraw || exit 1 w3_config_hook () { def SURFRAW_rfc_search all def SURFRAW_rfc_field all def SURFRAW_rfc_results $SURFRAW_results def SURFRAW_rfc_output txt defyn SURFRAW_rfc_matchexact no defyn SURFRAW_rfc_showabs no defyn SURFRAW_rfc_showkw no defyn SURFRAW_rfc_reverse no defyn SURFRAW_rfc_ftp no defyn SURFRAW_rfc_nodirect no searchset=0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the RFC (Request For Comments) internet standards. Local options: -results=NUM Number of search results returned Default: $SURFRAW_rfc_results Environment: SURFRAW_rfc_results -pdf Return files as PDF (Default: text) -rev Reverse order of results -exact Match exact words (instead of prefixes) -abs Show abstracts -keywords Show keywords -nodirect Don't try and go direct to RFC (Tries when arg is numeric and -search/-field not used) -ftp Retrieve RFCs via FTP instead of HTTP -field= Which field to search all | All fields number | title | author | keyword Default: if args are numeric, "number", else "all" Environment: SURFRAW_rfc_field -search= Collection to search all | All rfc | Requests For Comments std | Standards bcp | Best Current Practices fyi Informational (For Your Information) Default: $SURFRAW_rfc_search Environment: SURFRAW_rfc_search EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -res*=*) setopt SURFRAW_rfc_results $optarg ;; -pdf*) setopt SURFRAW_rfc_output pdf ;; -rev*) setoptyn SURFRAW_rfc_reverse yes ;; -ex*) setoptyn SURFRAW_rfc_matchexact yes ;; -abs*) setoptyn SURFRAW_rfc_showabs yes ;; -k*) setoptyn SURFRAW_rfc_showkw yes ;; -ftp*) setoptyn SURFRAW_rfc_ftp yes ;; -no*) setoptyn SURFRAW_rfc_nodirect yes ;; -se*=*) setopt SURFRAW_rfc_search $optarg ;; -fi*=*) setopt SURFRAW_rfc_field $optarg ; searchset=1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.rfc-editor.org/rfcsearch.html" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) # Is cmdline numeric? nodirect=0 if echo "$escaped_args" |grep '^[0-9]*$' >/dev/null 2>&1 then isnum=1 if ifyes SURFRAW_rfc_nodirect then nodirect=1 fi else isnum=0 fi # Do we want to go direct to rfc? if [ $isnum -eq 1 -a $searchset -eq 0 -a $nodirect -eq 0 ] then # do we want txt if [ "$SURFRAW_rfc_output" = "txt" ] then subdir="" case "$SURFRAW_rfc_search" in all) fileprefix="rfc";; rfc) fileprefix="rfc";; std) fileprefix="std"; subdir="/std";; bcp) fileprefix="bcp"; subdir="/bcp";; fyi) fileprefix="fyi"; subdir="/fyi";; *) echo "Unknown search: $SURFRAW_rfc_search"; exit;; esac if ifyes SURFRAW_rfc_ftp then url="ftp://ftp.rfc-editor.org/in-notes${subdir}/${fileprefix}${escaped_args}.txt" elif [ $fileprefix = rfc ] || [ $fileprefix = bcp ]; then url="https://tools.ietf.org/html/${fileprefix}${escaped_args}" else url="https://www.rfc-editor.org/rfc${subdir}/${fileprefix}${escaped_args}.txt" fi else # godless PDFs case "$SURFRAW_rfc_search" in all) ;; rfc) ;; *) echo "Only RFCs available as PDF files, not STDs, BCPs or FYIs. Try without -pdf"; exit 1;; esac # pdfs only available through ftp url="ftp://ftp.rfc-editor.org/in-notes/pdfrfc/rfc${escaped_args}.txt.pdf" fi else # not direct to rfc, construct url from options url="https://www.rfc-editor.org/cgi-bin/rfcsearch.pl?searchwords=${escaped_args}" if [ $isnum -eq 1 -a $searchset -eq 0 ] then url="$url&opt=Number" else case "$SURFRAW_rfc_field" in all*) url="$url&opt=All+Fields";; num*) url="$url&opt=Number";; tit*) url="$url&opt=Title";; auth*) url="$url&opt=Author";; key*) url="$url&opt=Keywords";; kw*) url="$url&opt=Keywords";; *) url="$url&opt=All+Fields";; esac fi url="$url&num=$SURFRAW_rfc_results" url="$url&filefmt=$SURFRAW_rfc_output" url="$url&search_doc=search_$SURFRAW_rfc_search" if ifyes SURFRAW_rfc_matchexact then url="$url&match_method=entire" else url="$url&match_method=prefix" fi if ifyes SURFRAW_rfc_showabs then url="$url&abstract=abson" else url="$url&abstract=absoff" fi if ifyes SURFRAW_rfc_showkw then url="$url&keywords=keyon" else url="$url&keywords=keyoff" fi if ifyes SURFRAW_rfc_reverse then url="$url&sort_method=older" else url="$url&sort_method=newer" fi if ifyes SURFRAW_rfc_ftp then url="$url&format=ftp" else url="$url&format=http" fi fi w3_browse_url "$url" fi diff --git a/elvi/scholar b/elvi/scholar index 368907c..32937a4 100755 --- a/elvi/scholar +++ b/elvi/scholar @@ -1,24 +1,24 @@ #!/bin/sh # $Id$ # elvis: scholar -- Search Google Scholar (scholar.google.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Google Scholar (scholar.google.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://scholar.google.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://scholar.google.com/scholar?q=${escaped_args}" fi diff --git a/elvi/scpan b/elvi/scpan index 8a5b23c..fef967d 100755 --- a/elvi/scpan +++ b/elvi/scpan @@ -1,52 +1,52 @@ #!/bin/sh # $Id$ # elvis: scpan -- Search the Comprehensive Perl Archive Network (metacpan.org) # [email protected] 20030918 . surfraw || exit 1 w3_config_hook () { def SURFRAW_scpan_search "$SURFRAW_scpan_opts" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Comprehensive Perl Archive Network (metacpan.org) Local options: -search= Search Type module | Modules dist | Distributions author | Authors Default: All EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -search=*) setopt SURFRAW_scpan_search $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_scpan_search" in module) searchopts="modules::" ;; dist) searchopts="dist::" ;; author) searchopts="author::" ;; all|*) searchopts="" ;; esac if test -z "$w3_args"; then w3_browse_url "https://metacpan.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://metacpan.org/search?q=${searchopts}${escaped_args}" fi diff --git a/elvi/slashdot b/elvi/slashdot index b5f19cf..8a2a7c2 100755 --- a/elvi/slashdot +++ b/elvi/slashdot @@ -1,23 +1,23 @@ #!/bin/sh # $Id$ # elvis: slashdot -- Search stories on Slashdot (www.slashdot.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search articles on Slashdot (www.slashdot.org) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.slashdot.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.slashdot.org/index2.pl?fhfilter=${escaped_args}" fi diff --git a/elvi/springer b/elvi/springer index 364d32f..5f737c9 100755 --- a/elvi/springer +++ b/elvi/springer @@ -1,62 +1,62 @@ #!/bin/sh # # author: Wim Van Hoydonck # # elvis: springer -- Search Springer for Books and Articles . surfraw || exit 1 w3_config_hook () { def SURFRAW_spinger_fields All } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search springer Local options: -fields=FIELD Subject field to search all | Seach all fields (default) author | Author name title | Title series | Series isbn | ISBN/ISSN Examples: $w3_argv0 -fields=author featherstone EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -fields=*) setopt SURFRAW_springer_fields $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_springer_fields" in all) field=all ;; author) field=authorEditor ;; title) field=title ;; series) field=bookSeries ;; isbn) field=all ;; *) field=all ;; esac if null "$w3_args"; then w3_browse_url "https://www.springer.com" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://www.springer.com/?searchKey=easySearchKey&searchType=easy&visited=true&propagate=false&resultStart=1&resultCount=10&SGWID=5-102-14-0-0&queryText=${escaped_args}&easySearchOption=${field}&go.x=8&go.y=7" w3_browse_url "${url}" fi diff --git a/elvi/stockquote b/elvi/stockquote index ab63996..b48195b 100755 --- a/elvi/stockquote +++ b/elvi/stockquote @@ -1,66 +1,66 @@ #!/bin/sh # $Id$ # elvis: stockquote -- Get a single stock quote (multiple providers) . surfraw || exit 1 w3_config_hook () { def SURFRAW_stockquote_provider yahoo } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] STOCK Description: Surfraw fetch a single stock quote Local options: -provider= Quote provider to use yahoo quote.yahoo.com nasdaq nasdaq.com (InfoQuote) quote quote.com Default: $SURFRAW_stockquote_provider Environment: SURFRAW_stockquote_provider Examples: $w3_argv0 Provider's standard quote page $w3_argv0 -provider=nasdaq Use NASDAQ for quote $w3_argv0 BLDP Obtain quote for 'Ballard Power' EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -provider=*) setopt SURFRAW_stockquote_provider $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test "$SURFRAW_stockquote_provider" = "yahoo"; then if test -z "$w3_args"; then w3_browse_url "https://quote.yahoo.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://quote.yahoo.com/q?s=${escaped_args}" fi elif test "$SURFRAW_stockquote_provider" = "nasdaq"; then if test -z "$w3_args"; then w3_browse_url "https://www.nasdaq.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://quotes.nasdaq.com/Quote.dll?mode=Stock&symbol=${escaped_args}&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&multi.x=44&multi.y=12" fi elif test "$SURFRAW_stockquote_provider" = "quote"; then if test -z "$w3_args"; then w3_browse_url "https://www.quote.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.quote.com/quotecom/stocks/quotes.asp?symbols=${escaped_args}" fi else err "-provider ${SURFRAW_stockquote_provider} unsupported" fi diff --git a/elvi/thesaurus b/elvi/thesaurus index 0b057ac..c556d3a 100755 --- a/elvi/thesaurus +++ b/elvi/thesaurus @@ -1,25 +1,25 @@ #!/bin/sh # $Id$ # elvis: thesaurus -- Look up a synonym in Oxford's thesaurus (en.oxforddictionaries.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Look up a synonym in Oxford's thesaurus (en.oxforddictionaries.com) EOF w3_global_usage } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://en.oxforddictionaries.com/english-thesaurus" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://en.oxforddictionaries.com/thesaurus/${escaped_args}" fi diff --git a/elvi/translate b/elvi/translate index 998fd5e..8729299 100755 --- a/elvi/translate +++ b/elvi/translate @@ -1,154 +1,154 @@ #!/bin/sh # $Id$ # elvis: translate -- Translate human languages . surfraw || exit 1 w3_config_hook () { def SURFRAW_translate_from "$SURFRAW_lang" def SURFRAW_translate_to "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [words|URI]... Description: Surfraw translate human language Local options: -from=LANGUAGE Source language Environment: SURFRAW_translate_from, SURFRAW_lang -to=LANGUAGE Destination language Environment: SURFRAW_translate_to, SURFRAW_lang Languages (any provider): nl Dutch en English fr French de German el Greek it Italian ja Japanese ko Korean pt Portuguese ru Russian es Spanish Languages (Systrans only): zh Chinese (Simplified) zt Chinese (Traditional) Languages (Google only): auto Automatically detect language af Afrikaans sq Albanian ar Arabic hy Armenian az Azerbaijani eu Basque be Belarusian bg Bulgarian ca Catalan zh-CN Chinese (Simplified) zh-TW Chinese (Traditional) hr Croatian cs Czech da Danish et Estonian tl Filipino fi Finnish gl Galician ka Georgian ht Hatian Creole iw Hebrew hi Hindi hu Hungarian is Icelandic id Indonesian ga Irish la Latin lv Latvian lt Lithuanian mk Macedonian ms Malay mt Maltese no Norwegian fa Persian pl Polish ro Romanian sr Serbian sk Slovak sl Slovenian sw Swahili sv Swedish th Thai tr Turkish uk Ukrainian ur Urdu vi Vietnamese cy Welsh yi Yiddish Examples: $w3_argv0 Provider's standard translation page $w3_argv0 -from=fr -to=en la verite vous liberera $w3_argv0 -from=en -to=es https://tashian.com/multibabel Translate the given Web page Bugs: Systrans derived providers only support the following translation combinations: English to Chinese English to French English to German English to Italian English to Japanese English to Korean English to Portuguese English to Spanish Chinese to English French to English French to German German to English German to French Italian to English Japanese to English Korean to English Portuguese to English Russian to English Spanish to English EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -from=*) setopt SURFRAW_translate_from $optarg ;; -to=*) setopt SURFRAW_translate_to $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args" then w3_browse_url "https://translate.google.com/" else if [ -z "$SURFRAW_translate_to" ]; then SURFRAW_translate_to="en" fi if [ -z "$SURFRAW_translate_from" ]; then SURFRAW_translate_from="fr" fi - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) case "$escaped_args" in http*) w3_browse_url "https://translate.google.com/translate?&sl=${SURFRAW_translate_from}&tl=${SURFRAW_translate_to}&u=${escaped_args}" ;; *) w3_browse_url "https://translate.google.com/?&sl=${SURFRAW_translate_from}&tl=${SURFRAW_translate_to}&q=${escaped_args}" ;; esac fi exit $? diff --git a/elvi/urban b/elvi/urban index e63419e..a611a36 100755 --- a/elvi/urban +++ b/elvi/urban @@ -1,28 +1,28 @@ #!/bin/sh # # AUTHOR: J.R. Mauro # # DATE: Sat Nov 1 18:01:13 EDT 2008 # # DESC: Elvi to search The Urban Dictionary # elvis: urban -- Search urbandictionary.com for a definition . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Look up a term in the Urban Dictionary EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.urbandictionary.com" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.urbandictionary.com/define.php?term=${escaped_args}" fi diff --git a/elvi/w3css b/elvi/w3css index 7e9170d..e484569 100755 --- a/elvi/w3css +++ b/elvi/w3css @@ -1,66 +1,66 @@ #!/bin/sh # $Id$ # elvis: w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) # [email protected] 20040909 . surfraw || exit 1 w3_config_hook () { def SURFRAW_w3css_warnings "1" def SURFRAW_w3css_profile "css2" def SURFRAW_w3css_medium "all" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [URL] Description: Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator/) Local options: -warnings=LEVEL Level of warnings displayed. Default: normal Values: all, normal, important, none Environment: SURFRAW_w3css_warnings -profile=PROFILE CSS Profile. Default: $SURFRAW_w3css_profile Values: none, css1, css2, css3, svg, svgbasic, svgtiny, mobile, atsv-tv, tv Environment: SURFRAW_w3css_profile -medium=MEDIUM User Medium Default: $SURFRAW_w3css_medium Values: all, aural, braille, embossed, handheld, print, projection, screen, tty, tv, presentation Environment: SURFRAW_w3css_medium EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -prof*=*) setopt SURFRAW_w3css_profile "$optarg" ;; -med*=*) setopt SURFRAW_w3css_medium "$optarg" ;; -warn*=*) case "$optarg" in [Aa]*) setopt SURFRAW_w3css_warnings "2" ;; [Nn][Oo][Rr]*) setopt SURFRAW_w3css_warnings "1" ;; [Ii]*) setopt SURFRAW_w3css_warnings "0" ;; [Nn][Oo][Nn]*) setopt SURFRAW_w3css_warnings "no" ;; *) echo "Invalid value $optarg"; exit 1 ;; esac ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://jigsaw.w3.org/css-validator/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://jigsaw.w3.org/css-validator/validator?uri=${escaped_args}&warning=${SURFRAW_w3css_warnings}&profile=${SURFRAW_w3css_profile}&usermedium=${SURFRAW_w3css_medium}" w3_browse_url "${url}" fi diff --git a/elvi/w3html b/elvi/w3html index c94b70b..18f6992 100755 --- a/elvi/w3html +++ b/elvi/w3html @@ -1,117 +1,117 @@ #!/bin/sh # $Id$ # elvis: w3html -- Validate a web page URL with the w3c validator (validator.w3.org) # [email protected] 20040906 . surfraw || exit 1 w3_config_hook () { def SURFRAW_w3html_encoding "%28detect+automatically%29" def SURFRAW_w3html_doctype "Inline" defyn SURFRAW_w3html_verbose 1 defyn SURFRAW_w3html_encodingfallback 0 defyn SURFRAW_w3html_doctypefallback 0 defyn SURFRAW_w3html_showsource 0 defyn SURFRAW_w3html_showparsetree 0 defyn SURFRAW_w3html_showoutline 0 defyn SURFRAW_w3html_excludeattributes 0 defyn SURFRAW_w3html_validateerror 0 defyn SURFRAW_w3html_usage 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [URL] Description: Validate a web page URL with the w3c validator (validator.w3.org) Local options: -usage Go to help page for validator. -encoding=ENCODING Set page encoding. Default: autodetect Environment: SURFRAW_w3html_encoding -encfb Fall back to encoding rather than override. Environment: SURFRAW_w3html_encodingfallback -doctype="DOCTYPE" Set page doctype. Default: SURFRAW_w3html_doctype -docfb Fall back to doctype rather than override. Environment: SURFRAW_w3html_doctypefallback -nv Be less verbose. Environment: SURFRAW_w3html_verbose -showsource Show page source. Environment: SURFRAW_w3html_showsource -showoutline Show page outline (headings) Environment: SURFRAW_w3html_showoutline -showparsetree Show parse tree. Environment: SURFRAW_w3html_showparsetree -excludeatt Exclude attributes from parse tree. Environment: SURFRAW_w3html_excludeattributes -err Validate Error (404) pages. Environment: SURFRAW_w3html_validateerror EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in - -enco*=*) setopt SURFRAW_w3html_encoding `w3_url_escape "$optarg"` ;; - -docty*=*) setopt SURFRAW_w3html_doctype `w3_url_escape "$optarg"` ;; + -enco*=*) setopt SURFRAW_w3html_encoding $(w3_url_escape "$optarg") ;; + -docty*=*) setopt SURFRAW_w3html_doctype $(w3_url_escape "$optarg") ;; -encfb) setoptyn SURFRAW_w3html_encodingfallback 1 ;; -docfb) setoptyn SURFRAW_w3html_doctypefallback 1 ;; -shows*) setoptyn SURFRAW_w3html_showsource 1 ;; -showp*) setoptyn SURFRAW_w3html_showparsetree 1 ;; -showo*) setoptyn SURFRAW_w3html_showoutline 1 ;; -exc*) setoptyn SURFRAW_w3html_excludeattributes 1 ;; -err*) setoptyn SURFRAW_w3html_validateerror 1 ;; -nv*) setoptyn SURFRAW_w3html_verbose 0 ;; -us*) setoptyn SURFRAW_w3html_usage 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ $SURFRAW_w3html_usage -eq 1 ]; then w3_browse_url "https://validator.w3.org/docs/users.html#Options" elif test -z "$w3_args"; then w3_browse_url "https://validator.w3.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://validator.w3.org/check?uri=${escaped_args}&charset=${SURFRAW_w3html_encoding}&doctype=${SURFRAW_w3html_doctype}" if [ $SURFRAW_w3html_encodingfallback -eq 1 ] then url="${url}&fbc=1" fi if [ $SURFRAW_w3html_doctypefallback -eq 1 ] then url="${url}&fbd=1" fi if [ $SURFRAW_w3html_showsource -eq 1 ] then url="${url}&ss=1" fi if [ $SURFRAW_w3html_showparsetree -eq 1 ] then url="${url}&sp=1" fi if [ $SURFRAW_w3html_showoutline -eq 1 ] then url="${url}&outline=1" fi if [ $SURFRAW_w3html_excludeattributes -eq 1 ] then url="${url}&noatt=1" fi if [ $SURFRAW_w3html_validateerror -eq 1 ] then url="${url}&No200=1" fi if [ $SURFRAW_w3html_verbose -eq 1 ] then url="${url}&verbose=1" fi w3_browse_url "${url}" fi diff --git a/elvi/w3link b/elvi/w3link index 90b2b9a..d633f4a 100755 --- a/elvi/w3link +++ b/elvi/w3link @@ -1,88 +1,88 @@ #!/bin/sh # $Id$ # elvis: w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) # [email protected] 20040908 . surfraw || exit 1 w3_config_hook () { def SURFRAW_w3link_depth -1 defyn SURFRAW_w3link_summary 1 defyn SURFRAW_w3link_hiderd 0 defyn SURFRAW_w3link_dhiderd 0 defyn SURFRAW_w3link_noacceptlanguage 0 defyn SURFRAW_w3link_recurse 0 defyn SURFRAW_w3link_cookie 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [URL] Description: Check web page links with the w3c linkchecker (validator.w3.org/checklink) Local options: -r Check linked documents recursively. Environment: SURFRAW_w3link_recurse -d=DEPTH Recursion depth. Default: unlimited (-1) Environment: SURFRAW_w3link_depth -s Summary only. Environment: SURFRAW_w3link_summary -hiderd Hide Redirects. Environment: SURFRAW_w3link_hiderd -dhiderd Hide Redirects for directories only. Environment: SURFRAW_w3link_dhidedrd -nolang Don't send the Accept-Language: header. Environment: SURFRAW_w3link_noacceptlanguage -cookie Save options in a cookie. Environment: SURFRAW_w3link_cookie EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -d*=*) setopt SURFRAW_w3link_depth "$optarg" ;; -r) setoptyn SURFRAW_w3link_recurse 1 ;; -s) setoptyn SURFRAW_w3link_summary 1 ;; -hiderd) setoptyn SURFRAW_w3link_hiderd 1 ;; -dhiderd) setoptyn SURFRAW_w3link_dhiderd 1 ;; -nolang) setoptyn SURFRAW_w3link_noacceptlanguage 1 ;; -cookie) setoptyn SURFRAW_w3link_cookie 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://validator.w3.org/checklink" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://validator.w3.org/checklink?uri=${escaped_args}&depth=${SURFRAW_w3link_depth}" if [ $SURFRAW_w3link_recurse -eq 1 -o $SURFRAW_w3link_depth -ge 0 ] then url="${url}&recursive=on" fi if [ $SURFRAW_w3link_summary -eq 1 ] then url="${url}&summary=on" fi if [ $SURFRAW_w3link_noacceptlanguage -eq 1 ] then url="${url}&no_accept_language=on" fi if [ $SURFRAW_w3link_hiderd -eq 1 ] then url="${url}&hide_redirects=on&hide_type=all" elif [ $SURFRAW_w3link_dhiderd -eq 1 ] then url="${url}&hide_redirects=on&hide_type=dir" fi w3_browse_url "${url}" fi diff --git a/elvi/w3rdf b/elvi/w3rdf index 2795321..775ec42 100755 --- a/elvi/w3rdf +++ b/elvi/w3rdf @@ -1,133 +1,133 @@ #!/bin/sh # $Id$ # elvis: w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) # [email protected] 20040909 . surfraw || exit 1 w3_config_hook () { def SURFRAW_w3rdf_output "PRINT_TRIPLES" def SURFRAW_w3rdf_format "PNG_EMBEDDED" defyn SURFRAW_w3rdf_savedot 0 defyn SURFRAW_w3rdf_ntriples 0 defyn SURFRAW_w3rdf_embedded 0 defyn SURFRAW_w3rdf_useme 0 defyn SURFRAW_w3rdf_anon 0 def SURFRAW_w3rdf_node "Black" def SURFRAW_w3rdf_nodetext "Blue" def SURFRAW_w3rdf_arc "Darkgreen" def SURFRAW_w3rdf_arctext "Red" def SURFRAW_w3rdf_fontsize 10 def SURFRAW_w3rdf_orientation "LR" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [URL] Description: Validate a RDF URL with the w3c RDF validator (www.w3.org/RDF/Validator) Local options: -output=TYPE Type of output displayed. Values: Triples, Graphs, Both Default: Triples Environment: SURFRAW_w3rdf_output -format=TYPE Graph Format Values: PNG_EMBED, PNG_LINK, SVG_LINK, SVG_EMBED, GIF_EMBED, GIF_LINK, PS_LINK, HP_PCL_LINK, HP_GL_LINK, ISV_ZVTM Default: $SURFRAW_w3rdf_format Environment: SURFRAW_w3rdf_format -savedot Save GraphViz DOT file. Environment: SURFRAW_w3rdf_savedot -ntriples Display triples in N-Triples format Environment: SURFRAW_w3rdf_ntriples -embedded RDF is NOT enclosed in <RDF>..</RDF> tags. Environment: SURFRAW_w3rdf_embedded -useme I grant w3c permission to save the RDF for developing test cases. Environment: SURFRAW_w3rdf_useme -anon Make anonymous nodes unlabelled. Environment: SURFRAW_w3rdf_anon -fontsize=SIZE Font Size. Values: 10, 12, 14, 16, 20 Default: $SURFRAW_w3rdf_fontsize Environment: SURFRAW_w3rdf_fontsize -orient=ORIENTATION Orientation Values: TB (Top to Bottom), LR (Left to Right) Default: $SURFRAW_w3rdf_orientation Environment: SURFRAW_w3rdf_orientation -node=COLOUR Node Colour. Environment: SURFRAW_w3rdf_node Default: $SURFRAW_w3rdf_node -nodetext=COLOUR Node Text Colour. Environment: SURFRAW_w3rdf_nodetext Default: $SURFRAW_w3rdf_nodetext -arc=COLOUR Arc Colour. Environment: SURFRAW_w3rdf_arc Default: $SURFRAW_w3rdf_arc -arctext=COLOUR Arc Text Colour. Environment: SURFRAW_w3rdf_arctext Default: $SURFRAW_w3rdf_arctext Valid Colours: Black, Blue, Darkgreen, Red EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -out*=*) case "$optarg" in [Tt]*) setopt SURFRAW_w3rdf_output "PRINT_TRIPLES" ;; [Gg]*) setopt SURFRAW_w3rdf_output "PRINT_GRAPH" ;; [Bb]*) setopt SURFRAW_w3rdf_output "PRINT_GRAPH" ;; *) echo "Invalid value $optarg"; exit 1 ;; esac ;; -for*=*) setopt SURFRAW_w3rdf_format "$optarg" ;; -sav*) setoptyn SURFRAW_w3rdf_savedot 1 ;; -nt*) setoptyn SURFRAW_w3rdf_ntriples 1 ;; -em*) setoptyn SURFRAW_w3rdf_embedded 1 ;; -use*) setoptyn SURFRAW_w3rdf_useme 1 ;; -anon*) setoptyn SURFRAW_w3rdf_anon 1 ;; -font*=*) setopt SURFRAW_w3rdf_fontsize "$optarg" ;; -or*=*) setopt SURFRAW_w3rdf_orientation "$optarg" ;; -node=*) setopt SURFRAW_w3rdf_node "$optarg" ;; -nodet*) setopt SURFRAW_w3rdf_nodetext "$optarg" ;; -arc=*) setopt SURFRAW_w3rdf_arc "$optarg" ;; -arct*=*) setopt SURFRAW_w3rdf_arctext "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.w3.org/RDF/Validator/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://www.w3.org/RDF/Validator/ARPServlet?PARSE=PARSE_URI&URI=${escaped_args}&TRIPLES_AND_GRAPH=${SURFRAW_w3rdf_output}&FORMAT=${SURFRAW_w3rdf_format}&NODE_COLOR=${SURFRAW_w3rdf_node}&NODE_TEXT_COLOR=${SURFRAW_w3rdf_nodetext}&EDGE_COLOR=${SURFRAW_w3rdf_arc}&EDGE_TEXT_COLOR=${SURFRAW_w3rdf_arctext}&FONT_SIZE=${SURFRAW_w3rdf_fontsize}&ORIENTATION=${SURFRAW_w3rdf_orientation}" if [ $SURFRAW_w3rdf_savedot -eq 1 ] then url="${url}&SAVE_DOT_FILE=on" fi if [ $SURFRAW_w3rdf_ntriples -eq 1 ] then url="${url}&NTRIPLES=on" fi if [ $SURFRAW_w3rdf_embedded -eq 1 ] then url="${url}&EMBEDDED_RDF=on" fi if [ $SURFRAW_w3rdf_useme -eq 1 ] then url="${url}&SAVE_RDF=on" fi if [ $SURFRAW_w3rdf_anon -eq 1 ] then url="${url}&ANON_NODES_EMPTY=on" fi w3_browse_url "${url}" fi diff --git a/elvi/wayback b/elvi/wayback index af0eb30..8b76d19 100755 --- a/elvi/wayback +++ b/elvi/wayback @@ -1,23 +1,23 @@ #!/bin/sh # $Id$ # elvis: wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [URL] Description: Search The Internet Archive's Wayback Machine for a URL (archive.org) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.archive.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) url="https://www.archive.org/searchresults.php?mediatype=web&Submit=Take+Me+Back" w3_browse_url "${url}&search=${escaped_args}" fi diff --git a/elvi/webster b/elvi/webster index c7ed691..d9e7d64 100755 --- a/elvi/webster +++ b/elvi/webster @@ -1,42 +1,42 @@ #!/bin/sh # $Id$ # elvis: webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_webster_book dictionary } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Look up word in Merriam-Webster's Dictionary (www.m-w.com) Local options: -t Search in Thesaurus EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -t*) setopt SURFRAW_webster_book thesaurus ;; *) return 1 ;; esac return 0 } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.merriam-webster.com/dictionary.htm" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.merriam-webster.com/${SURFRAW_webster_book}/${escaped_args}" fi diff --git a/elvi/wikipedia b/elvi/wikipedia index 5b2e091..3db5e4d 100755 --- a/elvi/wikipedia +++ b/elvi/wikipedia @@ -1,58 +1,58 @@ #!/bin/sh # elvis: wikipedia -- Search the free encyclopedia wikipedia # $Id$ # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_config_hook () { def SURFRAW_wikipedia_language "$SURFRAW_lang" defyn SURFRAW_wikipedia_deletionpedia no def SURFRAW_wikipedia_fallback wikipedia } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Wikipedia online encyclopedia Local options: -language=ISOCODE | -l=ISOCODE Two letter language code (resembles ISO country codes) Default: en Environment: SURFRAW_wikipedia_language, SURFRAW_lang Examples: $w3_argv0 -language=de Richard Stallman EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_wikipedia_language $optarg ;; -l=*) setopt SURFRAW_wikipedia_language $optarg ;; *) return 1 ;; esac return 0 } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" if [ -z "$SURFRAW_wikipedia_language" ]; then SURFRAW_wikipedia_language="en" fi prefix="https://${SURFRAW_wikipedia_language}.wikipedia.org/wiki/index.php?search=" suffix="&go=Go" if null "$w3_args"; then w3_browse_url "https://${SURFRAW_wikipedia_language}.wikipedia.org/wiki/Main_Page" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${prefix}${escaped_args}" fi diff --git a/elvi/wiktionary b/elvi/wiktionary index 64716a4..a852603 100755 --- a/elvi/wiktionary +++ b/elvi/wiktionary @@ -1,54 +1,54 @@ #!/bin/sh # elvis: wiktionary -- Search the free dictionary wiktionary # $Id$ # Author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_wiktionary_language "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Wiktionary online dictionary -language=ISOCODE | -l=ISOCODE Two letter language code (resembles ISO country codes) Default: en Environment: SURFRAW_wiktionary_language, SURFRAW_lang Examples: $w3_argv0 -language=de synecdoche EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_wiktionary_language $optarg ;; -l=*) setopt SURFRAW_wiktionary_language $optarg ;; *) return 1 ;; esac return 0 } w3_config # disable requoting, doesn't work with this elvi. #SURFRAW_quote_ifs=0 w3_parse_args "$@" if [ -z "$SURFRAW_wiktionary_language" ]; then SURFRAW_wiktionary_language="en" fi prefix="${SURFRAW_wiktionary_language}" if null "$w3_args"; then w3_browse_url "https://${SURFRAW_wiktionary_language}.wiktionary.org" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://${prefix}.wiktionary.org/wiki/${escaped_args}" fi diff --git a/elvi/woffle b/elvi/woffle index 21e21d3..1c15c85 100755 --- a/elvi/woffle +++ b/elvi/woffle @@ -1,67 +1,67 @@ #!/bin/sh # $Id$ # elvis: woffle -- Search the web using Woffle (localhost:8080) . surfraw || exit 1 w3_config_hook () { def SURFRAW_woffle_search search/htdig/htsearch def SURFRAW_woffle_format 'builtin-long' def SURFRAW_woffle_method and def SURFRAW_woffle_sort score } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Woffle (localhost:8080/) Local options: -method= Method used for searching... and | ALL or | ANY bool | BOOLEAN -format= Format of results short | just a link and title long | description please -sort= Sort method score | best result revscore | worst result! time | newest revtime | oldest title | abc by title revtitle | zyx by title EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -format=*) if [ "$optarg" = "short" ] ; then optarg="builtin-short" else optarg="builtin-long" fi setopt SURFRAW_woffle_format $optarg ;; -method=*) if [ "$optarg" = "bool" ] ; then optarg="boolean" fi setopt SURFRAW_woffle_method $optarg ;; -sort=*) setopt SURFRAW_woffle_sort $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "http://localhost:8080/search/htdig/search.html" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "http://localhost:8080/${SURFRAW_woffle_search}?words=${escaped_args}&method=${SURFRAW_woffle_method}&format=${SURFRAW_woffle_format}&sort=${SURFRAW_woffle_sort}" fi diff --git a/elvi/wolfram b/elvi/wolfram index 95960d3..6c1522d 100755 --- a/elvi/wolfram +++ b/elvi/wolfram @@ -1,41 +1,41 @@ #!/bin/sh # elvis: wolfram -- Ask questions of the computational knowledge engine # [email protected] 20110105 . surfraw || exit 1 w3_config_hook () { def SURFRAW_wolfram_results "$SURFRAW_results" def SURFRAW_wolfram_base_url "www.wolframalpha.com/" def SURFRAW_wolfram_search search def SURFRAW_wolfram_params "input/?i=" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using wolfram (www.wolfram.com) Local options: (null) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments SURFRAW_wolfram_base_url="https://${SURFRAW_wolfram_base_url}" -escaped_args=`w3_url_of_arg $w3_args` +escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "${SURFRAW_wolfram_base_url}${SURFRAW_wolfram_params}${escaped_args}" diff --git a/elvi/worldwidescience b/elvi/worldwidescience index 487433e..3d3f402 100755 --- a/elvi/worldwidescience +++ b/elvi/worldwidescience @@ -1,23 +1,23 @@ #!/bin/sh # elvis: worldwidescience -- Search for science with www.worldwidescience.org . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search for science with worldwidescience.org EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://worldwidescience.org/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://worldwidescience.org/wws/result-list/fullRecord:${escaped_args}/" fi diff --git a/elvi/yahoo b/elvi/yahoo index c9b0943..b1fef3e 100755 --- a/elvi/yahoo +++ b/elvi/yahoo @@ -1,41 +1,41 @@ #!/bin/sh # $Id$ # elvis: yahoo -- Search Yahoo categories (www.yahoo.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_yahoo_results $SURFRAW_results } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Yahoo categories (www.yahoo.com) Local options: -results=NUM Number of search results returned Default: $SURFRAW_yahoo_results Environment: SURFRAW_yahoo_results EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_yahoo_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://www.yahoo.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://search.yahoo.com/search?p=${escaped_args}&n=${SURFRAW_yahoo_results}" fi diff --git a/elvi/yandex b/elvi/yandex index a131c12..b10d0e3 100755 --- a/elvi/yandex +++ b/elvi/yandex @@ -1,50 +1,50 @@ #!/bin/sh # $Id$ # elvis: yandex -- Search the web using Yandex (yandex.ru) . surfraw || exit 1 w3_config_hook () { def SURFRAW_yandex_search "${search:-yandsearch?}text" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Yandex (yandex.ru) Local options: Specialized search on topic -dict | Slovari -news | News -images | Images -market | Market -maps | Maps EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -dict) search="search.xml?" opt=slovari ;; -news) search="yandsearch?rpt=nnews2\&" ;; -market) search="search.xml?" ;; -images) search="search?" ;; -maps) search="?" ;; *) return 1 esac setopt SURFRAW_yandex_domain "${opt:+${opt#-}.}" [ -n $search ] && setopt SURFRAW_yandex_search "${search}text" return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then w3_browse_url "https://${SURFRAW_yandex_domain}yandex.ru/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://${SURFRAW_yandex_domain}yandex.ru/${SURFRAW_yandex_search}=${escaped_args}" fi diff --git a/elvi/youtube b/elvi/youtube index b005d92..a058644 100755 --- a/elvi/youtube +++ b/elvi/youtube @@ -1,27 +1,27 @@ #!/bin/sh # # AUTHOR: S.S.R. Oemrawsingh # # DATE: Sat Nov 07 2009 # # DESC: Elvi to search YouTube # elvis: youtube -- Search YouTube (www.youtube.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search YouTube (www.youtube.com) for videos EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then w3_browse_url "https://www.youtube.com/" else - escaped_args=`w3_url_of_arg $w3_args` + escaped_args=$(w3_url_of_arg $w3_args) w3_browse_url "https://www.youtube.com/results?search_query=${escaped_args}" fi diff --git a/surfraw.IN b/surfraw.IN index 1e2db3b..5e962cc 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,698 +1,698 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 -w3_argv0=`basename "$0"` +w3_argv0=$(basename "$0") elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { base="$1" local conf OIFS conf="" if test -n "$XDG_CONFIG_DIRS"; then OIFS="$IFS" IFS=: set $XDG_CONFIG_DIRS IFS="$OIFS" for i in "$@"; do if test -r "$i/surfraw/$base"; then conf="$i/surfraw/$base" break fi done fi if test -n "$conf"; then if test -r "@sysconfdir@/xdg/surfraw/$base"; then # XDG default conf="@sysconfdir@/xdg/surfraw/$base" elif test -r "@sysconfdir@/surfraw.$base"; then # old surfraw default conf="@sysconfdir@/surfraw.$base" fi fi echo "$conf" } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value=\$${1} - case `echo "$value" | tr A-Z a-z` in + case $(echo "$value" | tr A-Z a-z) in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value=\$${1} test -z "$value" || return 0 eval ${1}="$2" return 0 } defyn () { eval value=\$${1} test -z "$value" && eval ${1}="$2" yesno "$1" } setopt () { eval value=\$${1} eval ${1}="$2" } setoptyn () { eval value=\$${1} eval ${1}="$2" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in - -*=*) optarg=`echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//'` + -*=*) optarg=$(echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//') esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then - w3_shquoted_args="`quote "$arg"`" + w3_shquoted_args="$(quote "$arg")" else - w3_shquoted_args="$w3_shquoted_args `quote "$arg"`" + w3_shquoted_args="$w3_shquoted_args $(quote "$arg")" fi if ok SURFRAW_quote_ifs then - arg=`quote_ifs "$arg"` + arg=$(quote_ifs "$arg") fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { - if ok SURFRAW_new_screen && test `echo $TERM | cut -c 1-6` = "screen" && + if ok SURFRAW_new_screen && test $(echo $TERM | cut -c 1-6) = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { - quoted=`echo "$1"|sed "s/'/'\\\\\''/g"` + quoted=$(echo "$1"|sed "s/'/'\\\\\''/g") echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then case "$arg" in -help | --help |-h) do_help=1 ;; -local-help | \ --local-help | \ -lh | -\? ) do_help=1 ; setoptyn SURFRAW_local_help yes ;; -elvi*) w3_parse_option -elvi; exit 0 ;; esac fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then - opts="`quote "$arg"`" + opts="$(quote "$arg")" unquoted_opts="$arg" else - opts="$opts `quote "$arg"`" + opts="$opts $(quote "$arg")" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then - searchterms="`quote "$arg"`" + searchterms="$(quote "$arg")" unquoted_searchterms="$arg" else - searchterms="$searchterms `quote "$arg"`" + searchterms="$searchterms $(quote "$arg")" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then sh -c "$elvidir/$elvi $opts $searchterms" else - bookmark=`bookmark_lookup $elvi` + bookmark=$(bookmark_lookup $elvi) if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else - echo "`basename $0`: $elvi: No elvis or bookmark with that name" + echo "$(basename $0): $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
95861039e1b5143f881293f706aecef327ec8378
Added Dmitry Bogatov's dockerhub elvis.
diff --git a/ChangeLog b/ChangeLog index 3ec3e5e..794c030 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,512 +1,516 @@ +2018-10-09 Dmitry Bogatov <[email protected]> + + * new elvi: dockerhub + 2018-01-13 Jason Ryan <[email protected]> * Bump version to 2.3.0 * Select Perl version at buildtime (Mark Meyer) * Remove lynx-cur (closes #882286) * Packages the https elvi 2017-06-07 Jason Ryan <[email protected]> * new elvi: wiktionary 2017-07-14 Jason Ryan <[email protected]> * Moved all elvi to https * Removed elvi that don't support https: - cablesearch - dmoz - openports - opensearch - pasearch - rhyme - rpmsearch - scicom - scirus - wetandwild - yacy - yubnub 2015-09-13 Kyle Isom <[email protected]> * use awk instead of sed for listing elvi This provides better cross-platform behaviour. 2015-08-23 Jason Ryan <[email protected]> * new elvi: searx 2014-09-20 Lucas Hoffmann <l-m-h at web.de> * new elvi: commandlinefu 2104-06-04 Jason Ryan <[email protected]> * new elvi: nlab 2013-12-10 Ian Beckwith <[email protected]> * yandex: disabled test: redirects to captcha when used with LWP. * Fix make distcheck: remove last traces of codesearch and scitopia. 2013-12-09 Ian Beckwith <[email protected]> * deja: disable tests, google groups now requires javascript. * gmane: fix test. * codesearch: removed, service shut down. * scitopia: removed, service shut down. * scicom: down, status unknown, made note in NEWS. 2013-12-08 Ian Beckwith <[email protected]> * new elvi: gmane * openbsd -mail: use gmane (directly, not via gmane elvi) * fix tests: ads, pgdoc, pin, yacy 2013-10-27 Ian Beckwith <[email protected]> * surfraw.IN: w3_custom_search_google: don't give full path to surfraw. * pgdoc, wayback: fixed tests. 2013-10-20 Ian Beckwith <[email protected]> * new elvi: yacy: search using yacy p2p search. -S searches ScienceNet, a yacy-based science search engine. * rae: fix url, remove -tipo option (no longer supported), disable test as there is now gratuitous javascript. 2013-10-06 Ian Beckwith <[email protected]> * Replaced phpdoc with version posted back in 2011 by Jon Yamokoski <[email protected]> Thanks, and apologies for missing it! * S: add test. * Include debian packaging in upstream tarball. 2013-10-05 Ian Beckwith <[email protected]> * ask, cisco: fix elvi. * new elvi: + oraclesearch - Replaces removed sunonesearch <sigh>. + S - search using w3_custom_search. * google: -g for groups clashed with -g for graphical browser. Invoke groups with -G, -gr, -groups or -search=groups. * mdn: site invokes google custom search via gratuitous javascript, so switch to w3_custom_search. * alioth: changed test to SKIP:, works OK but won't talk to LWP, hence test breaks. * discogs, openbsd: fixed tests. * mdn, mysqldoc, pgdoc, phpdoc: added tests. * w3_custom_search: + document in README. + remove documentation for ixquick support. It still works(ish), but doesn't support enough features to support (eg) mysqldoc -v=. + add -custom-search= commandline option. * updated copyright years to 2013. 2013-09-30 Ian Beckwith <[email protected]> * new elvi: mdn, mysqldoc, pgdoc, phpdoc * new function: w3_custom_search Is used by elvi that use a generic search engine with (eg) site: or inurl: to narrow down the search. Pass it -s=site -u=url for site: and inurl: args plus the quoted search args * new environment variable: SURFRAW_customsearch_provider to set provider used by w3_custom_search can be set to: google, duckduckgo or ixquick. Currently affects: mysqldoc, netbsd(*), openbsd(*), pgdoc, phpdoc, mysqldoc. (*) = only used by some options of elvi. * new internal variable w3_shquoted_args, contains arguments 'quoted' 'like this' for passing to w3_custom_search * Fixed url-encoding for '\' 2013-05-07 Ian Beckwith <[email protected]> * new elvi: jquery 2013-05-04 Ian Beckwith <[email protected]> * bump version to 2.2.9 * rae: fixed, at least as far as the test passing. Could really do with some love from someone who actually speaks spanish. * ctan: fixed search, updated options. Note command-line options have changed. * genportage: switch to gpo.zugaina.org * debcodesearch: new (trivial) elvi for codesearch.debian.net * jamendo: fix url, disable test (search now javascript) * deli: fix url; remove options; disable test (search now javascript) 2013-04-28 Ian Beckwith <[email protected]> * musicbrainz: fixed mbid search. * springer: fixed test. 2013-04-27 Ian Beckwith <[email protected]> * javasun: fixed test. 2013-04-24 Ian Beckwith <[email protected]> * Rewrote deblists for new xapian search. + -author, -lists, -lang no longer supported. + added -ml and -mv to show message id links and list view. * Removed happypenguin. Currently defunct and they are talking about a rewrite, so when it is back it will need fixing anyway. 2012-10-22 Ian Beckwith <[email protected]> * Fixed elvi: cisco, slashdot, slinuxdoc. * Removed elvi: scroogle (site gone). * Fixed tests: acronym, bbcnews, bugzilla, cisco, cite[1], currency, discogs, excite, fsfdir, gcache, github, imdb, ixquick, lastfm, leodict, openbsd[2], scholar. * test/Makefile.am: Added missing tests to EXTRA_DIST 2012-06-28 Manolo Martínez <[email protected]> * examples/hooks.lua: Added elinks integration script 2012-06-28 Ivy Foster <[email protected]> * Further simplified searchable bookmarks 2012-06-28 Thomas Zervogiannis <[email protected]> * Simplified searchable bookmarks 2012-06-27 Ivy Foster <[email protected]> * Fixed arg parsing in searchable bookmarks * New variable: SURFRAW_bookmark_search_elvis + When using searchable bookmarks, if all else fails run this elvis. Defaults to google * Updated manual to reflect changes to bookmarks * duckduckgo: Removed -p option. -safe still works. + Prevents clobbering global option -p[rint]. 2012-06-27 Thomas Zervogiannis <[email protected]> * Added searchable bookmarks + Bookmarks can now be searchable by adding '%s' to the url string. 2012-06-01 Jason Ryan <[email protected]> * New elvi: github (search github.com) 2012-03-17 Ivy Foster <[email protected]> * Fix a typo in duckduckgo code. 2012-03-17 Ivy Foster <[email protected]> * Keep duckduckgo's -l[ucky] from clobbering -lh 2012-01-10 Ivy Foster <[email protected]> * aur: now uses HTTPS by default + On the AUR, connecting via HTTP disables login. + Added switch -no-https to enable connection via plain HTTP 2011-10-10 Ian Beckwith <[email protected]> * surfraw.IN: test_elvi(): tweak sed regex * add tests for f5, cisco and pin. 2011-10-10 Shain Singh <[email protected]> * New elvi: f5, cisco 2011-10-10 Jason Ryan <[email protected]> * New elvi: pin (search pinboard.in). 2011-09-09 Kyle Isom <[email protected]> * New elvi: wolfram - query Wolfram Alpha * Author: Kyle Isom <[email protected]> * Added test for wolfram. 2011-08-09 Ian Beckwith <[email protected]> * New elvi: priberam - search Portuguese dictionary. Author: Paulo Almeida <[email protected]> * Added test for priberam. 2011-07-11 Ian Beckwith <[email protected]> * netbsd: fix normal & mail search. google custom searches were complaining I was a bot, so I switched to normal google searches with site:{mail-index,}.netbsd.org. * cia: fix search URL 2011-06-17 Ian Beckwith <[email protected]> * arxiv: fix -scope=author with single-word queries. Thanks to Nikos Apostolakis. * btw, note about entry below, netbsd make *does* support '$<', but only in suffix rules. 2011-06-16 Ian Beckwith <[email protected]> * Fix more make(1) portability problems. Either I am horribly confused or netbsd make (or at least pmake in debian) doesn't support '$<'. Switched to '$?'. * Also switched submit-lsm rule to '$?'. Thanks to Kyle Isom. * Removed long-obsolete commented-out sourceforge upload rules. 2011-06-15 Ian Beckwith <[email protected]> * scitopia, worldwidescience: fixed URLs. * Fixed make portability problems. We cannot portably combine single suffix rules (foo.IN->foo) and separated dependencies so we have to explicitly specify all the .IN rules. The solution we used for this until now was specific to GNU make. * Removed Makefile.include, no longer used. * './configure --enable-opensearch' now only controls installation of the (direct) dependencies for opensearch, not opensearch itself, as opensearch now falls back to using a remote reflector if opensearch-discover(1) and opensearch-genquery(1) aren't found. * yandex: fix test. 2011-06-14 Ian Beckwith <[email protected]> * musicbrainz, codesearch, rpmsearch: Fixed URLs, options and tests. The sites have all changed significantly which means both new options and no-longer-supported options. Codesearch has gone all ajaxy, so I've implemented the options via the search string, e.g. adding " package:foo". Disabled codesearch.test, as it now needs javascript. Codesearch on both google.com and google.co.uk was acting up, so I've pointed it at google.fr. * Removed filesearching elvi, it now requires a 'Referer:' header to work. There is no browser-portable way to specify a 'Refer[r]er:' header, plus we should probably take it as a hint. * Tweaked debian packaging. * Updated NEWS. 2011-06-13 Ian Beckwith <[email protected]> * w3link: fixed URLs. 2011-06-10 Ian Beckwith <[email protected]> * Fixed ctan. Option -doc has been replaced by -id. Options are no longer mutually exclusive, you can now do (eg) ctan -d -i -n texlive. 2011-06-09 Ian Beckwith <[email protected]> * fixed tests: debwiki, ntrs, wayback. 2011-06-07 Ian Beckwith <[email protected]> * Default to surfraw_graphical_remote=no, as chromium doesn't support "-remote openURL". 2011-05-31 Jason Ryan <[email protected]> * Add options to archpkg. 2011-05-12 Sara Fauzia <[email protected]> * Fix archpkg URL. 2011-05-12 Ian Beckwith <[email protected]> * surfraw.IN: + if elvi doesn't exist, send usage to stderr not stdout. + bookmark names: do exact match not substring match. * Added tests for archwiki, deli & stack. * README: + added INTEGRATION section on uzbl and pentadactyl. + upcased section headings for clarity. 2011-05-12 Jason Ryan <[email protected]> * New elvi: + archwiki: search the arch wiki. + deli: search delicious.com. + stack: search stackoverflow.com and friends. 2011-03-21 Ian Beckwith <[email protected]> * google: Added -safe=default|off|moderate|strict option for Safe Search. 2011-03-21 Ivy Foster <[email protected]> * Added Google Translate to elvi/translate. 2011-03-03 Ian Beckwith <[email protected]> * opensearch: new option -r, uses redirector at http://erislabs.net/ianb/webtools/opensearch/ instead of calling opensearch-discover and opensearch-genquery. -r is selected automatically if those tools are not installed. This enables us to ship opensearch in the main surfraw package and it still functions if the dependencies are not installed. See debian/changelog. * wikipedia: new options: + -d, uses a redirector at http://erislabs.net/ianb/webtools/wpdp/ This redirector searches for a page with that name at wikipedia. If not found, it searches deletionpedia, if not found there it falls back to a normal wikipedia search. + -f=w|d, -fallback=wikipedia|deletionpedia Implies -d. If page not found at either wikipedia or deletionpedia, whether to fallback to wikipedia search or deletionpedia search. * google: + support video, maps and news. + new options -i, -v, -m, -n, shortcuts for -search={images,videos,maps,news}. * debcontents, debpackages: update docs for new arches and distributions. * bugzilla: + fix url so it works with redhat & eclipse bugzillas too. + enable -s=redhat. * ixquick, w3css: fix tests. * opensearch, wikipedia: add redirector tests. 2011-02-20 Ian Beckwith <[email protected]> * New elvi: bugzilla - searches various bugzillas, defaults to kernel. * pgpkeys: add more options, support more keyservers, default to sks-keyservers.net. * bump version to 2.2.8. * test/Makefile.am: add cablesearch.test. 2011-02-19 Ian Beckwith <[email protected]> * lastfm: fix url to avoid a redirect that mangled args with spaces. * debbugs: add -s as an alias for -search=src. * surfraw.IN: (finally) update copyright year to 2011. * remove traces of port elvi from build system. 2011-02-09 Kyle Isom <[email protected]> * fix a number of tests to match current site formats 2011-01-12 Kyle Isom <[email protected]> * New elvi: + cablesearch - search wikileaks cables + duckduckgo - replace with better implementation + openports - search openbsd ports 2010-12-04 Jakob <[email protected]> * new elvis: pasearch. 2010-12-08 Ian Beckwith <[email protected]> * arxiv: Thanks to MT <[email protected]> for patch that fixes: 1. Search queries with more than two terms would fail, e.g. 'supermassive black hole'. 2. Full text search was broken, it works now. 3. Enhancement: quoting the query now does an exact string match. 2010-10-29 Ian Beckwith <[email protected]> * wayback: advanced search is broken, rip out all options and use basic search. * w3_url_escape: add /g to '/'->'%2F' replacement. * uzbl_load_url_from_surfraw: use @AWK@ to pick up ./configure's choice of awk implementation. 2010-10-28 Ian Beckwith <[email protected]> * Support -local-help, --local-help or -lh to get elvi-specific help without displaying the global options. This works for all elvi and the main surfraw script. * google, duckduckgo, opensearch, wayback: tweak overbroad option parsing so it doesn't interfere with -lh. * Support -h as a synonym for -help. 2010-10-25 Ian Beckwith <[email protected]> * new elvi: scirus, scitopia, worldwidescience. * yahoo: reduced query string to just p and n options. * openbsd: support -misc and -tech. Thanks to Sunil Nimmagadda for the patch. * removed cddb: gracenote made the "hard decision" to remove the website search. sigh. * removed altavista: is now just a front-end to yahoo. * removed fast: another yahoo front-end. * imdb: fix test. * javasun: oracleized URLs. * w3link: fixed URL. 2010-08-22 Jameson Rollins <[email protected]> * surfraw.IN: Improve listing of elvi. 2010-08-20 James Rowe <[email protected]> * new elvi: ads. Thanks to Jameson Rollins. 2010-07-02 Ian Beckwith <[email protected]> * new elvi: yandex. Thanks to Uspenskiy Andrey. 2010-05-06 Ian Beckwith <[email protected]> * uzbl_load_url_from_surfraw: fix menu. Thanks to Sumant Oemrawsingh. * Fixed tests: deblists google openbsd. 2010-04-28 Ian Beckwith <[email protected]> * configure.in: test for google-chrome, opera and links2. 2010-04-22 Ian Beckwith <[email protected]> * debwiki: remove -w, Debian Women wiki is now being merged into main wiki. Thanks to Simone Fittabile. * debwiki.test: stop testing -w option. * surfraw.IN: change an awk to @AWK@. 2010-04-21 Ian Beckwith <[email protected]> * New elvi: jamendo - Search Jamendo: free music with Creative Commons licenses (www.jamendo.com). Thanks to Simone Fittabile. * wikipedia, ixquick: Support https. Thanks to Simone Fittabile. * wikipedia: tweak Simone's patch to support https for start page and document the SURFRAW_wikipedia_ssl variable. * ixquick: add -nossl option. * javasun.test: revert to previous test, works again. 2010-04-19 James Rowe <[email protected]> * genpkg: removed, use genportage. 2010-04-16 Ian Beckwith <[email protected]> * New elvi: + scroogle: Search Google anonymously via www.scroogle.org. + duckduckgo: Search the web via duckduckgo.com. * Fix tests: excite, javasun, musicbrainz, yahoo. 2010-03-03 James Rowe <[email protected]> * bookfinder: fix ISBN search test. 2010-03-01 Ian Beckwith <[email protected]> * Removed autotools-generated files from git repo use ./prebuild to regenerate. * Lower required automake version to 1.10. * prebuild: try and find a sane set of autotools, then call autoreconf -vi diff --git a/README b/README index 6ba4151..07c73dc 100644 --- a/README +++ b/README @@ -1,345 +1,346 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Home Page: https://gitlab.com/surfraw/Surfraw ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web New: https://gitlab.com/surfraw/Surfraw Old: http://surfraw.alioth.debian.org Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS Surfraw now supports bookmarks. To add a bookmark, add it to to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/stack -u -s=vote shell OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) discogs -- Search the Discogs database of music information (www.discogs.com) +dockerhub -- Search for Docker images (https://hub.docker.com) duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) oraclesearch -- Search an OpenSearch-enabled website pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) scholar -- Search Google Scholar (scholar.google.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) wikipedia -- Search the free encyclopedia wikipedia wiktionary -- Search the free multilingual dictionary (wiktionary.org) woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) All elvi have useful low calorie help, for example: sr bbcnews -help Usage: bbcnews [options] [search words]... Description: Surfraw search BBC News (news.bbc.co.uk) Local options: -scope=world | uk Search world or uk news Default: world Environment: SURFRAW_bbcnews_scope If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________ diff --git a/elvi/Makefile.am b/elvi/Makefile.am index 9c41f00..a0a9bda 100644 --- a/elvi/Makefile.am +++ b/elvi/Makefile.am @@ -1,120 +1,121 @@ # $Id$ elvidir=$(ELVIDIR) dist_elvi_SCRIPTS = \ S \ W \ acronym \ ads \ alioth \ amazon \ archpkg \ archwiki \ arxiv \ ask \ aur \ austlii \ bing \ bbcnews \ bookfinder \ bugmenot \ bugzilla \ cia \ cisco \ cite \ cliki \ cnn \ comlaw \ commandlinefu \ ctan \ currency \ cve \ debbugs \ debcodesearch \ debcontents \ deblists \ deblogs \ debpackages \ debpkghome \ debpts \ debsec \ debvcsbrowse \ debwiki \ deja \ discogs \ + dockerhub \ duckduckgo \ ebay \ etym \ excite \ f5 \ foldoc \ finkpkg \ freebsd \ freedb \ freshmeat \ fsfdir \ gcache \ genbugs \ genportage \ github \ gmane \ google \ gutenberg \ imdb \ ixquick \ jamendo \ javasun \ jquery \ l1sp \ lastfm \ leodict \ lsm \ macports \ mathworld \ mdn \ mininova \ musicbrainz \ mysqldoc \ netbsd \ nlab \ ntrs \ openbsd \ oraclesearch \ pgdoc \ pgpkeys \ phpdoc \ pin \ piratebay \ priberam \ pubmed \ rae \ rfc \ scholar \ scpan \ searx \ slashdot \ slinuxdoc \ sourceforge \ springer \ stack \ stockquote \ thesaurus \ translate \ urban \ w3css \ w3html \ w3link \ w3rdf \ wayback \ webster \ wikipedia \ wiktionary \ woffle \ wolfram \ worldwidescience \ yahoo \ yandex \ youtube uninstall-local: -rmdir $(DESTDIR)$(PREFIX)/$(ELVIDIR) diff --git a/elvi/dockerhub b/elvi/dockerhub new file mode 100755 index 0000000..4b8838f --- /dev/null +++ b/elvi/dockerhub @@ -0,0 +1,60 @@ +#!/bin/sh +# $Id$ +# elvis: dockerhub -- Search for Docker images (https://hub.docker.com) +. surfraw || exit 1 + +w3_config_hook () { + defyn SURFRAW_dockerhub_automatic 0 + defyn SURFRAW_dockerhub_official 0 + def SURFRAW_dockerhub_pulls 0 + def SURFRAW_dockerhub_stars 0 +} + +w3_usage_hook () { + cat <<EOF +Usage: $w3_argv0 [options] [search words] +Description: + Surfraw search the Docker images. +Local options: + -automatic Search only for automatically built images + Default: $SURFRAW_dockerhub_automatic + Environment: SURFRAW_dockerhub_automatic + -official Search only for official images + Default: $SURFRAW_dockerhub_official + -pulls Search only for images with no less than + given number of pulls + Default: $SURFRAW_dockerhub_pulls + Environment: SURFRAW_dockerhub_pulls + -stars Search only for images with no less than + given number of stars + Default: $SURFRAW_dockerhub_stars + Environment: SURFRAW_dockerhub_stars +EOF + w3_global_usage +} + +w3_parse_option_hook () { + opt="$1" + optarg="$2" + case "$opt" in + (-a|-auto*) setoptyn SURFRAW_dockerhub_automatic 1 ;; + (-f|-off*) setoptyn SURFRAW_dockerhub_official 1 ;; + (-s=*|-stars=*) setopt SURFRAW_dockerhub_stars "$optarg" ;; + (-p=*|-pulls=*) setopt SURFRAW_dockerhub_pulls "$optarg" ;; + (*) return 1 ;; + esac + return 0 +} + +w3_config +w3_parse_args "$@" + +escaped_args=$(w3_url_of_arg $w3_args) +url='https://hub.docker.com/search/' +url="${url}?isAutomated=${SURFRAW_dockerhub_automatic}" +url="${url}&isOfficial=${SURFRAW_dockerhub_official}" +url="${url}&pullCount=${SURFRAW_dockerhub_pulls}" +url="${url}&starCount=${SURFRAW_dockerhub_stars}" +url="${url}&q=${escaped_args}" + +w3_browse_url "${url}" diff --git a/links.IN b/links.IN index dc12a4c..18c4911 100644 --- a/links.IN +++ b/links.IN @@ -1,108 +1,109 @@ elvi.1sr.gz @mandir@/man1/W.1.gz elvi.1sr.gz @mandir@/man1/S.1sr.gz elvi.1sr.gz @mandir@/man1/acronym.1sr.gz elvi.1sr.gz @mandir@/man1/ads.1sr.gz elvi.1sr.gz @mandir@/man1/alioth.1sr.gz elvi.1sr.gz @mandir@/man1/amazon.1sr.gz elvi.1sr.gz @mandir@/man1/archpkg.1sr.gz elvi.1sr.gz @mandir@/man1/archwiki.1sr.gz elvi.1sr.gz @mandir@/man1/arxiv.1sr.gz elvi.1sr.gz @mandir@/man1/ask.1sr.gz elvi.1sr.gz @mandir@/man1/aur.1sr.gz elvi.1sr.gz @mandir@/man1/austlii.1sr.gz elvi.1sr.gz @mandir@/man1/bing.1sr.gz elvi.1sr.gz @mandir@/man1/bbcnews.1sr.gz elvi.1sr.gz @mandir@/man1/bookfinder.1sr.gz elvi.1sr.gz @mandir@/man1/bugmenot.1sr.gz elvi.1sr.gz @mandir@/man1/bugzilla.1sr.gz elvi.1sr.gz @mandir@/man1/cite.1sr.gz elvi.1sr.gz @mandir@/man1/cia.1sr.gz elvi.1sr.gz @mandir@/man1/cliki.1sr.gz elvi.1sr.gz @mandir@/man1/cnn.1sr.gz elvi.1sr.gz @mandir@/man1/comlaw.1sr.gz elvi.1sr.gz @mandir@/man1/commandlinefu.1sr.gz elvi.1sr.gz @mandir@/man1/ctan.1sr.gz elvi.1sr.gz @mandir@/man1/currency.1sr.gz elvi.1sr.gz @mandir@/man1/cve.1sr.gz elvi.1sr.gz @mandir@/man1/debbugs.1sr.gz elvi.1sr.gz @mandir@/man1/debcodesearch.1sr.gz elvi.1sr.gz @mandir@/man1/debcontents.1sr.gz elvi.1sr.gz @mandir@/man1/deblists.1sr.gz elvi.1sr.gz @mandir@/man1/deblogs.1sr.gz elvi.1sr.gz @mandir@/man1/debpackages.1sr.gz elvi.1sr.gz @mandir@/man1/debpkghome.1sr.gz elvi.1sr.gz @mandir@/man1/debpts.1sr.gz elvi.1sr.gz @mandir@/man1/debsec.1sr.gz elvi.1sr.gz @mandir@/man1/debvcsbrowse.1sr.gz elvi.1sr.gz @mandir@/man1/debwiki.1sr.gz elvi.1sr.gz @mandir@/man1/deja.1sr.gz elvi.1sr.gz @mandir@/man1/discogs.1sr.gz elvi.1sr.gz @mandir@/man1/duckduckgo.1sr.gz +elvi.1sr.gz @mandir@/man1/dockerhub.1sr.gz elvi.1sr.gz @mandir@/man1/ebay.1sr.gz elvi.1sr.gz @mandir@/man1/etym.1sr.gz elvi.1sr.gz @mandir@/man1/excite.1sr.gz elvi.1sr.gz @mandir@/man1/finkpkg.1sr.gz elvi.1sr.gz @mandir@/man1/foldoc.1sr.gz elvi.1sr.gz @mandir@/man1/freebsd.1sr.gz elvi.1sr.gz @mandir@/man1/freedb.1sr.gz elvi.1sr.gz @mandir@/man1/freshmeat.1sr.gz elvi.1sr.gz @mandir@/man1/fsfdir.1sr.gz elvi.1sr.gz @mandir@/man1/gcache.1sr.gz elvi.1sr.gz @mandir@/man1/genbugs.1sr.gz elvi.1sr.gz @mandir@/man1/genportage.1sr.gz elvi.1sr.gz @mandir@/man1/github.1sr.gz elvi.1sr.gz @mandir@/man1/google.1sr.gz elvi.1sr.gz @mandir@/man1/gutenberg.1sr.gz elvi.1sr.gz @mandir@/man1/imdb.1sr.gz elvi.1sr.gz @mandir@/man1/ixquick.1sr.gz elvi.1sr.gz @mandir@/man1/jamendo.1sr.gz elvi.1sr.gz @mandir@/man1/javasun.1sr.gz elvi.1sr.gz @mandir@/man1/lastfm.1sr.gz elvi.1sr.gz @mandir@/man1/leodict.1sr.gz elvi.1sr.gz @mandir@/man1/l1sp.1sr.gz elvi.1sr.gz @mandir@/man1/lsm.1sr.gz elvi.1sr.gz @mandir@/man1/macports.1sr.gz elvi.1sr.gz @mandir@/man1/mathworld.1sr.gz elvi.1sr.gz @mandir@/man1/mdn.1sr.gz elvi.1sr.gz @mandir@/man1/mininova.1sr.gz elvi.1sr.gz @mandir@/man1/musicbrainz.1sr.gz elvi.1sr.gz @mandir@/man1/mysqldoc.1sr.gz elvi.1sr.gz @mandir@/man1/netbsd.1sr.gz elvi.1sr.gz @mandir@/man1/ntrs.1sr.gz elvi.1sr.gz @mandir@/man1/openbsd.1sr.gz elvi.1sr.gz @mandir@/man1/oraclesearch.1sr.gz elvi.1sr.gz @mandir@/man1/pgdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pgpkeys.1sr.gz elvi.1sr.gz @mandir@/man1/phpdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pin.1sr.gz elvi.1sr.gz @mandir@/man1/piratebay.1sr.gz elvi.1sr.gz @mandir@/man1/priberam.1sr.gz elvi.1sr.gz @mandir@/man1/pubmed.1sr.gz elvi.1sr.gz @mandir@/man1/rae.1sr.gz elvi.1sr.gz @mandir@/man1/rfc.1sr.gz elvi.1sr.gz @mandir@/man1/scholar.1sr.gz elvi.1sr.gz @mandir@/man1/scpan.1sr.gz elvi.1sr.gz @mandir@/man1/searx.1sr.gz elvi.1sr.gz @mandir@/man1/slashdot.1sr.gz elvi.1sr.gz @mandir@/man1/slinuxdoc.1sr.gz elvi.1sr.gz @mandir@/man1/sourceforge.1sr.gz elvi.1sr.gz @mandir@/man1/springer.1sr.gz elvi.1sr.gz @mandir@/man1/stack.1sr.gz elvi.1sr.gz @mandir@/man1/stockquote.1sr.gz elvi.1sr.gz @mandir@/man1/thesaurus.1sr.gz elvi.1sr.gz @mandir@/man1/translate.1sr.gz elvi.1sr.gz @mandir@/man1/urban.1sr.gz elvi.1sr.gz @mandir@/man1/w3css.1sr.gz elvi.1sr.gz @mandir@/man1/w3html.1sr.gz elvi.1sr.gz @mandir@/man1/w3link.1sr.gz elvi.1sr.gz @mandir@/man1/w3rdf.1sr.gz elvi.1sr.gz @mandir@/man1/wayback.1sr.gz elvi.1sr.gz @mandir@/man1/webster.1sr.gz elvi.1sr.gz @mandir@/man1/wikipedia.1sr.gz elvi.1sr.gz @mandir@/man1/wiktionary.1sr.gz elvi.1sr.gz @mandir@/man1/woffle.1sr.gz elvi.1sr.gz @mandir@/man1/wolfram.1sr.gz elvi.1sr.gz @mandir@/man1/worldwidescience.1sr.gz elvi.1sr.gz @mandir@/man1/yahoo.1sr.gz elvi.1sr.gz @mandir@/man1/yandex.1sr.gz elvi.1sr.gz @mandir@/man1/youtube.1sr.gz diff --git a/test/Makefile.am b/test/Makefile.am index 21b72d6..e44454f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,31 +1,31 @@ EXTRA_DIST = runtests elviwithouttests README COOKIES W.test S.test \ acronym.test ads.test alioth.test amazon.test archpkg.test \ archwiki.test arxiv.test ask.test aur.test austlii.test \ bbcnews.test bing.test bookfinder.test bugmenot.test \ bugzilla.test cia.test cisco.test cite.test cliki.test cnn.test \ comlaw.test commandlinefu.test ctan.test currency.test cve.test \ debbugs.test debcodesearch.test debcontents.test deblists.test \ deblogs.test debpackages.test debpkghome.test debpts.test \ debsec.test debvcsbrowse.test debwiki.test deja.test discogs.test \ - duckduckgo.test ebay.test etym.test excite.test f5.test \ - finkpkg.test foldoc.test freebsd.test freedb.test freshmeat.test \ - fsfdir.test gcache.test genbugs.test genportage.test github.test \ - gmane.test google.test gutenberg.test imdb.test ixquick.test \ - jamendo.test javasun.test jquery.test lastfm.test leodict.test \ - l1sp.test lsm.test macports.test mathworld.test mdn.test \ - mininova.test musicbrainz.test mysqldoc.test netbsd.test \ + dockerhub.test duckduckgo.test ebay.test etym.test excite.test \ + f5.test finkpkg.test foldoc.test freebsd.test freedb.test \ + freshmeat.test fsfdir.test gcache.test genbugs.test genportage.test \ + github.test gmane.test google.test gutenberg.test imdb.test \ + ixquick.test jamendo.test javasun.test jquery.test lastfm.test \ + leodict.test l1sp.test lsm.test macports.test mathworld.test \ + mdn.test mininova.test musicbrainz.test mysqldoc.test netbsd.test \ nlab.test ntrs.test openbsd.test oraclesearch.test pgdoc.test \ phpdoc.test pin.test piratebay.test pgpkeys.test priberam.test \ pubmed.test rae.test rfc.test scholar.test scpan.test searx.test \ slashdot.test slinuxdoc.test sourceforge.test springer.test \ stack.test stockquote.test thesaurus.test translate.test \ urban.test w3css.test w3html.test w3link.test w3rdf.test \ wayback.test webster.test wikipedia.test wiktionary.test \ wolfram.test woffle.test worldwidescience.test yahoo.test \ yandex.test youtube.test test: ./runtests ./elviwithouttests diff --git a/test/dockerhub.test b/test/dockerhub.test new file mode 100644 index 0000000..edbcfc5 --- /dev/null +++ b/test/dockerhub.test @@ -0,0 +1,5 @@ +dockerhub nginx +official +dockerhub -automatic matomo +wonderfall +
JNRowe/surfraw
fe51e9ce14c69016eddd8d9b4a12a6e1e74922a6
Use ChangeLog date instead of build date Thanks B.M. Wiedemann
diff --git a/configure.in b/configure.in index 7dbe05d..806ff5c 100644 --- a/configure.in +++ b/configure.in @@ -1,60 +1,60 @@ dnl $Id$ dnl Process this file with autoconf to produce a configure script. dnl This is the only place where the package version appears dnl (apart from changelogs & NEWS) AC_INIT(surfraw, 2.3.0) AC_PREREQ(2.54) AC_CONFIG_SRCDIR([surfraw.IN]) dnl minimum automake version, not surfraw version AM_INIT_AUTOMAKE([1.10]) AC_MSG_CHECKING([whether to enable local OpenSearch support]) AC_ARG_ENABLE([opensearch], [AS_HELP_STRING([--disable-opensearch], [disable local OpenSearch support])],, [enable_opensearch=yes]) AC_MSG_RESULT([$enable_opensearch]) AM_CONDITIONAL(OPENSEARCH, test "$enable_opensearch" = "yes") AC_MSG_CHECKING([whether to install sr alias]) AC_ARG_ENABLE([sr], [AS_HELP_STRING([--disable-sr], [disable sr alias])],, [enable_sr=yes]) AC_MSG_RESULT([$enable_sr]) AM_CONDITIONAL(INSTALLSR, test "$enable_sr" = "yes") ELVIDIR="\$(libdir)/surfraw" AC_CHECK_PROGS(TEXTBROWSER, lynx links2 links elinks w3m netrik) AC_CHECK_PROGS(GRAPHICALBROWSER, iceweasel firefox google-chrome opera mozilla \ xombrero luakit safari epiphany-browser konqueror galeon kazenhakase \ conkeror dillo netscape chromium chrome) AC_ARG_WITH([elvidir], [AS_HELP_STRING([--with-elvidir=ELVIDIR], [specify location of elvi])], [if test -n "$withval" && test "$withval" != "no" ; then ELVIDIR="$withval";fi]) AC_ARG_WITH([text-browser], [AS_HELP_STRING([--with-text-browser=BROWSER], [specify default text browser])], [if test -n "$withval" && test "$withval" != "no" ; then TEXTBROWSER="$withval";fi]) AC_ARG_WITH([graphical-browser], [AS_HELP_STRING([--with-graphical-browser=BROWSER], [specify default graphical browser])], [if test -n "$withval" && test "$withval" != "no" ; then GRAPHICALBROWSER="$withval";fi]) AC_SUBST(ELVIDIR) AC_SUBST(VERSION) AC_SUBST(TEXTBROWSER) AC_SUBST(GRAPHICALBROWSER) -ISODATE=`date +%Y-%m-%d` +ISODATE=`date -u -r ChangeLog +%Y-%m-%d` AC_SUBST(ISODATE) dnl Checks for programs. AC_PROG_INSTALL AC_PROG_AWK AC_PATH_PROG([PERL], [perl], [perl]) AC_SUBST(PERL) AC_CONFIG_FILES([Makefile surfraw.lsm surfraw.spec elvi/Makefile test/Makefile examples/Makefile]) AC_OUTPUT
JNRowe/surfraw
88b7f26d21d257681f23f31d2d06ea125d6268c0
Yaml file for static pages
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..25e78d3 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,6 @@ +pages: + artifacts: + paths: + - public + only: + - master \ No newline at end of file
JNRowe/surfraw
60e4fa3c06cf89f3272a788c28d57331cea977d4
Search in sysconfdir if there is no config in $XDG_CONFIG_DIRS
diff --git a/surfraw.IN b/surfraw.IN index 01130c0..1e2db3b 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,554 +1,558 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=`basename "$0"` elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { base="$1" local conf OIFS conf="" if test -n "$XDG_CONFIG_DIRS"; then OIFS="$IFS" IFS=: set $XDG_CONFIG_DIRS IFS="$OIFS" for i in "$@"; do if test -r "$i/surfraw/$base"; then conf="$i/surfraw/$base" break fi done - elif test -r "@sysconfdir@/xdg/surfraw/$base"; then # XDG default - conf="@sysconfdir@/xdg/surfraw/$base" - elif test -r "@sysconfdir@/surfraw.$base"; then # old surfraw default - conf="@sysconfdir@/surfraw.$base" + fi + + if test -n "$conf"; then + if test -r "@sysconfdir@/xdg/surfraw/$base"; then # XDG default + conf="@sysconfdir@/xdg/surfraw/$base" + elif test -r "@sysconfdir@/surfraw.$base"; then # old surfraw default + conf="@sysconfdir@/surfraw.$base" + fi fi echo "$conf" } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value=\$${1} case `echo "$value" | tr A-Z a-z` in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value=\$${1} test -z "$value" || return 0 eval ${1}="$2" return 0 } defyn () { eval value=\$${1} test -z "$value" && eval ${1}="$2" yesno "$1" } setopt () { eval value=\$${1} eval ${1}="$2" } setoptyn () { eval value=\$${1} eval ${1}="$2" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=`echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//'` esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="`quote "$arg"`" else w3_shquoted_args="$w3_shquoted_args `quote "$arg"`" fi if ok SURFRAW_quote_ifs then arg=`quote_ifs "$arg"` fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test `echo $TERM | cut -c 1-6` = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg"
JNRowe/surfraw
8b7e1d1f4f63d07370953ffc3abe492f943c90a2
2.3.0 release
diff --git a/COPYING b/COPYING index 2db7b7a..0fdb80e 100644 --- a/COPYING +++ b/COPYING @@ -1,9 +1,9 @@ - Copyright (c) 2003-2013 The Surfraw-Devel Team + Copyright (c) 2003-2018 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study The copyright holders listed above assert no rights on this release of the software ``surfraw'' and thereby explicity place this release into the public domain. Do what you will. diff --git a/ChangeLog b/ChangeLog index ae2c7f3..3ec3e5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,512 +1,518 @@ +2018-01-13 Jason Ryan <[email protected]> + * Bump version to 2.3.0 + * Select Perl version at buildtime (Mark Meyer) + * Remove lynx-cur (closes #882286) + * Packages the https elvi + 2017-06-07 Jason Ryan <[email protected]> * new elvi: wiktionary 2017-07-14 Jason Ryan <[email protected]> * Moved all elvi to https * Removed elvi that don't support https: - cablesearch - dmoz - openports - opensearch - pasearch - rhyme - rpmsearch - scicom - scirus - wetandwild - yacy - yubnub 2015-09-13 Kyle Isom <[email protected]> * use awk instead of sed for listing elvi This provides better cross-platform behaviour. 2015-08-23 Jason Ryan <[email protected]> * new elvi: searx 2014-09-20 Lucas Hoffmann <l-m-h at web.de> * new elvi: commandlinefu 2104-06-04 Jason Ryan <[email protected]> * new elvi: nlab 2013-12-10 Ian Beckwith <[email protected]> * yandex: disabled test: redirects to captcha when used with LWP. * Fix make distcheck: remove last traces of codesearch and scitopia. 2013-12-09 Ian Beckwith <[email protected]> * deja: disable tests, google groups now requires javascript. * gmane: fix test. * codesearch: removed, service shut down. * scitopia: removed, service shut down. * scicom: down, status unknown, made note in NEWS. 2013-12-08 Ian Beckwith <[email protected]> * new elvi: gmane * openbsd -mail: use gmane (directly, not via gmane elvi) * fix tests: ads, pgdoc, pin, yacy 2013-10-27 Ian Beckwith <[email protected]> * surfraw.IN: w3_custom_search_google: don't give full path to surfraw. * pgdoc, wayback: fixed tests. 2013-10-20 Ian Beckwith <[email protected]> * new elvi: yacy: search using yacy p2p search. -S searches ScienceNet, a yacy-based science search engine. * rae: fix url, remove -tipo option (no longer supported), disable test as there is now gratuitous javascript. 2013-10-06 Ian Beckwith <[email protected]> * Replaced phpdoc with version posted back in 2011 by Jon Yamokoski <[email protected]> Thanks, and apologies for missing it! * S: add test. * Include debian packaging in upstream tarball. 2013-10-05 Ian Beckwith <[email protected]> * ask, cisco: fix elvi. * new elvi: + oraclesearch - Replaces removed sunonesearch <sigh>. + S - search using w3_custom_search. * google: -g for groups clashed with -g for graphical browser. Invoke groups with -G, -gr, -groups or -search=groups. * mdn: site invokes google custom search via gratuitous javascript, so switch to w3_custom_search. * alioth: changed test to SKIP:, works OK but won't talk to LWP, hence test breaks. * discogs, openbsd: fixed tests. * mdn, mysqldoc, pgdoc, phpdoc: added tests. * w3_custom_search: + document in README. + remove documentation for ixquick support. It still works(ish), but doesn't support enough features to support (eg) mysqldoc -v=. + add -custom-search= commandline option. * updated copyright years to 2013. 2013-09-30 Ian Beckwith <[email protected]> * new elvi: mdn, mysqldoc, pgdoc, phpdoc * new function: w3_custom_search Is used by elvi that use a generic search engine with (eg) site: or inurl: to narrow down the search. Pass it -s=site -u=url for site: and inurl: args plus the quoted search args * new environment variable: SURFRAW_customsearch_provider to set provider used by w3_custom_search can be set to: google, duckduckgo or ixquick. Currently affects: mysqldoc, netbsd(*), openbsd(*), pgdoc, phpdoc, mysqldoc. (*) = only used by some options of elvi. * new internal variable w3_shquoted_args, contains arguments 'quoted' 'like this' for passing to w3_custom_search * Fixed url-encoding for '\' 2013-05-07 Ian Beckwith <[email protected]> * new elvi: jquery 2013-05-04 Ian Beckwith <[email protected]> * bump version to 2.2.9 * rae: fixed, at least as far as the test passing. Could really do with some love from someone who actually speaks spanish. * ctan: fixed search, updated options. Note command-line options have changed. * genportage: switch to gpo.zugaina.org * debcodesearch: new (trivial) elvi for codesearch.debian.net * jamendo: fix url, disable test (search now javascript) * deli: fix url; remove options; disable test (search now javascript) 2013-04-28 Ian Beckwith <[email protected]> * musicbrainz: fixed mbid search. * springer: fixed test. 2013-04-27 Ian Beckwith <[email protected]> * javasun: fixed test. 2013-04-24 Ian Beckwith <[email protected]> * Rewrote deblists for new xapian search. + -author, -lists, -lang no longer supported. + added -ml and -mv to show message id links and list view. * Removed happypenguin. Currently defunct and they are talking about a rewrite, so when it is back it will need fixing anyway. 2012-10-22 Ian Beckwith <[email protected]> * Fixed elvi: cisco, slashdot, slinuxdoc. * Removed elvi: scroogle (site gone). * Fixed tests: acronym, bbcnews, bugzilla, cisco, cite[1], currency, discogs, excite, fsfdir, gcache, github, imdb, ixquick, lastfm, leodict, openbsd[2], scholar. * test/Makefile.am: Added missing tests to EXTRA_DIST 2012-06-28 Manolo Martínez <[email protected]> * examples/hooks.lua: Added elinks integration script 2012-06-28 Ivy Foster <[email protected]> * Further simplified searchable bookmarks 2012-06-28 Thomas Zervogiannis <[email protected]> * Simplified searchable bookmarks 2012-06-27 Ivy Foster <[email protected]> * Fixed arg parsing in searchable bookmarks * New variable: SURFRAW_bookmark_search_elvis + When using searchable bookmarks, if all else fails run this elvis. Defaults to google * Updated manual to reflect changes to bookmarks * duckduckgo: Removed -p option. -safe still works. + Prevents clobbering global option -p[rint]. 2012-06-27 Thomas Zervogiannis <[email protected]> * Added searchable bookmarks + Bookmarks can now be searchable by adding '%s' to the url string. 2012-06-01 Jason Ryan <[email protected]> * New elvi: github (search github.com) 2012-03-17 Ivy Foster <[email protected]> * Fix a typo in duckduckgo code. 2012-03-17 Ivy Foster <[email protected]> * Keep duckduckgo's -l[ucky] from clobbering -lh 2012-01-10 Ivy Foster <[email protected]> * aur: now uses HTTPS by default + On the AUR, connecting via HTTP disables login. + Added switch -no-https to enable connection via plain HTTP 2011-10-10 Ian Beckwith <[email protected]> * surfraw.IN: test_elvi(): tweak sed regex * add tests for f5, cisco and pin. 2011-10-10 Shain Singh <[email protected]> * New elvi: f5, cisco 2011-10-10 Jason Ryan <[email protected]> * New elvi: pin (search pinboard.in). 2011-09-09 Kyle Isom <[email protected]> * New elvi: wolfram - query Wolfram Alpha * Author: Kyle Isom <[email protected]> * Added test for wolfram. 2011-08-09 Ian Beckwith <[email protected]> * New elvi: priberam - search Portuguese dictionary. Author: Paulo Almeida <[email protected]> * Added test for priberam. 2011-07-11 Ian Beckwith <[email protected]> * netbsd: fix normal & mail search. google custom searches were complaining I was a bot, so I switched to normal google searches with site:{mail-index,}.netbsd.org. * cia: fix search URL 2011-06-17 Ian Beckwith <[email protected]> * arxiv: fix -scope=author with single-word queries. Thanks to Nikos Apostolakis. * btw, note about entry below, netbsd make *does* support '$<', but only in suffix rules. 2011-06-16 Ian Beckwith <[email protected]> * Fix more make(1) portability problems. Either I am horribly confused or netbsd make (or at least pmake in debian) doesn't support '$<'. Switched to '$?'. * Also switched submit-lsm rule to '$?'. Thanks to Kyle Isom. * Removed long-obsolete commented-out sourceforge upload rules. 2011-06-15 Ian Beckwith <[email protected]> * scitopia, worldwidescience: fixed URLs. * Fixed make portability problems. We cannot portably combine single suffix rules (foo.IN->foo) and separated dependencies so we have to explicitly specify all the .IN rules. The solution we used for this until now was specific to GNU make. * Removed Makefile.include, no longer used. * './configure --enable-opensearch' now only controls installation of the (direct) dependencies for opensearch, not opensearch itself, as opensearch now falls back to using a remote reflector if opensearch-discover(1) and opensearch-genquery(1) aren't found. * yandex: fix test. 2011-06-14 Ian Beckwith <[email protected]> * musicbrainz, codesearch, rpmsearch: Fixed URLs, options and tests. The sites have all changed significantly which means both new options and no-longer-supported options. Codesearch has gone all ajaxy, so I've implemented the options via the search string, e.g. adding " package:foo". Disabled codesearch.test, as it now needs javascript. Codesearch on both google.com and google.co.uk was acting up, so I've pointed it at google.fr. * Removed filesearching elvi, it now requires a 'Referer:' header to work. There is no browser-portable way to specify a 'Refer[r]er:' header, plus we should probably take it as a hint. * Tweaked debian packaging. * Updated NEWS. 2011-06-13 Ian Beckwith <[email protected]> * w3link: fixed URLs. 2011-06-10 Ian Beckwith <[email protected]> * Fixed ctan. Option -doc has been replaced by -id. Options are no longer mutually exclusive, you can now do (eg) ctan -d -i -n texlive. 2011-06-09 Ian Beckwith <[email protected]> * fixed tests: debwiki, ntrs, wayback. 2011-06-07 Ian Beckwith <[email protected]> * Default to surfraw_graphical_remote=no, as chromium doesn't support "-remote openURL". 2011-05-31 Jason Ryan <[email protected]> * Add options to archpkg. 2011-05-12 Sara Fauzia <[email protected]> * Fix archpkg URL. 2011-05-12 Ian Beckwith <[email protected]> * surfraw.IN: + if elvi doesn't exist, send usage to stderr not stdout. + bookmark names: do exact match not substring match. * Added tests for archwiki, deli & stack. * README: + added INTEGRATION section on uzbl and pentadactyl. + upcased section headings for clarity. 2011-05-12 Jason Ryan <[email protected]> * New elvi: + archwiki: search the arch wiki. + deli: search delicious.com. + stack: search stackoverflow.com and friends. 2011-03-21 Ian Beckwith <[email protected]> * google: Added -safe=default|off|moderate|strict option for Safe Search. 2011-03-21 Ivy Foster <[email protected]> * Added Google Translate to elvi/translate. 2011-03-03 Ian Beckwith <[email protected]> * opensearch: new option -r, uses redirector at http://erislabs.net/ianb/webtools/opensearch/ instead of calling opensearch-discover and opensearch-genquery. -r is selected automatically if those tools are not installed. This enables us to ship opensearch in the main surfraw package and it still functions if the dependencies are not installed. See debian/changelog. * wikipedia: new options: + -d, uses a redirector at http://erislabs.net/ianb/webtools/wpdp/ This redirector searches for a page with that name at wikipedia. If not found, it searches deletionpedia, if not found there it falls back to a normal wikipedia search. + -f=w|d, -fallback=wikipedia|deletionpedia Implies -d. If page not found at either wikipedia or deletionpedia, whether to fallback to wikipedia search or deletionpedia search. * google: + support video, maps and news. + new options -i, -v, -m, -n, shortcuts for -search={images,videos,maps,news}. * debcontents, debpackages: update docs for new arches and distributions. * bugzilla: + fix url so it works with redhat & eclipse bugzillas too. + enable -s=redhat. * ixquick, w3css: fix tests. * opensearch, wikipedia: add redirector tests. 2011-02-20 Ian Beckwith <[email protected]> * New elvi: bugzilla - searches various bugzillas, defaults to kernel. * pgpkeys: add more options, support more keyservers, default to sks-keyservers.net. * bump version to 2.2.8. * test/Makefile.am: add cablesearch.test. 2011-02-19 Ian Beckwith <[email protected]> * lastfm: fix url to avoid a redirect that mangled args with spaces. * debbugs: add -s as an alias for -search=src. * surfraw.IN: (finally) update copyright year to 2011. * remove traces of port elvi from build system. 2011-02-09 Kyle Isom <[email protected]> * fix a number of tests to match current site formats 2011-01-12 Kyle Isom <[email protected]> * New elvi: + cablesearch - search wikileaks cables + duckduckgo - replace with better implementation + openports - search openbsd ports 2010-12-04 Jakob <[email protected]> * new elvis: pasearch. 2010-12-08 Ian Beckwith <[email protected]> * arxiv: Thanks to MT <[email protected]> for patch that fixes: 1. Search queries with more than two terms would fail, e.g. 'supermassive black hole'. 2. Full text search was broken, it works now. 3. Enhancement: quoting the query now does an exact string match. 2010-10-29 Ian Beckwith <[email protected]> * wayback: advanced search is broken, rip out all options and use basic search. * w3_url_escape: add /g to '/'->'%2F' replacement. * uzbl_load_url_from_surfraw: use @AWK@ to pick up ./configure's choice of awk implementation. 2010-10-28 Ian Beckwith <[email protected]> * Support -local-help, --local-help or -lh to get elvi-specific help without displaying the global options. This works for all elvi and the main surfraw script. * google, duckduckgo, opensearch, wayback: tweak overbroad option parsing so it doesn't interfere with -lh. * Support -h as a synonym for -help. 2010-10-25 Ian Beckwith <[email protected]> * new elvi: scirus, scitopia, worldwidescience. * yahoo: reduced query string to just p and n options. * openbsd: support -misc and -tech. Thanks to Sunil Nimmagadda for the patch. * removed cddb: gracenote made the "hard decision" to remove the website search. sigh. * removed altavista: is now just a front-end to yahoo. * removed fast: another yahoo front-end. * imdb: fix test. * javasun: oracleized URLs. * w3link: fixed URL. 2010-08-22 Jameson Rollins <[email protected]> * surfraw.IN: Improve listing of elvi. 2010-08-20 James Rowe <[email protected]> * new elvi: ads. Thanks to Jameson Rollins. 2010-07-02 Ian Beckwith <[email protected]> * new elvi: yandex. Thanks to Uspenskiy Andrey. 2010-05-06 Ian Beckwith <[email protected]> * uzbl_load_url_from_surfraw: fix menu. Thanks to Sumant Oemrawsingh. * Fixed tests: deblists google openbsd. 2010-04-28 Ian Beckwith <[email protected]> * configure.in: test for google-chrome, opera and links2. 2010-04-22 Ian Beckwith <[email protected]> * debwiki: remove -w, Debian Women wiki is now being merged into main wiki. Thanks to Simone Fittabile. * debwiki.test: stop testing -w option. * surfraw.IN: change an awk to @AWK@. 2010-04-21 Ian Beckwith <[email protected]> * New elvi: jamendo - Search Jamendo: free music with Creative Commons licenses (www.jamendo.com). Thanks to Simone Fittabile. * wikipedia, ixquick: Support https. Thanks to Simone Fittabile. * wikipedia: tweak Simone's patch to support https for start page and document the SURFRAW_wikipedia_ssl variable. * ixquick: add -nossl option. * javasun.test: revert to previous test, works again. 2010-04-19 James Rowe <[email protected]> * genpkg: removed, use genportage. 2010-04-16 Ian Beckwith <[email protected]> * New elvi: + scroogle: Search Google anonymously via www.scroogle.org. + duckduckgo: Search the web via duckduckgo.com. * Fix tests: excite, javasun, musicbrainz, yahoo. 2010-03-03 James Rowe <[email protected]> * bookfinder: fix ISBN search test. 2010-03-01 Ian Beckwith <[email protected]> * Removed autotools-generated files from git repo use ./prebuild to regenerate. * Lower required automake version to 1.10. * prebuild: try and find a sane set of autotools, then call autoreconf -vi * Add autotools-generated files to .gitignore * Bump version to 2.2.7 * cnn: fix URL. * cnn.test: Disable. Bloody CNN now needs javascript for search, so should be tested manually. * W, yahoo: fix tests. diff --git a/Makefile.am b/Makefile.am index b929c17..0141193 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,139 +1,129 @@ SUBDIRS = elvi test examples bin_SCRIPTS = surfraw surfraw-update-path if OPENSEARCH dist_bin_SCRIPTS = opensearch-discover opensearch-genquery endif devel_extra = banner prebuild -if BASHCOMPLETIONS -noinst_DATA = surfraw.bookmarks -else -noinst_DATA = surfraw.bookmarks surfraw-bash-completion -endif +noinst_DATA = surfraw-bash-completion surfraw.bookmarks man_MANS = surfraw-update-path.1 surfraw.1 elvi.1sr if OPENSEARCH man_MANS += opensearch-discover.1 opensearch-genquery.1 endif debian_extra = debian/NEWS debian/README.Debian debian/changelog debian/compat debian/control \ debian/copyright debian/docs debian/postrm debian/rules debian/source/format \ debian/surfraw-extra.files debian/surfraw-extra.install debian/watch EXTRA_DIST = surfraw.lsm.in surfraw.IN surfraw-update-path.IN\ - surfraw.spec.in aclocal.m4 HACKING \ + surfraw.spec.in aclocal.m4 HACKING STYLE \ surfraw.1.IN elvi.1sr.IN surfraw.bookmarks links.IN \ surfraw-bash-completion.IN surfraw.conf.IN \ $(devel_extra) $(debian_extra) CLEANFILES = surfraw surfraw-update-path surfraw-update-path.1 surfraw.spec surfraw.lsm \ surfraw.1 elvi.1sr links surfraw-bash-completion surfraw.conf surfraw.1 \ elvi.1sr opensearch-discover.1 opensearch-genquery.1 BUILT_SOURCES = surfraw.conf # we cannot portably combine single suffix rules and separated dependencies # so we have to explicitly specify all the .IN rules surfraw: surfraw.IN -rm -f $@ [email protected] sed -e 's,@VERSION\@,${VERSION},g; '\ -e 's,@ELVIDIR\@,${ELVIDIR},g; '\ -e 's,@AWK\@,${AWK},g; '\ -e 's,@PERL\@,${PERL},g; '\ -e 's,@sysconfdir\@,${sysconfdir},g ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw.conf: surfraw.conf.IN -rm -f $@ [email protected] sed -e 's,@prefix\@,${prefix},g; '\ -e 's,@TEXTBROWSER\@,${TEXTBROWSER},g; '\ -e 's,@GRAPHICALBROWSER\@,${GRAPHICALBROWSER},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-update-path: surfraw-update-path.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-bash-completion: surfraw-bash-completion.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ elvi.1sr: elvi.1sr.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw.1: surfraw.1.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; '\ -e 's,@sysconfdir\@,${sysconfdir},g' $? > [email protected] chmod +x [email protected] mv [email protected] $@ links: links.IN -rm -f $@ [email protected] sed -e 's,@mandir\@,${mandir},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-update-path.1: surfraw-update-path -rm -f $@ pod2man $? > $@ opensearch-discover.1: opensearch-discover -rm -f $@ pod2man $? > $@ opensearch-genquery.1: opensearch-genquery -rm -f $@ pod2man $? > $@ -install-data-hook: links surfraw-bash-completion +install-data-hook: links chmod -x surfraw.conf elvi.1sr surfraw.1 mkdir -p $(DESTDIR)@sysconfdir@/xdg/surfraw cp surfraw.conf $(DESTDIR)@sysconfdir@/xdg/surfraw/conf cp $(top_srcdir)/surfraw.bookmarks $(DESTDIR)@sysconfdir@/xdg/surfraw/bookmarks while read target link ;\ do \ ln -sf $$target $(DESTDIR)/$$link ;\ done < links if INSTALLSR ln -sf surfraw $(DESTDIR)/@bindir@/sr ln -sf surfraw.1.gz $(DESTDIR)/@mandir@/man1/sr.1.gz endif -if BASHCOMPLETIONS - mkdir -p $(DESTDIR)@sysconfdir@/bash_completion.d - @cp $(top_srcdir)/surfraw-bash-completion $(DESTDIR)@sysconfdir@/bash_completion.d/surfraw -endif uninstall-local: links -rm -f $(DESTDIR)@sysconfdir@/xdg/surfraw/conf -rm -f $(DESTDIR)@sysconfdir@/xdg/surfraw/bookmarks rmdir $(DESTDIR)@sysconfdir@/xdg/surfraw 2>/dev/null rmdir $(DESTDIR)@sysconfdir@/xdg 2>/dev/null while read target link ;\ do \ rm -f $(DESTDIR)/$$link ;\ done < links if INSTALLSR rm -f $(DESTDIR)/@bindir@/sr rm -f $(DESTDIR)/@mandir@/man1/sr.1.gz endif -if BASHCOMPLETIONS - -rm -f $(DESTDIR)@sysconfdir@/bash_completion.d/surfraw -endif + submit-lsm: surfraw.lsm mail -s add [email protected] < $? test: all surfraw.conf make -C test test .PHONY: test diff --git a/NEWS b/NEWS index 6eac192..e01c79e 100644 --- a/NEWS +++ b/NEWS @@ -1,486 +1,508 @@ ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! N E W S +Sat Jan 13 18:55:20 GMT 2018 - surfraw 2.3.0 + + * We are moving! This is the last release on Debian's platform. + For all future development, please check out + https://gitlab.com/surfraw/Surfraw + + * All elvi now use HTTPS + + Elvi for sites that don't work with HTTPS have left the building: + - cablesearch + - dmoz + - openports + - opensearch + - pasearch + - rhyme + - rpmsearch + - scicom + - scirus + - wetandwild + - yacy + - yubnub + * Select Perl version at buildtime (Mark Meyer) + * Remove lynx-cur (closes #882286) Tue Dec 10 15:49:46 GMT 2013 - surfraw 2.2.9 * New elvi: + S - search using w3_custom_search (see below) + cisco - search Cisco documentation + debcodesearch - search Debian codebase + github - search github + gmane - search mailing lists + jquery - search jQuery documentation + mdn - search Mozilla Developer Network + mysqldoc - search MySQL documentation + oraclesearch - search Oracle documentation + pgdoc - search PostgreSQL documentation + phpdoc - search PHP documentation + pin - search pinboard.in + wolfram - search Wolfram Alpha + yacy - search YaCy P2P search engines, including ScienceNet * Changed elvi: + aur - uses HTTPS by default, use -no-https to disable + deblists * Removed options -author, -lists, -lang * added options -ml (message links) and -mv (list view) + duckduckgo: * removed -p (clashes with global print option), use -safe instead * stopped -l[ucky] from clobbering -lh + google: changed -g option to -G to avoid clash with -g for graphical view * Fixed elvi: ask, ctan, deli, genportage, jamendo, javasun, openbsd musicbrainz, rae, slashdot, slinuxdoc * Removed elvi for dead sites: happypenguin, scroogle, sunonesearch (replaced by oraclesearch) * w3_custom_search + elvi that use a search engine as a backend with site: and inurl: can now choose which search engine to use. So far, google and duckduckgo are supported, with duckduckgo the default. + Affected elvi: mdn, mysqldoc, netbsd, openbsd, pgdoc, slinuxdoc + To select on the commandline use -custom-search=google or -custom-search=duckduckgo + Or configure SURFRAW_customsearch_provider * New variable: SURFRAW_bookmark_search_elvis When using searchable bookmarks, if all else fails run this elvis. Defaults to google * New example elinks integration script in examples/hooks.lua. * Debian packaging now included in release, in debian/ dir. * Known problems at time of release + deblogs - down (hopefully) temporarily + yacy - demo portal down, ScienceNet still up + scicom - down, status unknown Tue Jul 12 00:46:02 BST 2011 - surfraw 2.2.8 * New elvi: + ads - search the SAO/NASA Astrophysics data system. + archwiki: search the arch wiki. + bugzilla - search various bugzillas, defaults to kernel. + cablesearch - search wikileaks cables + deli: search delicious.com. + duckduckgo - replace with better implementation + openports - search openbsd ports + pasearch - search Penny Arcade archives. + scirus, scitopia, worldwidescience - science searches + stack: search stackoverflow.com and friends. + yandex - russian web search. * Changed elvi: + archpkg: now supports options. + arxiv: quote queries for exact string matches. + ctan: Option -doc replaced by -id. Options no longer mutually exclusive. + codesearch, musicbrainz, rpmsearch: rewritten to match new site. Options have changed to match site, see help message. + debbugs: add -s as an alias for -search=src. + google: new options: * -v, -search=video: search video * -m, -search=maps: search maps * -n, -search=news: search news * -i: new shortcut for -search=images * -safe=default|off|moderate|strict: safe search + openbsd: support -misc and -tech. + opensearch: new option -r, uses remote redirector which means it can run without heavy dependencies. + pgpkeys: add more options, support more keyservers, default to sks-keyservers.net. + translate: added Google Translate support. + wayback: advanced search is broken, rip out all options and use basic search. + wikipedia: new option -d, uses remote redirector to search both wikipedia and deletionpedia. use -fallback=wikipedia|deletionpedia to customise behaviour. * Fixed elvi: archpkg, arxiv, cia, codesearch, ctan, javasun, lastfm, musicbrainz, netbsd, rpmsearch, w3link, yahoo. * Removed elvi: + altavista: is now just a front-end to yahoo. RIP. + cddb: gracenote made the "hard decision" to remove the website search. sigh. + fast: another yahoo front-end. + filesearching: refuses to work without 'Referer:' header. + port: site gone * Support -local-help, --local-help or -lh to get elvi-specific help without displaying the global options. This works for all elvi and the main surfraw script. * Support -h as a synonym for -help. * Improved listing of elvi. * Default to surfraw_graphical_remote=no, as chromium doesn't support "-remote openURL". * Bookmark names are now an exact match not a substring match. * Support BSD/POSIX make. * README: added INTEGRATION section on uzbl and pentadactyl. Thu May 6 20:20:09 BST 2010 - surfraw 2.2.7 * New elvi (surfraw now has over one hundred elvi!): + by tczy: * bing: Search using Microsoft's Bing. + by Ivy Foster: * bookfinder: Search for books using www.bookfinder.com. * bugmenot: Bypass compulsory web registration with bugmenot.com. + by Ian Beckwith: * duckduckgo: Search the web via duckduckgo.com. * scroogle: Search Google anonymously via www.scroogle.org. + by Simone Fittabile: * jamendo: Search Jamendo: free music with Creative Commons licenses * Removed elvi: genpkg (use genportage instead). * Fixed elvi: + cnn + imdb (thanks to Sadako) + bbcnews (thanks to Sumant Oemrawsingh and James Rowe) * aur: added options (thanks to Ivy Foster) * wikipedia, ixquick: support https. Thanks to Simone Fittabile. * debwiki: remove -w, Debian Women wiki is being merged into main Debian wiki. Thanks to Simone Fittabile. * Improved support for screen(1). Thanks to Ivy Foster: + Support for using tmux as $SURFRAW_screen. + Added `-ns|-newscreen' switch for setting $SURFRAW_new_screen. + Added $SURFRAW_screen_args for passing arguments to the defined screen tool. * uzbl_load_url_from_surfraw: fix menu. Thanks to Sumant Oemrawsingh. Fri Nov 20 03:34:19 GMT 2009 - surfraw 2.2.6 * New elvi: + by Sumant Oemrawsingh: * cliki - search the common lisp wiki. * l1sp - search lisp documentation. * mathworld - search Wolfram MathWorld. * mininova - search mininova for torrents. * youtube - search youtube for videos. + by Simone Fittabile: * acronym - find acronyms * gcache - search google cache. + by Nick White: * genbugs - search gentoo bug tracker + by Ian Beckwith: * debpkghome - view home page of a debian package. * debvcsbrowse - browse vcs of a debian package * rpmsearch - search for packages in rpm-based distros. * finkpkg - search Fink packages. * macports - search macports packages. * Move config files to follow XDG basedir spec This means that if your global config was in /etc/surfraw.conf it is now in /etc/xdg/surfraw/conf, and local config is now in $HOME/.config/surfraw/conf. The same applies to bookmarks. See README for details on configuring config locations, and http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html for the gory details. The old locations are still supported for backwards-compatibility. * Support per-user elvi in $HOME/.config/surfraw/elvi/ Patch by James Rowe, idea by Sumant Oemrawsingh. * Added -o | -o=FILE option, to fetch URL and dump to stdout or FILE. * Modified elvi: + freebsd: new options -psearch=TYPE -psection=SEC to conduct a search of type TYPE in section SEC of ports. + netbsd: new option -ps to search ports + openbsd: new option -ps to search ports + debsec: fixed (Thanks to Moritz Muehlenhoff, for this and all his other work). + cia: fixed. * Added examples/uzbl_load_url_from_surfraw, to integrate surfraw with uzbl (uzbl.org), thanks to Sumant Oemrawsingh. Wed May 13 02:30:21 BST 2009 - surfraw 2.2.5 * Replaced scaleplus elvi with comlaw. * rfc: use HTML for RFCs and BCPs. * Support '--' to indicate end of options, so, for instance, "sr google -g -- foo -bar" works. * debpackages, debcontents: update ubuntu release names. Sun Mar 1 02:12:14 GMT 2009 - surfraw 2.2.4 * New elvi: + ntrs, scicom, springer - Thanks to Wim Van Hoydonck. + urban - Thanks to J. R. Mauro. + aur - Thanks to René Reigel. * excite: fixed. * cite: changed to use citeseerx.ist.psu.edu, the old citeseer is no longer being updated. * amazon: fixed; updated categories. Sat Sep 13 20:40:01 BST 2008 - surfraw 2.2.3 * Surfraw now defaults to graphical mode. See surfraw(1) for how to change the default back. * Search for default browsers during build. This can be overridden by passing --with-text-browser=BROWSER and --with-graphical-browser=BROWSER to ./configure. * New elvis: piratebay, genportage. Thanks to J.R. Mauro. * Detect which awk to use. * Fixed slinuxdoc and webster. * Removed bashisms. * Fixed uninstall. * Add --disable-sr option to ./configure to disable installing the 'sr' symbolic link, to avoid clashes with the SR programming language. Thu Jul 3 08:47:14 BST 2008 - surfraw 2.2.2 * New elvis: + arxiv - Search the Los Alamos Science E-Print Archive replaces xxx which was just a stub (thanks to John Gruenenfelder). + javasun - search Java API Docs (thanks to James TD Smith) * Fixed elvis: + debpackages/debcontents: update options and distributions, add -a options to use archive.debian.net. + wetandwild: switched to weather.com, as yahoo now uses AJAX. Command line options and SURFRAW_weather_* variables no longer supported. + austlii: fixed search URL, default method is now 'auto'. + port: original site is back. + translate: fixed URLs. * Removed elvis: + sundocs: use sunonesearch. + xxx: replaced by arxiv. * surfraw: fix w3_url_escape quoting (thanks Micah Anderson) * surfraw-update-path: fix csh syntax (thanks John Gruenenfelder) * google: Add -country option to specify country. Respects SURFRAW_lang variable (Thanks to James TD Smith). Sun Mar 9 19:24:26 GMT 2008 - surfraw 2.2.1 * New elvi: + lsm - Search the Linux Software Map. + sunonesearch - Search Sun's One Search (replaces sunsolve). * Fixed elvi: cddb, cnn, debcontents, deblists, debpackages, freedb, fsfdir, genpkg, and yubnub (thanks for the latter to Nathaniel Heinrichs). * Removed elvis: sunsolve (replaced by sunonesearch). * amazon, ebay, translate: expanded language/country list. * Added new configuration variable SURFRAW_lang. Elvi that support specifying language or country will use this as a default. If used, it should be set to an ISO 2-letter country code (eg uk, de, ca). Thanks to Simon Ernst for the idea. * Fixed quoting single quotes in URLs (thanks to Alexander Becher for the patch). Thu Sep 6 21:59:35 BST 2007 - surfraw 2.2.0 * Resumed making upstream releases. Surfraw is now maintained by the Debian Surfraw-Devel Team. Please report bugs to <[email protected]>, and feel free to join us on the list. There have been many changes since the last official release. New elvi: alioth archpkg bbcnews cddb cia codesearch ctan cve deblists deblogs debpts debsec debwiki discogs dmoz ebay etym foldoc freedb fsfdir genpkg gutenberg happypenguin imdb ixquick lastfm leodict musicbrainz opensearch pgpkeys port rae rfc scholar scpan w3css w3html w3link w3rdf wayback wikipedia yubnub Removed elvi: appwatch britannica ftpfind ftpsearch jake raging swhois Elvi now live in /usr/lib/surfraw (or /usr/local/lib/surfraw) Use surfraw-update-path to add this directory to your path or prefix elvi with sr or surfraw, eg "sr google foo bar". Bookmarks can be defined in /etc/surfraw.bookmarks or ~/.surfraw.bookmarks. See /etc/surfraw.bookmarks for the format. Bookmarks can be used with "sr [options] bookmarkname". There is now a test suite. "make test" to run it or see test/README. For a full list of changes since the last release, see debian/changelog. From this release onwards, changes will be logged in ./ChangeLog as normal. Tur Mar 30 01:21:03 CEST 2004 - surfraw 2.0.2 * Added bash completion support by Justin B Rye * Do not set $DISPLAY when running in text mode * Removed sharereactor elvi Tue Feb 10 04:01:40 GMT 2004 - surfraw 2.0.1 Please note that the elvi have moved again, to /usr/lib/surfraw If you used surfraw-update-path from version 2.0 to add the elvi directory to your path, you will need to run it again, first with -remove to remove the old path, then again with -add. To change your path you will need to either log out and in again or source the relevant config files. * Moved elvi to /usr/lib/surfraw * Updated docs for new elvi location * Changed man page section for all elvi to 1sr * Fixed surfraw help text * Added man page links for pgpkeys, ebay and sharereactor * Added linda override (and surfraw.dirs) for usr-lib-in-arch-all * Added debhelper tokens to prerm/postinst (they were in released 2.0-1 but not CVS) * Rewrote man page surfraw.1.in, added man page elvi.1sr.in Both go via autoconf. * Removed old debian/surfraw.1 * Updated debian/surfraw.links to point elvi to elvi.1sr.gz * Updated AUTHORS to hopefully include every contributor, ever. * Changed a few "def"s to "defyn"s in surfraw.conf.in * Fixed quoting so sr google foo "bar baz" qux works * Makefile.am: Added missing files to EXTRA_DIST * Added a debconf note (only visible if upgrading from 2.0-1) explaining the elvi have moved again * configure.in: changed to new AM_INIT_AUTOMAKE format, specified minimum automake version 1.7 * updated surfraw.lsm with new URLs * deleted debian/rules.save (old rules backup) * Removed elvi: + britannica: gone subscription-only + swhois: all whois sites I can find have anti-harvester features that stop us using them. * Fixed elvi: + wikipedia - added missing quotes (could've sworn I did this already) + cnn - updated url + translate - corrected docs * Moved debian/surfraw.links to links.IN in top dir, now uses autoconf and is not debian-specific * Makefile.am: Added install-data-hook to create links * configure.in, elvi/Makefile.in: fixed ELVIDIR quoting * added elvi/surfraw_elvi to CLEANFILES & removed it from cvs, as it is generated on build. * disabled ifs quoting in elvi that don't like it: freedb, happypenguin, jake, rhyme, scaleplus, sharereactor, thesaurus, webster, deblists. * Added note to HACKING explaining how to disable ifs quoting * synced NAMESPACE branch with HEAD Please use the main HEAD branch from now on. * links.IN: made links relative * Converted debconf to po-debconf * Eliminated templates.IN, as it confused po-debconf * Deautoconfiscated the debian directory, as only templates went through autoconf Tue Dec 23 03:19:58 GMT 2003 - surfraw 2.0 New development team, see http://alioth.debian.org/projects/surfraw * Moved elvi to /usr/bin/surfraw-elvi. (Closes: #209155, #192869, #201175) * Provided surfraw-update-path to put new dir in path. * Added sr as alias to surfraw. * Added bookmark support and /etc/surfraw.bookmarks. * New elvi: alioth, rfc, scpan, deblists. (Closes: #134498) plus leodict and happypenguin by Moritz Muehlenhoff (Closes: #217799) and wikipedia, also by Moritz Muehlenhoff (Closes: #223953) and sharereactor, pgpkeys and ebay, also by Moritz Muehlenhoff * Fixed elvi: altavista, debcontents, excite, jake, scaleplus, slinuxdoc, sundocs, swhois, translate. * amazon: fixed test (Closes: #163903) and -country, removed tag-id stuff. * debcontents: changed options to SURFRAW_debcontents_*. * sourceforge: added -type and -exact options. * webster: added -t (thesaurus) option. * debbugs: added options. * Removed elvi: appwatch, ftpsearch, ftpfind, raging (sites defunct). * Updated Debian Standards-Version to 3.6.1.0 * surfraw.in: - Applied Brian Nelson's "-remote openURL" patch (Closes: #165967). - Fixed browser selection (Closes: #118314). * google -l/-lucky support (Closes: #127078, #128544). * Added deja patch from Christian Garbs (Closes: #149600). * debian/rules: changed to use DESTDIR. * Force default browser to sensible-browser (Closes: #119357) - This supercedes NMU changes (Closes: #200164, #201229, #149584) - Change default browser in manpage (Closes: #113148) * Rename stranslate back to translate (Closes: #141243) * Make woffle not look for /usr/local/bin/surfraw (Closes: #156466) * Add lynx to Recommends (Closes: #141242) * Make surfraw lintian-clean - Remove '(s)' from copyright - Remove /etc conffile entries * Kevin Kreamer <[email protected]> did this work. * Easy bugs first - fix type in README (Closes: #154304) - s/README/README.gz/ in manpage (Closes: #164206) * Added elvi for imdb, cddb, freedb and bbcnews written by Ian Beckwith. * changed "Author(s)" to "Author" in debian/copyright * removed debian/conffiles to prevent debhelper being so incredibly "helpful" as to inlude conffiles *twice* Wed Dec 26 02:48:06 EST 2001 - Surfraw 1.0.7 Fix major sed lossage in 1.0.6 which removed all references to http:// (not just in the documentation strings as was intended) Sun Dec 23 21:02:57 EST 2001 - Surfraw 1.0.6 New elvi: freebsd, openbsd, filesearching, ftpfind Updated elvi: translate (babelfish), ftpsearch, fast, netbsd Rename linuxdoc elvi to slinuxdoc, to prevent name clash with sgmltools Use test -r instead of test -e which inexplicably chocked Solaris8 Documentation changes Tue Nov 6 11:14:21 EST 2001 - Surfraw 1.0.5 Fix wayward indentation introduced in 1.0.4 which caused -browser to fail Note that SURFRAW_browser was made obsolete in 1.0.4. SURFRAW_text_browser and SURFRAW_graphical_browser replace its functionality STATE EXTRA CLEARLY THE FORMAT OF ~/.surfraw.conf so even Redhat users get it. Thu Oct 25 05:32:25 EST 2001 - Surfraw 1.0.4 New elvi: debbugs, debcontents, debpackages, swhois, woffle Dead elvi: ircsearch, newscientist -g and -t switch between graphical & text browsers -new opens a new window on -remote comprehending browsers Support "--" option to end all options Fix url space escaping problem Surfraw placed into the public domain Fri Jan 12 14:51:10 EST 2001 - Surfraw 1.0.3 New elvi: amazon Add `scaleplus' elvi to elvi/Makefile.am Minor documentation bug fixes Wed Sep 27 06:37:48 EST 2000 - Surfraw 1.0.2 Viva l`explorateur de texte! http://slashdot.org/articles/00/08/28/1143249.shtml http://www.theage.com.au/frontpage/20000828/A32287-2000Aug28.html Translate elvi didn't correctly parse -from or -to HACKING file was missing from EXTRA_DIST Fri Aug 25 23:42:31 EST 2000 - Surfraw 1.0.1 New elvi: britannica Updated elvi: freshmeat Fri Aug 25 02:26:31 EST 2000 - Surfraw 0.5.8 New elvi: stockquote (nasdaq, quote.com, yahoo), jake Don't open new screen(1)s by default Zorch usage of local variables (not POSIX) Sat Aug 12 20:00:45 EST 2000 - Surfraw 0.5.7 New elvi: fast netbsd translate W wetandwild. Auto detect browser during configure phase. Built in support for screen(1) Built in support for netscape-remote `surfraw' on its own now displays a list of elvi Sun Aug 6 11:43:50 EST 2000 - Surfraw 0.5.6 New elvi: newscientist pubmed freshmeat Sat Aug 5 16:07:55 EST 2000 - Surfraw 0.5.5 New elvi: appwatch cnn excite ftpsearch linuxdoc scaleplus sundocs sunsolve thesaurus weather webster Wed Aug 2 08:56:04 EST 2000 Name change, surfaw -> surfraw Web-site is now http://surfraw.sourceforge.net/ Sun Jul 30 17:51:50 EST 2000 - Surfaw 0.5.4 A Lazy sunday. A tired, but happy mood. The afternoon drowses by and we have the initial version. $Id$ diff --git a/README b/README index 7d4ad7b..9a62b45 100644 --- a/README +++ b/README @@ -1,395 +1,395 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web -Home Page: http://surfraw.alioth.debian.org +Home Page: https://gitlab.com/surfraw/Surfraw ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web - New: http://surfraw.alioth.debian.org - Old: http://surfraw.sourceforge.net/ + New: https://gitlab.com/surfraw/Surfraw + Old: http://surfraw.alioth.debian.org Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS Surfraw now supports bookmarks. To add a bookmark, add it to to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/rhyme -method=perfect Julian OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) discogs -- Search the Discogs database of music information (www.discogs.com) <<<<<<< HEAD dmoz -- Search the Open Directory Project web directory (dmoz.org) duckduckgo -- Securely search the web using duckduckgo (duckduckgo.com) ======= duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) >>>>>>> kyle/https-elvi ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) oraclesearch -- Search an OpenSearch-enabled website pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) scholar -- Search Google Scholar (scholar.google.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) wikipedia -- Search the free encyclopedia wikipedia wiktionary -- Search the free multilingual dictionary (wiktionary.org) woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) All elvi have useful low calorie help, for example: Usage: rhyme [options] [search words]... Description: Surfraw search for rhymes and other word correlations using Lycos Rhyme (rhyme.lycos.com) Example: $ rhyme Julian $ rhyme -method=rel surfer Results: Hurclean St. Julien. surfboarder, bather, natator, swimmer Local options: -method= Type of word correlation to search for prefect | Perfect rhyme syn | Synonyms hom | Homophones cons | Consonsant rhymes only rel | Semantically related words sub | Phrases spell | Similar spellings pic | Pictures shake | Match with Shakespeare archives def Find wordnet definition Default: perfect Environment: SURFRAW_rhyme_method Global options: -browser=EXECUTABLE Set browser Default: sensible-browser -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: yes Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: yes Environment: SURFRAW_graphical -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: no Environment: SURFRAW_new_window -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: no Environment: SURFRAW_quote_args -version Display Surfraw version (2.2.7) -- End of options Copyright: - Copyright (c) 2003-2013 The Surfraw-Devel Team + Copyright (c) 2003-2018 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________ diff --git a/configure.in b/configure.in index c2dbe1f..7dbe05d 100644 --- a/configure.in +++ b/configure.in @@ -1,67 +1,60 @@ dnl $Id$ dnl Process this file with autoconf to produce a configure script. dnl This is the only place where the package version appears dnl (apart from changelogs & NEWS) -AC_INIT(surfraw, 2.2.9) +AC_INIT(surfraw, 2.3.0) AC_PREREQ(2.54) AC_CONFIG_SRCDIR([surfraw.IN]) dnl minimum automake version, not surfraw version AM_INIT_AUTOMAKE([1.10]) AC_MSG_CHECKING([whether to enable local OpenSearch support]) AC_ARG_ENABLE([opensearch], [AS_HELP_STRING([--disable-opensearch], [disable local OpenSearch support])],, [enable_opensearch=yes]) AC_MSG_RESULT([$enable_opensearch]) AM_CONDITIONAL(OPENSEARCH, test "$enable_opensearch" = "yes") -AC_MSG_CHECKING([wether to install Bash completions]) -AC_ARG_ENABLE([bash-completions], - [AS_HELP_STRING([--disable-bash-completions], [disable Bash completions support])],, - [enable_bashcompletions=yes]) -AC_MSG_RESULT([$enable_bashcompletions]) -AM_CONDITIONAL(BASHCOMPLETIONS, test "$enable_bashcompletions" = "yes") - AC_MSG_CHECKING([whether to install sr alias]) AC_ARG_ENABLE([sr], [AS_HELP_STRING([--disable-sr], [disable sr alias])],, [enable_sr=yes]) AC_MSG_RESULT([$enable_sr]) AM_CONDITIONAL(INSTALLSR, test "$enable_sr" = "yes") ELVIDIR="\$(libdir)/surfraw" AC_CHECK_PROGS(TEXTBROWSER, lynx links2 links elinks w3m netrik) AC_CHECK_PROGS(GRAPHICALBROWSER, iceweasel firefox google-chrome opera mozilla \ xombrero luakit safari epiphany-browser konqueror galeon kazenhakase \ conkeror dillo netscape chromium chrome) AC_ARG_WITH([elvidir], [AS_HELP_STRING([--with-elvidir=ELVIDIR], [specify location of elvi])], [if test -n "$withval" && test "$withval" != "no" ; then ELVIDIR="$withval";fi]) AC_ARG_WITH([text-browser], [AS_HELP_STRING([--with-text-browser=BROWSER], [specify default text browser])], [if test -n "$withval" && test "$withval" != "no" ; then TEXTBROWSER="$withval";fi]) AC_ARG_WITH([graphical-browser], [AS_HELP_STRING([--with-graphical-browser=BROWSER], [specify default graphical browser])], [if test -n "$withval" && test "$withval" != "no" ; then GRAPHICALBROWSER="$withval";fi]) AC_SUBST(ELVIDIR) AC_SUBST(VERSION) AC_SUBST(TEXTBROWSER) AC_SUBST(GRAPHICALBROWSER) ISODATE=`date +%Y-%m-%d` AC_SUBST(ISODATE) dnl Checks for programs. AC_PROG_INSTALL AC_PROG_AWK AC_PATH_PROG([PERL], [perl], [perl]) AC_SUBST(PERL) AC_CONFIG_FILES([Makefile surfraw.lsm surfraw.spec elvi/Makefile test/Makefile examples/Makefile]) AC_OUTPUT diff --git a/debian/changelog b/debian/changelog index c45b068..72bea17 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,512 +1,521 @@ +surfraw (2.3.0-1) unstable; urgency=low + + * New upstream version + * Select Perl version at buildtime (Mark Meyer) + * Remove lynx-cur (Closes: #882286) + * Packages the https elvi + + -- Jason Ryan <[email protected]> Sat, 13 Jan 2018 18:52:10 +0000 + surfraw (2.2.9-1) unstable; urgency=low * New upstream version + yandex: Fix bashism (Closes: #690615). + rae: Fix URL (Closes: #680138). * Standards-Version: 3.9.5 (no changes). * update debian/copyright. * switch to source format 3.0 (quilt). * update Vcs-Browser fields. -- Ian Beckwith <[email protected]> Tue, 10 Dec 2013 17:03:19 +0000 surfraw (2.2.8-1) unstable; urgency=low * New upstream version + SURFRAW_graphical_remote defaults to off, as chromium doesn't support '-remote openURL()' (Closes: #628683). * Move opensearch elvi to main surfraw package. It now has an optional mode that uses a redirector if the dependencies are not installed. * debian/rules: + hardcode AWK as awk (Closes: #608967). + use dh_prep instead of dh_clean -k. + add build-arch and build-indep targets. * debian/control: + Build-Depends: bump debhelper dependency to (>= 7). + Standards-Version: 3.9.2. + surfraw-extra: convert Conflicts: to Breaks:. + surfraw: * Breaks: surfraw-extra (<= 2.2.7-1) as we have taken over /usr/lib/surfraw/opensearch. * Recommends: surfraw-extra: add version of (>> 2.2.7-1). * Tweak Description. * debian/source/format: explicitly specify 1.0 source format. -- Ian Beckwith <[email protected]> Tue, 12 Jul 2011 01:31:52 +0100 surfraw (2.2.7-1) unstable; urgency=low * New upstream version. + fixed imdb elvi (Closes: #577263). * Standards-Version: 3.8.4 (no changes). * Add ${misc:Depends} to dependencies. -- Ian Beckwith <[email protected]> Fri, 16 Apr 2010 20:43:27 +0100 surfraw (2.2.6-1) unstable; urgency=low * New upstream version. + Only use first matching bookmark (Closes: #530786). + Fix debsec (patch from Moritz Muehlenhoff) (Closes: #550741). * Remove Moritz from Uploaders (per #550741), thanks for your work!. * debian/rules: call dh_installexamples to install examples/ dir. * debian/control: + update vcs- fields to point to new git repo. + Standards-Version: 3.8.3 (No changes). + add Recommends: curl | wget | libwww-perl for -o. + Remove Conflicts/Replaces: surfaw, this transition was complete many releases ago. -- Ian Beckwith <[email protected]> Fri, 20 Nov 2009 03:34:34 +0000 surfraw (2.2.5-1) unstable; urgency=low * New upstream version. * Removed Thomas Smith from Uploaders (Closes: #519378). Thanks for your work!. * Updated my email address in Uploaders. * Fixed VCS-Browser URL (Closes: #528299). * Removed DM-Upload-Allowed header. * Standards-Version: 3.8.1 (no changes). -- Ian Beckwith <[email protected]> Wed, 13 May 2009 02:09:49 +0100 surfraw (2.2.4-1) unstable; urgency=low * New upstream version. * postrm: add 'set -e'. * debian/copyright: + Update copyright years to include 2009. + point to right GPL link (NB only the file 'missing' is GPLed, most of the package is PD). -- Ian Beckwith <[email protected]> Sun, 01 Mar 2009 02:30:59 +0000 surfraw (2.2.3-1) unstable; urgency=low * New upstream version. + Now defaults to graphical mode, see surfraw(1) for how to change it back. * Change default text browser to www-browser and default graphical browser to sensible-browser. -- Ian Beckwith <[email protected]> Tue, 26 Aug 2008 22:36:24 +0100 surfraw (2.2.2-3) unstable; urgency=low * Backport slinuxdoc fix from 2.2.3 prerelease. -- Ian Beckwith <[email protected]> Fri, 25 Jul 2008 05:14:30 +0100 surfraw (2.2.2-2) unstable; urgency=medium * google: fix bashism and quote more variable expansions (Closes: #489902). Thanks to Philip Armstrong and John Briggs. * Reformat debian/copyright to keep lintian happy. -- Ian Beckwith <[email protected]> Sat, 19 Jul 2008 00:50:33 +0100 surfraw (2.2.2-1) unstable; urgency=low * New upstream version: + fix url escaping (Closes: #487430). + surfraw-update-path: fix csh support (Closes: #484871). * Recommends: Drop w3m-ssl (folded into w3m) and lynx-cur (not in lenny) (Closes: #471359). * surfraw-extra: improve long description (Closes: #471321). * Standards-Version: 3.8.0 (no changes). * Remove linda override. * Add watch file. -- Ian Beckwith <[email protected]> Thu, 03 Jul 2008 01:22:36 +0100 surfraw (2.2.1-2) unstable; urgency=low * Remove my old email address from Uploaders. -- Ian Beckwith <[email protected]> Tue, 11 Mar 2008 14:07:35 +0000 surfraw (2.2.1-1) unstable; urgency=low * New upstream release. + bashisms removed (Closes: #465361, #468139). * debian/rules: move .deb building to binary-indep: target. * debian/compat: bump to 6. * debian/control: + DM-Upload-Allowed: yes merged from Debian-only 2.1.7-1 (see below). Dropped XS- prefix, no longer needed. + Recommends: add elinks | elinks-lite to existing browser alternatives. + Uploaders: update my email address. + Standards-Version: 3.7.3 (no changes). + Build-Depends: Bump debhelper version to >= 6. + Vcs-Cvs/Vcs-Browser: remove XS- prefix and -d workaround. + Homepage: added. * debian/changelog: merged Moritz's debian-only 2.1.7 release changelog. * debian/linda.overrides: remove exec-not-elf-or-script tag now file(1) is fixed. * debian/copyright: update, use machine-interpretable format. -- Ian Beckwith <[email protected]> Tue, 11 Mar 2008 14:07:08 +0000 surfraw (2.2.0-1) UNRELEASED; urgency=low * Actual first new upstream release. See changelog.gz for upstream changes, like a normal package. * debian/rules: Use $(CURDIR) instead of `pwd`. * debian/copyright: updated copyright dates. -- Ian Beckwith <[email protected]> Tue, 11 Sep 2007 03:41:09 +0100 surfraw (2.1.8-1) UNRELEASED; urgency=low * First proper upstream release of the surfraw-devel version. After this release non-debian changes will be logged in the upstream changelog.gz. * Split off opensearch into new package: surfraw-extra as it has a huge dependency tree that not everyone will want to install. * Fixed "sr -options bookmark" (excessive quoting). * New elvi: + archpkg - search Arch Linux packages. Thanks to Simon Ernst. + port - look up a TCP/UDP port on seifried.org/security/ports. * Fixed elvi + debbugs: fixed help formatting. + debcontents - new options * Fixed tests: + austlii - (since when does a legal db not contain "tort"?). + deblists - -security-announce not indexed (#440347), so we search for WNPP posts on -devel. + debpackages. + sunsolve - added cookie to accept license. + w3html - validator will not validate itself. * runtests (see test/README): + Added cookie support. + Added support for skipping tests with SKIP. + Abort if libwww-perl not installed. + Documented changes in test/README. * Makefile.am: removed debian/ files from EXTRA_DIST, they should be in the debian patch not the main tarball. * Bumped debhelper compat level to 5. * Really updated to automake-1.10. * Updated AUTHORS, NEWS, README, HACKING, ChangeLog, NEWS.Debian. -- Ian Beckwith <[email protected]> Fri, 07 Sep 2007 00:18:38 +0100 surfraw (2.1.7) unstable; urgency=low * Add "XS-DM-Upload-Allowed: yes", so that Ian can upload further updates on his own. -- Moritz Muehlenhoff <[email protected]> Sun, 13 Jan 2008 23:23:30 +0100 surfraw (2.1.6) unstable; urgency=low * New elvi: + codesearch - search google code search. + debwiki - search wiki.debian.org and women.debian.org/wiki. + lastfm - search last.fm. + musicbrainz - search musicbrainz.org. + opensearch - search sites that provide an OpenSearch description: - Install helper scripts opensearch-discover and opensearch-genquery to /usr/bin. - Add Dependencies on libwww-opensearch-perl, libwww-perl and libhtml-parser-perl. - Makefile.am: replaced explicit rule for surfraw-update-path.1 with a static pattern rule for making man pages from perl scripts. * Fixed elvi: + amazon - fixed example usage. + cia - switched to https. + cite - fixed URL and options. + debpackages - updated ubuntu distro names. + debcontents - updated ubuntu distro names. + freebsd - fixed help formatting. + netbsd - fixed mailing list searches. + openbsd - fixed PR search URL. + slinuxdoc - fixed URLs. + sundocs - fixed URLs. + woffle - updated URLs to match woffle 2.9a. * Removed elvi: jake - site shut down January 2007. * Implemented test suite - 'make test' or see test/README. * Fixed make distcheck. * Updated to automake 1.10. * debian/rules: stopped ignoring return code of 'make distclean'. * Updated Copyright dates to 2007. * Add Vcs-Cvs and Vcs-Browser fields to debian/control. -- Ian Beckwith <[email protected]> Sat, 30 Jun 2007 22:15:14 +0100 surfraw (2.1.5) unstable; urgency=low * Added myself to Uploaders. * Ack not-really-NMU (Closes: #354737). * Applied bash completion fixes, thanks to Justin B. Rye (Closes: #361668). * wikipedia: disable requoting; use Go rather than Search. * Fixes to ixquick elvi, thanks to Aparna Jaitly. * debpackages/debcontents: new options + ubuntu support with -u. * New elvi: scholar - search google scholar. * New elvi: discogs, thanks to Patroklos Argyroudis. * Thanks to James Rowe for the following patches: + Move W to /usr/lib/surfraw (see http://bugs.gentoo.org/show_bug.cgi?id=58955). + New elvi: genpkg for Gentoo package search. + Generate elvi list on demand and eliminate surfraw_elvi.list + Make elvidir configurable. + Make sysconfdir configurable. + Fix 'make dist' and 'make distcheck'. + Remove unused browser checks. + Drop AC_CANONICAL_HOST - not needed. * New global option: -p / -print: just print search url. * Remove config.guess and config.sub - not needed. * Remove config.{guess,sub} updating logic from debian/rules. * postrm: remove /etc/surfraw_elvi.list if it exists. * Convert debhelper Build-Depends-Indep: to Build-Depends:. * Standards-Version: 3.7.2 (No changes). * Updated Copyright dates to 2006. * Added linda override exec-not-elf-or-script for /usr/bin/surfraw due to erroneous file(1) output (See: #369977). * Tweak HACKING appendix 1 to remove need to build surfraw_elvi.list. -- Ian Beckwith <[email protected]> Tue, 26 Sep 2006 04:22:53 +0100 surfraw (2.1.4) unstable; urgency=low * Ian Beckwith <[email protected]>: + changed elvi: - debsec: fix tabbing (Closes: #354737). - debbugs: updated search options. + new elvi: - ixquick (Thanks to Aparna Jaitly). - ctan. - fsfdir. - gutenberg. - wayback. + Makefile.include: changed sed invocation to work with both old and new make(1). + debian/rules install: removed spurious mkdir. + removed debian/{prerm,postinst}. + Switched to debhelper compat level 4. + HACKING: corrected appendix 1. -- Ian Beckwith <[email protected]> Fri, 17 Mar 2006 22:26:37 +0000 surfraw (2.1.3) unstable; urgency=high * Urgency high, as it renders surfraw uninstallable * Really, really remove debconfage (Closes: #354263) -- Moritz Muehlenhoff <[email protected]> Fri, 24 Feb 2006 23:00:09 +0100 surfraw (2.1.2) unstable; urgency=low * Moritz Muehlenhoff <[email protected]>: + Fix FTBFS due to make changes (Patch by Matt Kraai) (Closes: 353314) + Fix zsh completion for yubnub (Patch by Micah Anderson) (Closes: #341872) + Remove debian/po to prevent further translations in vain. Sorry for the wasted work on the Swedish translation, Daniel Nylander! (Closes: #338149, #336687) + Changed maintainer address to "Debian surfraw maintainers", added Christian, Thomas and myself to uploaders + New elvis: debsec (for the Debian security tracker) -- Moritz Muehlenhoff <[email protected]> Thu, 23 Feb 2006 16:49:55 +0100 surfraw (2.1.1) unstable; urgency=low * Moritz Muehlenhoff <[email protected]>: + Removed debconf information about new elvi structure, now that Sarge has been released with it. Moved it to README.Debian. (Closes: #313852, #312979, #319841, #319842) + New elvis: yubnub (by Iain D Broadfoot) (Closes: #315188) + Removed unused SURFRAW_p0rn option (Closes: #324166) + Bumped standards version (no changes required) + Change to a native package, most of the elvis are now more or less Debian specific anyway -- Moritz Muehlenhoff <[email protected]> Fri, 29 Apr 2005 16:20:39 +0200 surfraw (2.1.0-1) unstable; urgency=medium * Ian Beckwith <[email protected]>: + New elvi: dmoz, w3html, w3link, w3css, w3rdf. + New elvi: rae (by Ruben Pollan <[email protected]>). + surfraw.IN:w3_url_escape: escaped `(' and `)'. + Fixed elvi (Thanks to Justin B. Rye): - sunsolve (Closes: #289502). - altavista (Closes: #289503). + deblists: Updated list of debian mailing lists. + currency: Now a proper elvis. + Added appendix 2 to HACKING on preparing a release. * Moritz Muehlenhoff <[email protected]>: + Switch rhymes search from Lycos to Rhymezone (by Justin B Rye) (Closes: #289498) + Fix BBC News search (by Justin B Rye) (Closes: #289499) + New elvi by by Justin B Rye (Closes: #290032) - cia Search for CIA documents - deblogs Debian changelogs - etym Search for word origins - foldoc Free online dictionary of computing + New cve elvis for CAN assignment searches + Rewrite debian/copyright properly -- Thomas Smith <[email protected]> Wed, 20 Apr 2005 17:00:59 -0500 surfraw (2.0.2-2) unstable; urgency=low * Applied Brian Mcdonald's workaround for bash bug (Closes: #269982) -- Christian Surchi <[email protected]> Mon, 13 Sep 2004 16:34:53 +0100 surfraw (2.0.2-1) unstable; urgency=low * Several patches from Justin B Rye: + Add bash completion (Closes: #240629) + Add some missing elvis in surfraw_elvi.list (Closes: #241079) + Don't set DISPLAY when in text-only mode (Closes: #235251) + Correctly test for text-mode in w3_browse_url() + Readability improvements + Use argv[0] instead of computing it through basename * Removed elvi: + sharereactor: has been closed down * Added French debconf template by Christian Perrier (Closes: #236088) * Added German debconf template by Helge Kreutzmann (Closes: #253800) * New elvi: debpts. * man page hyphenation fixes. * debian/control: + Dropped optional last part of Standards-Version. + Changed lynx to lynx-cur in Recommends to avoid confusing apt. + Added po-debconf to Build-Depends-Indep. * debian/rules clean: + enabled config.{guess,sub} update. + remove templates.merged. * HACKING: updated Appendix 1. * surfraw.conf.in: set SURFRAW_graphical_browser to x-www-browser (Closes: #256201) -- Ian Beckwith <[email protected]> Thu, 29 Jul 2004 15:31:10 +0100 surfraw (2.0.1-1) unstable; urgency=low * Moved elvi to /usr/lib/surfraw (Closes: #230276) * Updated docs for new elvi location * Changed man page section for all elvi to 1sr (Closes: #230056) * Fixed surfraw help text (Closes: #230109) * Added man page links for pgpkeys, ebay and sharereactor * Added linda override (and surfraw.dirs) for usr-lib-in-arch-all * Added debhelper tokens to prerm/postinst (they were in released 2.0-1 but not CVS) * Rewrote man page surfraw.1.in, added man page elvi.1sr.in Both go via autoconf. * Removed old debian/surfraw.1 * Updated debian/surfraw.links to point elvi to elvi.1sr.gz * Updated AUTHORS to hopefully include every contributor, ever. * Changed a few "def"s to "defyn"s in surfraw.conf.in * Updated README with text from new man page. * Added "Copyright (c) 2003, 2004 The Surfraw-Devel Team <[email protected]>" to the list of copyright holders. * Fixed quoting so sr google foo "bar baz" qux works * Makefile.am: Added missing files to EXTRA_DIST * Added a debconf note (only visible if upgrading from 2.0-1) explaining the elvi have moved again. * configure.in: changed to new AM_INIT_AUTOMAKE format, specified minimum automake version 1.7 * updated surfraw.lsm with new URLs * deleted debian/rules.save (old rules backup) * Removed elvi: + britannica: gone subscription-only + swhois: all whois sites I can find have anti-harvester features that stop us using them (Closes: #231939). * Fixed elvi: + wikipedia - added missing quotes (could've sworn I did this already) + cnn - updated url + translate - corrected docs * Moved debian/surfraw.links to links.IN in top dir, now uses autoconf and is not debian-specific * Makefile.am: Added install-data-hook to create links * configure.in, elvi/Makefile.in: fixed ELVIDIR quoting * Added elvi/surfraw_elvi to CLEANFILES & removed it from cvs, as it is generated on build. * Disabled ifs quoting in elvi that don't like it: freedb, happypenguin, jake, rhyme, scaleplus, sharereactor thesaurus, webster, deblists. * Added note to HACKING explaining how to disable ifs quoting * Synced NAMESPACE branch with HEAD Please use the main HEAD branch from now on. * links.IN: made links relative * Converted debconf to po-debconf * Eliminated templates.IN, as it confused po-debconf * Deautoconfiscated the debian directory, as only templates went through autoconf -- Ian Beckwith <[email protected]> Tue, 10 Feb 2004 03:33:14 +0000 surfraw (2.0-1) unstable; urgency=low * Ack NMUs. (Closes: #200164, #201229, #209155, #113148, #119357, #131661) * ..and.. (Closes: #149584, #156466, #141243, #154304, #164206, #141242) * Moved elvi to /usr/bin/surfraw-elvi. (Closes: #209155, #192869, #201175) * Provided surfraw-update-path to put new dir in path. * Added sr as alias to surfraw. * Added bookmark support and /etc/surfraw.bookmarks. * New elvi: alioth, rfc, scpan, deblists. (Closes: #134498) plus leodict and happypenguin by Moritz Muehlenhoff (Closes: #217799) and wikipedia, also by Moritz Muehlenhoff (Closes: #223953) and ebay, pgpkeys and sharereactor, also by Moritz Muehlenhoff * Fixed elvi: altavista, debcontents, excite, jake, scaleplus, slinuxdoc, sundocs, swhois, translate. * amazon: fixed test (Closes: #163903) and -country, removed tag-id stuff. * debcontents: changed options to SURFRAW_debcontents_*. * sourceforge: added -type and -exact options. * webster: added -t (thesaurus) option. * debbugs: added options. * Removed elvi: appwatch, ftpsearch, ftpfind, raging (sites defunct). * Updated Standards-Version to 3.6.1.0 * surfraw.in: - Applied Brian Nelson's "-remote openURL" patch (Closes: #165967). - Fixed browser selection (Closes: #118314). * google -l/-lucky support (Closes: #127078, #128544). * Added deja patch from Christian Garbs (Closes: #149600). * debian/rules: changed to use DESTDIR. * Closing non-bugs: - Complaint about correct behaviour (Closes: #173714). - Adds functionality already present in debcontents (Closes: #144080). - Obsoleted by sensible-browser (imho) (Closes: #155423). -- Ian Beckwith <[email protected]> Sun, 9 Nov 2003 22:02:44 +0000 surfraw (1.0.7-3) unstable; urgency=low * Force default browser to sensible-browser (Closes: #119357) - This supercedes NMU changes (Closes: #200164, #201229, #149584) - Change default browser in manpage (Closes: #113148) * Rename stranslate back to translate (Closes: #141243) * Make woffle not look for /usr/local/bin/surfraw (Closes: #156466) * Add lynx to Recommends (Closes: #141242) * Make surfraw lintian-clean - Remove '(s)' from copyright - Remove /etc conffile entries * Kevin Kreamer <[email protected]> did this work. -- Thomas Smith <[email protected]> Thu, 4 Sep 2003 18:09:29 -0500 surfraw (1.0.7-2) unstable; urgency=low * The first "collaborative" release :) * Easy bugs first - fix type in README (Closes: #154304) - s/README/README.gz/ in manpage (Closes: #164206) * Added elvi for imdb, cddb, freedb and bbcnews written by Ian Beckwith. * changed "Author(s)" to "Author" in debian/copyright * removed debian/conffiles to prevent debhelper being so incredibly "helpful" as to inlude conffiles *twice* -- Christian Surchi <[email protected]> Sat, 16 Aug 2003 17:02:03 +0000 surfraw (1.0.7-1) unstable; urgency=low * New upstream release * New debian/rules with DH_COMPAT=3 too * Elvi: linuxdoc renamed to slinuxdoc translate renamed to stranslate * Removed unuseful scripts in debian directory * Removed emacs settings in changelog -- Christian Surchi <[email protected]> Sat, 2 Mar 2002 23:54:34 +0100 diff --git a/debian/copyright b/debian/copyright index fbe1db2..942a750 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,83 +1,83 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: surfraw Upstream-Contact: Surfraw-Devel <[email protected]> -Source: http://surfraw.alioth.debian.org/dist/ +Source: https://gitlab.com/surfraw/Surfraw Comment: This package has initially been debianized by Christian Surchi <[email protected]> since Sat, 5 Aug 2000 18:59:30 +0200. . surfraw has originally been developed by Julian Assange <[email protected]>, and was originally downloaded from ftp://ftp.netbsd.org/pub/NetBSD/misc/proff/ . - Since July 2003 its development has continued through the surfraw Alioth - project, you're welcome to contribute. + Since July 2003 its development has continued through the surfraw project, + you're welcome to contribute. Files: * -Copyright: Copyright (c) 2003-2013 The Surfraw-Devel team +Copyright: Copyright (c) 2003-2018 The Surfraw-Devel team Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study License: PD The copyright holders listed above assert no rights on this release of the software ``surfraw'' and thereby explicity place this release into the public domain. Do what you will. Files: missing Copyright: © 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. License: GPL-2+ | other As a special exception to the GNU General Public License, if you distribute this file as part of a program that contains a configuration script generated by Autoconf, you may include it under the same distribution terms that you use for the rest of that program. . On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-2' Files: INSTALL Copyright: © 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. License: other This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Files: mkinstalldirs Copyright: Author: Noah Friedman <[email protected]> License: PD # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman <[email protected]> # Created: 1993-05-16 # Public domain Files: install-sh Copyright: © 1994 X Consortium License: other 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. . Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other deal- ings in this Software without prior written authorization from the X Consor- tium. . FSF changes to this file are in the public domain. Files: Makefile.in */Makefile.in Copyright: © 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. License: other This Makefile.in is free software; the Free Software Foundation gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. diff --git a/debian/watch b/debian/watch index ccee7e0..9d2258e 100644 --- a/debian/watch +++ b/debian/watch @@ -1,2 +1,2 @@ version=3 -http://surfraw.alioth.debian.org/ dist/surfraw-(.*)\.tar\.gz +https://gitlab.com/surfraw/Surfraw dist/surfraw-(.*)\.tar\.gz diff --git a/elvi.1sr.IN b/elvi.1sr.IN index 589d02d..b2b4bf4 100644 --- a/elvi.1sr.IN +++ b/elvi.1sr.IN @@ -1,173 +1,173 @@ .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH ELVI 1sr "Feb 03, 2004" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp <n> insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME elvi \- surfraw(1) search tools .SH SYNOPSIS .B surfraw .I elviname [options] search words ... .br .B sr .I elviname [options] search words ... .br .B sr .I elviname \-help .br .B sr \-elvi .br .SH DESCRIPTION This is the man page for the elvi, a set of search tools that form part of \fBsurfraw(1)\fP. Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, dejanews, freshmeat, research index, slashdot and many others from the false\(hyprophet, pox\(hyinfested heathen lands of html\(hyforms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. To search using this elvis, do: sr elvisname [options] search terms. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google \-l debian ports To find out about options specific to this elvis, do: sr elvisname \-local\-help To find out about surfraw, see the man page for surfraw(1). To see the full list of elvi, do: sr \-elvi .SS Adding the elvi to your path If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (\%@ELVIDIR@) to your path, either manually or using \fBsurfraw\-update\-path(1)\fP. .SH OPTIONS Use \fB\%sr elviname \-local-help\fP for elvi\(hyspecific options. The following options work with all elvi. .TP .B \-help Show summary of options (including elvi\(hyspecific options). .TP .B \-local-help Show elvi\(hyspecific options. .TP .B \-version Show version of program. .TP \fB\-browser=\fP\fIEXECUTABLE\fP Set browser (default: sensible\-browser). .TP .B \-elvi Display a list of other Surfraw mechanisms for conquering evil. .TP .B \-escape\-url\-args=yes|no Apply url escaping to arguments (default: yes) .TP .B \-q|\-quote Bracket arguments with " characters (default: no) Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine .SH EXAMPLES $ sr ask why is jeeves gay? $ surfraw google \-results=100 RMS, GNU, which is sinner, which is sin? $ sr austlii \-method=phrase dog like $ @ELVIDIR@/rhyme \-method=perfect Julian .SH BUGS Please report any bugs found (or any web sites in need of surfrawizing) either via the debian bug tracking system (\%http://bugs.debian.org/) or to the surfraw\-devel list (\%surfraw\[email protected]). .SH SEE ALSO http://alioth.debian.org/projects/surfraw/ .SH PROPAGANDA .ce 1000 Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! .ce 0 Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the \fBS\fPhell \fBU\fPsers' \fBR\fPevolutionary \fBFr\fPont \fBA\fPgainst the WW\fBW\fP by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on surfraw\[email protected] .SH AUTHORS Originally written by Julian Assange. Now maintained by the surfraw\-devel team <\%surfraw\[email protected]>. See the file AUTHORS for the full list of contributors. Man page by Ian Beckwith, based on the original README and an earlier man page for surfraw(1) by Christian Surchi. .SH COPYRIGHT - Copyright (c) 2003\(hy2013 The Surfraw\-Devel Team + Copyright (c) 2003\(hy2018 The Surfraw\-Devel Team <surfraw\[email protected]> Copyright (c) 2000\(hy2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study The copyright holders listed above assert no rights on this release of the software ``surfraw'' and thereby explicity place this release into the into the public domain. Do what you will. diff --git a/surfraw.1.IN b/surfraw.1.IN index f05b890..7609ced 100644 --- a/surfraw.1.IN +++ b/surfraw.1.IN @@ -1,398 +1,398 @@ .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH SURFRAW 1 "Feb 03, 2004" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp <n> insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME surfraw \- a fast unix command line interface to WWW services .SH SYNOPSIS .B surfraw .I elviname [options] search words ... .br .B sr .I elviname [options] search words ... .br .B sr \-elvi .br .B sr .I [options] bookmark [search words] .br .SH DESCRIPTION Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, dejanews, freshmeat, research index, slashdot and many others from the false\(hyprophet, pox\(hyinfested heathen lands of html\(hyforms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. .PP Surfraw consists of a collection of \fBelvi\fP, each of which knows how to search a specific web site. To see the list of elvi type: surfraw \-elvi Note that sr is an alias for surfraw, so that could equally be sr \-elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google \-l debian ports .SS Adding the elvi to your path If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (\%@ELVIDIR@) to your path, either manually or using \fB\%surfraw\-update\-path(1)\fP. .SS Bookmarks Surfraw supports bookmarks. To add a bookmark, add it to \fB\%@sysconfdir@/xdg/surfraw/bookmarks\fP or \fB\%$HOME/.config/surfraw/bookmarks\fP The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ If the url contains the string \fB%s\fP, you can specify an optional argument to the bookmark. Without an argument, only the domain will be returned. With arguments, \fb%s\fP will be replaced by the arguments. This obviates the need to create elvi for sites with very simple search options. To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in \%@sysconfdir@/xdg/surfraw/bookmarks .SH OPTIONS Use \fB\%sr elviname \-local\-help\fP for elvi\(hyspecific options. The following options work with all elvi. .TP .B \-help Show summary of options (including elvi\(hyspecific options). .TP .B \-local-help Show elvi\(hyspecific options. .TP .B \-version Show version of program. .TP \fB\-browser=\fP\fIEXECUTABLE\fP Set browser (default: sensible\-browser). .TP .B \-elvi Display a list of other Surfraw mechanisms for conquering evil. .TP .B \-escape\-url\-args=yes|no Apply url escaping to arguments (default: yes) .TP .B \-q|\-quote Bracket all arguments with " characters (default: no). Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine .SH EXAMPLES $ sr ask why is jeeves gay? $ surfraw google \-results=100 RMS, GNU, which is sinner, which is sin? $ sr austlii \-method=phrase dog like $ @ELVIDIR@/rhyme \-method=perfect Julian .SH CONFIGURATION Surfraw uses the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) to locate config files. The default locations are shown below, but can be modified by setting the environment variables .B $XDG_CONFIG_HOME and .B $XDG_CONFIG_DIRS. See the spec for more details. Surfraw gets its configuration from three sources, in order: .IP 1. 4 Environment variables .IP 2. \%@sysconfdir@/xdg/surfraw/conf .IP 3. \%$HOME/.config/surfraw/conf .PP @sysconfdir@/xdg/surfraw.conf and $HOME/.config/surfraw/conf are both fragments of bourne\(hyshell style shell script. @sysconfdir@/xdg/surfraw.conf should use def and defyn to define variables. These functions set variables unless they are already set by the environment. defyn is used for boolean configuration variables, def for all others. For instance: def SURFRAW_text_browser /usr/bin/lynx defyn SURFRAW_graphical no $HOME/.config/surfraw/conf should use sh\(hystyle entries, eg: SURFRAW_text_browser=/usr/bin/lynx SURFRAW_graphical=no This is because you want them to override environment variables unconditionally. .SH CONFIGURATION VARIABLES .TP .B SURFRAW_global_conf Location of global configuration file. Default: def SURFRAW_global_conf @sysconfdir@/xdg/surfraw/conf .TP .B SURFRAW_conf Location of per\(hyuser configuration file. Default: def SURFRAW_conf $HOME/.config/surfraw/conf .TP .B SURFRAW_graphical Whether to use a graphical browser. Default: defyn SURFRAW_graphical no .TP .B SURFRAW_text_browser Name/path of text browser executable. e.g. links, lynx, w3m Default: def SURFRAW_text_browser sensible\-browser .TP .B SURFRAW_graphical_browser Name/path of graphical browser executable. e.g mozilla, netscape etc. Default: def SURFRAW_graphical_browser sensible\-browser .TP .B SURFRAW_text_browser_args Text browser arguments, or "none". Default: def SURFRAW_text_browser_args none .TP .B SURFRAW_graphical_browser_args Graphical browser arguments, or "none". Default: def SURFRAW_graphical_browser_args none .TP .B SURFRAW_graphical_remote Whether to use "\fB\-remote openURL\fP" for graphical browser. Default: defyn SURFRAW_graphical_remote yes .TP .B SURFRAW_new_window When using SURFRAW_graphical_remote, open a new window? Default: defyn SURFRAW_new_window no .TP .B SURFRAW_screen Name of screen command to run. Default: def SURFRAW_screen screen .TP .B SURFRAW_new_screen If surfraw is running under screen(1), start a new screen for each text browser invocation? Default: defyn SURFRAW_new_screen no .TP .B SURFRAW_screen_args Arguments to pass to the SURFRAW_screen command Default: def SURFRAW_screen_args "" .TP .B SURFRAW_quote_args Whether to "quote" all the arguments. Default: defyn SURFRAW_quote_args no .TP .B SURFRAW_quote_ifs Whether to re\(hyquote arguments if they have spaces in, ie so: sr google foo "bar baz" bam .br works as expected. Default: defyn SURFRAW_quote_ifs yes .TP .B SURFRAW_results Default number of results to return (not supported by all elvi). Default: def SURFRAW_results 30 .TP .B SURFRAW_escape_url_args Whether to escape [% "$%&+,/:;<=>?@[\^{|}~'] characters in command line arguments subsequently used to construct a url. Default: defyn SURFRAW_escape_url_args yes .SH FILES .TP .B @ELVIDIR@ Location of the elvi. .TP .B ${HOME}/.config/surfraw/elvi Per\(hyuser elvi. .TP .B @sysconfdir@/xdg/surfraw/conf Default system wide configuration file. .TP .B $HOME/.config/surfraw/conf Default per\(hyuser config file .TP .B @sysconfdir@/xdg/surfraw/bookmarks System wide bookmarks file. .TP .B $HOME/.config/surfraw/bookmarks Per\(hyuser bookmarks file. .SH BUGS Please report any bugs found (or any web sites in need of surfrawizing) either via the debian bug tracking system (\%http://bugs.debian.org/) or to the surfraw\-devel list (\%surfraw\[email protected]). .SH SEE ALSO http://alioth.debian.org/projects/surfraw/ .SH PROPAGANDA .ce 1000 Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! .ce 0 Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the \fBS\fPhell \fBU\fPsers' \fBR\fPevolutionary \fBFr\fPont \fBA\fPgainst the WW\fBW\fP by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on surfraw\[email protected] .SH AUTHORS Originally written by Julian Assange. Now maintained by the surfraw\-devel team <\%surfraw\[email protected]>. See the file AUTHORS for the full list of contributors. Man page by Ian Beckwith, based on the original README and an earlier man page by Christian Surchi. .SH COPYRIGHT - Copyright (c) 2003-2013 The Surfraw\-Devel Team + Copyright (c) 2003-2018 The Surfraw\-Devel Team <surfraw\[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study The copyright holders listed above assert no rights on this release of the software ``surfraw'' and thereby explicity place this release into the into the public domain. Do what you will. diff --git a/surfraw.IN b/surfraw.IN index 756a474..01130c0 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,516 +1,516 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # -# Copyright (c) 2003-2013 The Surfraw-Devel Team +# Copyright (c) 2003-2018 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=`basename "$0"` elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { base="$1" local conf OIFS conf="" if test -n "$XDG_CONFIG_DIRS"; then OIFS="$IFS" IFS=: set $XDG_CONFIG_DIRS IFS="$OIFS" for i in "$@"; do if test -r "$i/surfraw/$base"; then conf="$i/surfraw/$base" break fi done elif test -r "@sysconfdir@/xdg/surfraw/$base"; then # XDG default conf="@sysconfdir@/xdg/surfraw/$base" elif test -r "@sysconfdir@/surfraw.$base"; then # old surfraw default conf="@sysconfdir@/surfraw.$base" fi echo "$conf" } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value=\$${1} case `echo "$value" | tr A-Z a-z` in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value=\$${1} test -z "$value" || return 0 eval ${1}="$2" return 0 } defyn () { eval value=\$${1} test -z "$value" && eval ${1}="$2" yesno "$1" } setopt () { eval value=\$${1} eval ${1}="$2" } setoptyn () { eval value=\$${1} eval ${1}="$2" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=`echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//'` esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="`quote "$arg"`" else w3_shquoted_args="$w3_shquoted_args `quote "$arg"`" fi if ok SURFRAW_quote_ifs then arg=`quote_ifs "$arg"` fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test `echo $TERM | cut -c 1-6` = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) diff --git a/surfraw.lsm.in b/surfraw.lsm.in index 4994499..c57cd13 100644 --- a/surfraw.lsm.in +++ b/surfraw.lsm.in @@ -1,16 +1,16 @@ Begin4 Title: surfraw Version: @VERSION@ Entered-date: @ISODATE@ Description: Shell Users' Revolutionary Front Rage Against the Web Fast unix command line interface to a variety of popular WWW search engines and other evils Keywords: surfraw, www, web, search Author: [email protected] (Julian Assange) [email protected] (Current surfraw developers) Maintained-by: [email protected] -Primary-site: http://surfraw.alioth.debian.org -Original-site: surfraw.sourceforge.net +Primary-site: https://gitlab.com/surfraw/Surfraw +Original-site: http://surfraw.alioth.debian.org Platforms: shell, perl and sed script Copying-policy: Public Domain End diff --git a/test/Makefile.am b/test/Makefile.am index 2dd709b..21b72d6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,34 +1,31 @@ -EXTRA_DIST = runtests elviwithouttests README COOKIES W.test S.test \ - acronym.test ads.test alioth.test amazon.test archpkg.test \ - archwiki.test arxiv.test ask.test aur.test austlii.test \ - bbcnews.test bing.test bookfinder.test bugmenot.test \ - bugzilla.test cia.test cisco.test cite.test \ - cliki.test cnn.test comlaw.test ctan.test currency.test \ - cve.test debbugs.test debcodesearch.test debcontents.test \ - deblists.test deblogs.test debpackages.test debpkghome.test \ - debpts.test debsec.test debvcsbrowse.test debwiki.test \ - deja.test deli.test discogs.test duckduckgo.test \ - ebay.test etym.test excite.test f5.test finkpkg.test \ - foldoc.test freebsd.test freedb.test freshmeat.test \ - fsfdir.test gcache.test genbugs.test genportage.test \ - github.test gmane.test google.test gutenberg.test imdb.test \ - ixquick.test jamendo.test javasun.test jquery.test lastfm.test \ - leodict.test l1sp.test lsm.test macports.test mathworld.test \ - mdn.test mininova.test musicbrainz.test mysqldoc.test \ - netbsd.test ntrs.test openbsd.test openports.test \ - opensearch.test oraclesearch.test pasearch.test pgdoc.test \ - phpdoc.test pin.test piratebay.test pgpkeys.test priberam.test \ - pubmed.test rae.test rfc.test rhyme.test rpmsearch.test \ - scholar.test scicom.test scirus.test scpan.test slashdot.test \ - slinuxdoc.test sourceforge.test springer.test stack.test \ - stockquote.test thesaurus.test translate.test urban.test \ - w3css.test w3html.test w3link.test w3rdf.test wayback.test \ - webster.test wetandwild.test wikipedia.test wolfram.test \ - woffle.test worldwidescience.test yacy.test yahoo.test \ - yandex.test youtube.test yubnub.test +EXTRA_DIST = runtests elviwithouttests README COOKIES W.test S.test \ + acronym.test ads.test alioth.test amazon.test archpkg.test \ + archwiki.test arxiv.test ask.test aur.test austlii.test \ + bbcnews.test bing.test bookfinder.test bugmenot.test \ + bugzilla.test cia.test cisco.test cite.test cliki.test cnn.test \ + comlaw.test commandlinefu.test ctan.test currency.test cve.test \ + debbugs.test debcodesearch.test debcontents.test deblists.test \ + deblogs.test debpackages.test debpkghome.test debpts.test \ + debsec.test debvcsbrowse.test debwiki.test deja.test discogs.test \ + duckduckgo.test ebay.test etym.test excite.test f5.test \ + finkpkg.test foldoc.test freebsd.test freedb.test freshmeat.test \ + fsfdir.test gcache.test genbugs.test genportage.test github.test \ + gmane.test google.test gutenberg.test imdb.test ixquick.test \ + jamendo.test javasun.test jquery.test lastfm.test leodict.test \ + l1sp.test lsm.test macports.test mathworld.test mdn.test \ + mininova.test musicbrainz.test mysqldoc.test netbsd.test \ + nlab.test ntrs.test openbsd.test oraclesearch.test pgdoc.test \ + phpdoc.test pin.test piratebay.test pgpkeys.test priberam.test \ + pubmed.test rae.test rfc.test scholar.test scpan.test searx.test \ + slashdot.test slinuxdoc.test sourceforge.test springer.test \ + stack.test stockquote.test thesaurus.test translate.test \ + urban.test w3css.test w3html.test w3link.test w3rdf.test \ + wayback.test webster.test wikipedia.test wiktionary.test \ + wolfram.test woffle.test worldwidescience.test yahoo.test \ + yandex.test youtube.test test: ./runtests ./elviwithouttests
JNRowe/surfraw
414468dbf102fa5cb9b42b4fec6d360182e1f784
Mark Meyer's patch to select Perl version at build
diff --git a/Makefile.am b/Makefile.am index ffd469a..b929c17 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,138 +1,139 @@ SUBDIRS = elvi test examples bin_SCRIPTS = surfraw surfraw-update-path if OPENSEARCH dist_bin_SCRIPTS = opensearch-discover opensearch-genquery endif devel_extra = banner prebuild if BASHCOMPLETIONS noinst_DATA = surfraw.bookmarks else noinst_DATA = surfraw.bookmarks surfraw-bash-completion endif man_MANS = surfraw-update-path.1 surfraw.1 elvi.1sr if OPENSEARCH man_MANS += opensearch-discover.1 opensearch-genquery.1 endif debian_extra = debian/NEWS debian/README.Debian debian/changelog debian/compat debian/control \ debian/copyright debian/docs debian/postrm debian/rules debian/source/format \ debian/surfraw-extra.files debian/surfraw-extra.install debian/watch EXTRA_DIST = surfraw.lsm.in surfraw.IN surfraw-update-path.IN\ surfraw.spec.in aclocal.m4 HACKING \ surfraw.1.IN elvi.1sr.IN surfraw.bookmarks links.IN \ surfraw-bash-completion.IN surfraw.conf.IN \ $(devel_extra) $(debian_extra) CLEANFILES = surfraw surfraw-update-path surfraw-update-path.1 surfraw.spec surfraw.lsm \ surfraw.1 elvi.1sr links surfraw-bash-completion surfraw.conf surfraw.1 \ elvi.1sr opensearch-discover.1 opensearch-genquery.1 BUILT_SOURCES = surfraw.conf # we cannot portably combine single suffix rules and separated dependencies # so we have to explicitly specify all the .IN rules surfraw: surfraw.IN -rm -f $@ [email protected] sed -e 's,@VERSION\@,${VERSION},g; '\ -e 's,@ELVIDIR\@,${ELVIDIR},g; '\ -e 's,@AWK\@,${AWK},g; '\ + -e 's,@PERL\@,${PERL},g; '\ -e 's,@sysconfdir\@,${sysconfdir},g ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw.conf: surfraw.conf.IN -rm -f $@ [email protected] sed -e 's,@prefix\@,${prefix},g; '\ -e 's,@TEXTBROWSER\@,${TEXTBROWSER},g; '\ -e 's,@GRAPHICALBROWSER\@,${GRAPHICALBROWSER},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-update-path: surfraw-update-path.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-bash-completion: surfraw-bash-completion.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ elvi.1sr: elvi.1sr.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw.1: surfraw.1.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; '\ -e 's,@sysconfdir\@,${sysconfdir},g' $? > [email protected] chmod +x [email protected] mv [email protected] $@ links: links.IN -rm -f $@ [email protected] sed -e 's,@mandir\@,${mandir},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-update-path.1: surfraw-update-path -rm -f $@ pod2man $? > $@ opensearch-discover.1: opensearch-discover -rm -f $@ pod2man $? > $@ opensearch-genquery.1: opensearch-genquery -rm -f $@ pod2man $? > $@ install-data-hook: links surfraw-bash-completion chmod -x surfraw.conf elvi.1sr surfraw.1 mkdir -p $(DESTDIR)@sysconfdir@/xdg/surfraw cp surfraw.conf $(DESTDIR)@sysconfdir@/xdg/surfraw/conf cp $(top_srcdir)/surfraw.bookmarks $(DESTDIR)@sysconfdir@/xdg/surfraw/bookmarks while read target link ;\ do \ ln -sf $$target $(DESTDIR)/$$link ;\ done < links if INSTALLSR ln -sf surfraw $(DESTDIR)/@bindir@/sr ln -sf surfraw.1.gz $(DESTDIR)/@mandir@/man1/sr.1.gz endif if BASHCOMPLETIONS mkdir -p $(DESTDIR)@sysconfdir@/bash_completion.d @cp $(top_srcdir)/surfraw-bash-completion $(DESTDIR)@sysconfdir@/bash_completion.d/surfraw endif uninstall-local: links -rm -f $(DESTDIR)@sysconfdir@/xdg/surfraw/conf -rm -f $(DESTDIR)@sysconfdir@/xdg/surfraw/bookmarks rmdir $(DESTDIR)@sysconfdir@/xdg/surfraw 2>/dev/null rmdir $(DESTDIR)@sysconfdir@/xdg 2>/dev/null while read target link ;\ do \ rm -f $(DESTDIR)/$$link ;\ done < links if INSTALLSR rm -f $(DESTDIR)/@bindir@/sr rm -f $(DESTDIR)/@mandir@/man1/sr.1.gz endif if BASHCOMPLETIONS -rm -f $(DESTDIR)@sysconfdir@/bash_completion.d/surfraw endif submit-lsm: surfraw.lsm mail -s add [email protected] < $? test: all surfraw.conf make -C test test .PHONY: test diff --git a/configure.in b/configure.in index d457430..c2dbe1f 100644 --- a/configure.in +++ b/configure.in @@ -1,65 +1,67 @@ dnl $Id$ dnl Process this file with autoconf to produce a configure script. dnl This is the only place where the package version appears dnl (apart from changelogs & NEWS) AC_INIT(surfraw, 2.2.9) AC_PREREQ(2.54) AC_CONFIG_SRCDIR([surfraw.IN]) dnl minimum automake version, not surfraw version AM_INIT_AUTOMAKE([1.10]) AC_MSG_CHECKING([whether to enable local OpenSearch support]) AC_ARG_ENABLE([opensearch], [AS_HELP_STRING([--disable-opensearch], [disable local OpenSearch support])],, [enable_opensearch=yes]) AC_MSG_RESULT([$enable_opensearch]) AM_CONDITIONAL(OPENSEARCH, test "$enable_opensearch" = "yes") AC_MSG_CHECKING([wether to install Bash completions]) AC_ARG_ENABLE([bash-completions], [AS_HELP_STRING([--disable-bash-completions], [disable Bash completions support])],, [enable_bashcompletions=yes]) AC_MSG_RESULT([$enable_bashcompletions]) AM_CONDITIONAL(BASHCOMPLETIONS, test "$enable_bashcompletions" = "yes") AC_MSG_CHECKING([whether to install sr alias]) AC_ARG_ENABLE([sr], [AS_HELP_STRING([--disable-sr], [disable sr alias])],, [enable_sr=yes]) AC_MSG_RESULT([$enable_sr]) AM_CONDITIONAL(INSTALLSR, test "$enable_sr" = "yes") ELVIDIR="\$(libdir)/surfraw" AC_CHECK_PROGS(TEXTBROWSER, lynx links2 links elinks w3m netrik) AC_CHECK_PROGS(GRAPHICALBROWSER, iceweasel firefox google-chrome opera mozilla \ xombrero luakit safari epiphany-browser konqueror galeon kazenhakase \ conkeror dillo netscape chromium chrome) AC_ARG_WITH([elvidir], [AS_HELP_STRING([--with-elvidir=ELVIDIR], [specify location of elvi])], [if test -n "$withval" && test "$withval" != "no" ; then ELVIDIR="$withval";fi]) AC_ARG_WITH([text-browser], [AS_HELP_STRING([--with-text-browser=BROWSER], [specify default text browser])], [if test -n "$withval" && test "$withval" != "no" ; then TEXTBROWSER="$withval";fi]) AC_ARG_WITH([graphical-browser], [AS_HELP_STRING([--with-graphical-browser=BROWSER], [specify default graphical browser])], [if test -n "$withval" && test "$withval" != "no" ; then GRAPHICALBROWSER="$withval";fi]) AC_SUBST(ELVIDIR) AC_SUBST(VERSION) AC_SUBST(TEXTBROWSER) AC_SUBST(GRAPHICALBROWSER) ISODATE=`date +%Y-%m-%d` AC_SUBST(ISODATE) dnl Checks for programs. AC_PROG_INSTALL AC_PROG_AWK +AC_PATH_PROG([PERL], [perl], [perl]) +AC_SUBST(PERL) AC_CONFIG_FILES([Makefile surfraw.lsm surfraw.spec elvi/Makefile test/Makefile examples/Makefile]) AC_OUTPUT diff --git a/surfraw.IN b/surfraw.IN index 8471216..756a474 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,675 +1,676 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2013 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=`basename "$0"` elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { base="$1" local conf OIFS conf="" if test -n "$XDG_CONFIG_DIRS"; then OIFS="$IFS" IFS=: set $XDG_CONFIG_DIRS IFS="$OIFS" for i in "$@"; do if test -r "$i/surfraw/$base"; then conf="$i/surfraw/$base" break fi done elif test -r "@sysconfdir@/xdg/surfraw/$base"; then # XDG default conf="@sysconfdir@/xdg/surfraw/$base" elif test -r "@sysconfdir@/surfraw.$base"; then # old surfraw default conf="@sysconfdir@/surfraw.$base" fi echo "$conf" } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value=\$${1} case `echo "$value" | tr A-Z a-z` in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value=\$${1} test -z "$value" || return 0 eval ${1}="$2" return 0 } defyn () { eval value=\$${1} test -z "$value" && eval ${1}="$2" yesno "$1" } setopt () { eval value=\$${1} eval ${1}="$2" } setoptyn () { eval value=\$${1} eval ${1}="$2" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi - perl -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" + @PERL@ -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" + } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { local_dir="$1" awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=`echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//'` esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="`quote "$arg"`" else w3_shquoted_args="$w3_shquoted_args `quote "$arg"`" fi if ok SURFRAW_quote_ifs then arg=`quote_ifs "$arg"` fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test `echo $TERM | cut -c 1-6` = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=`echo "$1"|sed "s/'/'\\\\\''/g"` echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then case "$arg" in -help | --help |-h) do_help=1 ;; -local-help | \ --local-help | \ -lh | -\? ) do_help=1 ; setoptyn SURFRAW_local_help yes ;; -elvi*) w3_parse_option -elvi; exit 0 ;; esac fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="`quote "$arg"`" unquoted_opts="$arg" else opts="$opts `quote "$arg"`" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="`quote "$arg"`" unquoted_searchterms="$arg" else searchterms="$searchterms `quote "$arg"`" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then
JNRowe/surfraw
ad8e7d2547b2263992afff2f14eef45bac0afe9c
ng0's patch to include bash completions
diff --git a/Makefile.am b/Makefile.am index e0a3e22..ffd469a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,128 +1,138 @@ SUBDIRS = elvi test examples bin_SCRIPTS = surfraw surfraw-update-path if OPENSEARCH dist_bin_SCRIPTS = opensearch-discover opensearch-genquery endif devel_extra = banner prebuild -noinst_DATA = surfraw-bash-completion surfraw.bookmarks +if BASHCOMPLETIONS +noinst_DATA = surfraw.bookmarks +else +noinst_DATA = surfraw.bookmarks surfraw-bash-completion +endif man_MANS = surfraw-update-path.1 surfraw.1 elvi.1sr if OPENSEARCH man_MANS += opensearch-discover.1 opensearch-genquery.1 endif debian_extra = debian/NEWS debian/README.Debian debian/changelog debian/compat debian/control \ debian/copyright debian/docs debian/postrm debian/rules debian/source/format \ debian/surfraw-extra.files debian/surfraw-extra.install debian/watch EXTRA_DIST = surfraw.lsm.in surfraw.IN surfraw-update-path.IN\ surfraw.spec.in aclocal.m4 HACKING \ surfraw.1.IN elvi.1sr.IN surfraw.bookmarks links.IN \ surfraw-bash-completion.IN surfraw.conf.IN \ $(devel_extra) $(debian_extra) CLEANFILES = surfraw surfraw-update-path surfraw-update-path.1 surfraw.spec surfraw.lsm \ surfraw.1 elvi.1sr links surfraw-bash-completion surfraw.conf surfraw.1 \ elvi.1sr opensearch-discover.1 opensearch-genquery.1 BUILT_SOURCES = surfraw.conf # we cannot portably combine single suffix rules and separated dependencies # so we have to explicitly specify all the .IN rules surfraw: surfraw.IN -rm -f $@ [email protected] sed -e 's,@VERSION\@,${VERSION},g; '\ -e 's,@ELVIDIR\@,${ELVIDIR},g; '\ -e 's,@AWK\@,${AWK},g; '\ -e 's,@sysconfdir\@,${sysconfdir},g ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw.conf: surfraw.conf.IN -rm -f $@ [email protected] sed -e 's,@prefix\@,${prefix},g; '\ -e 's,@TEXTBROWSER\@,${TEXTBROWSER},g; '\ -e 's,@GRAPHICALBROWSER\@,${GRAPHICALBROWSER},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-update-path: surfraw-update-path.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-bash-completion: surfraw-bash-completion.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ elvi.1sr: elvi.1sr.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw.1: surfraw.1.IN -rm -f $@ [email protected] sed -e 's,@ELVIDIR\@,${ELVIDIR},g; '\ -e 's,@sysconfdir\@,${sysconfdir},g' $? > [email protected] chmod +x [email protected] mv [email protected] $@ links: links.IN -rm -f $@ [email protected] sed -e 's,@mandir\@,${mandir},g; ' $? > [email protected] chmod +x [email protected] mv [email protected] $@ surfraw-update-path.1: surfraw-update-path -rm -f $@ pod2man $? > $@ opensearch-discover.1: opensearch-discover -rm -f $@ pod2man $? > $@ opensearch-genquery.1: opensearch-genquery -rm -f $@ pod2man $? > $@ -install-data-hook: links +install-data-hook: links surfraw-bash-completion chmod -x surfraw.conf elvi.1sr surfraw.1 mkdir -p $(DESTDIR)@sysconfdir@/xdg/surfraw cp surfraw.conf $(DESTDIR)@sysconfdir@/xdg/surfraw/conf cp $(top_srcdir)/surfraw.bookmarks $(DESTDIR)@sysconfdir@/xdg/surfraw/bookmarks while read target link ;\ do \ ln -sf $$target $(DESTDIR)/$$link ;\ done < links if INSTALLSR ln -sf surfraw $(DESTDIR)/@bindir@/sr ln -sf surfraw.1.gz $(DESTDIR)/@mandir@/man1/sr.1.gz endif +if BASHCOMPLETIONS + mkdir -p $(DESTDIR)@sysconfdir@/bash_completion.d + @cp $(top_srcdir)/surfraw-bash-completion $(DESTDIR)@sysconfdir@/bash_completion.d/surfraw +endif uninstall-local: links -rm -f $(DESTDIR)@sysconfdir@/xdg/surfraw/conf -rm -f $(DESTDIR)@sysconfdir@/xdg/surfraw/bookmarks rmdir $(DESTDIR)@sysconfdir@/xdg/surfraw 2>/dev/null rmdir $(DESTDIR)@sysconfdir@/xdg 2>/dev/null while read target link ;\ do \ rm -f $(DESTDIR)/$$link ;\ done < links if INSTALLSR rm -f $(DESTDIR)/@bindir@/sr rm -f $(DESTDIR)/@mandir@/man1/sr.1.gz endif - +if BASHCOMPLETIONS + -rm -f $(DESTDIR)@sysconfdir@/bash_completion.d/surfraw +endif submit-lsm: surfraw.lsm mail -s add [email protected] < $? test: all surfraw.conf make -C test test .PHONY: test diff --git a/configure.in b/configure.in index 5101510..d457430 100644 --- a/configure.in +++ b/configure.in @@ -1,58 +1,65 @@ dnl $Id$ dnl Process this file with autoconf to produce a configure script. dnl This is the only place where the package version appears dnl (apart from changelogs & NEWS) AC_INIT(surfraw, 2.2.9) AC_PREREQ(2.54) AC_CONFIG_SRCDIR([surfraw.IN]) dnl minimum automake version, not surfraw version AM_INIT_AUTOMAKE([1.10]) AC_MSG_CHECKING([whether to enable local OpenSearch support]) AC_ARG_ENABLE([opensearch], [AS_HELP_STRING([--disable-opensearch], [disable local OpenSearch support])],, [enable_opensearch=yes]) AC_MSG_RESULT([$enable_opensearch]) AM_CONDITIONAL(OPENSEARCH, test "$enable_opensearch" = "yes") +AC_MSG_CHECKING([wether to install Bash completions]) +AC_ARG_ENABLE([bash-completions], + [AS_HELP_STRING([--disable-bash-completions], [disable Bash completions support])],, + [enable_bashcompletions=yes]) +AC_MSG_RESULT([$enable_bashcompletions]) +AM_CONDITIONAL(BASHCOMPLETIONS, test "$enable_bashcompletions" = "yes") + AC_MSG_CHECKING([whether to install sr alias]) AC_ARG_ENABLE([sr], [AS_HELP_STRING([--disable-sr], [disable sr alias])],, [enable_sr=yes]) AC_MSG_RESULT([$enable_sr]) AM_CONDITIONAL(INSTALLSR, test "$enable_sr" = "yes") ELVIDIR="\$(libdir)/surfraw" AC_CHECK_PROGS(TEXTBROWSER, lynx links2 links elinks w3m netrik) AC_CHECK_PROGS(GRAPHICALBROWSER, iceweasel firefox google-chrome opera mozilla \ xombrero luakit safari epiphany-browser konqueror galeon kazenhakase \ conkeror dillo netscape chromium chrome) AC_ARG_WITH([elvidir], [AS_HELP_STRING([--with-elvidir=ELVIDIR], [specify location of elvi])], [if test -n "$withval" && test "$withval" != "no" ; then ELVIDIR="$withval";fi]) AC_ARG_WITH([text-browser], [AS_HELP_STRING([--with-text-browser=BROWSER], [specify default text browser])], [if test -n "$withval" && test "$withval" != "no" ; then TEXTBROWSER="$withval";fi]) AC_ARG_WITH([graphical-browser], [AS_HELP_STRING([--with-graphical-browser=BROWSER], [specify default graphical browser])], [if test -n "$withval" && test "$withval" != "no" ; then GRAPHICALBROWSER="$withval";fi]) AC_SUBST(ELVIDIR) AC_SUBST(VERSION) AC_SUBST(TEXTBROWSER) AC_SUBST(GRAPHICALBROWSER) ISODATE=`date +%Y-%m-%d` AC_SUBST(ISODATE) dnl Checks for programs. AC_PROG_INSTALL AC_PROG_AWK AC_CONFIG_FILES([Makefile surfraw.lsm surfraw.spec elvi/Makefile test/Makefile examples/Makefile]) AC_OUTPUT
JNRowe/surfraw
571cfff8537dae5730d7d1146658f943ad8eb9e5
Remove lynx-cur as per Bug#882286
diff --git a/debian/control b/debian/control index 993c998..c97e1e4 100644 --- a/debian/control +++ b/debian/control @@ -1,66 +1,66 @@ Source: surfraw Section: web Priority: optional Maintainer: Debian surfraw maintainers <[email protected]> Uploaders: Christian Surchi <[email protected]>, Ian Beckwith <[email protected]> Standards-Version: 3.9.5 Build-Depends: debhelper (>= 7) Vcs-Git: git://anonscm.debian.org/surfraw/surfraw.git Vcs-Browser: http://anonscm.debian.org/gitweb/?p=surfraw/surfraw.git Homepage: http://surfraw.alioth.debian.org Package: surfraw Architecture: all Depends: ${misc:Depends}, lynx | www-browser Recommends: surfraw-extra (>> 2.2.7-1), links | elinks | elinks-lite | w3m, curl | wget | libwww-perl Breaks: surfraw-extra (<= 2.2.7-1) Suggests: screen Description: fast unix command line interface to WWW Surfraw - Shell Users' Revolutionary Front Rage Against the World Wide Web . Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. . Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with incremental text browsers, such as links, w3m (or even lynx), and screen(1), or netscape-remote a Surfraw liberateur is capable of research speeds that leave GUI tainted idolaters agape with fear and wonder. Package: surfraw-extra Architecture: all Depends: surfraw, ${misc:Depends}, lynx | www-browser, libwww-opensearch-perl, libwww-perl, libhtml-parser-perl -Recommends: links | elinks | elinks-lite | w3m | w3m-ssl | lynx-cur +Recommends: links | elinks | elinks-lite | w3m | w3m-ssl Suggests: screen Breaks: surfraw (<< 2.1.7) Description: extra surfraw search tools with heavy dependencies surfraw-extra contains extra website search tools for surfraw that have large dependency trees. Currently surfraw-extra only contains support tools for the opensearch elvi: . opensearch-discover - find an opensearch link from a URL. opensearch-genquery - construct a search URL from an opensearch description . Surfraw - Shell Users' Revolutionary Front Rage Against the World Wide Web . Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. . Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with incremental text browsers, such as links, w3m (or even lynx), and screen(1), or netscape-remote a Surfraw liberateur is capable of research speeds that leave GUI tainted idolaters agape with fear and wonder.
JNRowe/surfraw
2476f5bc4c4ba5ac40d35fb25385504237cc107b
Delicious is defunkt
diff --git a/README b/README index 0af577d..312bd10 100644 --- a/README +++ b/README @@ -1,390 +1,389 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Home Page: http://surfraw.alioth.debian.org ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web New: http://surfraw.alioth.debian.org Old: http://surfraw.sourceforge.net/ Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS Surfraw now supports bookmarks. To add a bookmark, add it to to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/rhyme -method=perfect Julian OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) -deli -- Search Delicious bookmarks discogs -- Search the Discogs database of music information (www.discogs.com) duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) oraclesearch -- Search an OpenSearch-enabled website pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) scholar -- Search Google Scholar (scholar.google.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) wikipedia -- Search the free encyclopedia wikipedia woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) All elvi have useful low calorie help, for example: Usage: rhyme [options] [search words]... Description: Surfraw search for rhymes and other word correlations using Lycos Rhyme (rhyme.lycos.com) Example: $ rhyme Julian $ rhyme -method=rel surfer Results: Hurclean St. Julien. surfboarder, bather, natator, swimmer Local options: -method= Type of word correlation to search for prefect | Perfect rhyme syn | Synonyms hom | Homophones cons | Consonsant rhymes only rel | Semantically related words sub | Phrases spell | Similar spellings pic | Pictures shake | Match with Shakespeare archives def Find wordnet definition Default: perfect Environment: SURFRAW_rhyme_method Global options: -browser=EXECUTABLE Set browser Default: sensible-browser -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: yes Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: yes Environment: SURFRAW_graphical -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: no Environment: SURFRAW_new_window -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: no Environment: SURFRAW_quote_args -version Display Surfraw version (2.2.7) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________ diff --git a/elvi/Makefile.am b/elvi/Makefile.am index 855cee8..d554014 100644 --- a/elvi/Makefile.am +++ b/elvi/Makefile.am @@ -1,120 +1,119 @@ # $Id$ elvidir=$(ELVIDIR) dist_elvi_SCRIPTS = \ S \ W \ acronym \ ads \ alioth \ amazon \ archpkg \ archwiki \ arxiv \ ask \ aur \ austlii \ bing \ bbcnews \ bookfinder \ bugmenot \ bugzilla \ cia \ cisco \ cite \ cliki \ cnn \ comlaw \ commandlinefu \ ctan \ currency \ cve \ debbugs \ debcodesearch \ debcontents \ deblists \ deblogs \ debpackages \ debpkghome \ debpts \ debsec \ debvcsbrowse \ debwiki \ deja \ - deli \ discogs \ duckduckgo \ ebay \ etym \ excite \ f5 \ foldoc \ finkpkg \ freebsd \ freedb \ freshmeat \ fsfdir \ gcache \ genbugs \ genportage \ github \ gmane \ google \ gutenberg \ imdb \ ixquick \ jamendo \ javasun \ jquery \ l1sp \ lastfm \ leodict \ lsm \ macports \ mathworld \ mdn \ mininova \ musicbrainz \ mysqldoc \ netbsd \ nlab \ ntrs \ openbsd \ oraclesearch \ pgdoc \ pgpkeys \ phpdoc \ pin \ piratebay \ priberam \ pubmed \ rae \ rfc \ scholar \ scpan \ searx \ slashdot \ slinuxdoc \ sourceforge \ springer \ stack \ stockquote \ thesaurus \ translate \ urban \ w3css \ w3html \ w3link \ w3rdf \ wayback \ webster \ wikipedia \ woffle \ wolfram \ worldwidescience \ yahoo \ yandex \ youtube uninstall-local: -rmdir $(DESTDIR)$(PREFIX)/$(ELVIDIR) diff --git a/elvi/deli b/elvi/deli deleted file mode 100755 index 96ffe8f..0000000 --- a/elvi/deli +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# elvis: deli -- Search Delicious bookmarks -# Author: jason ryan • http://jasonwryan.com - -. surfraw || exit 1 - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [search-string] -Description: Search Delicious bookmarks (del.icio.us) - -EOF - w3_global_usage -} - -w3_config -w3_parse_args "$@" -# w3_args now contains list of arguments - -# standard topic seach -if [ -z "$w3_args" ]; then - w3_browse_url "https://www.del.icio.us/" -else - escaped_args=$(w3_url_of_arg $w3_args) - w3_browse_url "https://del.icio.us/search?p=${escaped_args}" -fi diff --git a/links.IN b/links.IN index 3033e19..ae53c84 100644 --- a/links.IN +++ b/links.IN @@ -1,108 +1,107 @@ elvi.1sr.gz @mandir@/man1/W.1.gz elvi.1sr.gz @mandir@/man1/S.1sr.gz elvi.1sr.gz @mandir@/man1/acronym.1sr.gz elvi.1sr.gz @mandir@/man1/ads.1sr.gz elvi.1sr.gz @mandir@/man1/alioth.1sr.gz elvi.1sr.gz @mandir@/man1/amazon.1sr.gz elvi.1sr.gz @mandir@/man1/archpkg.1sr.gz elvi.1sr.gz @mandir@/man1/archwiki.1sr.gz elvi.1sr.gz @mandir@/man1/arxiv.1sr.gz elvi.1sr.gz @mandir@/man1/ask.1sr.gz elvi.1sr.gz @mandir@/man1/aur.1sr.gz elvi.1sr.gz @mandir@/man1/austlii.1sr.gz elvi.1sr.gz @mandir@/man1/bing.1sr.gz elvi.1sr.gz @mandir@/man1/bbcnews.1sr.gz elvi.1sr.gz @mandir@/man1/bookfinder.1sr.gz elvi.1sr.gz @mandir@/man1/bugmenot.1sr.gz elvi.1sr.gz @mandir@/man1/bugzilla.1sr.gz elvi.1sr.gz @mandir@/man1/cite.1sr.gz elvi.1sr.gz @mandir@/man1/cia.1sr.gz elvi.1sr.gz @mandir@/man1/cliki.1sr.gz elvi.1sr.gz @mandir@/man1/cnn.1sr.gz elvi.1sr.gz @mandir@/man1/comlaw.1sr.gz elvi.1sr.gz @mandir@/man1/commandlinefu.1sr.gz elvi.1sr.gz @mandir@/man1/ctan.1sr.gz elvi.1sr.gz @mandir@/man1/currency.1sr.gz elvi.1sr.gz @mandir@/man1/cve.1sr.gz elvi.1sr.gz @mandir@/man1/debbugs.1sr.gz elvi.1sr.gz @mandir@/man1/debcodesearch.1sr.gz elvi.1sr.gz @mandir@/man1/debcontents.1sr.gz elvi.1sr.gz @mandir@/man1/deblists.1sr.gz elvi.1sr.gz @mandir@/man1/deblogs.1sr.gz elvi.1sr.gz @mandir@/man1/debpackages.1sr.gz elvi.1sr.gz @mandir@/man1/debpkghome.1sr.gz elvi.1sr.gz @mandir@/man1/debpts.1sr.gz elvi.1sr.gz @mandir@/man1/debsec.1sr.gz elvi.1sr.gz @mandir@/man1/debvcsbrowse.1sr.gz elvi.1sr.gz @mandir@/man1/debwiki.1sr.gz elvi.1sr.gz @mandir@/man1/deja.1sr.gz -elvi.1sr.gz @mandir@/man1/deli.1sr.gz elvi.1sr.gz @mandir@/man1/discogs.1sr.gz elvi.1sr.gz @mandir@/man1/duckduckgo.1sr.gz elvi.1sr.gz @mandir@/man1/ebay.1sr.gz elvi.1sr.gz @mandir@/man1/etym.1sr.gz elvi.1sr.gz @mandir@/man1/excite.1sr.gz elvi.1sr.gz @mandir@/man1/finkpkg.1sr.gz elvi.1sr.gz @mandir@/man1/foldoc.1sr.gz elvi.1sr.gz @mandir@/man1/freebsd.1sr.gz elvi.1sr.gz @mandir@/man1/freedb.1sr.gz elvi.1sr.gz @mandir@/man1/freshmeat.1sr.gz elvi.1sr.gz @mandir@/man1/fsfdir.1sr.gz elvi.1sr.gz @mandir@/man1/gcache.1sr.gz elvi.1sr.gz @mandir@/man1/genbugs.1sr.gz elvi.1sr.gz @mandir@/man1/genportage.1sr.gz elvi.1sr.gz @mandir@/man1/github.1sr.gz elvi.1sr.gz @mandir@/man1/google.1sr.gz elvi.1sr.gz @mandir@/man1/gutenberg.1sr.gz elvi.1sr.gz @mandir@/man1/imdb.1sr.gz elvi.1sr.gz @mandir@/man1/ixquick.1sr.gz elvi.1sr.gz @mandir@/man1/jamendo.1sr.gz elvi.1sr.gz @mandir@/man1/javasun.1sr.gz elvi.1sr.gz @mandir@/man1/lastfm.1sr.gz elvi.1sr.gz @mandir@/man1/leodict.1sr.gz elvi.1sr.gz @mandir@/man1/l1sp.1sr.gz elvi.1sr.gz @mandir@/man1/lsm.1sr.gz elvi.1sr.gz @mandir@/man1/macports.1sr.gz elvi.1sr.gz @mandir@/man1/mathworld.1sr.gz elvi.1sr.gz @mandir@/man1/mdn.1sr.gz elvi.1sr.gz @mandir@/man1/mininova.1sr.gz elvi.1sr.gz @mandir@/man1/musicbrainz.1sr.gz elvi.1sr.gz @mandir@/man1/mysqldoc.1sr.gz elvi.1sr.gz @mandir@/man1/netbsd.1sr.gz elvi.1sr.gz @mandir@/man1/ntrs.1sr.gz elvi.1sr.gz @mandir@/man1/openbsd.1sr.gz elvi.1sr.gz @mandir@/man1/oraclesearch.1sr.gz elvi.1sr.gz @mandir@/man1/pgdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pgpkeys.1sr.gz elvi.1sr.gz @mandir@/man1/phpdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pin.1sr.gz elvi.1sr.gz @mandir@/man1/piratebay.1sr.gz elvi.1sr.gz @mandir@/man1/priberam.1sr.gz elvi.1sr.gz @mandir@/man1/pubmed.1sr.gz elvi.1sr.gz @mandir@/man1/rae.1sr.gz elvi.1sr.gz @mandir@/man1/rfc.1sr.gz elvi.1sr.gz @mandir@/man1/scholar.1sr.gz elvi.1sr.gz @mandir@/man1/scpan.1sr.gz elvi.1sr.gz @mandir@/man1/searx.1sr.gz elvi.1sr.gz @mandir@/man1/slashdot.1sr.gz elvi.1sr.gz @mandir@/man1/slinuxdoc.1sr.gz elvi.1sr.gz @mandir@/man1/sourceforge.1sr.gz elvi.1sr.gz @mandir@/man1/springer.1sr.gz elvi.1sr.gz @mandir@/man1/stack.1sr.gz elvi.1sr.gz @mandir@/man1/stockquote.1sr.gz elvi.1sr.gz @mandir@/man1/thesaurus.1sr.gz elvi.1sr.gz @mandir@/man1/translate.1sr.gz elvi.1sr.gz @mandir@/man1/urban.1sr.gz elvi.1sr.gz @mandir@/man1/w3css.1sr.gz elvi.1sr.gz @mandir@/man1/w3html.1sr.gz elvi.1sr.gz @mandir@/man1/w3link.1sr.gz elvi.1sr.gz @mandir@/man1/w3rdf.1sr.gz elvi.1sr.gz @mandir@/man1/wayback.1sr.gz elvi.1sr.gz @mandir@/man1/webster.1sr.gz elvi.1sr.gz @mandir@/man1/wikipedia.1sr.gz elvi.1sr.gz @mandir@/man1/woffle.1sr.gz elvi.1sr.gz @mandir@/man1/wolfram.1sr.gz elvi.1sr.gz @mandir@/man1/worldwidescience.1sr.gz elvi.1sr.gz @mandir@/man1/yahoo.1sr.gz elvi.1sr.gz @mandir@/man1/yandex.1sr.gz elvi.1sr.gz @mandir@/man1/youtube.1sr.gz diff --git a/test/deli.test b/test/deli.test deleted file mode 100644 index 1c09ea8..0000000 --- a/test/deli.test +++ /dev/null @@ -1 +0,0 @@ -SKIP: needs javascript
JNRowe/surfraw
e9f76cc73e88f6b8b8ee09d49df23ff30505e016
Tidied up last of the https move
diff --git a/ChangeLog b/ChangeLog index f5bd63a..fdd55b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,517 +1,534 @@ +2017-07-14 Jason Ryan <[email protected]> + + * Moved all elvi to https + * Removed elvi that don't support https: + - cablesearch + - dmoz + - openports + - opensearch + - pasearch + - rhyme + - rpmsearch + - scicom + - scirus + - wetandwild + - yacy + - yubnub + 2015-09-13 Kyle Isom <[email protected]> * use awk instead of sed for listing elvi - This provides better cross-platform behaviour. + This provides better cross-platform behaviour. 2015-08-23 Jason Ryan <[email protected]> * new elvi: searx 2014-09-20 Lucas Hoffmann <l-m-h at web.de> * new elvi: commandlinefu 2104-06-04 Jason Ryan <[email protected]> * new elvi: nlab 2013-12-10 Ian Beckwith <[email protected]> * yandex: disabled test: redirects to captcha when used with LWP. * Fix make distcheck: remove last traces of codesearch and scitopia. 2013-12-09 Ian Beckwith <[email protected]> * deja: disable tests, google groups now requires javascript. * gmane: fix test. * codesearch: removed, service shut down. * scitopia: removed, service shut down. * scicom: down, status unknown, made note in NEWS. 2013-12-08 Ian Beckwith <[email protected]> * new elvi: gmane * openbsd -mail: use gmane (directly, not via gmane elvi) * fix tests: ads, pgdoc, pin, yacy 2013-10-27 Ian Beckwith <[email protected]> * surfraw.IN: w3_custom_search_google: don't give full path to surfraw. * pgdoc, wayback: fixed tests. 2013-10-20 Ian Beckwith <[email protected]> * new elvi: yacy: search using yacy p2p search. -S searches ScienceNet, a yacy-based science search engine. * rae: fix url, remove -tipo option (no longer supported), disable test as there is now gratuitous javascript. 2013-10-06 Ian Beckwith <[email protected]> * Replaced phpdoc with version posted back in 2011 by Jon Yamokoski <[email protected]> Thanks, and apologies for missing it! * S: add test. * Include debian packaging in upstream tarball. 2013-10-05 Ian Beckwith <[email protected]> * ask, cisco: fix elvi. * new elvi: + oraclesearch - Replaces removed sunonesearch <sigh>. + S - search using w3_custom_search. * google: -g for groups clashed with -g for graphical browser. Invoke groups with -G, -gr, -groups or -search=groups. * mdn: site invokes google custom search via gratuitous javascript, so switch to w3_custom_search. * alioth: changed test to SKIP:, works OK but won't talk to LWP, hence test breaks. * discogs, openbsd: fixed tests. * mdn, mysqldoc, pgdoc, phpdoc: added tests. * w3_custom_search: + document in README. + remove documentation for ixquick support. It still works(ish), but doesn't support enough features to support (eg) mysqldoc -v=. + add -custom-search= commandline option. * updated copyright years to 2013. 2013-09-30 Ian Beckwith <[email protected]> * new elvi: mdn, mysqldoc, pgdoc, phpdoc * new function: w3_custom_search Is used by elvi that use a generic search engine with (eg) site: or inurl: to narrow down the search. Pass it -s=site -u=url for site: and inurl: args plus the quoted search args * new environment variable: SURFRAW_customsearch_provider to set provider used by w3_custom_search can be set to: google, duckduckgo or ixquick. Currently affects: mysqldoc, netbsd(*), openbsd(*), pgdoc, phpdoc, mysqldoc. (*) = only used by some options of elvi. * new internal variable w3_shquoted_args, contains arguments 'quoted' 'like this' for passing to w3_custom_search * Fixed url-encoding for '\' 2013-05-07 Ian Beckwith <[email protected]> * new elvi: jquery 2013-05-04 Ian Beckwith <[email protected]> * bump version to 2.2.9 * rae: fixed, at least as far as the test passing. Could really do with some love from someone who actually speaks spanish. * ctan: fixed search, updated options. Note command-line options have changed. * genportage: switch to gpo.zugaina.org * debcodesearch: new (trivial) elvi for codesearch.debian.net * jamendo: fix url, disable test (search now javascript) * deli: fix url; remove options; disable test (search now javascript) 2013-04-28 Ian Beckwith <[email protected]> * musicbrainz: fixed mbid search. * springer: fixed test. 2013-04-27 Ian Beckwith <[email protected]> * javasun: fixed test. 2013-04-24 Ian Beckwith <[email protected]> * Rewrote deblists for new xapian search. + -author, -lists, -lang no longer supported. + added -ml and -mv to show message id links and list view. * Removed happypenguin. Currently defunct and they are talking about a rewrite, so when it is back it will need fixing anyway. 2012-10-22 Ian Beckwith <[email protected]> * Fixed elvi: cisco, slashdot, slinuxdoc. * Removed elvi: scroogle (site gone). * Fixed tests: acronym, bbcnews, bugzilla, cisco, cite[1], currency, discogs, excite, fsfdir, gcache, github, imdb, ixquick, lastfm, leodict, openbsd[2], scholar. * test/Makefile.am: Added missing tests to EXTRA_DIST 2012-06-28 Manolo Martínez <[email protected]> * examples/hooks.lua: Added elinks integration script 2012-06-28 Ivy Foster <[email protected]> * Further simplified searchable bookmarks 2012-06-28 Thomas Zervogiannis <[email protected]> * Simplified searchable bookmarks 2012-06-27 Ivy Foster <[email protected]> * Fixed arg parsing in searchable bookmarks * New variable: SURFRAW_bookmark_search_elvis + When using searchable bookmarks, if all else fails run this elvis. Defaults to google * Updated manual to reflect changes to bookmarks * duckduckgo: Removed -p option. -safe still works. + Prevents clobbering global option -p[rint]. 2012-06-27 Thomas Zervogiannis <[email protected]> * Added searchable bookmarks + Bookmarks can now be searchable by adding '%s' to the url string. 2012-06-01 Jason Ryan <[email protected]> * New elvi: github (search github.com) 2012-03-17 Ivy Foster <[email protected]> * Fix a typo in duckduckgo code. 2012-03-17 Ivy Foster <[email protected]> * Keep duckduckgo's -l[ucky] from clobbering -lh 2012-01-10 Ivy Foster <[email protected]> * aur: now uses HTTPS by default + On the AUR, connecting via HTTP disables login. + Added switch -no-https to enable connection via plain HTTP 2011-10-10 Ian Beckwith <[email protected]> * surfraw.IN: test_elvi(): tweak sed regex * add tests for f5, cisco and pin. 2011-10-10 Shain Singh <[email protected]> * New elvi: f5, cisco 2011-10-10 Jason Ryan <[email protected]> * New elvi: pin (search pinboard.in). 2011-09-09 Kyle Isom <[email protected]> * New elvi: wolfram - query Wolfram Alpha * Author: Kyle Isom <[email protected]> * Added test for wolfram. 2011-08-09 Ian Beckwith <[email protected]> * New elvi: priberam - search Portuguese dictionary. Author: Paulo Almeida <[email protected]> * Added test for priberam. 2011-07-11 Ian Beckwith <[email protected]> * netbsd: fix normal & mail search. google custom searches were complaining I was a bot, so I switched to normal google searches with site:{mail-index,}.netbsd.org. * cia: fix search URL 2011-06-17 Ian Beckwith <[email protected]> * arxiv: fix -scope=author with single-word queries. Thanks to Nikos Apostolakis. * btw, note about entry below, netbsd make *does* support '$<', but only in suffix rules. 2011-06-16 Ian Beckwith <[email protected]> * Fix more make(1) portability problems. Either I am horribly confused or netbsd make (or at least pmake in debian) doesn't support '$<'. Switched to '$?'. * Also switched submit-lsm rule to '$?'. Thanks to Kyle Isom. * Removed long-obsolete commented-out sourceforge upload rules. 2011-06-15 Ian Beckwith <[email protected]> * scitopia, worldwidescience: fixed URLs. * Fixed make portability problems. We cannot portably combine single suffix rules (foo.IN->foo) and separated dependencies so we have to explicitly specify all the .IN rules. The solution we used for this until now was specific to GNU make. * Removed Makefile.include, no longer used. * './configure --enable-opensearch' now only controls installation of the (direct) dependencies for opensearch, not opensearch itself, as opensearch now falls back to using a remote reflector if opensearch-discover(1) and opensearch-genquery(1) aren't found. * yandex: fix test. 2011-06-14 Ian Beckwith <[email protected]> * musicbrainz, codesearch, rpmsearch: Fixed URLs, options and tests. The sites have all changed significantly which means both new options and no-longer-supported options. Codesearch has gone all ajaxy, so I've implemented the options via the search string, e.g. adding " package:foo". Disabled codesearch.test, as it now needs javascript. Codesearch on both google.com and google.co.uk was acting up, so I've pointed it at google.fr. * Removed filesearching elvi, it now requires a 'Referer:' header to work. There is no browser-portable way to specify a 'Refer[r]er:' header, plus we should probably take it as a hint. * Tweaked debian packaging. * Updated NEWS. 2011-06-13 Ian Beckwith <[email protected]> * w3link: fixed URLs. 2011-06-10 Ian Beckwith <[email protected]> * Fixed ctan. Option -doc has been replaced by -id. Options are no longer mutually exclusive, you can now do (eg) ctan -d -i -n texlive. 2011-06-09 Ian Beckwith <[email protected]> * fixed tests: debwiki, ntrs, wayback. 2011-06-07 Ian Beckwith <[email protected]> * Default to surfraw_graphical_remote=no, as chromium doesn't support "-remote openURL". 2011-05-31 Jason Ryan <[email protected]> * Add options to archpkg. 2011-05-12 Sara Fauzia <[email protected]> * Fix archpkg URL. 2011-05-12 Ian Beckwith <[email protected]> * surfraw.IN: + if elvi doesn't exist, send usage to stderr not stdout. + bookmark names: do exact match not substring match. * Added tests for archwiki, deli & stack. * README: + added INTEGRATION section on uzbl and pentadactyl. + upcased section headings for clarity. 2011-05-12 Jason Ryan <[email protected]> * New elvi: + archwiki: search the arch wiki. + deli: search delicious.com. + stack: search stackoverflow.com and friends. 2011-03-21 Ian Beckwith <[email protected]> * google: Added -safe=default|off|moderate|strict option for Safe Search. 2011-03-21 Ivy Foster <[email protected]> * Added Google Translate to elvi/translate. 2011-03-03 Ian Beckwith <[email protected]> * opensearch: new option -r, uses redirector at http://erislabs.net/ianb/webtools/opensearch/ instead of calling opensearch-discover and opensearch-genquery. -r is selected automatically if those tools are not installed. This enables us to ship opensearch in the main surfraw package and it still functions if the dependencies are not installed. See debian/changelog. * wikipedia: new options: + -d, uses a redirector at http://erislabs.net/ianb/webtools/wpdp/ This redirector searches for a page with that name at wikipedia. If not found, it searches deletionpedia, if not found there it falls back to a normal wikipedia search. + -f=w|d, -fallback=wikipedia|deletionpedia Implies -d. If page not found at either wikipedia or deletionpedia, whether to fallback to wikipedia search or deletionpedia search. * google: + support video, maps and news. + new options -i, -v, -m, -n, shortcuts for -search={images,videos,maps,news}. * debcontents, debpackages: update docs for new arches and distributions. * bugzilla: + fix url so it works with redhat & eclipse bugzillas too. + enable -s=redhat. * ixquick, w3css: fix tests. * opensearch, wikipedia: add redirector tests. 2011-02-20 Ian Beckwith <[email protected]> * New elvi: bugzilla - searches various bugzillas, defaults to kernel. * pgpkeys: add more options, support more keyservers, default to sks-keyservers.net. * bump version to 2.2.8. * test/Makefile.am: add cablesearch.test. 2011-02-19 Ian Beckwith <[email protected]> * lastfm: fix url to avoid a redirect that mangled args with spaces. * debbugs: add -s as an alias for -search=src. * surfraw.IN: (finally) update copyright year to 2011. * remove traces of port elvi from build system. 2011-02-09 Kyle Isom <[email protected]> * fix a number of tests to match current site formats 2011-01-12 Kyle Isom <[email protected]> * New elvi: + cablesearch - search wikileaks cables + duckduckgo - replace with better implementation + openports - search openbsd ports 2010-12-04 Jakob <[email protected]> * new elvis: pasearch. 2010-12-08 Ian Beckwith <[email protected]> * arxiv: Thanks to MT <[email protected]> for patch that fixes: 1. Search queries with more than two terms would fail, e.g. 'supermassive black hole'. 2. Full text search was broken, it works now. 3. Enhancement: quoting the query now does an exact string match. 2010-10-29 Ian Beckwith <[email protected]> * wayback: advanced search is broken, rip out all options and use basic search. * w3_url_escape: add /g to '/'->'%2F' replacement. * uzbl_load_url_from_surfraw: use @AWK@ to pick up ./configure's choice of awk implementation. 2010-10-28 Ian Beckwith <[email protected]> * Support -local-help, --local-help or -lh to get elvi-specific help without displaying the global options. This works for all elvi and the main surfraw script. * google, duckduckgo, opensearch, wayback: tweak overbroad option parsing so it doesn't interfere with -lh. * Support -h as a synonym for -help. 2010-10-25 Ian Beckwith <[email protected]> * new elvi: scirus, scitopia, worldwidescience. * yahoo: reduced query string to just p and n options. * openbsd: support -misc and -tech. Thanks to Sunil Nimmagadda for the patch. * removed cddb: gracenote made the "hard decision" to remove the website search. sigh. * removed altavista: is now just a front-end to yahoo. * removed fast: another yahoo front-end. * imdb: fix test. * javasun: oracleized URLs. * w3link: fixed URL. 2010-08-22 Jameson Rollins <[email protected]> * surfraw.IN: Improve listing of elvi. 2010-08-20 James Rowe <[email protected]> * new elvi: ads. Thanks to Jameson Rollins. 2010-07-02 Ian Beckwith <[email protected]> * new elvi: yandex. Thanks to Uspenskiy Andrey. 2010-05-06 Ian Beckwith <[email protected]> * uzbl_load_url_from_surfraw: fix menu. Thanks to Sumant Oemrawsingh. * Fixed tests: deblists google openbsd. 2010-04-28 Ian Beckwith <[email protected]> * configure.in: test for google-chrome, opera and links2. 2010-04-22 Ian Beckwith <[email protected]> * debwiki: remove -w, Debian Women wiki is now being merged into main wiki. Thanks to Simone Fittabile. * debwiki.test: stop testing -w option. * surfraw.IN: change an awk to @AWK@. 2010-04-21 Ian Beckwith <[email protected]> * New elvi: jamendo - Search Jamendo: free music with Creative Commons licenses (www.jamendo.com). Thanks to Simone Fittabile. * wikipedia, ixquick: Support https. Thanks to Simone Fittabile. * wikipedia: tweak Simone's patch to support https for start page and document the SURFRAW_wikipedia_ssl variable. * ixquick: add -nossl option. * javasun.test: revert to previous test, works again. 2010-04-19 James Rowe <[email protected]> * genpkg: removed, use genportage. 2010-04-16 Ian Beckwith <[email protected]> * New elvi: + scroogle: Search Google anonymously via www.scroogle.org. + duckduckgo: Search the web via duckduckgo.com. * Fix tests: excite, javasun, musicbrainz, yahoo. 2010-03-03 James Rowe <[email protected]> * bookfinder: fix ISBN search test. 2010-03-01 Ian Beckwith <[email protected]> * Removed autotools-generated files from git repo use ./prebuild to regenerate. * Lower required automake version to 1.10. * prebuild: try and find a sane set of autotools, then call autoreconf -vi * Add autotools-generated files to .gitignore * Bump version to 2.2.7 * cnn: fix URL. * cnn.test: Disable. Bloody CNN now needs javascript for search, so should be tested manually. * W, yahoo: fix tests. * Remove unused '-quiet' option. * Update AUTHORS. * Add a note to appendix 1 of HACKING about updating AUTHORS. * runtests: explicitly use elvi and config from source tree, now works when surfraw is not installed (but you need to have run make). * test/Makefile.am: fix bookfinder typo, add bing.test. * remove leading 'sr ' from command lines for following tests: acronym aur bing cliki gcache genportage google javasun l1sp lsm mathworld mininova piratebay youtube * HACKING, README, test/README: document autotools and test suite changes. * Makefile.am: add surfraw.conf to BUILT_SOURCES so it is made by 'make'. This may be a misuse of BUILT_SOURCES. 2010-02-22 Ivy Foster <[email protected]> * Added `-ns|-newscreen' switch for setting $SURFRAW_new_screen. 2010-02-15 James Rowe <[email protected]> * elvi/imdb: Fixes for upstream search changes. Thanks to Sadako. * New elvi: bookfinder, thanks to Ivy Foster. 2010-02-14 James Rowe <[email protected]> diff --git a/README b/README index cec4b81..0af577d 100644 --- a/README +++ b/README @@ -1,400 +1,390 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Home Page: http://surfraw.alioth.debian.org ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web New: http://surfraw.alioth.debian.org Old: http://surfraw.sourceforge.net/ Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS Surfraw now supports bookmarks. To add a bookmark, add it to to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/rhyme -method=perfect Julian OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) deli -- Search Delicious bookmarks discogs -- Search the Discogs database of music information (www.discogs.com) duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) -openports -- search openports for OpenBSD packages -opensearch -- Search an OpenSearch-enabled website oraclesearch -- Search an OpenSearch-enabled website -pasearch -- Search the unofficial Penny Arcade archives (pipefour.org/pa) pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) -rhyme -- Search for rhymes et al using Lycos Rhyme (rhyme.lycos.com) -rpmsearch -- Search for RPMs in various distros scholar -- Search Google Scholar (scholar.google.com) -scicom -- Search Scientific Commons -scirus -- Search for science using Scirus (scirus.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) -wetandwild -- Real time weather information (many sources) wikipedia -- Search the free encyclopedia wikipedia woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org -yacy -- Search YaCy P2P search, including ScienceNet yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) -yubnub -- Use the social command-line for the web (yubnub.org) All elvi have useful low calorie help, for example: Usage: rhyme [options] [search words]... Description: Surfraw search for rhymes and other word correlations using Lycos Rhyme (rhyme.lycos.com) Example: $ rhyme Julian $ rhyme -method=rel surfer Results: Hurclean St. Julien. surfboarder, bather, natator, swimmer Local options: -method= Type of word correlation to search for prefect | Perfect rhyme syn | Synonyms hom | Homophones cons | Consonsant rhymes only rel | Semantically related words sub | Phrases spell | Similar spellings pic | Pictures shake | Match with Shakespeare archives def Find wordnet definition Default: perfect Environment: SURFRAW_rhyme_method Global options: -browser=EXECUTABLE Set browser Default: sensible-browser -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: yes Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: yes Environment: SURFRAW_graphical -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: no Environment: SURFRAW_new_window -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: no Environment: SURFRAW_quote_args -version Display Surfraw version (2.2.7) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________ diff --git a/elvi/Makefile.am b/elvi/Makefile.am index fa399a0..855cee8 100644 --- a/elvi/Makefile.am +++ b/elvi/Makefile.am @@ -1,130 +1,120 @@ # $Id$ elvidir=$(ELVIDIR) dist_elvi_SCRIPTS = \ S \ W \ acronym \ ads \ alioth \ amazon \ archpkg \ archwiki \ arxiv \ ask \ aur \ austlii \ bing \ bbcnews \ bookfinder \ bugmenot \ bugzilla \ cia \ cisco \ cite \ cliki \ cnn \ comlaw \ commandlinefu \ ctan \ currency \ cve \ debbugs \ debcodesearch \ debcontents \ deblists \ deblogs \ debpackages \ debpkghome \ debpts \ debsec \ debvcsbrowse \ debwiki \ deja \ deli \ discogs \ duckduckgo \ ebay \ etym \ excite \ f5 \ foldoc \ finkpkg \ freebsd \ freedb \ freshmeat \ fsfdir \ gcache \ genbugs \ genportage \ github \ gmane \ google \ gutenberg \ imdb \ ixquick \ jamendo \ javasun \ jquery \ l1sp \ lastfm \ leodict \ lsm \ macports \ mathworld \ mdn \ mininova \ musicbrainz \ mysqldoc \ netbsd \ nlab \ ntrs \ openbsd \ - openports \ - opensearch \ oraclesearch \ - pasearch \ pgdoc \ pgpkeys \ phpdoc \ pin \ piratebay \ priberam \ pubmed \ rae \ rfc \ - rhyme \ - rpmsearch \ scholar \ - scicom \ - scirus \ scpan \ searx \ slashdot \ slinuxdoc \ sourceforge \ springer \ stack \ stockquote \ thesaurus \ translate \ urban \ w3css \ w3html \ w3link \ w3rdf \ wayback \ webster \ - wetandwild \ wikipedia \ woffle \ wolfram \ worldwidescience \ - yacy \ yahoo \ yandex \ - youtube \ - yubnub + youtube uninstall-local: -rmdir $(DESTDIR)$(PREFIX)/$(ELVIDIR) diff --git a/links.IN b/links.IN index 6c3f555..3033e19 100644 --- a/links.IN +++ b/links.IN @@ -1,118 +1,108 @@ elvi.1sr.gz @mandir@/man1/W.1.gz elvi.1sr.gz @mandir@/man1/S.1sr.gz elvi.1sr.gz @mandir@/man1/acronym.1sr.gz elvi.1sr.gz @mandir@/man1/ads.1sr.gz elvi.1sr.gz @mandir@/man1/alioth.1sr.gz elvi.1sr.gz @mandir@/man1/amazon.1sr.gz elvi.1sr.gz @mandir@/man1/archpkg.1sr.gz elvi.1sr.gz @mandir@/man1/archwiki.1sr.gz elvi.1sr.gz @mandir@/man1/arxiv.1sr.gz elvi.1sr.gz @mandir@/man1/ask.1sr.gz elvi.1sr.gz @mandir@/man1/aur.1sr.gz elvi.1sr.gz @mandir@/man1/austlii.1sr.gz elvi.1sr.gz @mandir@/man1/bing.1sr.gz elvi.1sr.gz @mandir@/man1/bbcnews.1sr.gz elvi.1sr.gz @mandir@/man1/bookfinder.1sr.gz elvi.1sr.gz @mandir@/man1/bugmenot.1sr.gz elvi.1sr.gz @mandir@/man1/bugzilla.1sr.gz elvi.1sr.gz @mandir@/man1/cite.1sr.gz elvi.1sr.gz @mandir@/man1/cia.1sr.gz elvi.1sr.gz @mandir@/man1/cliki.1sr.gz elvi.1sr.gz @mandir@/man1/cnn.1sr.gz elvi.1sr.gz @mandir@/man1/comlaw.1sr.gz elvi.1sr.gz @mandir@/man1/commandlinefu.1sr.gz elvi.1sr.gz @mandir@/man1/ctan.1sr.gz elvi.1sr.gz @mandir@/man1/currency.1sr.gz elvi.1sr.gz @mandir@/man1/cve.1sr.gz elvi.1sr.gz @mandir@/man1/debbugs.1sr.gz elvi.1sr.gz @mandir@/man1/debcodesearch.1sr.gz elvi.1sr.gz @mandir@/man1/debcontents.1sr.gz elvi.1sr.gz @mandir@/man1/deblists.1sr.gz elvi.1sr.gz @mandir@/man1/deblogs.1sr.gz elvi.1sr.gz @mandir@/man1/debpackages.1sr.gz elvi.1sr.gz @mandir@/man1/debpkghome.1sr.gz elvi.1sr.gz @mandir@/man1/debpts.1sr.gz elvi.1sr.gz @mandir@/man1/debsec.1sr.gz elvi.1sr.gz @mandir@/man1/debvcsbrowse.1sr.gz elvi.1sr.gz @mandir@/man1/debwiki.1sr.gz elvi.1sr.gz @mandir@/man1/deja.1sr.gz elvi.1sr.gz @mandir@/man1/deli.1sr.gz elvi.1sr.gz @mandir@/man1/discogs.1sr.gz elvi.1sr.gz @mandir@/man1/duckduckgo.1sr.gz elvi.1sr.gz @mandir@/man1/ebay.1sr.gz elvi.1sr.gz @mandir@/man1/etym.1sr.gz elvi.1sr.gz @mandir@/man1/excite.1sr.gz elvi.1sr.gz @mandir@/man1/finkpkg.1sr.gz elvi.1sr.gz @mandir@/man1/foldoc.1sr.gz elvi.1sr.gz @mandir@/man1/freebsd.1sr.gz elvi.1sr.gz @mandir@/man1/freedb.1sr.gz elvi.1sr.gz @mandir@/man1/freshmeat.1sr.gz elvi.1sr.gz @mandir@/man1/fsfdir.1sr.gz elvi.1sr.gz @mandir@/man1/gcache.1sr.gz elvi.1sr.gz @mandir@/man1/genbugs.1sr.gz elvi.1sr.gz @mandir@/man1/genportage.1sr.gz elvi.1sr.gz @mandir@/man1/github.1sr.gz elvi.1sr.gz @mandir@/man1/google.1sr.gz elvi.1sr.gz @mandir@/man1/gutenberg.1sr.gz elvi.1sr.gz @mandir@/man1/imdb.1sr.gz elvi.1sr.gz @mandir@/man1/ixquick.1sr.gz elvi.1sr.gz @mandir@/man1/jamendo.1sr.gz elvi.1sr.gz @mandir@/man1/javasun.1sr.gz elvi.1sr.gz @mandir@/man1/lastfm.1sr.gz elvi.1sr.gz @mandir@/man1/leodict.1sr.gz elvi.1sr.gz @mandir@/man1/l1sp.1sr.gz elvi.1sr.gz @mandir@/man1/lsm.1sr.gz elvi.1sr.gz @mandir@/man1/macports.1sr.gz elvi.1sr.gz @mandir@/man1/mathworld.1sr.gz elvi.1sr.gz @mandir@/man1/mdn.1sr.gz elvi.1sr.gz @mandir@/man1/mininova.1sr.gz elvi.1sr.gz @mandir@/man1/musicbrainz.1sr.gz elvi.1sr.gz @mandir@/man1/mysqldoc.1sr.gz elvi.1sr.gz @mandir@/man1/netbsd.1sr.gz elvi.1sr.gz @mandir@/man1/ntrs.1sr.gz elvi.1sr.gz @mandir@/man1/openbsd.1sr.gz -elvi.1sr.gz @mandir@/man1/openports.1sr.gz -elvi.1sr.gz @mandir@/man1/opensearch.1sr.gz elvi.1sr.gz @mandir@/man1/oraclesearch.1sr.gz -elvi.1sr.gz @mandir@/man1/pasearch.1sr.gz elvi.1sr.gz @mandir@/man1/pgdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pgpkeys.1sr.gz elvi.1sr.gz @mandir@/man1/phpdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pin.1sr.gz elvi.1sr.gz @mandir@/man1/piratebay.1sr.gz elvi.1sr.gz @mandir@/man1/priberam.1sr.gz elvi.1sr.gz @mandir@/man1/pubmed.1sr.gz elvi.1sr.gz @mandir@/man1/rae.1sr.gz elvi.1sr.gz @mandir@/man1/rfc.1sr.gz -elvi.1sr.gz @mandir@/man1/rhyme.1sr.gz -elvi.1sr.gz @mandir@/man1/rpmsearch.1sr.gz elvi.1sr.gz @mandir@/man1/scholar.1sr.gz -elvi.1sr.gz @mandir@/man1/scicom.1sr.gz -elvi.1sr.gz @mandir@/man1/scirus.1sr.gz elvi.1sr.gz @mandir@/man1/scpan.1sr.gz elvi.1sr.gz @mandir@/man1/searx.1sr.gz elvi.1sr.gz @mandir@/man1/slashdot.1sr.gz elvi.1sr.gz @mandir@/man1/slinuxdoc.1sr.gz elvi.1sr.gz @mandir@/man1/sourceforge.1sr.gz elvi.1sr.gz @mandir@/man1/springer.1sr.gz elvi.1sr.gz @mandir@/man1/stack.1sr.gz elvi.1sr.gz @mandir@/man1/stockquote.1sr.gz elvi.1sr.gz @mandir@/man1/thesaurus.1sr.gz elvi.1sr.gz @mandir@/man1/translate.1sr.gz elvi.1sr.gz @mandir@/man1/urban.1sr.gz elvi.1sr.gz @mandir@/man1/w3css.1sr.gz elvi.1sr.gz @mandir@/man1/w3html.1sr.gz elvi.1sr.gz @mandir@/man1/w3link.1sr.gz elvi.1sr.gz @mandir@/man1/w3rdf.1sr.gz elvi.1sr.gz @mandir@/man1/wayback.1sr.gz elvi.1sr.gz @mandir@/man1/webster.1sr.gz -elvi.1sr.gz @mandir@/man1/wetandwild.1sr.gz elvi.1sr.gz @mandir@/man1/wikipedia.1sr.gz elvi.1sr.gz @mandir@/man1/woffle.1sr.gz elvi.1sr.gz @mandir@/man1/wolfram.1sr.gz elvi.1sr.gz @mandir@/man1/worldwidescience.1sr.gz -elvi.1sr.gz @mandir@/man1/yacy.1sr.gz elvi.1sr.gz @mandir@/man1/yahoo.1sr.gz elvi.1sr.gz @mandir@/man1/yandex.1sr.gz elvi.1sr.gz @mandir@/man1/youtube.1sr.gz -elvi.1sr.gz @mandir@/man1/yubnub.1sr.gz
JNRowe/surfraw
2e0ef038979ccb64b3700d583de94265c8e87b30
Added new elvis: wiktionary
diff --git a/ChangeLog b/ChangeLog index f5bd63a..133c678 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,512 +1,516 @@ +2017-06-07 Jason Ryan <[email protected]> + + * new elvi: wiktionary + 2015-09-13 Kyle Isom <[email protected]> * use awk instead of sed for listing elvi This provides better cross-platform behaviour. 2015-08-23 Jason Ryan <[email protected]> * new elvi: searx 2014-09-20 Lucas Hoffmann <l-m-h at web.de> * new elvi: commandlinefu 2104-06-04 Jason Ryan <[email protected]> * new elvi: nlab 2013-12-10 Ian Beckwith <[email protected]> * yandex: disabled test: redirects to captcha when used with LWP. * Fix make distcheck: remove last traces of codesearch and scitopia. 2013-12-09 Ian Beckwith <[email protected]> * deja: disable tests, google groups now requires javascript. * gmane: fix test. * codesearch: removed, service shut down. * scitopia: removed, service shut down. * scicom: down, status unknown, made note in NEWS. 2013-12-08 Ian Beckwith <[email protected]> * new elvi: gmane * openbsd -mail: use gmane (directly, not via gmane elvi) * fix tests: ads, pgdoc, pin, yacy 2013-10-27 Ian Beckwith <[email protected]> * surfraw.IN: w3_custom_search_google: don't give full path to surfraw. * pgdoc, wayback: fixed tests. 2013-10-20 Ian Beckwith <[email protected]> * new elvi: yacy: search using yacy p2p search. -S searches ScienceNet, a yacy-based science search engine. * rae: fix url, remove -tipo option (no longer supported), disable test as there is now gratuitous javascript. 2013-10-06 Ian Beckwith <[email protected]> * Replaced phpdoc with version posted back in 2011 by Jon Yamokoski <[email protected]> Thanks, and apologies for missing it! * S: add test. * Include debian packaging in upstream tarball. 2013-10-05 Ian Beckwith <[email protected]> * ask, cisco: fix elvi. * new elvi: + oraclesearch - Replaces removed sunonesearch <sigh>. + S - search using w3_custom_search. * google: -g for groups clashed with -g for graphical browser. Invoke groups with -G, -gr, -groups or -search=groups. * mdn: site invokes google custom search via gratuitous javascript, so switch to w3_custom_search. * alioth: changed test to SKIP:, works OK but won't talk to LWP, hence test breaks. * discogs, openbsd: fixed tests. * mdn, mysqldoc, pgdoc, phpdoc: added tests. * w3_custom_search: + document in README. + remove documentation for ixquick support. It still works(ish), but doesn't support enough features to support (eg) mysqldoc -v=. + add -custom-search= commandline option. * updated copyright years to 2013. 2013-09-30 Ian Beckwith <[email protected]> * new elvi: mdn, mysqldoc, pgdoc, phpdoc * new function: w3_custom_search Is used by elvi that use a generic search engine with (eg) site: or inurl: to narrow down the search. Pass it -s=site -u=url for site: and inurl: args plus the quoted search args * new environment variable: SURFRAW_customsearch_provider to set provider used by w3_custom_search can be set to: google, duckduckgo or ixquick. Currently affects: mysqldoc, netbsd(*), openbsd(*), pgdoc, phpdoc, mysqldoc. (*) = only used by some options of elvi. * new internal variable w3_shquoted_args, contains arguments 'quoted' 'like this' for passing to w3_custom_search * Fixed url-encoding for '\' 2013-05-07 Ian Beckwith <[email protected]> * new elvi: jquery 2013-05-04 Ian Beckwith <[email protected]> * bump version to 2.2.9 * rae: fixed, at least as far as the test passing. Could really do with some love from someone who actually speaks spanish. * ctan: fixed search, updated options. Note command-line options have changed. * genportage: switch to gpo.zugaina.org * debcodesearch: new (trivial) elvi for codesearch.debian.net * jamendo: fix url, disable test (search now javascript) * deli: fix url; remove options; disable test (search now javascript) 2013-04-28 Ian Beckwith <[email protected]> * musicbrainz: fixed mbid search. * springer: fixed test. 2013-04-27 Ian Beckwith <[email protected]> * javasun: fixed test. 2013-04-24 Ian Beckwith <[email protected]> * Rewrote deblists for new xapian search. + -author, -lists, -lang no longer supported. + added -ml and -mv to show message id links and list view. * Removed happypenguin. Currently defunct and they are talking about a rewrite, so when it is back it will need fixing anyway. 2012-10-22 Ian Beckwith <[email protected]> * Fixed elvi: cisco, slashdot, slinuxdoc. * Removed elvi: scroogle (site gone). * Fixed tests: acronym, bbcnews, bugzilla, cisco, cite[1], currency, discogs, excite, fsfdir, gcache, github, imdb, ixquick, lastfm, leodict, openbsd[2], scholar. * test/Makefile.am: Added missing tests to EXTRA_DIST 2012-06-28 Manolo Martínez <[email protected]> * examples/hooks.lua: Added elinks integration script 2012-06-28 Ivy Foster <[email protected]> * Further simplified searchable bookmarks 2012-06-28 Thomas Zervogiannis <[email protected]> * Simplified searchable bookmarks 2012-06-27 Ivy Foster <[email protected]> * Fixed arg parsing in searchable bookmarks * New variable: SURFRAW_bookmark_search_elvis + When using searchable bookmarks, if all else fails run this elvis. Defaults to google * Updated manual to reflect changes to bookmarks * duckduckgo: Removed -p option. -safe still works. + Prevents clobbering global option -p[rint]. 2012-06-27 Thomas Zervogiannis <[email protected]> * Added searchable bookmarks + Bookmarks can now be searchable by adding '%s' to the url string. 2012-06-01 Jason Ryan <[email protected]> * New elvi: github (search github.com) 2012-03-17 Ivy Foster <[email protected]> * Fix a typo in duckduckgo code. 2012-03-17 Ivy Foster <[email protected]> * Keep duckduckgo's -l[ucky] from clobbering -lh 2012-01-10 Ivy Foster <[email protected]> * aur: now uses HTTPS by default + On the AUR, connecting via HTTP disables login. + Added switch -no-https to enable connection via plain HTTP 2011-10-10 Ian Beckwith <[email protected]> * surfraw.IN: test_elvi(): tweak sed regex * add tests for f5, cisco and pin. 2011-10-10 Shain Singh <[email protected]> * New elvi: f5, cisco 2011-10-10 Jason Ryan <[email protected]> * New elvi: pin (search pinboard.in). 2011-09-09 Kyle Isom <[email protected]> * New elvi: wolfram - query Wolfram Alpha * Author: Kyle Isom <[email protected]> * Added test for wolfram. 2011-08-09 Ian Beckwith <[email protected]> * New elvi: priberam - search Portuguese dictionary. Author: Paulo Almeida <[email protected]> * Added test for priberam. 2011-07-11 Ian Beckwith <[email protected]> * netbsd: fix normal & mail search. google custom searches were complaining I was a bot, so I switched to normal google searches with site:{mail-index,}.netbsd.org. * cia: fix search URL 2011-06-17 Ian Beckwith <[email protected]> * arxiv: fix -scope=author with single-word queries. Thanks to Nikos Apostolakis. * btw, note about entry below, netbsd make *does* support '$<', but only in suffix rules. 2011-06-16 Ian Beckwith <[email protected]> * Fix more make(1) portability problems. Either I am horribly confused or netbsd make (or at least pmake in debian) doesn't support '$<'. Switched to '$?'. * Also switched submit-lsm rule to '$?'. Thanks to Kyle Isom. * Removed long-obsolete commented-out sourceforge upload rules. 2011-06-15 Ian Beckwith <[email protected]> * scitopia, worldwidescience: fixed URLs. * Fixed make portability problems. We cannot portably combine single suffix rules (foo.IN->foo) and separated dependencies so we have to explicitly specify all the .IN rules. The solution we used for this until now was specific to GNU make. * Removed Makefile.include, no longer used. * './configure --enable-opensearch' now only controls installation of the (direct) dependencies for opensearch, not opensearch itself, as opensearch now falls back to using a remote reflector if opensearch-discover(1) and opensearch-genquery(1) aren't found. * yandex: fix test. 2011-06-14 Ian Beckwith <[email protected]> * musicbrainz, codesearch, rpmsearch: Fixed URLs, options and tests. The sites have all changed significantly which means both new options and no-longer-supported options. Codesearch has gone all ajaxy, so I've implemented the options via the search string, e.g. adding " package:foo". Disabled codesearch.test, as it now needs javascript. Codesearch on both google.com and google.co.uk was acting up, so I've pointed it at google.fr. * Removed filesearching elvi, it now requires a 'Referer:' header to work. There is no browser-portable way to specify a 'Refer[r]er:' header, plus we should probably take it as a hint. * Tweaked debian packaging. * Updated NEWS. 2011-06-13 Ian Beckwith <[email protected]> * w3link: fixed URLs. 2011-06-10 Ian Beckwith <[email protected]> * Fixed ctan. Option -doc has been replaced by -id. Options are no longer mutually exclusive, you can now do (eg) ctan -d -i -n texlive. 2011-06-09 Ian Beckwith <[email protected]> * fixed tests: debwiki, ntrs, wayback. 2011-06-07 Ian Beckwith <[email protected]> * Default to surfraw_graphical_remote=no, as chromium doesn't support "-remote openURL". 2011-05-31 Jason Ryan <[email protected]> * Add options to archpkg. 2011-05-12 Sara Fauzia <[email protected]> * Fix archpkg URL. 2011-05-12 Ian Beckwith <[email protected]> * surfraw.IN: + if elvi doesn't exist, send usage to stderr not stdout. + bookmark names: do exact match not substring match. * Added tests for archwiki, deli & stack. * README: + added INTEGRATION section on uzbl and pentadactyl. + upcased section headings for clarity. 2011-05-12 Jason Ryan <[email protected]> * New elvi: + archwiki: search the arch wiki. + deli: search delicious.com. + stack: search stackoverflow.com and friends. 2011-03-21 Ian Beckwith <[email protected]> * google: Added -safe=default|off|moderate|strict option for Safe Search. 2011-03-21 Ivy Foster <[email protected]> * Added Google Translate to elvi/translate. 2011-03-03 Ian Beckwith <[email protected]> * opensearch: new option -r, uses redirector at http://erislabs.net/ianb/webtools/opensearch/ instead of calling opensearch-discover and opensearch-genquery. -r is selected automatically if those tools are not installed. This enables us to ship opensearch in the main surfraw package and it still functions if the dependencies are not installed. See debian/changelog. * wikipedia: new options: + -d, uses a redirector at http://erislabs.net/ianb/webtools/wpdp/ This redirector searches for a page with that name at wikipedia. If not found, it searches deletionpedia, if not found there it falls back to a normal wikipedia search. + -f=w|d, -fallback=wikipedia|deletionpedia Implies -d. If page not found at either wikipedia or deletionpedia, whether to fallback to wikipedia search or deletionpedia search. * google: + support video, maps and news. + new options -i, -v, -m, -n, shortcuts for -search={images,videos,maps,news}. * debcontents, debpackages: update docs for new arches and distributions. * bugzilla: + fix url so it works with redhat & eclipse bugzillas too. + enable -s=redhat. * ixquick, w3css: fix tests. * opensearch, wikipedia: add redirector tests. 2011-02-20 Ian Beckwith <[email protected]> * New elvi: bugzilla - searches various bugzillas, defaults to kernel. * pgpkeys: add more options, support more keyservers, default to sks-keyservers.net. * bump version to 2.2.8. * test/Makefile.am: add cablesearch.test. 2011-02-19 Ian Beckwith <[email protected]> * lastfm: fix url to avoid a redirect that mangled args with spaces. * debbugs: add -s as an alias for -search=src. * surfraw.IN: (finally) update copyright year to 2011. * remove traces of port elvi from build system. 2011-02-09 Kyle Isom <[email protected]> * fix a number of tests to match current site formats 2011-01-12 Kyle Isom <[email protected]> * New elvi: + cablesearch - search wikileaks cables + duckduckgo - replace with better implementation + openports - search openbsd ports 2010-12-04 Jakob <[email protected]> * new elvis: pasearch. 2010-12-08 Ian Beckwith <[email protected]> * arxiv: Thanks to MT <[email protected]> for patch that fixes: 1. Search queries with more than two terms would fail, e.g. 'supermassive black hole'. 2. Full text search was broken, it works now. 3. Enhancement: quoting the query now does an exact string match. 2010-10-29 Ian Beckwith <[email protected]> * wayback: advanced search is broken, rip out all options and use basic search. * w3_url_escape: add /g to '/'->'%2F' replacement. * uzbl_load_url_from_surfraw: use @AWK@ to pick up ./configure's choice of awk implementation. 2010-10-28 Ian Beckwith <[email protected]> * Support -local-help, --local-help or -lh to get elvi-specific help without displaying the global options. This works for all elvi and the main surfraw script. * google, duckduckgo, opensearch, wayback: tweak overbroad option parsing so it doesn't interfere with -lh. * Support -h as a synonym for -help. 2010-10-25 Ian Beckwith <[email protected]> * new elvi: scirus, scitopia, worldwidescience. * yahoo: reduced query string to just p and n options. * openbsd: support -misc and -tech. Thanks to Sunil Nimmagadda for the patch. * removed cddb: gracenote made the "hard decision" to remove the website search. sigh. * removed altavista: is now just a front-end to yahoo. * removed fast: another yahoo front-end. * imdb: fix test. * javasun: oracleized URLs. * w3link: fixed URL. 2010-08-22 Jameson Rollins <[email protected]> * surfraw.IN: Improve listing of elvi. 2010-08-20 James Rowe <[email protected]> * new elvi: ads. Thanks to Jameson Rollins. 2010-07-02 Ian Beckwith <[email protected]> * new elvi: yandex. Thanks to Uspenskiy Andrey. 2010-05-06 Ian Beckwith <[email protected]> * uzbl_load_url_from_surfraw: fix menu. Thanks to Sumant Oemrawsingh. * Fixed tests: deblists google openbsd. 2010-04-28 Ian Beckwith <[email protected]> * configure.in: test for google-chrome, opera and links2. 2010-04-22 Ian Beckwith <[email protected]> * debwiki: remove -w, Debian Women wiki is now being merged into main wiki. Thanks to Simone Fittabile. * debwiki.test: stop testing -w option. * surfraw.IN: change an awk to @AWK@. 2010-04-21 Ian Beckwith <[email protected]> * New elvi: jamendo - Search Jamendo: free music with Creative Commons licenses (www.jamendo.com). Thanks to Simone Fittabile. * wikipedia, ixquick: Support https. Thanks to Simone Fittabile. * wikipedia: tweak Simone's patch to support https for start page and document the SURFRAW_wikipedia_ssl variable. * ixquick: add -nossl option. * javasun.test: revert to previous test, works again. 2010-04-19 James Rowe <[email protected]> * genpkg: removed, use genportage. 2010-04-16 Ian Beckwith <[email protected]> * New elvi: + scroogle: Search Google anonymously via www.scroogle.org. + duckduckgo: Search the web via duckduckgo.com. * Fix tests: excite, javasun, musicbrainz, yahoo. 2010-03-03 James Rowe <[email protected]> * bookfinder: fix ISBN search test. 2010-03-01 Ian Beckwith <[email protected]> * Removed autotools-generated files from git repo use ./prebuild to regenerate. * Lower required automake version to 1.10. * prebuild: try and find a sane set of autotools, then call autoreconf -vi * Add autotools-generated files to .gitignore * Bump version to 2.2.7 * cnn: fix URL. * cnn.test: Disable. Bloody CNN now needs javascript for search, so should be tested manually. * W, yahoo: fix tests. * Remove unused '-quiet' option. * Update AUTHORS. * Add a note to appendix 1 of HACKING about updating AUTHORS. * runtests: explicitly use elvi and config from source tree, now works when surfraw is not installed (but you need to have run make). * test/Makefile.am: fix bookfinder typo, add bing.test. * remove leading 'sr ' from command lines for following tests: acronym aur bing cliki gcache genportage google javasun l1sp lsm mathworld mininova piratebay youtube * HACKING, README, test/README: document autotools and test suite changes. * Makefile.am: add surfraw.conf to BUILT_SOURCES so it is made by 'make'. This may be a misuse of BUILT_SOURCES. 2010-02-22 Ivy Foster <[email protected]> * Added `-ns|-newscreen' switch for setting $SURFRAW_new_screen. 2010-02-15 James Rowe <[email protected]> diff --git a/README b/README index da8cef4..89e47f3 100644 --- a/README +++ b/README @@ -1,402 +1,403 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Home Page: http://surfraw.alioth.debian.org ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web New: http://surfraw.alioth.debian.org Old: http://surfraw.sourceforge.net/ Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS Surfraw now supports bookmarks. To add a bookmark, add it to to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/rhyme -method=perfect Julian OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers cablesearch -- search for leaked diplomatic communications cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) deli -- Search Delicious bookmarks discogs -- Search the Discogs database of music information (www.discogs.com) dmoz -- Search the Open Directory Project web directory (dmoz.org) duckduckgo -- Securely search the web using duckduckgo (duckduckgo.com) ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) openports -- search openports for OpenBSD packages opensearch -- Search an OpenSearch-enabled website oraclesearch -- Search an OpenSearch-enabled website pasearch -- Search the unofficial Penny Arcade archives (pipefour.org/pa) pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) rhyme -- Search for rhymes et al using Lycos Rhyme (rhyme.lycos.com) rpmsearch -- Search for RPMs in various distros scholar -- Search Google Scholar (scholar.google.com) scicom -- Search Scientific Commons scirus -- Search for science using Scirus (scirus.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) wetandwild -- Real time weather information (many sources) wikipedia -- Search the free encyclopedia wikipedia +wiktionary -- Search the free multilingual dictionary (wiktionary.org) woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org yacy -- Search YaCy P2P search, including ScienceNet yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) yubnub -- Use the social command-line for the web (yubnub.org) All elvi have useful low calorie help, for example: Usage: rhyme [options] [search words]... Description: Surfraw search for rhymes and other word correlations using Lycos Rhyme (rhyme.lycos.com) Example: $ rhyme Julian $ rhyme -method=rel surfer Results: Hurclean St. Julien. surfboarder, bather, natator, swimmer Local options: -method= Type of word correlation to search for prefect | Perfect rhyme syn | Synonyms hom | Homophones cons | Consonsant rhymes only rel | Semantically related words sub | Phrases spell | Similar spellings pic | Pictures shake | Match with Shakespeare archives def Find wordnet definition Default: perfect Environment: SURFRAW_rhyme_method Global options: -browser=EXECUTABLE Set browser Default: sensible-browser -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: yes Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: yes Environment: SURFRAW_graphical -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: no Environment: SURFRAW_new_window -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: no Environment: SURFRAW_quote_args -version Display Surfraw version (2.2.7) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________ diff --git a/elvi/Makefile.am b/elvi/Makefile.am index 44527e2..325bea7 100644 --- a/elvi/Makefile.am +++ b/elvi/Makefile.am @@ -1,132 +1,133 @@ # $Id$ elvidir=$(ELVIDIR) dist_elvi_SCRIPTS = \ S \ W \ acronym \ ads \ alioth \ amazon \ archpkg \ archwiki \ arxiv \ ask \ aur \ austlii \ bing \ bbcnews \ bookfinder \ bugmenot \ bugzilla \ cablesearch \ cia \ cisco \ cite \ cliki \ cnn \ comlaw \ commandlinefu \ ctan \ currency \ cve \ debbugs \ debcodesearch \ debcontents \ deblists \ deblogs \ debpackages \ debpkghome \ debpts \ debsec \ debvcsbrowse \ debwiki \ deja \ deli \ discogs \ dmoz \ duckduckgo \ ebay \ etym \ excite \ f5 \ foldoc \ finkpkg \ freebsd \ freedb \ freshmeat \ fsfdir \ gcache \ genbugs \ genportage \ github \ gmane \ google \ gutenberg \ imdb \ ixquick \ jamendo \ javasun \ jquery \ l1sp \ lastfm \ leodict \ lsm \ macports \ mathworld \ mdn \ mininova \ musicbrainz \ mysqldoc \ netbsd \ nlab \ ntrs \ openbsd \ openports \ opensearch \ oraclesearch \ pasearch \ pgdoc \ pgpkeys \ phpdoc \ pin \ piratebay \ priberam \ pubmed \ rae \ rfc \ rhyme \ rpmsearch \ scholar \ scicom \ scirus \ scpan \ searx \ slashdot \ slinuxdoc \ sourceforge \ springer \ stack \ stockquote \ thesaurus \ translate \ urban \ w3css \ w3html \ w3link \ w3rdf \ wayback \ webster \ wetandwild \ wikipedia \ + wiktionary \ woffle \ wolfram \ worldwidescience \ yacy \ yahoo \ yandex \ youtube \ yubnub uninstall-local: -rmdir $(DESTDIR)$(PREFIX)/$(ELVIDIR) diff --git a/elvi/wiktionary b/elvi/wiktionary new file mode 100755 index 0000000..64716a4 --- /dev/null +++ b/elvi/wiktionary @@ -0,0 +1,54 @@ +#!/bin/sh +# elvis: wiktionary -- Search the free dictionary wiktionary +# $Id$ +# Author: jason ryan • http://jasonwryan.com + +. surfraw || exit 1 + +w3_config_hook () { +def SURFRAW_wiktionary_language "$SURFRAW_lang" +} + +w3_usage_hook () { + cat <<EOF +Usage: $w3_argv0 [options] [search-string] +Description: + Search the Wiktionary online dictionary + -language=ISOCODE | -l=ISOCODE Two letter language code (resembles ISO country codes) + Default: en + Environment: SURFRAW_wiktionary_language, SURFRAW_lang +Examples: + $w3_argv0 -language=de synecdoche +EOF + w3_global_usage +} + +w3_parse_option_hook () { + opt="$1" + optarg="$2" + case "$opt" in + -language=*) setopt SURFRAW_wiktionary_language $optarg ;; + -l=*) setopt SURFRAW_wiktionary_language $optarg ;; + *) return 1 ;; + esac + return 0 +} + +w3_config +# disable requoting, doesn't work with this elvi. +#SURFRAW_quote_ifs=0 +w3_parse_args "$@" + +if [ -z "$SURFRAW_wiktionary_language" ]; then + SURFRAW_wiktionary_language="en" +fi + +prefix="${SURFRAW_wiktionary_language}" + +if null "$w3_args"; then + w3_browse_url "https://${SURFRAW_wiktionary_language}.wiktionary.org" +else + escaped_args=`w3_url_of_arg $w3_args` + w3_browse_url "https://${prefix}.wiktionary.org/wiki/${escaped_args}" +fi + diff --git a/links.IN b/links.IN index bd9170a..14f1f88 100644 --- a/links.IN +++ b/links.IN @@ -1,120 +1,121 @@ elvi.1sr.gz @mandir@/man1/W.1.gz elvi.1sr.gz @mandir@/man1/S.1sr.gz elvi.1sr.gz @mandir@/man1/acronym.1sr.gz elvi.1sr.gz @mandir@/man1/ads.1sr.gz elvi.1sr.gz @mandir@/man1/alioth.1sr.gz elvi.1sr.gz @mandir@/man1/amazon.1sr.gz elvi.1sr.gz @mandir@/man1/archpkg.1sr.gz elvi.1sr.gz @mandir@/man1/archwiki.1sr.gz elvi.1sr.gz @mandir@/man1/arxiv.1sr.gz elvi.1sr.gz @mandir@/man1/ask.1sr.gz elvi.1sr.gz @mandir@/man1/aur.1sr.gz elvi.1sr.gz @mandir@/man1/austlii.1sr.gz elvi.1sr.gz @mandir@/man1/bing.1sr.gz elvi.1sr.gz @mandir@/man1/bbcnews.1sr.gz elvi.1sr.gz @mandir@/man1/bookfinder.1sr.gz elvi.1sr.gz @mandir@/man1/bugmenot.1sr.gz elvi.1sr.gz @mandir@/man1/bugzilla.1sr.gz elvi.1sr.gz @mandir@/man1/cablesearch.1sr.gz elvi.1sr.gz @mandir@/man1/cite.1sr.gz elvi.1sr.gz @mandir@/man1/cia.1sr.gz elvi.1sr.gz @mandir@/man1/cliki.1sr.gz elvi.1sr.gz @mandir@/man1/cnn.1sr.gz elvi.1sr.gz @mandir@/man1/comlaw.1sr.gz elvi.1sr.gz @mandir@/man1/commandlinefu.1sr.gz elvi.1sr.gz @mandir@/man1/ctan.1sr.gz elvi.1sr.gz @mandir@/man1/currency.1sr.gz elvi.1sr.gz @mandir@/man1/cve.1sr.gz elvi.1sr.gz @mandir@/man1/debbugs.1sr.gz elvi.1sr.gz @mandir@/man1/debcodesearch.1sr.gz elvi.1sr.gz @mandir@/man1/debcontents.1sr.gz elvi.1sr.gz @mandir@/man1/deblists.1sr.gz elvi.1sr.gz @mandir@/man1/deblogs.1sr.gz elvi.1sr.gz @mandir@/man1/debpackages.1sr.gz elvi.1sr.gz @mandir@/man1/debpkghome.1sr.gz elvi.1sr.gz @mandir@/man1/debpts.1sr.gz elvi.1sr.gz @mandir@/man1/debsec.1sr.gz elvi.1sr.gz @mandir@/man1/debvcsbrowse.1sr.gz elvi.1sr.gz @mandir@/man1/debwiki.1sr.gz elvi.1sr.gz @mandir@/man1/deja.1sr.gz elvi.1sr.gz @mandir@/man1/deli.1sr.gz elvi.1sr.gz @mandir@/man1/discogs.1sr.gz elvi.1sr.gz @mandir@/man1/dmoz.1sr.gz elvi.1sr.gz @mandir@/man1/duckduckgo.1sr.gz elvi.1sr.gz @mandir@/man1/ebay.1sr.gz elvi.1sr.gz @mandir@/man1/etym.1sr.gz elvi.1sr.gz @mandir@/man1/excite.1sr.gz elvi.1sr.gz @mandir@/man1/finkpkg.1sr.gz elvi.1sr.gz @mandir@/man1/foldoc.1sr.gz elvi.1sr.gz @mandir@/man1/freebsd.1sr.gz elvi.1sr.gz @mandir@/man1/freedb.1sr.gz elvi.1sr.gz @mandir@/man1/freshmeat.1sr.gz elvi.1sr.gz @mandir@/man1/fsfdir.1sr.gz elvi.1sr.gz @mandir@/man1/gcache.1sr.gz elvi.1sr.gz @mandir@/man1/genbugs.1sr.gz elvi.1sr.gz @mandir@/man1/genportage.1sr.gz elvi.1sr.gz @mandir@/man1/github.1sr.gz elvi.1sr.gz @mandir@/man1/google.1sr.gz elvi.1sr.gz @mandir@/man1/gutenberg.1sr.gz elvi.1sr.gz @mandir@/man1/imdb.1sr.gz elvi.1sr.gz @mandir@/man1/ixquick.1sr.gz elvi.1sr.gz @mandir@/man1/jamendo.1sr.gz elvi.1sr.gz @mandir@/man1/javasun.1sr.gz elvi.1sr.gz @mandir@/man1/lastfm.1sr.gz elvi.1sr.gz @mandir@/man1/leodict.1sr.gz elvi.1sr.gz @mandir@/man1/l1sp.1sr.gz elvi.1sr.gz @mandir@/man1/lsm.1sr.gz elvi.1sr.gz @mandir@/man1/macports.1sr.gz elvi.1sr.gz @mandir@/man1/mathworld.1sr.gz elvi.1sr.gz @mandir@/man1/mdn.1sr.gz elvi.1sr.gz @mandir@/man1/mininova.1sr.gz elvi.1sr.gz @mandir@/man1/musicbrainz.1sr.gz elvi.1sr.gz @mandir@/man1/mysqldoc.1sr.gz elvi.1sr.gz @mandir@/man1/netbsd.1sr.gz elvi.1sr.gz @mandir@/man1/ntrs.1sr.gz elvi.1sr.gz @mandir@/man1/openbsd.1sr.gz elvi.1sr.gz @mandir@/man1/openports.1sr.gz elvi.1sr.gz @mandir@/man1/opensearch.1sr.gz elvi.1sr.gz @mandir@/man1/oraclesearch.1sr.gz elvi.1sr.gz @mandir@/man1/pasearch.1sr.gz elvi.1sr.gz @mandir@/man1/pgdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pgpkeys.1sr.gz elvi.1sr.gz @mandir@/man1/phpdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pin.1sr.gz elvi.1sr.gz @mandir@/man1/piratebay.1sr.gz elvi.1sr.gz @mandir@/man1/priberam.1sr.gz elvi.1sr.gz @mandir@/man1/pubmed.1sr.gz elvi.1sr.gz @mandir@/man1/rae.1sr.gz elvi.1sr.gz @mandir@/man1/rfc.1sr.gz elvi.1sr.gz @mandir@/man1/rhyme.1sr.gz elvi.1sr.gz @mandir@/man1/rpmsearch.1sr.gz elvi.1sr.gz @mandir@/man1/scholar.1sr.gz elvi.1sr.gz @mandir@/man1/scicom.1sr.gz elvi.1sr.gz @mandir@/man1/scirus.1sr.gz elvi.1sr.gz @mandir@/man1/scpan.1sr.gz elvi.1sr.gz @mandir@/man1/searx.1sr.gz elvi.1sr.gz @mandir@/man1/slashdot.1sr.gz elvi.1sr.gz @mandir@/man1/slinuxdoc.1sr.gz elvi.1sr.gz @mandir@/man1/sourceforge.1sr.gz elvi.1sr.gz @mandir@/man1/springer.1sr.gz elvi.1sr.gz @mandir@/man1/stack.1sr.gz elvi.1sr.gz @mandir@/man1/stockquote.1sr.gz elvi.1sr.gz @mandir@/man1/thesaurus.1sr.gz elvi.1sr.gz @mandir@/man1/translate.1sr.gz elvi.1sr.gz @mandir@/man1/urban.1sr.gz elvi.1sr.gz @mandir@/man1/w3css.1sr.gz elvi.1sr.gz @mandir@/man1/w3html.1sr.gz elvi.1sr.gz @mandir@/man1/w3link.1sr.gz elvi.1sr.gz @mandir@/man1/w3rdf.1sr.gz elvi.1sr.gz @mandir@/man1/wayback.1sr.gz elvi.1sr.gz @mandir@/man1/webster.1sr.gz elvi.1sr.gz @mandir@/man1/wetandwild.1sr.gz elvi.1sr.gz @mandir@/man1/wikipedia.1sr.gz +elvi.1sr.gz @mandir@/man1/wiktionary.1sr.gz elvi.1sr.gz @mandir@/man1/woffle.1sr.gz elvi.1sr.gz @mandir@/man1/wolfram.1sr.gz elvi.1sr.gz @mandir@/man1/worldwidescience.1sr.gz elvi.1sr.gz @mandir@/man1/yacy.1sr.gz elvi.1sr.gz @mandir@/man1/yahoo.1sr.gz elvi.1sr.gz @mandir@/man1/yandex.1sr.gz elvi.1sr.gz @mandir@/man1/youtube.1sr.gz elvi.1sr.gz @mandir@/man1/yubnub.1sr.gz diff --git a/test/wiktionary.test b/test/wiktionary.test new file mode 100644 index 0000000..a61cc9c --- /dev/null +++ b/test/wiktionary.test @@ -0,0 +1,4 @@ +wiktionary synecdoche +the name of a part of something to represent the whole +wiktionary -l=fr croix +Sorte de gibet
JNRowe/surfraw
7e10ab9e7f6ba370a788c35b575492d3405351e2
Applied Tadas' ddg patch
diff --git a/README b/README index f6ac9a7..da8cef4 100644 --- a/README +++ b/README @@ -1,402 +1,402 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Home Page: http://surfraw.alioth.debian.org ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web New: http://surfraw.alioth.debian.org Old: http://surfraw.sourceforge.net/ Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS Surfraw now supports bookmarks. To add a bookmark, add it to to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/rhyme -method=perfect Julian OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers cablesearch -- search for leaked diplomatic communications cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) deli -- Search Delicious bookmarks discogs -- Search the Discogs database of music information (www.discogs.com) dmoz -- Search the Open Directory Project web directory (dmoz.org) -duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) +duckduckgo -- Securely search the web using duckduckgo (duckduckgo.com) ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) openports -- search openports for OpenBSD packages opensearch -- Search an OpenSearch-enabled website oraclesearch -- Search an OpenSearch-enabled website pasearch -- Search the unofficial Penny Arcade archives (pipefour.org/pa) pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) rhyme -- Search for rhymes et al using Lycos Rhyme (rhyme.lycos.com) rpmsearch -- Search for RPMs in various distros scholar -- Search Google Scholar (scholar.google.com) scicom -- Search Scientific Commons scirus -- Search for science using Scirus (scirus.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) wetandwild -- Real time weather information (many sources) wikipedia -- Search the free encyclopedia wikipedia woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org yacy -- Search YaCy P2P search, including ScienceNet yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) yubnub -- Use the social command-line for the web (yubnub.org) All elvi have useful low calorie help, for example: Usage: rhyme [options] [search words]... Description: Surfraw search for rhymes and other word correlations using Lycos Rhyme (rhyme.lycos.com) Example: $ rhyme Julian $ rhyme -method=rel surfer Results: Hurclean St. Julien. surfboarder, bather, natator, swimmer Local options: -method= Type of word correlation to search for prefect | Perfect rhyme syn | Synonyms hom | Homophones cons | Consonsant rhymes only rel | Semantically related words sub | Phrases spell | Similar spellings pic | Pictures shake | Match with Shakespeare archives def Find wordnet definition Default: perfect Environment: SURFRAW_rhyme_method Global options: -browser=EXECUTABLE Set browser Default: sensible-browser -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: yes Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: yes Environment: SURFRAW_graphical -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: no Environment: SURFRAW_new_window -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: no Environment: SURFRAW_quote_args -version Display Surfraw version (2.2.7) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________ diff --git a/elvi/duckduckgo b/elvi/duckduckgo index 0f5feaf..1695cf2 100755 --- a/elvi/duckduckgo +++ b/elvi/duckduckgo @@ -1,82 +1,82 @@ #!/bin/sh -# elvis: duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) +# elvis: duckduckgo -- Securely search the web using duckduckgo (duckduckgo.com) # [email protected] 20110105 # relevant: https://duckduckgo.com/params.html # similar to duckduckgo elvi, adds more options and defaults to SSL. . surfraw || exit 1 w3_config_hook () { def SURFRAW_duckduckgo_results "$SURFRAW_results" - def SURFRAW_duckduckgo_base_url "www.duckduckgo.com" + def SURFRAW_duckduckgo_base_url "duckduckgo.com" def SURFRAW_duckduckgo_search search def SURFRAW_duckduckgo_params "&kg=g" defyn SURFRAW_duckduckgo_https_arg 0 defyn SURFRAW_duckduckgo_safe_arg 0 defyn SURFRAW_duckduckgo_redirect_arg 0 defyn SURFRAW_duckduckgo_use_javascript 0 defyn SURFRAW_duckduckgo_got_a_ducky_feeling 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: - Surfraw search the web using DuckDuckGo (www.duckduckgo.com) + Surfraw search the web using DuckDuckGo (duckduckgo.com) Local options: -d,-ducky,-l,-lucky use in case of overwhelming feeling of duckiness -j,-javascript use javascript -safe enable safe search -r,-redirect use redirection -s,-insecure disable SSL search EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in - -d*|-l|-lu*) setoptyn SURFRAW_duckduckgo_got_a_ducky_feeling 1 ;; + -d*|-l|-lu*) setoptyn SURFRAW_duckduckgo_got_a_ducky_feeling 1 ;; -j|-javascript*) setoptyn SURFRAW_duckduckgo_use_javascript 1 ;; -safe*) setoptyn SURFRAW_duckduckgo_safe_arg 1 ;; -r|-redirect*) setoptyn SURFRAW_duckduckgo_redirect_arg 1 ;; -s|-sec*) setoptyn SURFRAW_duckduckgo_https_arg 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ "${SURFRAW_duckduckgo_https_arg}" = 0 ] ; then SURFRAW_duckduckgo_base_url="https://${SURFRAW_duckduckgo_base_url}" else SURFRAW_duckduckgo_base_url="http://${SURFRAW_duckduckgo_base_url}" fi # need to send the user to the non-javascript version if using a non-graphical # browser if [ "$SURFRAW_duckduckgo_use_javascript" = 0 ]; then SURFRAW_duckduckgo_base_url="${SURFRAW_duckduckgo_base_url}/lite" fi if [ "$SURFRAW_duckduckgo_safe_arg" = 1 ]; then SURFRAW_duckduckgo_params="${SURFRAW_duckduckgo_params}&kp=1" fi if [ "$SURFRAW_duckduckgo_redirect_arg" = 1 ] ; then SURFRAW_duckduckgo_params="${SURFRAW_duckduckgo_params}&kd=1" fi if [ "$SURFRAW_graphical" != "yes" ] ; then SURFRAW_duckduckgo_params="${SURFRAW_duckduckgo_params}&kf=-1&kz=-1&kq=-1&kv=-1" fi escaped_args=`w3_url_of_arg $w3_args` if [ "$SURFRAW_duckduckgo_got_a_ducky_feeling" = 1 ]; then escaped_args="! ${escaped_args}" fi w3_browse_url "${SURFRAW_duckduckgo_base_url}/?q=${escaped_args}${SURFRAW_duckduckgo_params}"
JNRowe/surfraw
5a6f066f6675e4b2da57ea47258b43fc64246c33
N-O cleanup
diff --git a/elvi/netbsd b/elvi/netbsd index 0ec7f96..1c37363 100755 --- a/elvi/netbsd +++ b/elvi/netbsd @@ -1,87 +1,73 @@ #!/bin/sh # $Id$ # elvis: netbsd -- Search NetBSD related information (www.netbsd.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_netbsd_mail no defyn SURFRAW_netbsd_pr no -defyn SURFRAW_netbsd_ports no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search NetBSD related information Local options: -mail[=(yes|no)] Search netbsd mailinglists Default: $SURFRAW_netbsd_mail Environment: SURFRAW_netbsd_mail -pr[=(yes|no)] Query Problem Reports Default: $SURFRAW_netbsd_pr Environment: SURFRAW_netbsd_pr - -ps[=(yes|no)] Search ports - Default: $SURFRAW_netbsd_ports - Environment: SURFRAW_netbsd_ports Examples: $w3_argv0 Teleport to the NetBSD website $w3_argv0 mycroft Search NetBSD website for odeur de mycroft $w3_argv0 -mail Teleport to the mail-index Query form $w3_argv0 -mail proff Search mailing-list archives for odeur de proff $w3_argv0 -pr Query Problem Report form $w3_argv0 -ps surfraw Search Ports for surfraw EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -mail) setoptyn SURFRAW_netbsd_mail yes ;; -mail=*) setoptyn SURFRAW_netbsd_mail $optarg ;; -pr) setoptyn SURFRAW_netbsd_pr yes ;; -pr=*) setoptyn SURFRAW_netbsd_pr $optarg ;; - -ps) setoptyn SURFRAW_netbsd_ports yes ;; - -ps=*) setoptyn SURFRAW_netbsd_ports $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments test -z "$w3_args" || escaped_args=`w3_url_of_arg $w3_args` -if ok SURFRAW_netbsd_ports; then - if test -z "$escaped_args"; then - w3_browse_url "http://pkgsrc.se/" - else - w3_browse_url "http://pkgsrc.se/search.php?so=${escaped_args}" - fi - exit $? -fi if ok SURFRAW_netbsd_pr; then if test -z "$escaped_args"; then - w3_browse_url "http://www.netbsd.org/Misc/query-pr.html" + w3_browse_url "https://www.netbsd.org/Misc/query-pr.html" else - w3_browse_url "http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=${escaped_args}" + w3_browse_url "https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=${escaped_args}" fi exit $? fi if ok SURFRAW_netbsd_mail; then if test -z "$escaped_args"; then - w3_browse_url "http://mail-index.netbsd.org/" + w3_browse_url "https://mail-index.netbsd.org/" else w3_custom_search -s=mail-index.netbsd.org "$w3_shquoted_args" fi exit $? fi if test -z "$escaped_args"; then - w3_browse_url "http://www.netbsd.org/" + w3_browse_url "https://www.netbsd.org/" else w3_custom_search -s=netbsd.org "$w3_shquoted_args" fi exit $? diff --git a/elvi/nlab b/elvi/nlab index 2e086fe..fcc976c 100755 --- a/elvi/nlab +++ b/elvi/nlab @@ -1,29 +1,29 @@ #!/bin/sh # elvis: nlab -- Search the nLab Wiki (http://ncatlab.org) # author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search terms]... Description: - Search the nLab Wiki (http://ncatlab.org) + Search the nLab Wiki (https://ncatlab.org) Local options: The nLab wiki search accepts regular expressions as search terms. EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ -z "$w3_args" ]; then - w3_browse_url "http://ncatlab.org/" + w3_browse_url "https://ncatlab.org/" else escaped_args=$(w3_url_of_arg $w3_args) - w3_browse_url "http://ncatlab.org/nlab/search?&query=${escaped_args}" + w3_browse_url "https://ncatlab.org/nlab/search?&query=${escaped_args}" fi diff --git a/elvi/ntrs b/elvi/ntrs index 186b4ca..4402c3f 100755 --- a/elvi/ntrs +++ b/elvi/ntrs @@ -1,86 +1,86 @@ #!/bin/sh # # author: Wim Van Hoydonck # # elvis: ntrs -- Search the NASA Technical Report Server . surfraw || exit 1 w3_config_hook () { def SURFRAW_ntrs_fields Abstract def SURFRAW_ntrs_results matchall } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search ntrs Local options: -fields=FIELD Subject field to search all | Seach all fields abstract | Words in abstract (default) accession | Accession number center | NASA Center author | Author name docID | Document ID keywords | Keywords date | Publication date title | Title -results=RESULT Find Results with all | All of the words any | At least one of the words Examples: $w3_argv0 -fields=abstract -results=all free wake EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -fields=*) setopt SURFRAW_ntrs_fields $optarg ;; -results=*) setopt SURFRAW_ntrs_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_ntrs_fields" in all) field=All ;; abstract) field=Abstract ;; accession) field=AccessionNum ;; center) field=ArchiveName ;; author) field=AuthorList ;; docID) field=DocumentID ;; keyword) field=Keywords ;; date) field=PublicationDate ;; title) field=Title ;; *) field=Abstract ;; esac case "$SURFRAW_ntrs_results" in all) result=matchall ;; any) result=matchany ;; *) result=matchall ;; esac if null "$w3_args"; then - w3_browse_url "http://ntrs.nasa.gov/search.jsp" + w3_browse_url "https://ntrs.nasa.gov/search.jsp" else # TODO: combine multiple searches, e.g. # first search the abstract for certain keywords, # then search the authors of those results # this gives urls that look like this: - #http://ntrs.nasa.gov/search.jsp?N=0&Ntk=Abstract|AuthorList&Ntx=mode%20matchall|mode%20matchall&Ntt=free%20wake|wachspress + #https://ntrs.nasa.gov/search.jsp?N=0&Ntk=Abstract|AuthorList&Ntx=mode%20matchall|mode%20matchall&Ntt=free%20wake|wachspress escaped_args=`w3_url_of_arg $w3_args` - url="http://ntrs.nasa.gov/search.jsp?N=0&Ntk=${field}&Ntx=mode%20${result}&Ntt=${escaped_args}" + url="https://ntrs.nasa.gov/search.jsp?N=0&Ntk=${field}&Ntx=mode%20${result}&Ntt=${escaped_args}" w3_browse_url "${url}" fi diff --git a/elvi/openbsd b/elvi/openbsd index 53ef839..cc2cdcf 100755 --- a/elvi/openbsd +++ b/elvi/openbsd @@ -1,102 +1,28 @@ #!/bin/sh # $Id$ # elvis: openbsd -- Search OpenBSD related information (www.openbsd.org) . surfraw || exit 1 -w3_config_hook () { -defyn SURFRAW_openbsd_mail no -defyn SURFRAW_openbsd_pr no -defyn SURFRAW_openbsd_ports no -defyn SURFRAW_openbsd_mail_misc no -defyn SURFRAW_openbsd_mail_tech no -} - w3_usage_hook () { cat <<EOF -Usage: $w3_argv0 [options] [search-string | PR-number] +Usage: $w3_argv0 [search-string] Description: Surfraw search OpenBSD related information -Local options: - -mail[=(yes|no)] Search OpenBSD mailinglists - Default: $SURFRAW_openbsd_mail - Environment: SURFRAW_openbsd_mail - -ps[=(yes|no)] Search ports. - Default: $SURFRAW_openbsd_ports - Environment: SURFRAW_openbsd_ports - -misc[=(yes|no)] Search misc mailing list. - Default: $SURFRAW_openbsd_mail_misc - -tech[=(yes|no)] Search tech mailing list. - Default: $SURFRAW_openbsd_mail_tech Examples: $w3_argv0 Teleport to the OpenBSD website - $w3_argv0 mycroft Search OpenBSD website for odeur de mycroft - $w3_argv0 -mail Teleport to the mail-index Query form - $w3_argv0 -mail proff Search mailing-list archives for odeur de proff - $w3_argv0 -ps surfraw Search ports for surfraw - $w3_argv0 -misc supermicro Search misc mailing list for supermico - $w3_argv0 -tech SMP Search tech mailing list for SMP EOF w3_custom_search_usage w3_global_usage } -w3_parse_option_hook () { - opt="$1" - optarg="$2" - case "$opt" in - -mail) setoptyn SURFRAW_openbsd_mail yes ;; - -mail=*) setoptyn SURFRAW_openbsd_mail $optarg ;; - -ps) setoptyn SURFRAW_openbsd_ports yes ;; - -ps=*) setoptyn SURFRAW_openbsd_ports $optarg ;; - -misc) setoptyn SURFRAW_openbsd_mail_misc yes ;; - -misc=*) setoptyn SURFRAW_openbsd_mail_misc $optarg ;; - -tech) setoptyn SURFRAW_openbsd_mail_tech yes ;; - -tech=*) setoptyn SURFRAW_openbsd_mail_tech $optarg ;; - *) return 1 ;; - esac - return 0 -} - w3_config w3_parse_args "$@" # w3_args now contains a list of arguments test -z "$w3_args" || escaped_args=`w3_url_of_arg $w3_args` -if ok SURFRAW_openbsd_ports; then - if test -z "$escaped_args"; then - w3_browse_url "http://openports.se/" - else - w3_browse_url "http://openports.se/search.php?so=${escaped_args}" - fi - exit $? -fi -if ok SURFRAW_openbsd_mail; then - if test -z "$escaped_args"; then - w3_browse_url "http://www.openbsd.org/mail.html" - else - w3_browse_url "http://search.gmane.org/?query=${escaped_args}&sort=relevance&DEFAULTOP=and&group=gmane.os.openbsd.*" - fi - exit $? -fi -if ok SURFRAW_openbsd_mail_misc; then - if test -z "$escaped_args"; then - w3_browse_url "http://marc.info/?l=openbsd-misc&r=1&w=2" - else - w3_browse_url "http://marc.info/?l=openbsd-misc&w=2&r=1&s=${escaped_args}&q=b" - fi - exit $? -fi -if ok SURFRAW_openbsd_mail_tech; then - if test -z "$escaped_args"; then - w3_browse_url "http://marc.info/?l=openbsd-tech&r=1&w=2" - else - w3_browse_url "http://marc.info/?l=openbsd-tech&w=2&r=1&s=${escaped_args}&q=b" - fi - exit $? -fi if test -z "$escaped_args"; then - w3_browse_url "http://www.openbsd.org/" + w3_browse_url "https://www.openbsd.org/" else w3_custom_search -s=openbsd.org "$w3_shquoted_args" fi exit $? diff --git a/elvi/openports b/elvi/openports deleted file mode 100755 index 577be98..0000000 --- a/elvi/openports +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# elvis: openports -- search openports for OpenBSD packages -# [email protected] 20110105 -. surfraw || exit 1 - -w3_config_hook () { - def SURFRAW_openports_search "http://openports.se/search.php?" - def SURFRAW_openports_stype "" -} - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [search words]... -Description: - Search openports for OpenBSD packages / ports. Only one search is active - at a time. Feel free to n00b it up and use more than one flag. Go ahead, - just try. -Local options: - -m,-maintainer search by maintainer - -c,-comment search by comment - -b,-builddeps search by build dependencies - -r,-rundeps search by run dependencies - -s,-mastersite search by master site - -d,-description search by description - -l,-commitlogs search by commit logs -EOF - w3_global_usage -} - -w3_parse_option_hook () { - opt="$1" - optarg="$2" - case "$opt" in - -m|-mai*) setopt SURFRAW_openports_stype "maintainer" ;; - -c|-comme*) setopt SURFRAW_openports_stype "comment" ;; - -b|-bu*) setopt SURFRAW_openports_stype "dependbuild" ;; - -r|-ru*) setopt SURFRAW_openports_stype "dependrun" ;; - -s|-mas*) setopt SURFRAW_openports_stype "MASTER_SITES" ;; - -d|-de*) setopt SURFRAW_openports_stype "description" ;; - -l|-commi*) setopt SURFRAW_openports_stype "commitlog" ;; - *) return 1 ;; - esac - return 0 -} - -w3_config -w3_parse_args "$@" -# w3_args now contains a list of arguments - -escaped_args=`w3_url_of_arg $w3_args` - -if test -z $SURFRAW_openports_stype ; then - url="${SURFRAW_openports_search}so=${escaped_args}" -else - url="${SURFRAW_openports_search}stype=${SURFRAW_openports_stype}&so=${escaped_args}" -fi - -w3_browse_url $url diff --git a/elvi/opensearch b/elvi/opensearch deleted file mode 100755 index 558c0e8..0000000 --- a/elvi/opensearch +++ /dev/null @@ -1,191 +0,0 @@ -#!/bin/sh -# elvis: opensearch -- Search an OpenSearch-enabled website -# [email protected] 20060903 - -. surfraw || exit 1 - -w3_config_hook () { -def SURFRAW_opensearch_title "" -def SURFRAW_opensearch_count $SURFRAW_results -def SURFRAW_opensearch_startindex "" -def SURFRAW_opensearch_pageindex "" -def SURFRAW_opensearch_language "$SURFRAW_lang" -def SURFRAW_opensearch_inputencoding "" -def SURFRAW_opensearch_outputencoding "" -defyn SURFRAW_opensearch_list no -defyn SURFRAW_opensearch_redirect no -} - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [url] [search words]... -Description: - Surfraw search an OpenSearch-enabled website. - If opensearch-discover and opensearch-genquery are installed then - it will handle the opensearch lookups locally, otherwise it will fall - back on a redirector. -Local options: - -r Explicitly use redirector. - -l List OpenSearch searches at url. - -title=TITLE Use search with title matching TITLE. - TITLE is case-insensitive. - Example: -t book matches "Book Search" -Many sites do not implement all (or any) of the following -parameters, in which case they will be silently ignored. - -count=NUM Number of search results returned. - Default: $SURFRAW_opensearch_count. - Environment: SURFRAW_opensearch_count. - If not set, defaults to value of SURFRAW_results - -index=NUM Offset of first result. - -page=NUM Which page of results to show. - -language=LANG Language to display results in. - LANG should be a 2-letter ISO country code. - Examples: -l=en or -lang=de. - Environment: SURFRAW_opensearch_lang, SURFRAW_lang - -inputencoding=ENC Specify how search terms are encoded. - -outputencoding=ENC Request output encoded as ENC. - Environment: SURFRAW_opensearch_search -EOF - w3_global_usage -} - -w3_parse_option_hook () { - opt="$1" - optarg="$2" - case "$opt" in - -t*=*) setopt SURFRAW_opensearch_title "$optarg" ;; - -c*=*) setopt SURFRAW_opensearch_count "$optarg" ;; - -i*=*) setopt SURFRAW_opensearch_startindex "$optarg" ;; - -p*=*) setopt SURFRAW_opensearch_pageindex "$optarg" ;; - -la*=*) setopt SURFRAW_opensearch_language "$optarg" ;; - -in*=*) setopt SURFRAW_opensearch_inputencoding "$optarg" ;; - -o*=*) setopt SURFRAW_opensearch_outputencoding "$optarg" ;; - -l) setoptyn SURFRAW_opensearch_list 1 ;; - -r) setoptyn SURFRAW_opensearch_redirect yes ;; - *) return 1 ;; - esac - return 0 -} - -w3_config -w3_parse_args "$@" -if test -z "$w3_args"; then - w3_usage_hook - exit 0 -fi - -if ifno SURFRAW_opensearch_redirect && - [ ! -x $(which opensearch-discover) ] || - [ ! -x $(which opensearch-genquery) ] -then - setoptyn SURFRAW_opensearch_redirect yes -fi - -# Clobbers command line, but we've already parsed it -set $w3_args -siteurl="$1" -shift -w3_args="$*" -# w3_args now contains a list of arguments - -if ifyes SURFRAW_opensearch_redirect; then - if ifyes SURFRAW_opensearch_list; then - err "-l not supported with -r" - elif test -z "$w3_args"; then - w3_browse_url "$siteurl" - else - escaped_args=`w3_url_of_arg $w3_args` - - if [ -n "$SURFRAW_opensearch_title" ]; then - err "-t not supported with -r" - fi - - url="http://erislabs.net/ianb/webtools/opensearch/" - url="${url}?site=$(w3_url_of_arg "$siteurl")" - url="${url}&searchTerms=${escaped_args}" - url="${url}&count=${SURFRAW_opensearch_count}" - url="${url}&startIndex=${SURFRAW_opensearch_startindex}" - url="${url}&pageIndex=${SURFRAW_opensearch_pageindex}" - url="${url}&language=${SURFRAW_opensearch_language}" - url="${url}&inputEncoding=${SURFRAW_opensearch_inputencoding}" - url="${url}&outputEncoding=${SURFRAW_opensearch_outputencoding}" - url="${url}&fmt=html" - - w3_browse_url "$url" - fi - -else # dont use redirector - - if ifyes SURFRAW_opensearch_list; then - opensearch-discover -q -v -a $siteurl - case "$?" in - 0) ;; # OK - 1) err "Cannot access $siteurl" ;; - 2) err "Cannot find ${matching}OpenSearch link at $siteurl" ;; - 3) err "opensearch-discover: required perl module not found" ;; - *) err "Unknown error from opensearch-discover" ;; - esac - - elif test -z "$w3_args"; then - w3_browse_url "$siteurl" - else - escaped_args=`w3_url_of_arg $w3_args` - - discover_args="-q" - matching="" # for error message below - if [ -n "$SURFRAW_opensearch_title" ]; then - discover_args="-q -t $SURFRAW_opensearch_title" - matching="matching " - fi - - opensearchurl=`opensearch-discover $discover_args $siteurl` - - case "$?" in - 0) ;; # OK - 1) err "Cannot access $siteurl" ;; - 2) err "Cannot find ${matching}OpenSearch link at $siteurl" ;; - 3) err "opensearch-discover: required perl module not found" ;; - *) err "Unknown error from opensearch-discover" ;; - esac - - queryargs="-q -H" - - if [ -n "$SURFRAW_opensearch_count" ]; then - queryargs="$queryargs -c $SURFRAW_opensearch_count" - fi - - if [ -n "$SURFRAW_opensearch_startindex" ]; then - queryargs="$queryargs -i $SURFRAW_opensearch_startindex" - fi - - if [ -n "$SURFRAW_opensearch_pageindex" ]; then - queryargs="$queryargs -p $SURFRAW_opensearch_pageindex" - fi - - if [ -n "$SURFRAW_opensearch_language" ]; then - queryargs="$queryargs -l $SURFRAW_opensearch_language" - fi - - if [ -n "$SURFRAW_opensearch_inputencoding" ]; then - queryargs="$queryargs -I $SURFRAW_opensearch_inputencoding" - fi - - if [ -n "$SURFRAW_opensearch_outputencoding" ]; then - queryargs="$queryargs -O $SURFRAW_opensearch_outputencoding" - fi - - query=`opensearch-genquery $queryargs $opensearchurl $w3_args` - - case "$?" in - 0) ;; # OK - 1) err "Cannot access OpenSearch description $opensearchurl" ;; - 2) err "Error parsing OpenSearch Description at $opensearchurl" ;; - 3) err "No HTML search specified in $opensearchurl" ;; - 4) err "opensearch-genquery: cannot find required perl module WWW::OpenSearch" ;; - *) err "Unknown error from opensearch-genquery" ;; - esac - - w3_browse_url "$query" - - fi -fi diff --git a/elvi/oraclesearch b/elvi/oraclesearch index c316fd8..c472348 100755 --- a/elvi/oraclesearch +++ b/elvi/oraclesearch @@ -1,24 +1,24 @@ #!/bin/sh # elvis: oraclesearch -- Search Oracle (search.oracle.com) # [email protected] 20131005 . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Oracle (search.oracle.com) EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then w3_browse_url "http://search.oracle.com/search/search" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://search.oracle.com/search/search?q=${escaped_args}" + w3_browse_url "https://www.oracle.com/search/results?Ntt=${escaped_args}&Dy=1&Nty=1&Ntk=S3" fi diff --git a/test/netbsd.test b/test/netbsd.test index ec7e322..c31a78e 100644 --- a/test/netbsd.test +++ b/test/netbsd.test @@ -1,8 +1,6 @@ netbsd netbsd NetBSD netbsd -pr 666 loose source routing netbsd -mail netbsd NetBSD -netbsd -ps surfraw -Shell Users Revolutionary Front diff --git a/test/openbsd.test b/test/openbsd.test index d1080a0..e541859 100644 --- a/test/openbsd.test +++ b/test/openbsd.test @@ -1,6 +1,2 @@ openbsd Raadt Theo de -openbsd -mail Raadt -Theo -openbsd -ps surfraw -command line interface to popular WWW search engines diff --git a/test/openports.test b/test/openports.test deleted file mode 100644 index 9378c1d..0000000 --- a/test/openports.test +++ /dev/null @@ -1,2 +0,0 @@ -openports surfraw -www.surfraw diff --git a/test/opensearch.test b/test/opensearch.test deleted file mode 100644 index 959fd50..0000000 --- a/test/opensearch.test +++ /dev/null @@ -1,4 +0,0 @@ -opensearch en.wikipedia.org surfraw -Julian Assange -opensearch -r en.wikipedia.org surfraw -Julian Assange diff --git a/test/oraclesearch.test b/test/oraclesearch.test index 6812192..af07b54 100644 --- a/test/oraclesearch.test +++ b/test/oraclesearch.test @@ -1,2 +1,2 @@ oraclesearch mysql -Community Edition +Database in the cloud
JNRowe/surfraw
06ed55421120782a79d0992fe4e92d490b7e9a5f
P-R elvi cleanup
diff --git a/elvi/pasearch b/elvi/pasearch deleted file mode 100755 index 6417c56..0000000 --- a/elvi/pasearch +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh -# -# AUTHOR: jakob -# -# DATE: 2010.12.04 -# -# DESC: Elvis to search the unofficial Penny Arcade archives -# elvis: pasearch -- Search the unofficial Penny Arcade archives (pipefour.org/pa) -. surfraw || exit 1 - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [search words]... -Description: - Search the unofficial Penny Arcade archives (pipefour.org/pa) -Local options: - -t/-T Enable/disable searching title field - Default: yes - Environment: SURFRAW_pasearch_search_title - -b/-B Enable/disable searching body field - Default: yes - Environment: SURFRAW_pasearch_search_body - -n/-N Enable/disable searching notes field - Default: yes - Environment: SURFRAW_pasearch_search_notes - -p/-P Enable/disable showing preview thumbnails - Default: yes - Environment: SURFRAW_pasearch_show_previews -EOF - w3_global_usage -} - -w3_config_hook () { - defyn SURFRAW_pasearch_search_title 1 - defyn SURFRAW_pasearch_search_body 1 - defyn SURFRAW_pasearch_search_notes 1 - defyn SURFRAW_pasearch_show_previews 1 -} - -w3_parse_option_hook () { - opt="$1" - optarg="$2" - case "$opt" in - -t) setoptyn SURFRAW_pasearch_search_title 1 ;; - -T) setoptyn SURFRAW_pasearch_search_title 0 ;; - -b) setoptyn SURFRAW_pasearch_search_body 1 ;; - -B) setoptyn SURFRAW_pasearch_search_body 0 ;; - -n) setoptyn SURFRAW_pasearch_search_notes 1 ;; - -N) setoptyn SURFRAW_pasearch_search_notes 0 ;; - -p) setoptyn SURFRAW_pasearch_show_previews 1 ;; - -P) setoptyn SURFRAW_pasearch_show_previews 0 ;; - *) return 1 ;; - esac - return 0 -} - -w3_config -w3_parse_args "$@" - -# Make sure they have at least one field enabled -ifno SURFRAW_pasearch_search_title && -ifno SURFRAW_pasearch_search_body && -ifno SURFRAW_pasearch_search_notes && - err You can\'t search 0 fields. - -if test -z "$w3_args"; then - w3_browse_url "http://pipefour.org/pa/" -else - escaped_args=`w3_url_of_arg $w3_args` - ifyes SURFRAW_pasearch_search_title && fields=${fields}'&search[]=title' - ifyes SURFRAW_pasearch_search_body && fields=${fields}'&search[]=body' - ifyes SURFRAW_pasearch_search_notes && fields=${fields}'&search[]=notes' - - thumbs="off" - ifyes SURFRAW_pasearch_show_previews && thumbs=on - - w3_browse_url "http://pipefour.org/pa/search.php?thumbs=${thumbs}&${fields}&q=${escaped_args}" -fi diff --git a/elvi/pgdoc b/elvi/pgdoc index 42834d4..c46d633 100755 --- a/elvi/pgdoc +++ b/elvi/pgdoc @@ -1,85 +1,85 @@ #!/bin/sh # [email protected] 20130923 # elvis: pgdoc -- Search postgres documentation (www.pgdoc.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_pgdoc_version 9.1 defyn SURFRAW_pgdoc_comments no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Postgresql documentation (www.postgresql.org) Local options: -c Search in comments too -v=VERSION Search in version VERSION Default: $SURFRAW_pgdoc_version Environment: SURFRAW_pgdoc_version EOF w3_custom_search_usage w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -c*) setoptyn SURFRAW_pgdoc_comments 1 ;; -v*=*) setopt SURFRAW_pgdoc_version "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if test -z "$w3_args" then case "$SURFRAW_pgdoc_version" in all) inurl="/docs/" ;; *9.3*) inurl="/docs/9.3/" ;; *9.2*) inurl="/docs/9.2/" ;; *9.1*) inurl="/docs/9.1/" ;; *9.0*) inurl="/docs/9.0/" ;; *8.4*) inurl="/docs/8.4/" ;; *) inurl="/docs/" ;; esac if [ "$SURFRAW_pgdoc_version" != all ] then if ifyes SURFRAW_pgdoc_comments then inurl="${inurl}interactive/" else inurl="${inurl}static/" fi fi - w3_browse_url "http://www.postgresql.org${inurl}" + w3_browse_url "https://www.postgresql.org${inurl}" else case "$SURFRAW_pgdoc_version" in all) inurl="-u=docs" ;; *9.3*) inurl="-u=docs -u=9.3" ;; *9.2*) inurl="-u=docs -u=9.2" ;; *9.1*) inurl="-u=docs -u=9.1" ;; *9.0*) inurl="-u=docs -u=9.0" ;; *8.4*) inurl="-u=docs -u=8.4" ;; *) inurl="-u=docs" ;; esac if [ "$SURFRAW_pgdoc_version" != all ] then if ifyes SURFRAW_pgdoc_comments then inurl="${inurl} -u=interactive" else inurl="${inurl} -u=static" fi fi w3_custom_search -s=www.postgresql.org $inurl "$w3_shquoted_args" fi diff --git a/elvi/phpdoc b/elvi/phpdoc index fc46e87..5db3cd4 100644 --- a/elvi/phpdoc +++ b/elvi/phpdoc @@ -1,129 +1,129 @@ #!/bin/sh # elvis: phpdoc -- Search PHP documentation (php.net) # Author: http://jonyamo.net . surfraw || exit 1 w3_config_hook () { def SURFRAW_php_language "$SURFRAW_lang" def SURFRAW_php_search "functions" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Surfraw search PHP documentation (php.net) Local options: -l, -language= Two letter language code (resembles ISO country codes) en | English (default) pt | Brazilian Portuguese zh | Chinese (Simplified) fr | French de | German ja | Japanese pl | Polish ro | Romanian fa | Persian es | Spanish tr | Turkish Environment: SURFRAW_php_language, SURFRAW_lang Default: en -s, -search= Specialized search on topic all | All php.net sites functions | Function search manual | Online documentation bugs | Bug database news | News archive changelogs | Changelogs pear | Just pear.php.net pecl | Just pecl.php.net talks | Just talks.php.net maillist | General mailing list devlist | Developer mailing list phpdoc | Documentation mailing list Environment: SURFRAW_php_search Default: functions -a, -all alias of -search=all -f, -functions alias of -search=functions -m, -manual alias of -search=manual -b, -bugs alias of -search=bugs -n, -news alias of -search=news -c, -changelogs alias of -search=changelogs -t, -talks alias of -search=talks -maillist alias of -search=maillist -devlist alias of -search=devlist -phpdoc alias of -search=phpdoc EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -language=*) setopt SURFRAW_php_language "$optarg" ;; -l=*) setopt SURFRAW_php_language "$optarg" ;; -search=*) setopt SURFRAW_php_search "$optarg" ;; -s=*) setopt SURFRAW_php_search "$optarg" ;; -a|-all) setopt SURFRAW_php_search "all" ;; -f|-functions) setopt SURFRAW_php_search "functions" ;; -m|-manual) setopt SURFRAW_php_search "manual" ;; -b|-bugs) setopt SURFRAW_php_search "bugs" ;; -n|-news) setopt SURFRAW_php_search "news" ;; -c|-changelogs) setopt SURFRAW_php_search "changelogs" ;; -t|-talks) setopt SURFRAW_php_search "talks" ;; -maillist) setopt SURFRAW_php_search "maillist" ;; -devlist) setopt SURFRAW_php_search "devlist" ;; -phpdoc) setopt SURFRAW_php_search "phpdoc" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments -url="http://php.net/" +url="https://php.net/" case "$SURFRAW_php_language" in en) lang="en" ;; pt) lang="pt_BR" ;; zh) lang="zh" ;; fr) lang="fr" ;; de) lang="de" ;; ja) lang="ja" ;; pl) lang="pl" ;; ro) lang="ro" ;; fa) lang="fa" ;; es) lang="es" ;; tr) lang="tr" ;; *) lang="en" ;; esac case "$SURFRAW_php_search" in all) search="all" ;; functions) search="quickref" ;; manual) search="manual" ;; bugs) search="bugdb" ;; news) search="news_archive" ;; changelogs) search="changelogs" ;; pear) search="pear" ;; pecl) search="pecl" ;; talks) search="talks" ;; maillist) search="maillist" ;; devlist) search="devlist" ;; phpdoc) search="phpdoc" ;; *) search="functions" ;; esac if [ -n "$w3_args" ]; then escaped_args=$(w3_url_of_arg $w3_args) url="${url}search.php?lang=${lang}&show=${search}&pattern=${escaped_args}" fi w3_browse_url "$url" diff --git a/elvi/pin b/elvi/pin index 79b9a58..8978180 100755 --- a/elvi/pin +++ b/elvi/pin @@ -1,93 +1,93 @@ #!/bin/sh -# elvis: pin -- Search Pinboard bookmarks (http://pinboard.in) +# elvis: pin -- Search Pinboard bookmarks (https://pinboard.in) # author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_pinboard_tags "$SURFRAW_tags" def SURFRAW_pinboard_user "$SURFRAW_user" def SURFRAW_pinboard_new 0 def SURFRAW_pinboard_popular 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Pinboard bookmarks (http://pinboard.in) Local options: Default search (without any options) includes tags, titles and descriptions and is not limited to a specific number of search terms. -popular | -p Search popular tags -recent | -r Search recent tags -tags=TAGS | -t=TAGS Only search tags (separate a maximum of 3 TAGS with a "+" eg., unix+linux) -user=NAME | -u=NAME Search a user's bookmarks EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -p* ) setoptyn SURFRAW_pinboard_popular 1 ;; -r* ) setoptyn SURFRAW_pinboard_new 1 ;; -t=*) setopt SURFRAW_pinboard_tags $optarg ;; -u=*) setopt SURFRAW_pinboard_user $optarg ;; *) return 1 ;; esac return 0 } # create tag string tags () { local IFS=+ for tag in $SURFRAW_pinboard_tags; do printf "%s" "t:$tag/" done } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) base_url="https://pinboard.in/" # check for recent & popular if [ "$SURFRAW_pinboard_new" = 1 ]; then suffix="recent/" elif [ "$SURFRAW_pinboard_popular" = 1 ]; then suffix="popular" fi # Run through the other possibilities... if [ -z "$w3_args" ]; then if [ -n "$SURFRAW_pinboard_user" ] && [ -n "$SURFRAW_pinboard_tags" ]; then w3_browse_url "${base_url}u:$SURFRAW_pinboard_user/$(tags)" elif [ -n "$SURFRAW_pinboard_tags" ]; then w3_browse_url "${base_url}$(tags)" elif [ -n "$SURFRAW_pinboard_user" ]; then w3_browse_url "${base_url}u:$SURFRAW_pinboard_user" else w3_browse_url "$base_url${suffix}" fi elif [ -n "$w3_args" ]; then w3_browse_url "${base_url}search/?query=${escaped_args}&all=Search+All" else w3_browse_url "${base_url}" fi diff --git a/elvi/piratebay b/elvi/piratebay index 0afd76a..0777cbe 100755 --- a/elvi/piratebay +++ b/elvi/piratebay @@ -1,87 +1,88 @@ #!/bin/sh -# elvis: piratebay -- Search The Pirate Bay (http://thepiratebay.org) +# elvis: piratebay -- Search The Pirate Bay (https://thepiratebay.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_bay_categories "$SURFRAW_categories" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search thepiratebay.org for torrents -sort=CATEGORIES | -s=CATEGORIES Local options: all | search all categories (default) apps | search applications games | search games music | search music tv | search TV shows movies | search movies Default: All Subcategories: flac | flac audio files books | audio books dvd | DVD rips hrm | High-res movies hrt | High-res TV EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s*=*) setopt SURFRAW_bay_categories $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_bay_categories" in al*) category="0" ;; ap*) category="300" ;; ga*) category="400" ;; mu*) category="100" ;; tv*) category="205" ;; mo*) category="201" ;; fl*) category="104" ;; bo*) category="102" ;; dv*) category="202" ;; hrm) category="207" ;; hrt) category="208" ;; *) category="0" ;; esac # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) # just browsing category if [ -n "$SURFRAW_bay_categories" ] && [ -z "$w3_args" ]; then - w3_browse_url "http://thepiratebay.org/browse/${category}" + w3_browse_url "https://thepiratebay.org/browse/${category}" # searching category for string elif [ -n "$SURFRAW_bay_categories" ] && [ -n "$w3_args" ]; then - w3_browse_url "http://thepiratebay.org/search/${escaped_args}/0/99/${category}" + w3_browse_url "https://thepiratebay.org/search/${escaped_args}/0/99/${category}" # no arguments passed elif [ -z "$w3_args" ]; then - w3_browse_url "http://thepiratebay.org/" + w3_browse_url "https://thepiratebay.org/" # no category specified -else w3_browse_url "http://thepiratebay.org/search/${escaped_args}" +else w3_browse_url "https://thepiratebay.org/search/${escaped_args}" fi + diff --git a/elvi/priberam b/elvi/priberam index 05daddc..52f6d41 100755 --- a/elvi/priberam +++ b/elvi/priberam @@ -1,29 +1,29 @@ #!/bin/sh # $Id$ # elvis: priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) . surfraw || exit 1 w3_config_hook () { def SURFRAW_priberam dictionary } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Look up word in Priberam online dictionary (www.priberam.pt/dlpo) EOF w3_global_usage } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.priberam.pt/dlpo/" + w3_browse_url "https://www.priberam.pt/dlpo/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.priberam.pt/dlpo/default.aspx?pal=${escaped_args}" + w3_browse_url "https://www.priberam.pt/dlpo/default.aspx?pal=${escaped_args}" fi diff --git a/elvi/pubmed b/elvi/pubmed index 9df5936..5ba82a3 100755 --- a/elvi/pubmed +++ b/elvi/pubmed @@ -1,48 +1,48 @@ #!/bin/sh # $Id$ # elvis: pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) . surfraw || exit 1 w3_config_hook () { def SURFRAW_pubmed_database PubMed } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search PubMed medical/molbio databases (www.ncbi.nlm.nih.gov) Local options: -db= Database to search PubMed | Nucleotide | Protein | Genome | Structure | Popset Default: $SURFRAW_pubmed_database Environment: SURFRAW_pubmed_database EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -db=PubMed | -db=Nucleotide | -db=Protein | -db=Genome | -db=Structure | -db=Popset) setopt SURFRAW_pubmed_database $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi" + w3_browse_url "https://www.ncbi.nlm.nih.gov/entrez/query.fcgi" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?SUBMIT=y&term=${escaped_args}&db=${SURFRAW_pubmed_database}&orig_db=PubMed&cmd=" + w3_browse_url "https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?SUBMIT=y&term=${escaped_args}&db=${SURFRAW_pubmed_database}&orig_db=PubMed&cmd=" fi diff --git a/elvi/rae b/elvi/rae index 08d089d..6109637 100755 --- a/elvi/rae +++ b/elvi/rae @@ -1,26 +1,26 @@ #!/bin/sh # $Id$ # elvis: rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) # Author: Ruben Pollan <[email protected]> . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if null "$w3_args"; then - w3_browse_url "http://lema.rae.es/drae/" + w3_browse_url "https://lema.rae.es/drae/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://lema.rae.es/drae/?val=${escaped_args}" + w3_browse_url "https://lema.rae.es/drae/?val=${escaped_args}" fi diff --git a/elvi/rfc b/elvi/rfc index b643516..f93dd71 100755 --- a/elvi/rfc +++ b/elvi/rfc @@ -1,194 +1,194 @@ #!/bin/sh # $Id$ # elvis: rfc -- Search RFCs (internet standards documents) # [email protected] 20031220 . surfraw || exit 1 w3_config_hook () { def SURFRAW_rfc_search all def SURFRAW_rfc_field all def SURFRAW_rfc_results $SURFRAW_results def SURFRAW_rfc_output txt defyn SURFRAW_rfc_matchexact no defyn SURFRAW_rfc_showabs no defyn SURFRAW_rfc_showkw no defyn SURFRAW_rfc_reverse no defyn SURFRAW_rfc_ftp no defyn SURFRAW_rfc_nodirect no searchset=0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the RFC (Request For Comments) internet standards. Local options: -results=NUM Number of search results returned Default: $SURFRAW_rfc_results Environment: SURFRAW_rfc_results -pdf Return files as PDF (Default: text) -rev Reverse order of results -exact Match exact words (instead of prefixes) -abs Show abstracts -keywords Show keywords -nodirect Don't try and go direct to RFC (Tries when arg is numeric and -search/-field not used) -ftp Retrieve RFCs via FTP instead of HTTP -field= Which field to search all | All fields number | title | author | keyword Default: if args are numeric, "number", else "all" Environment: SURFRAW_rfc_field -search= Collection to search all | All rfc | Requests For Comments std | Standards bcp | Best Current Practices fyi Informational (For Your Information) Default: $SURFRAW_rfc_search Environment: SURFRAW_rfc_search EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -res*=*) setopt SURFRAW_rfc_results $optarg ;; -pdf*) setopt SURFRAW_rfc_output pdf ;; -rev*) setoptyn SURFRAW_rfc_reverse yes ;; -ex*) setoptyn SURFRAW_rfc_matchexact yes ;; -abs*) setoptyn SURFRAW_rfc_showabs yes ;; -k*) setoptyn SURFRAW_rfc_showkw yes ;; -ftp*) setoptyn SURFRAW_rfc_ftp yes ;; -no*) setoptyn SURFRAW_rfc_nodirect yes ;; -se*=*) setopt SURFRAW_rfc_search $optarg ;; -fi*=*) setopt SURFRAW_rfc_field $optarg ; searchset=1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.rfc-editor.org/rfcsearch.html" + w3_browse_url "https://www.rfc-editor.org/rfcsearch.html" else escaped_args=`w3_url_of_arg $w3_args` # Is cmdline numeric? nodirect=0 if echo "$escaped_args" |grep '^[0-9]*$' >/dev/null 2>&1 then isnum=1 if ifyes SURFRAW_rfc_nodirect then nodirect=1 fi else isnum=0 fi # Do we want to go direct to rfc? if [ $isnum -eq 1 -a $searchset -eq 0 -a $nodirect -eq 0 ] then # do we want txt if [ "$SURFRAW_rfc_output" = "txt" ] then subdir="" case "$SURFRAW_rfc_search" in all) fileprefix="rfc";; rfc) fileprefix="rfc";; std) fileprefix="std"; subdir="/std";; bcp) fileprefix="bcp"; subdir="/bcp";; fyi) fileprefix="fyi"; subdir="/fyi";; *) echo "Unknown search: $SURFRAW_rfc_search"; exit;; esac if ifyes SURFRAW_rfc_ftp then url="ftp://ftp.rfc-editor.org/in-notes${subdir}/${fileprefix}${escaped_args}.txt" elif [ $fileprefix = rfc ] || [ $fileprefix = bcp ]; then - url="http://tools.ietf.org/html/${fileprefix}${escaped_args}" + url="https://tools.ietf.org/html/${fileprefix}${escaped_args}" else - url="http://www.rfc-editor.org/rfc${subdir}/${fileprefix}${escaped_args}.txt" + url="https://www.rfc-editor.org/rfc${subdir}/${fileprefix}${escaped_args}.txt" fi else # godless PDFs case "$SURFRAW_rfc_search" in all) ;; rfc) ;; *) echo "Only RFCs available as PDF files, not STDs, BCPs or FYIs. Try without -pdf"; exit 1;; esac # pdfs only available through ftp url="ftp://ftp.rfc-editor.org/in-notes/pdfrfc/rfc${escaped_args}.txt.pdf" fi else # not direct to rfc, construct url from options - url="http://www.rfc-editor.org/cgi-bin/rfcsearch.pl?searchwords=${escaped_args}" + url="https://www.rfc-editor.org/cgi-bin/rfcsearch.pl?searchwords=${escaped_args}" if [ $isnum -eq 1 -a $searchset -eq 0 ] then url="$url&opt=Number" else case "$SURFRAW_rfc_field" in all*) url="$url&opt=All+Fields";; num*) url="$url&opt=Number";; tit*) url="$url&opt=Title";; auth*) url="$url&opt=Author";; key*) url="$url&opt=Keywords";; kw*) url="$url&opt=Keywords";; *) url="$url&opt=All+Fields";; esac fi url="$url&num=$SURFRAW_rfc_results" url="$url&filefmt=$SURFRAW_rfc_output" url="$url&search_doc=search_$SURFRAW_rfc_search" if ifyes SURFRAW_rfc_matchexact then url="$url&match_method=entire" else url="$url&match_method=prefix" fi if ifyes SURFRAW_rfc_showabs then url="$url&abstract=abson" else url="$url&abstract=absoff" fi if ifyes SURFRAW_rfc_showkw then url="$url&keywords=keyon" else url="$url&keywords=keyoff" fi if ifyes SURFRAW_rfc_reverse then url="$url&sort_method=older" else url="$url&sort_method=newer" fi if ifyes SURFRAW_rfc_ftp then url="$url&format=ftp" else url="$url&format=http" fi fi w3_browse_url "$url" fi diff --git a/elvi/rhyme b/elvi/rhyme deleted file mode 100755 index beaa6eb..0000000 --- a/elvi/rhyme +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# $Id$ -# elvis: rhyme -- Search for rhymes et al using Lycos Rhyme (rhyme.lycos.com) -. surfraw || exit 1 - -w3_config_hook () { -def SURFRAW_rhyme_method perfect -} - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [search words]... -Description: - Surfraw search for rhymes and other word correlations using - Lycos Rhyme (rhyme.lycos.com) -Example: - \$ rhyme Julian - \$ rhyme -method=rel surfer -Results: - Hurclean St. Julien. - surfboarder, bather, natator, swimmer -Local options: - -method= Type of word correlation to search for - prefect | Perfect rhyme - syn | Synonyms - hom | Homophones - cons | Consonsant rhymes only - rel | Semantically related words - sub | Phrases - spell | Similar spellings - pic | Pictures - shake | Match with Shakespeare archives - def Find wordnet definition - Default: $SURFRAW_rhyme_method - Environment: SURFRAW_rhyme_method -EOF - w3_global_usage -} - -w3_parse_option_hook () { - opt="$1" - optarg="$2" - case "$opt" in - -method=*) setopt SURFRAW_rhyme_method $optarg ;; - *) return 1 ;; - esac - return 0 -} - -w3_config -# disable requoting, doesn't work with this elvi. -SURFRAW_quote_ifs=0 -w3_parse_args "$@" -# w3_args now contains a list of arguments -if test -z "$w3_args"; then - w3_browse_url "http://www.rhymezone.com/" - else - escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.rhymezone.com/r/rhyme.cgi?Word=${escaped_args}&typeofrhyme=${SURFRAW_rhyme_method}&org1=syl&org2=l" - -fi diff --git a/elvi/rpmsearch b/elvi/rpmsearch deleted file mode 100755 index df34eb2..0000000 --- a/elvi/rpmsearch +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/sh -# elvis: rpmsearch -- Search for RPMs in various distros -# [email protected] 20091112 -. surfraw || exit 1 - -w3_config_hook () { - def SURFRAW_rpmsearch_distro all - def SURFRAW_rpmsearch_deptype "" - def SURFRAW_rpmsearch_by fuzzyname -} - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [search words]... -Description: - Search for RPMs in various distros -Local options: - -search=TYPE Search by TYPE - fuzzyname | Fuzzy name match - rpmname | RPM name - dep | Dependency Match - file | Search by File - Default: $SURFRAW_rpmsearch_by - Environment: SURFRAW_rpmsearch_by - -dep= Dependency match type (implies -search=dep) - provides | Provides - requires | Requires - conflict | Conflict - obsoletes | Obsoletes - trigger | Trigger - suggest | Suggest - enhanced | Enhanced - Default: $SURFRAW_rpmsearch_by - Environment: SURFRAW_rpmsearch_by - -distro=NAME Search in distribution NAME - all | All (default) - Altlinux | Altlinux - Arklinux | Arklinux - Caosity | Caosity - CentOS | CentOS - Fedora | Fedora - Mageia | Mageia - Mandriva | Mandriva - Momonga | Momonga - OpenSuse | OpenSuse - PLD | PLD - ScientificLinux | Scientific Linux - UnityLinux | Unity Linux - Default: $SURFRAW_rpmsearch_distro - Environment: SURFRAW_rpmsearch_distro -EOF - w3_global_usage -} - -w3_parse_option_hook () { - opt="$1" - optarg="$2" - case "$opt" in - -dist*=*) setopt SURFRAW_rpmsearch_distro "$optarg" ;; - -de*=*) case "$optarg" in - [Pp]*) setopt SURFRAW_rpmsearch_deptype "P";; - [Rr]*) setopt SURFRAW_rpmsearch_deptype "R";; - [Cc]*) setopt SURFRAW_rpmsearch_deptype "C";; - [Oo]*) setopt SURFRAW_rpmsearch_deptype "O";; - [Tt]*) setopt SURFRAW_rpmsearch_deptype "T";; - [Ss]*) setopt SURFRAW_rpmsearch_deptype "S";; - [Ee]*) setopt SURFRAW_rpmsearch_deptype "E";; - *) err "unknown dep type";; - esac - setopt SURFRAW_rpmsearch_by bydep ;; - -sear*=*) case "$optarg" in - fu*) setopt SURFRAW_rpmsearch_by fuzzyname;; - byn*|r*) setopt SURFRAW_rpmsearch_by byname;; - bydep|d*) setopt SURFRAW_rpmsearch_by bydep;; - byf|fi*) setopt SURFRAW_rpmsearch_by byfile;; - *) err "unknown search type" ;; - esac ;; - - *) return 1 ;; - esac - return 0 -} - -w3_config -w3_parse_args "$@" -# w3_args now contains a list of arguments - -if test -z "$w3_args"; then - w3_browse_url "http://sophie.zarb.org/search" -else - escaped_args=`w3_url_of_arg $w3_args` - - if [ "$SURFRAW_rpmsearch_distro" = all ]; then - SURFRAW_rpmsearch_distro="" - elif [ "$SURFRAW_rpmsearch_distro" = ScientificLinux ]; then - SURFRAW_rpmsearch_distro="Scientific+Linux" - fi - w3_browse_url "http://sophie.zarb.org/search?distribution=${SURFRAW_rpmsearch_distro}&search=${escaped_args}&type=${SURFRAW_rpmsearch_by}&deptype=${SURFRAW_rpmsearch_deptype}" -fi diff --git a/test/pasearch.test b/test/pasearch.test deleted file mode 100644 index 8867c27..0000000 --- a/test/pasearch.test +++ /dev/null @@ -1,8 +0,0 @@ -pasearch -Pipe Four -pasearch gabe -Pipe Four -pasearch wax pig -Virtually Unlimited Potential -pasearch -p gabe -\<th\> Preview \<\/th\> diff --git a/test/rhyme.test b/test/rhyme.test deleted file mode 100644 index b3c046e..0000000 --- a/test/rhyme.test +++ /dev/null @@ -1,2 +0,0 @@ -rhyme foo -outrigger.*canoe diff --git a/test/rpmsearch.test b/test/rpmsearch.test deleted file mode 100644 index a87723b..0000000 --- a/test/rpmsearch.test +++ /dev/null @@ -1,2 +0,0 @@ -rpmsearch surfraw -surfraw-.*\.noarch
JNRowe/surfraw
28b7c189c4c841f3d1ee03fd8f72bdf0a61e3496
Elvi cleanup (g-m).
diff --git a/elvi/gcache b/elvi/gcache index 8dae92a..6c4a428 100755 --- a/elvi/gcache +++ b/elvi/gcache @@ -1,49 +1,49 @@ #!/bin/sh # $Id$ # elvis: gcache -- Search the web using Google cache (www.google.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_cache_graphic 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [option] [URL]... Description: Surfraw shows the cached page using Google (www.google.com) Local option: -i, -images Retrieve the stored page WITH images and media. Default: textonly. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -i*) setoptyn SURFRAW_cache_graphic 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if !( test -n "$SURFRAW_lang" ); then SURFRAW_lang="en"; fi if test -z "$w3_args"; then - w3_browse_url "http://www.google.com/intl/$SURFRAW_lang/help/features_list.html#cached" + w3_browse_url "https://www.google.com/intl/$SURFRAW_lang/help/features_list.html#cached" else escaped_args=`w3_url_of_arg $w3_args` if [ "$SURFRAW_cache_graphic" = 1 ]; then - w3_browse_url "http://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang" + w3_browse_url "https://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang" else - w3_browse_url "http://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang&strip=1" + w3_browse_url "https://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang&strip=1" fi fi diff --git a/elvi/genbugs b/elvi/genbugs index c4f9c5b..457a128 100755 --- a/elvi/genbugs +++ b/elvi/genbugs @@ -1,24 +1,24 @@ #!/bin/sh # elvis: genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Surfraw search the Gentoo bug tracker (bugs.gentoo.org) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://bugs.gentoo.org/" + w3_browse_url "https://bugs.gentoo.org/" else escaped_args=`w3_url_of_arg $w3_args` terms=`echo $escaped_args | sed 's/%20/+/g'` - w3_browse_url "http://bugs.gentoo.org/buglist.cgi?quicksearch=${terms}" + w3_browse_url "https://bugs.gentoo.org/buglist.cgi?quicksearch=${terms}" fi diff --git a/elvi/genportage b/elvi/genportage index 61bfbe7..9e73f1c 100755 --- a/elvi/genportage +++ b/elvi/genportage @@ -1,28 +1,28 @@ #!/bin/sh # # Original Author: J.R. Mauro # # Modified to use Gentoo Portage Overlays # as gentoo-portage.com has gone -- ianb # # elvis: genportage -- Search gentoo-portage.com for packages . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search gentoo portage overlays for packages EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://gpo.zugaina.org" + w3_browse_url "https://gpo.zugaina.org" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://gpo.zugaina.org/Search?search=${escaped_args}" + w3_browse_url "https://gpo.zugaina.org/Search?search=${escaped_args}" fi diff --git a/elvi/gmane b/elvi/gmane index 23dc35e..a556d2a 100755 --- a/elvi/gmane +++ b/elvi/gmane @@ -1,85 +1,85 @@ #!/bin/sh # elvis: gmane -- Search mailing list with gmane (gmane.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_gmane_or 0 defyn SURFRAW_gmane_listsearch 0 def SURFRAW_gmane_list "" def SURFRAW_gmane_author "" def SURFRAW_gmane_sort "relevance" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search mailing lists with gmane (gmane.org) Local options: -list=LIST Search list(s) eg -l=gmane.os.openbsd.vax or -l="gmane.os.openbsd.*" -L Search by list name instead of contents -author=NAME Limit search to posts by NAME Default: $SURFRAW_gmane_results Environment: SURFRAW_gmane_results -sort= Sort by: relevance Relevance date Newest first revdate Oldest first -or OR search results instead of ANDing. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -li*=*) setopt SURFRAW_gmane_group "$optarg" ;; -au*=*) setopt SURFRAW_gmane_author "$optarg" ;; -so*=*) setopt SURFRAW_gmane_sort "$optarg" ;; -L) setoptyn SURFRAW_gmane_listsearch 1 ;; -or) setoptyn SURFRAW_gmane_or 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if test -z "$w3_args" then if ifyes SURFRAW_gmane_listsearch then - url=http://gmane.org/find.php + url=https://gmane.org/find.php else url=http://search.gmane.org/ fi else escaped_args=`w3_url_of_arg $w3_args` if ifyes SURFRAW_gmane_listsearch then url="http://dir.gmane.org/search.php?match=${escaped_args}" else url="http://search.gmane.org/?query=${escaped_args}&sort=${SURFRAW_gmane_sort}" if [ "$SURFRAW_gmane_author" != "" ] then url="${url}&author=${SURFRAW_gmane_author}" fi if ifyes SURFRAW_gmane_or then url="${url}&DEFAULTOP=or" else url="${url}&DEFAULTOP=and" fi if [ "${SURFRAW_gmane_group}" != "" ] then url="${url}&group=${SURFRAW_gmane_group}" fi fi fi w3_browse_url "$url" diff --git a/elvi/google b/elvi/google index df180c3..d2bba19 100755 --- a/elvi/google +++ b/elvi/google @@ -1,129 +1,129 @@ #!/bin/sh # $Id$ # elvis: google -- Search the web using Google (www.google.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_google_results "$SURFRAW_results" def SURFRAW_google_search search defyn SURFRAW_google_lucky 0 def SURFRAW_google_country us def SURFRAW_google_safe default } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Google (www.google.com) Local options: -l, -lucky Feeling lucky? Jump to first result. -results=NUM Number of search results returned Default: $SURFRAW_google_results Environment: SURFRAW_google_results -search= Specialized search on topic images | Images videos | Videos maps | Maps groups | groups news | News bsd | BSD linux | Linux mac | Apple Macintosh unclesam | U.S. Government Environment: SURFRAW_google_search -country= Select regional google site Default is us (google.com) <ISO 3166 alpha-2 code> Environment: SURFRAW_google_country -i, -images Image Search (same as -search=images) -v, -videos Video Search (same as -search=videos) -m, -maps Map Search (same as -search=maps) -n, -news News Search (same as -search=news) -G, -groups Groups Search (same as -search=groups) -safe= Safe Search level default | Default: $SURFRAW_google_safe off | Environment: SURFRAW_google_safe moderate | strict | EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -r*=*) setopt SURFRAW_google_results "$optarg" ;; -sa*=*) setopt SURFRAW_google_safe "$optarg" ;; -s*=*) setopt SURFRAW_google_search "$optarg" ;; -l|-lu*) setoptyn SURFRAW_google_lucky 1 ;; -c=*) setopt SURFRAW_google_country "$optarg" ;; -i*) setopt SURFRAW_google_search images ;; -v*) setopt SURFRAW_google_search videos ;; -m*) setopt SURFRAW_google_search maps ;; -n|-news) setopt SURFRAW_google_search news ;; -G|-gr|-groups) setopt SURFRAW_google_search groups ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments # Use SURFRAW_lang if present and the country has not been changed if test -n "$SURFRAW_lang" -a "$SURFRAW_google_country" = "us"; then SURFRAW_google_country="$SURFRAW_lang"; fi case "$SURFRAW_google_country" in af|ag|ai|ar|au|bd|bn|bo|br|bs|bw|by|bz|co|cu|do|ec|eg|et|fj|gi|gt|hk|jm|ly|mt|mx|my|na|nf|ng|ni|np|nz|om|pa|pe|ph|pk|pr|py|qa|sa|sb|sg|sv|tj|tr|tw|ua|ug|uy|vn) domain="com.${SURFRAW_google_country}" ;; cr|id|il|in|jp|ke|kh|kr|ls|ma|th|uk|uz|vc|ve|vg|vi|ck|yu|za|zm|zw) domain="co.${SURFRAW_google_country}" ;; us) domain="com";; *) domain="$SURFRAW_google_country" ;; esac safe="" case "$SURFRAW_google_safe" in strict) safe="&safe=strict" ;; moderate) safe="&safe=moderate" ;; off) safe="&safe=off" ;; esac -url="http://" +url="https://" if test -z "$w3_args" ; then case "$SURFRAW_google_search" in i*) url="${url}images" ;; m*) url="${url}maps" ;; g*) url="${url}groups" ;; n*) url="${url}news" ;; v*) url="${url}video" ;; *) url="${url}www" ;; esac url="${url}.google.${domain}" else search="$SURFRAW_google_search" case "$SURFRAW_google_search" in v*) url="${url}www"; search="search"; extra="&tbo=p&tbm=vid";; i*) url="${url}images" ; search="images";; m*) url="${url}maps" ; search=maps ;; g*) url="${url}groups" ; search=groups ;; n*) url="${url}news" ; search=news ;; *) url="${url}www" ;; esac url="${url}.google.${domain}/${search}" escaped_args=`w3_url_of_arg $w3_args` url="${url}?q=${escaped_args}&num=${SURFRAW_google_results}" if [ "$SURFRAW_google_lucky" = 1 ]; then button=`w3_url_escape "I'm Feeling Lucky"` url="${url}&btnI=$button" fi url="${url}${safe}${extra}" fi w3_browse_url "$url" diff --git a/elvi/gutenberg b/elvi/gutenberg index cbbae2a..d51e269 100755 --- a/elvi/gutenberg +++ b/elvi/gutenberg @@ -1,72 +1,72 @@ #!/bin/sh # $Id$ # elvis: gutenberg -- Search for books on Project Gutenberg (gutenberg.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_gutenberg_author 0 defyn SURFRAW_gutenberg_title 0 defyn SURFRAW_gutenberg_num 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search for books on Project Gutenberg (gutenberg.org) Local options: -title Search titles (default) -author Search authors -num Search etext numbers EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -a*) setoptyn SURFRAW_gutenberg_author 1 ;; -ti*) setoptyn SURFRAW_gutenberg_title 1 ;; -n*) setoptyn SURFRAW_gutenberg_num 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.gutenberg.org/" + w3_browse_url "https://www.gutenberg.org/" else escaped_args=`w3_url_of_arg $w3_args` if ifno SURFRAW_gutenberg_author && ifno SURFRAW_gutenberg_title && ifno SURFRAW_gutenberg_num then SURFRAW_gutenberg_title=1 fi - url="http://www.gutenberg.org/catalog/world/results?" + url="https://www.gutenberg.org/catalog/world/results?" if ifyes SURFRAW_gutenberg_author then url="$url&author=${escaped_args}" else url="$url&author=" fi if ifyes SURFRAW_gutenberg_title then url="$url&title=${escaped_args}" else url="$url&title=" fi if ifyes SURFRAW_gutenberg_num then url="$url&etextnr=${escaped_args}" else url="$url&etextnr=" fi w3_browse_url "$url" fi diff --git a/elvi/jamendo b/elvi/jamendo index eb0beb8..b2b2904 100755 --- a/elvi/jamendo +++ b/elvi/jamendo @@ -1,68 +1,68 @@ #!/bin/sh # elvis: jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_jamendo_lang "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Jamendo: free music with Creative Commons licenses (www.jamendo.com) Local options: -l= | -lang= Search with this l10n en|english fr|french de|german it|italian pt|portuguese pl|polish ru|russian es|spanish Default: English Environment: SURFRAW_jamendo_lang, SURFRAW_lang EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -l=*|-lang=*) setopt SURFRAW_jamendo_lang $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments # Use SURFRAW_lang if present if [ -z $SURFRAW_jamendo_lang ]; then SURFRAW_jamendo_lang="en"; fi if test -z "$w3_args"; then - w3_browse_url "http://www.jamendo.com/${SURFRAW_jamendo_lang}/search" + w3_browse_url "https://www.jamendo.com/${SURFRAW_jamendo_lang}/search" else case "$SURFRAW_jamendo_lang" in en|english) setopt SURFRAW_jamendo_lang en ;; fr|french) setopt SURFRAW_jamendo_lang fr ;; de|german) setopt SURFRAW_jamendo_lang de ;; it|italian) setopt SURFRAW_jamendo_lang it ;; pt|portuguese) setopt SURFRAW_jamendo_lang br;; pl|polish) setopt SURFRAW_jamendo_lang pl ;; ru|russian) setopt SURFRAW_jamendo_lang ru ;; es|spanish) setopt SURFRAW_jamendo_lang es ;; *) setopt SURFRAW_jamendo_lang en ;; esac escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.jamendo.com/${SURFRAW_jamendo_lang}/search?qs=q=${escaped_args}" + w3_browse_url "https://www.jamendo.com/${SURFRAW_jamendo_lang}/search?qs=q=${escaped_args}" fi diff --git a/elvi/jquery b/elvi/jquery index 195301e..b36111d 100755 --- a/elvi/jquery +++ b/elvi/jquery @@ -1,24 +1,24 @@ #!/bin/sh # elvis: jquery -- Search the jQuery documentation (api.jquery.com) # [email protected] 20130507 . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the jQuery documentation (api.jquery.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://api.jquery.com/" + w3_browse_url "https://api.jquery.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://api.jquery.com?s=${escaped_args}" + w3_browse_url "https://api.jquery.com?s=${escaped_args}" fi diff --git a/elvi/lastfm b/elvi/lastfm index 563ba61..6296426 100755 --- a/elvi/lastfm +++ b/elvi/lastfm @@ -1,45 +1,45 @@ #!/bin/sh # $Id$ # elvis: lastfm -- Search last.fm . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_lastfm_redirect 1 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search last.fm Local options: -l Show list even if exact match. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -l) setoptyn SURFRAW_lastfm_redirect 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://last.fm/" + w3_browse_url "https://last.fm/" else escaped_args=`w3_url_of_arg $w3_args` - url="http://last.fm/search?q=${escaped_args}" + url="https://last.fm/search?q=${escaped_args}" if ifno SURFRAW_lastfm_redirect then url="${url}&noredirect=1" fi w3_browse_url "${url}" fi diff --git a/elvi/leodict b/elvi/leodict index 6188a81..3f0c237 100755 --- a/elvi/leodict +++ b/elvi/leodict @@ -1,102 +1,102 @@ #!/bin/sh # elvis: leodict -- Search Leo's German <-> English dictionary (dict.leo.org) # $Id$ # surfraw plugin for the biggest English/German dictionary on # the WWW: dict.leo.org [email protected] # options added by Ian Beckwith <[email protected]> . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_leodict_link yes defyn SURFRAW_leodict_head yes defyn SURFRAW_leodict_grid yes def SURFRAW_leodict_to "either" def SURFRAW_leodict_spell "standard" def SURFRAW_leodict_tol "standard" def SURFRAW_leodict_lang "$SURFRAW_lang" } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -link*=*) setopt SURFRAW_leodict_link $optarg ;; -head*=*) setopt SURFRAW_leodict_head $optarg ;; -grid*=*) setopt SURFRAW_leodict_grid $optarg ;; -to=*) setopt SURFRAW_leodict_to $optarg ;; -spell*=*) setopt SURFRAW_leodict_spell $optarg ;; -tol*=*) setopt SURFRAW_leodict_tol $optarg ;; -lang*=*) setopt SURFRAW_leodict_lang $optarg ;; *) return 1 ;; esac return 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Surfraw search the German/English dictionary LEO (dict.leo.org) Local options: -to=de | en | either Language to translate to. Default: $SURFRAW_leodict_to Environment: SURFRAW_leodict_to -lang=en | de Language web page is in. Environment: SURFRAW_leodict_lang, SURFRAW_lang If above variables are not set, defaults to en, unless \$LANG is set and contains "de". -link=on | off Link results. Default: $SURFRAW_leodict_link Environment: SURFRAW_leodict_link -head=on | off Display headlines. Default: $SURFRAW_leodict_head Environment: SURFRAW_leodict_head -grid=on | off Show results in grid. Default: $SURFRAW_leodict_grid Environment: SURFRAW_leodict_grid -spell=off | standard | force Spelling tolerance Default: $SURFRAW_leodict_spell Environment: SURFRAW_leodict_spell -tol=off | standard | high Special characters tolerance Default: $SURFRAW_leodict_tol Environment: SURFRAW_leodict_tol EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then - w3_browse_url "http://dict.leo.org/" + w3_browse_url "https://dict.leo.org/" else escaped_args=`w3_url_of_arg $w3_args` - url="http://dict.leo.org/?search=${escaped_args}" + url="https://dict.leo.org/?search=${escaped_args}" case "$SURFRAW_leodict_lang" in en|de) ;; *) SURFRAW_leodict_lang=`perl -e 'if((exists($ENV{LANG})) && ($ENV{LANG}=~/de/i)) { print "de\n"; } else { print "en\n"; }'` ;; esac if yesno SURFRAW_leodict_link ; then url="$url&relink=on" else url="$url&relink=off";fi if yesno SURFRAW_leodict_head ; then url="$url&sectHdr=on" else url="$url&sectHdr=off";fi if yesno SURFRAW_leodict_grid ; then url="$url&tableBorder=1" else url="$url&tableBorder=0";fi if [ "$SURFRAW_leodict_to" = "de" ] ; then url="$url&searchLoc=-1" elif [ "$SURFRAW_leodict_to" = "en" ] ; then url="$url&searchLoc=1" else url="$url&searchLoc=0" ; fi if [ "$SURFRAW_leodict_spell" = "off" ] ; then url="$url&spellToler=off" elif [ "$SURFRAW_leodict_spell" = "force" ] ; then url="$url&spellToler=on" else url="$url&spellToler=standard" ; fi if [ "$SURFRAW_leodict_tol" = "high" ] ; then url="$url&cmpType=fuzzy" elif [ "$SURFRAW_leodict_tol" = "off" ] ; then url="$url&cmpType=exact" else url="$url&cmpType=relaxed" ; fi url="$url&lang=$SURFRAW_leodict_lang" w3_browse_url "$url" fi diff --git a/elvi/lsm b/elvi/lsm index 7d128bc..927a4a0 100755 --- a/elvi/lsm +++ b/elvi/lsm @@ -1,47 +1,47 @@ #!/bin/sh # $Id$ # elvis: lsm -- Search the Linux Software Map . surfraw || exit 1 w3_config_hook () { def SURFRAW_lsm_search title } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Linux Software Map (www.boutell.com/lsm/) Local options: -search= Specialized search on topic title | Title search (default) keyword Keyword search Environment: SURFRAW_lsm_search EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s*=*) setopt SURFRAW_lsm_search $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.boutell.com/lsm/" + w3_browse_url "https://www.boutell.com/lsm/" else escaped_args=`w3_url_of_arg $w3_args` if [ "$SURFRAW_lsm_search" = "keyword" ]; then - url="http://www.boutell.com/lsm/lsmbykey.cgi/submit?keyword=${escaped_args}" + url="https://www.boutell.com/lsm/lsmbykey.cgi/submit?keyword=${escaped_args}" else - url="http://www.boutell.com/lsm/lsmbytitle.cgi/submit?title=${escaped_args}" + url="https://www.boutell.com/lsm/lsmbytitle.cgi/submit?title=${escaped_args}" fi w3_browse_url "${url}" fi diff --git a/elvi/macports b/elvi/macports index 3b81d80..42ca42b 100755 --- a/elvi/macports +++ b/elvi/macports @@ -1,50 +1,50 @@ #!/bin/sh # elvis: macports -- Search macports packages (macports.org) # [email protected] 20091112 . surfraw || exit 1 w3_config_hook () { def SURFRAW_macports_by name } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search macports packages (macports.org) Local options: -by=TYPE Search by TYPE name | Software Title (default) category | Category maintainer | Maintainer variant | Variant platform | Platform Default: $SURFRAW_macports_by Environment: SURFRAW_macports_by EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -by*=*) setopt SURFRAW_macports_by $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) -url="http://www.macports.org/ports.php" +url="https://www.macports.org/ports.php" if [ -n "$escaped_args" ] then url="${url}?by=${SURFRAW_macports_by}&substr=${escaped_args}" fi w3_browse_url "$url" diff --git a/elvi/mdn b/elvi/mdn index d6ac037..c883b29 100755 --- a/elvi/mdn +++ b/elvi/mdn @@ -1,25 +1,25 @@ #!/bin/sh # [email protected] 20130923 # elvis: mdn -- Search the mozilla developer network (developer.mozilla.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Surfraw search the mozilla developer network (developer.mozilla.org) EOF w3_custom_search_usage w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args" then - w3_browse_url "http://developer.mozilla.org" + w3_browse_url "https://developer.mozilla.org" else w3_custom_search -s=developer.mozilla.org "$w3_shquoted_args" fi diff --git a/elvi/musicbrainz b/elvi/musicbrainz index 3f3b4b9..84b1fd0 100755 --- a/elvi/musicbrainz +++ b/elvi/musicbrainz @@ -1,165 +1,165 @@ #!/bin/sh # $Id$ # elvis: musicbrainz -- Search MusicBrainz (musicbrainz.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_musicbrainz_limit $SURFRAW_results def SURFRAW_musicbrainz_search artist def SURFRAW_musicbrainz_tagrelease "" def SURFRAW_musicbrainz_tagtrack "" def SURFRAW_musicbrainz_tagnum "" def SURFRAW_musicbrainz_taglen "" def SURFRAW_musicbrainz_tagpuid "" def SURFRAW_musicbrainz_tagfile "" defyn SURFRAW_musicbrainz_advanced 0 defyn SURFRAW_musicbrainz_direct 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search MusicBrainz (musicbrainz.org) Local options: -d Direct (old) search. -a Enable advanced query syntax. See: - http://musicbrainz.org/popup/TextSearchSyntax + https://musicbrainz.org/popup/TextSearchSyntax -results=NUM Number of search results returned Default: $SURFRAW_musicbrainz_results Environment: SURFRAW_musicbrainz_results 0 means all results. -search= Search type: artist | Artist [default] <*> release | Release (album) <*> release_group | Release Group label | Label <*> annotation | Annotation barcode | Barcode catno | Catalog number cdstub | CD Stub discid | Disc ID editor | Editor freedb | FreeDB freedb | FreeDB ID isrc | ISRC iswc | ISWC mbid | MBID puid | PUID recording | Recording trmid | TRM ID work | Work tag Tag Search With Tag Search, [search words] are treated as artist name, use -tag* below to specify other fields. <*> = supported by direct search (-d) Environment: SURFRAW_musicbrainz_search -tagrelease=ALBUM Album/Release tag search (implies -search=tag) -tagnum=TRACKNUM Track number tag search (implies -search=tag) -tagtrack=SONG Track tag search (implies -search=tag) -taglen=DURATION Track length tag search (implies -search=tag) -tagfile=FILENAME Filename tag search (implies -search=tag) -tagpuid=FILENAME PUID tag search (implies -search=tag) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_musicbrainz_results $optarg ;; -tagrel*=*) setopt SURFRAW_musicbrainz_tagrelease $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagnu*=*) setopt SURFRAW_musicbrainz_tagnum $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagtra*=*) setopt SURFRAW_musicbrainz_tagtrack $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagle*=*) setopt SURFRAW_musicbrainz_taglen $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagp*=*) setopt SURFRAW_musicbrainz_tagpuid $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagf*=*) setopt SURFRAW_musicbrainz_tagfile $optarg setopt SURFRAW_musicbrainz_search tag ;; -a) setoptyn SURFRAW_musicbrainz_advanced 1 ;; -d) setoptyn SURFRAW_musicbrainz_direct 1 ;; -search=*) searchtype="$optarg" case "$searchtype" in ar*) setopt SURFRAW_musicbrainz_search artist ;; release_*) setopt SURFRAW_musicbrainz_search release_group ;; release|rel|al*) setopt SURFRAW_musicbrainz_search release ;; an*) setopt SURFRAW_musicbrainz_search annotation ;; ba*) setopt SURFRAW_musicbrainz_search barcode ;; ca*) setopt SURFRAW_musicbrainz_search catno ;; cd*) setopt SURFRAW_musicbrainz_search cdstub ;; d*) setopt SURFRAW_musicbrainz_search discid ;; e*) setopt SURFRAW_musicbrainz_search editor ;; freedb|fr) setopt SURFRAW_musicbrainz_search freedb ;; freedbid) setopt SURFRAW_musicbrainz_search freedbid ;; isr*) setopt SURFRAW_musicbrainz_search isrc ;; isw*) setopt SURFRAW_musicbrainz_search iswc ;; l*) setopt SURFRAW_musicbrainz_search label ;; m*) setopt SURFRAW_musicbrainz_search mbid ;; p*) setopt SURFRAW_musicbrainz_search puid ;; rec*) setopt SURFRAW_musicbrainz_search recording ;; tr*) setopt SURFRAW_musicbrainz_search trmid ;; w*) setopt SURFRAW_musicbrainz_search work ;; ta*) setopt SURFRAW_musicbrainz_search tag ;; *) err "Search type not known" esac ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args" && test -z "$SURFRAW_musicbrainz_tagrelease" && test -z "$SURFRAW_musicbrainz_tagnum" && test -z "$SURFRAW_musicbrainz_tagtrack" && test -z "$SURFRAW_musicbrainz_taglen" && test -z "$SURFRAW_musicbrainz_tagpuid" && test -z "$SURFRAW_musicbrainz_tagfile" then - w3_browse_url "http://musicbrainz.org/search.html" + w3_browse_url "https://musicbrainz.org/search.html" else escaped_args=`w3_url_of_arg $w3_args` - url="http://musicbrainz.org" + url="https://musicbrainz.org" if ifyes SURFRAW_musicbrainz_direct then case "$SURFRAW_musicbrainz_search" in artist|release|label) url="${url}/search/oldsearch.html?query=${escaped_args}&type=${SURFRAW_musicbrainz_search}&limit=${SURFAW_musicbrainz_results}&handlearguments=1" ;; *) err "Search type $SURFRAW_musicbrainz_search not supported by Direct Search (-d)" ;; esac else case "$SURFRAW_musicbrainz_search" in artist|release_group|release|recording|work| \ label|annotation|cdstub|editor| \ freedb) url="${url}/search?query=${escaped_args}&type=${SURFRAW_musicbrainz_search}&limit=${SURFRAW_musicbrainz_limit}" if ifyes SURFRAW_musicbrainz_advanced then url="${url}&adv=on" fi ;; catno|barcode|discid|freedbid|freedb| \ puid|trmid|isrc|iswc| \ discid) url="${url}/otherlookup?${SURFRAW_musicbrainz_search}=${escaped_args}" ;; mbid) url="${url}/release/${escaped_args}" ;; tag) url="${url}/taglookup?artist=${escaped_args}&release=${SURFRAW_musicbrainz_tagrelease}&track=${SURFRAW_musicbrainz_tagtrack}&tracknum=${SURFRAW_musicbrainz_tagnum}&duration=${SURFRAW_musicbrainz_taglen}&filename=${SURFRAW_musicbrainz_tagfile}&puid=${SURFRAW_musicbrainz_puid}" ;; *) err Unknown search type "${SURFRAW_musicbrainz_search}" ;; esac fi w3_browse_url "$url" fi diff --git a/elvi/mysqldoc b/elvi/mysqldoc index 4bd6917..efcd6d0 100755 --- a/elvi/mysqldoc +++ b/elvi/mysqldoc @@ -1,63 +1,63 @@ #!/bin/sh # [email protected] 20130923 # elvis: mysqldoc -- Search mysql documentation (dev.mysql.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_mysqldoc_version all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search mysql documentation (dev.mysql.com) Local options: -a Search all versions/docs -v=VERSION Search docs for mysql version VERSION Default: $SURFRAW_mysqldoc_version Environment: SURFRAW_mysqldoc_version EOF w3_custom_search_usage w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -a) setopt SURFRAW_mysqldoc_version "all" ;; -v*=*) setopt SURFRAW_mysqldoc_version "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if test -z "$w3_args" then case "$SURFRAW_mysqldoc_version" in all) inurl="/doc/" ;; *5.7*) inurl="/doc/refman/5.7/en/" ;; *5.6*) inurl="/doc/refman/5.6/en/" ;; *5.5*) inurl="/doc/refman/5.5/en/" ;; *5.0*) inurl="/doc/refman/5.0/en/" ;; *[34]*) inurl="/doc/refman/4.1/en/" ;; *) inurl="/doc/" esac - w3_browse_url "http://dev.mysql.com${inurl}" + w3_browse_url "https://dev.mysql.com${inurl}" else case "$SURFRAW_mysqldoc_version" in all) inurl="-u=doc" ;; *5.7*) inurl="-u=doc -u=refman -u=5.7" ;; *5.6*) inurl="-u=doc -u=refman -u=5.6" ;; *5.5*) inurl="-u=doc -u=refman -u=5.5" ;; *5.0*) inurl="-u=doc -u=refman -u=5.0" ;; *[34]*) inurl="-u=doc -u=refman -u=4.1" ;; *) inurl="-u=doc" ;; esac w3_custom_search -s=dev.mysql.com $inurl "$w3_shquoted_args" fi
JNRowe/surfraw
2d9eb34e88073f3448074dc51f5e1deac45480f5
Clean up the dmoz and cablesearch removals.
diff --git a/README b/README index f6ac9a7..cec4b81 100644 --- a/README +++ b/README @@ -1,402 +1,400 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Home Page: http://surfraw.alioth.debian.org ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web New: http://surfraw.alioth.debian.org Old: http://surfraw.sourceforge.net/ Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS Surfraw now supports bookmarks. To add a bookmark, add it to to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/rhyme -method=perfect Julian OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers -cablesearch -- search for leaked diplomatic communications cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) deli -- Search Delicious bookmarks discogs -- Search the Discogs database of music information (www.discogs.com) -dmoz -- Search the Open Directory Project web directory (dmoz.org) duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) openports -- search openports for OpenBSD packages opensearch -- Search an OpenSearch-enabled website oraclesearch -- Search an OpenSearch-enabled website pasearch -- Search the unofficial Penny Arcade archives (pipefour.org/pa) pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) rhyme -- Search for rhymes et al using Lycos Rhyme (rhyme.lycos.com) rpmsearch -- Search for RPMs in various distros scholar -- Search Google Scholar (scholar.google.com) scicom -- Search Scientific Commons scirus -- Search for science using Scirus (scirus.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) wetandwild -- Real time weather information (many sources) wikipedia -- Search the free encyclopedia wikipedia woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org yacy -- Search YaCy P2P search, including ScienceNet yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) yubnub -- Use the social command-line for the web (yubnub.org) All elvi have useful low calorie help, for example: Usage: rhyme [options] [search words]... Description: Surfraw search for rhymes and other word correlations using Lycos Rhyme (rhyme.lycos.com) Example: $ rhyme Julian $ rhyme -method=rel surfer Results: Hurclean St. Julien. surfboarder, bather, natator, swimmer Local options: -method= Type of word correlation to search for prefect | Perfect rhyme syn | Synonyms hom | Homophones cons | Consonsant rhymes only rel | Semantically related words sub | Phrases spell | Similar spellings pic | Pictures shake | Match with Shakespeare archives def Find wordnet definition Default: perfect Environment: SURFRAW_rhyme_method Global options: -browser=EXECUTABLE Set browser Default: sensible-browser -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: yes Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: yes Environment: SURFRAW_graphical -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: no Environment: SURFRAW_new_window -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: no Environment: SURFRAW_quote_args -version Display Surfraw version (2.2.7) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________ diff --git a/elvi/Makefile.am b/elvi/Makefile.am index 44527e2..fa399a0 100644 --- a/elvi/Makefile.am +++ b/elvi/Makefile.am @@ -1,132 +1,130 @@ # $Id$ elvidir=$(ELVIDIR) dist_elvi_SCRIPTS = \ S \ W \ acronym \ ads \ alioth \ amazon \ archpkg \ archwiki \ arxiv \ ask \ aur \ austlii \ bing \ bbcnews \ bookfinder \ bugmenot \ bugzilla \ - cablesearch \ cia \ cisco \ cite \ cliki \ cnn \ comlaw \ commandlinefu \ ctan \ currency \ cve \ debbugs \ debcodesearch \ debcontents \ deblists \ deblogs \ debpackages \ debpkghome \ debpts \ debsec \ debvcsbrowse \ debwiki \ deja \ deli \ discogs \ - dmoz \ duckduckgo \ ebay \ etym \ excite \ f5 \ foldoc \ finkpkg \ freebsd \ freedb \ freshmeat \ fsfdir \ gcache \ genbugs \ genportage \ github \ gmane \ google \ gutenberg \ imdb \ ixquick \ jamendo \ javasun \ jquery \ l1sp \ lastfm \ leodict \ lsm \ macports \ mathworld \ mdn \ mininova \ musicbrainz \ mysqldoc \ netbsd \ nlab \ ntrs \ openbsd \ openports \ opensearch \ oraclesearch \ pasearch \ pgdoc \ pgpkeys \ phpdoc \ pin \ piratebay \ priberam \ pubmed \ rae \ rfc \ rhyme \ rpmsearch \ scholar \ scicom \ scirus \ scpan \ searx \ slashdot \ slinuxdoc \ sourceforge \ springer \ stack \ stockquote \ thesaurus \ translate \ urban \ w3css \ w3html \ w3link \ w3rdf \ wayback \ webster \ wetandwild \ wikipedia \ woffle \ wolfram \ worldwidescience \ yacy \ yahoo \ yandex \ youtube \ yubnub uninstall-local: -rmdir $(DESTDIR)$(PREFIX)/$(ELVIDIR) diff --git a/links.IN b/links.IN index bd9170a..6c3f555 100644 --- a/links.IN +++ b/links.IN @@ -1,120 +1,118 @@ elvi.1sr.gz @mandir@/man1/W.1.gz elvi.1sr.gz @mandir@/man1/S.1sr.gz elvi.1sr.gz @mandir@/man1/acronym.1sr.gz elvi.1sr.gz @mandir@/man1/ads.1sr.gz elvi.1sr.gz @mandir@/man1/alioth.1sr.gz elvi.1sr.gz @mandir@/man1/amazon.1sr.gz elvi.1sr.gz @mandir@/man1/archpkg.1sr.gz elvi.1sr.gz @mandir@/man1/archwiki.1sr.gz elvi.1sr.gz @mandir@/man1/arxiv.1sr.gz elvi.1sr.gz @mandir@/man1/ask.1sr.gz elvi.1sr.gz @mandir@/man1/aur.1sr.gz elvi.1sr.gz @mandir@/man1/austlii.1sr.gz elvi.1sr.gz @mandir@/man1/bing.1sr.gz elvi.1sr.gz @mandir@/man1/bbcnews.1sr.gz elvi.1sr.gz @mandir@/man1/bookfinder.1sr.gz elvi.1sr.gz @mandir@/man1/bugmenot.1sr.gz elvi.1sr.gz @mandir@/man1/bugzilla.1sr.gz -elvi.1sr.gz @mandir@/man1/cablesearch.1sr.gz elvi.1sr.gz @mandir@/man1/cite.1sr.gz elvi.1sr.gz @mandir@/man1/cia.1sr.gz elvi.1sr.gz @mandir@/man1/cliki.1sr.gz elvi.1sr.gz @mandir@/man1/cnn.1sr.gz elvi.1sr.gz @mandir@/man1/comlaw.1sr.gz elvi.1sr.gz @mandir@/man1/commandlinefu.1sr.gz elvi.1sr.gz @mandir@/man1/ctan.1sr.gz elvi.1sr.gz @mandir@/man1/currency.1sr.gz elvi.1sr.gz @mandir@/man1/cve.1sr.gz elvi.1sr.gz @mandir@/man1/debbugs.1sr.gz elvi.1sr.gz @mandir@/man1/debcodesearch.1sr.gz elvi.1sr.gz @mandir@/man1/debcontents.1sr.gz elvi.1sr.gz @mandir@/man1/deblists.1sr.gz elvi.1sr.gz @mandir@/man1/deblogs.1sr.gz elvi.1sr.gz @mandir@/man1/debpackages.1sr.gz elvi.1sr.gz @mandir@/man1/debpkghome.1sr.gz elvi.1sr.gz @mandir@/man1/debpts.1sr.gz elvi.1sr.gz @mandir@/man1/debsec.1sr.gz elvi.1sr.gz @mandir@/man1/debvcsbrowse.1sr.gz elvi.1sr.gz @mandir@/man1/debwiki.1sr.gz elvi.1sr.gz @mandir@/man1/deja.1sr.gz elvi.1sr.gz @mandir@/man1/deli.1sr.gz elvi.1sr.gz @mandir@/man1/discogs.1sr.gz -elvi.1sr.gz @mandir@/man1/dmoz.1sr.gz elvi.1sr.gz @mandir@/man1/duckduckgo.1sr.gz elvi.1sr.gz @mandir@/man1/ebay.1sr.gz elvi.1sr.gz @mandir@/man1/etym.1sr.gz elvi.1sr.gz @mandir@/man1/excite.1sr.gz elvi.1sr.gz @mandir@/man1/finkpkg.1sr.gz elvi.1sr.gz @mandir@/man1/foldoc.1sr.gz elvi.1sr.gz @mandir@/man1/freebsd.1sr.gz elvi.1sr.gz @mandir@/man1/freedb.1sr.gz elvi.1sr.gz @mandir@/man1/freshmeat.1sr.gz elvi.1sr.gz @mandir@/man1/fsfdir.1sr.gz elvi.1sr.gz @mandir@/man1/gcache.1sr.gz elvi.1sr.gz @mandir@/man1/genbugs.1sr.gz elvi.1sr.gz @mandir@/man1/genportage.1sr.gz elvi.1sr.gz @mandir@/man1/github.1sr.gz elvi.1sr.gz @mandir@/man1/google.1sr.gz elvi.1sr.gz @mandir@/man1/gutenberg.1sr.gz elvi.1sr.gz @mandir@/man1/imdb.1sr.gz elvi.1sr.gz @mandir@/man1/ixquick.1sr.gz elvi.1sr.gz @mandir@/man1/jamendo.1sr.gz elvi.1sr.gz @mandir@/man1/javasun.1sr.gz elvi.1sr.gz @mandir@/man1/lastfm.1sr.gz elvi.1sr.gz @mandir@/man1/leodict.1sr.gz elvi.1sr.gz @mandir@/man1/l1sp.1sr.gz elvi.1sr.gz @mandir@/man1/lsm.1sr.gz elvi.1sr.gz @mandir@/man1/macports.1sr.gz elvi.1sr.gz @mandir@/man1/mathworld.1sr.gz elvi.1sr.gz @mandir@/man1/mdn.1sr.gz elvi.1sr.gz @mandir@/man1/mininova.1sr.gz elvi.1sr.gz @mandir@/man1/musicbrainz.1sr.gz elvi.1sr.gz @mandir@/man1/mysqldoc.1sr.gz elvi.1sr.gz @mandir@/man1/netbsd.1sr.gz elvi.1sr.gz @mandir@/man1/ntrs.1sr.gz elvi.1sr.gz @mandir@/man1/openbsd.1sr.gz elvi.1sr.gz @mandir@/man1/openports.1sr.gz elvi.1sr.gz @mandir@/man1/opensearch.1sr.gz elvi.1sr.gz @mandir@/man1/oraclesearch.1sr.gz elvi.1sr.gz @mandir@/man1/pasearch.1sr.gz elvi.1sr.gz @mandir@/man1/pgdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pgpkeys.1sr.gz elvi.1sr.gz @mandir@/man1/phpdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pin.1sr.gz elvi.1sr.gz @mandir@/man1/piratebay.1sr.gz elvi.1sr.gz @mandir@/man1/priberam.1sr.gz elvi.1sr.gz @mandir@/man1/pubmed.1sr.gz elvi.1sr.gz @mandir@/man1/rae.1sr.gz elvi.1sr.gz @mandir@/man1/rfc.1sr.gz elvi.1sr.gz @mandir@/man1/rhyme.1sr.gz elvi.1sr.gz @mandir@/man1/rpmsearch.1sr.gz elvi.1sr.gz @mandir@/man1/scholar.1sr.gz elvi.1sr.gz @mandir@/man1/scicom.1sr.gz elvi.1sr.gz @mandir@/man1/scirus.1sr.gz elvi.1sr.gz @mandir@/man1/scpan.1sr.gz elvi.1sr.gz @mandir@/man1/searx.1sr.gz elvi.1sr.gz @mandir@/man1/slashdot.1sr.gz elvi.1sr.gz @mandir@/man1/slinuxdoc.1sr.gz elvi.1sr.gz @mandir@/man1/sourceforge.1sr.gz elvi.1sr.gz @mandir@/man1/springer.1sr.gz elvi.1sr.gz @mandir@/man1/stack.1sr.gz elvi.1sr.gz @mandir@/man1/stockquote.1sr.gz elvi.1sr.gz @mandir@/man1/thesaurus.1sr.gz elvi.1sr.gz @mandir@/man1/translate.1sr.gz elvi.1sr.gz @mandir@/man1/urban.1sr.gz elvi.1sr.gz @mandir@/man1/w3css.1sr.gz elvi.1sr.gz @mandir@/man1/w3html.1sr.gz elvi.1sr.gz @mandir@/man1/w3link.1sr.gz elvi.1sr.gz @mandir@/man1/w3rdf.1sr.gz elvi.1sr.gz @mandir@/man1/wayback.1sr.gz elvi.1sr.gz @mandir@/man1/webster.1sr.gz elvi.1sr.gz @mandir@/man1/wetandwild.1sr.gz elvi.1sr.gz @mandir@/man1/wikipedia.1sr.gz elvi.1sr.gz @mandir@/man1/woffle.1sr.gz elvi.1sr.gz @mandir@/man1/wolfram.1sr.gz elvi.1sr.gz @mandir@/man1/worldwidescience.1sr.gz elvi.1sr.gz @mandir@/man1/yacy.1sr.gz elvi.1sr.gz @mandir@/man1/yahoo.1sr.gz elvi.1sr.gz @mandir@/man1/yandex.1sr.gz elvi.1sr.gz @mandir@/man1/youtube.1sr.gz elvi.1sr.gz @mandir@/man1/yubnub.1sr.gz diff --git a/test/Makefile.am b/test/Makefile.am index 64009b1..2dd709b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,34 +1,34 @@ EXTRA_DIST = runtests elviwithouttests README COOKIES W.test S.test \ acronym.test ads.test alioth.test amazon.test archpkg.test \ archwiki.test arxiv.test ask.test aur.test austlii.test \ - bbcnews.test bing.test bookfinder.test bugmenot.test \ - bugzilla.test cablesearch.test cia.test cisco.test cite.test \ + bbcnews.test bing.test bookfinder.test bugmenot.test \ + bugzilla.test cia.test cisco.test cite.test \ cliki.test cnn.test comlaw.test ctan.test currency.test \ cve.test debbugs.test debcodesearch.test debcontents.test \ deblists.test deblogs.test debpackages.test debpkghome.test \ debpts.test debsec.test debvcsbrowse.test debwiki.test \ - deja.test deli.test discogs.test dmoz.test duckduckgo.test \ - ebay.test etym.test excite.test f5.test finkpkg.test \ - foldoc.test freebsd.test freedb.test freshmeat.test \ - fsfdir.test gcache.test genbugs.test genportage.test \ + deja.test deli.test discogs.test duckduckgo.test \ + ebay.test etym.test excite.test f5.test finkpkg.test \ + foldoc.test freebsd.test freedb.test freshmeat.test \ + fsfdir.test gcache.test genbugs.test genportage.test \ github.test gmane.test google.test gutenberg.test imdb.test \ - ixquick.test jamendo.test javasun.test jquery.test lastfm.test \ + ixquick.test jamendo.test javasun.test jquery.test lastfm.test \ leodict.test l1sp.test lsm.test macports.test mathworld.test \ mdn.test mininova.test musicbrainz.test mysqldoc.test \ - netbsd.test ntrs.test openbsd.test openports.test \ + netbsd.test ntrs.test openbsd.test openports.test \ opensearch.test oraclesearch.test pasearch.test pgdoc.test \ - phpdoc.test pin.test piratebay.test pgpkeys.test priberam.test \ + phpdoc.test pin.test piratebay.test pgpkeys.test priberam.test \ pubmed.test rae.test rfc.test rhyme.test rpmsearch.test \ - scholar.test scicom.test scirus.test scpan.test slashdot.test \ + scholar.test scicom.test scirus.test scpan.test slashdot.test \ slinuxdoc.test sourceforge.test springer.test stack.test \ stockquote.test thesaurus.test translate.test urban.test \ w3css.test w3html.test w3link.test w3rdf.test wayback.test \ webster.test wetandwild.test wikipedia.test wolfram.test \ woffle.test worldwidescience.test yacy.test yahoo.test \ yandex.test youtube.test yubnub.test test: ./runtests ./elviwithouttests diff --git a/test/cablesearch.test b/test/cablesearch.test deleted file mode 100644 index a8bc8ed..0000000 --- a/test/cablesearch.test +++ /dev/null @@ -1,2 +0,0 @@ -cablesearch america -Chile diff --git a/test/dmoz.test b/test/dmoz.test deleted file mode 100644 index 0da17d5..0000000 --- a/test/dmoz.test +++ /dev/null @@ -1,2 +0,0 @@ -dmoz foo -1-20 of \d+
JNRowe/surfraw
0ae51b6094debeeb6f0df6abf6bc41ad196e9674
Elvi cleanup (d-f).
diff --git a/elvi/debbugs b/elvi/debbugs index 2a46471..6ac05aa 100755 --- a/elvi/debbugs +++ b/elvi/debbugs @@ -1,235 +1,235 @@ #!/bin/sh # $Id$ # elvis: debbugs -- Search the debian BTS (bugs.debian.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debbugs_search pkg def SURFRAW_debbugs_version "" def SURFRAW_debbugs_dist "" defyn SURFRAW_debbugs_archive 0 defyn SURFRAW_debbugs_merge 0 defyn SURFRAW_debbugs_statussort 1 defyn SURFRAW_debbugs_head 1 defyn SURFRAW_debbugs_foot 1 def SURFRAW_debbugs_incstatus "" def SURFRAW_debbugs_excstatus "" def SURFRAW_debbugs_incsev "" def SURFRAW_debbugs_excsev "" def SURFRAW_debbugs_inctag "" def SURFRAW_debbugs_exctag "" defyn SURFRAW_debbugs_asmbox 0 defyn SURFRAW_debbugs_headers 0 defyn SURFRAW_debbugs_boring 0 defyn SURFRAW_debbugs_revstat 0 defyn SURFRAW_debbugs_revsev 0 defyn SURFRAW_debbugs_revbugs 0 defyn setsearch 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [package | bug number | maintainer email] Description: Surfraw search debian BTS (bugs.debian.org) Examples: debbugs 20000 | show report for bug #20000 debbugs [email protected] | show bugs for csurchi debbugs surfraw | show bugs for surfraw package debbugs -raw -rb surfraw | show surfraw bugs newest first Defaults if -search is not supplied: If arg is numeric, searches by bug number, If it contains '@', searches by maintainer, Otherwise, searches by package. Local options: -search= pkg | Search type. src | bug | (bug number) maint | tag | submitter | severity | tag -s Alias for -search=src -version=VERSION Package version. -dist=oldstable | Distribution stable | proposed-updates | testing | unstable | experimental | testing-proposed-updates -arc Show archived bugs. -raw Do not sort by status or severity. -rb Reverse order of bugs shown. -rst Reverse order of statuses shown. -rse Reverse order of severities shown. -merge Display merged bugs only once. -nohead Do not show table of contents header. -nofoot Do not show statistics in the footer. -mbox View results in mbox format. * -sh Show headers. * -boring Show boring messages. * (* = only when searching by bug number.) -incstat=stat1,stat2 Include given status list. -exstat=stat3,stat4 Exclude given status list. Available statuses: open, forwarded, pending, fixed, done. -incsev=sev1,sev2 Include given severities. -exsev=sev3,sev4 Exclude given severities. Available severities: critical, grave, serious, important, normal, minor, wishlist, fixed. -inctag=tag1,tag2 Include given tags. -extag=tag3,tag4 Exclude given tags. Available tags: potato, woody, sarge, sarge-ignore, etch, etch-ignore, sid, experimental, confirmed, d-i, fixed, fixed-in-experimental, fixed-upstream, help, l10n, moreinfo, patch, pending, security, unreproducible, upstream, wontfix, ipv6, lfs EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s) setopt SURFRAW_debbugs_search src ; setoptyn setsearch 1 ;; -se*=*) setopt SURFRAW_debbugs_search $optarg; setoptyn setsearch 1 ;; -ve*=*) setopt SURFRAW_debbugs_version $optarg ;; -dis*=*) setopt SURFRAW_debbugs_dist $optarg ;; -arc*) setoptyn SURFRAW_debbugs_archive 1;; -mer*) setoptyn SURFRAW_debbugs_merge 1;; -raw*) setoptyn SURFRAW_debbugs_statussort 0;; -noh*) setoptyn SURFRAW_debbugs_head 0;; -nof*) setoptyn SURFRAW_debbugs_foot 0;; -in*stat*=*) setopt SURFRAW_debbugs_incstatus $optarg;; -ex*stat*=*) setopt SURFRAW_debbugs_excstatus $optarg;; -in*sev*=*) setopt SURFRAW_debbugs_incsev $optarg;; -ex*sev*=*) setopt SURFRAW_debbugs_excsev $optarg;; -in*tag*=*) setopt SURFRAW_debbugs_inctag $optarg;; -ex*tag*=*) setopt SURFRAW_debbugs_exctag $optarg;; -rb*) setoptyn SURFRAW_debbugs_revbugs 1;; -rst*) setoptyn SURFRAW_debbugs_revstat 1;; -rse*) setoptyn SURFRAW_debbugs_revsev 1;; -mb*) setoptyn SURFRAW_debbugs_asmbox 1;; -sh*) setoptyn SURFRAW_debbugs_headers 1;; -bo*) setoptyn SURFRAW_debbugs_boring 1;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://bugs.debian.org/" + w3_browse_url "https://www.debian.org/Bugs" else escaped_args=`w3_url_of_arg $w3_args` setoptyn donum 0 setoptyn domaint 0 case "$SURFRAW_debbugs_search" in bug*) setoptyn donum 1;; esac # default search unless searchtype set on cmdline if ifno setsearch then export escaped_args if perl -e 'if($ENV{escaped_args} =~/^((\#|\%23)(\s|\%20)*)?\d+$/) { exit 0; } exit 1;' then # %23 = uri escaped '#', %20=' ' setoptyn donum 1 elif perl -e 'if($ENV{escaped_args} =~/\%40|@/) { exit 0; } exit 1;' then # %40 = uri escaped '@' setopt SURFRAW_debbugs_search "maint" fi fi if ifyes donum then - url="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${escaped_args}" + url="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${escaped_args}" if yesno SURFRAW_debbugs_asmbox then url="$url&mbox=yes" fi if yesno SURFRAW_debbugs_headers then url="$url&trim=no" fi if yesno SURFRAW_debbugs_boring then url="$url&boring=yes" fi else - url="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=${SURFRAW_debbugs_search}&version=${SURFRAW_debbugs_version}&dist=${SURFRAW_debbugs_dist}&data=${escaped_args}" + url="https://bugs.debian.org/cgi-bin/pkgreport.cgi?which=${SURFRAW_debbugs_search}&version=${SURFRAW_debbugs_version}&dist=${SURFRAW_debbugs_dist}&data=${escaped_args}" if yesno SURFRAW_debbugs_archive then url="$url&archive=yes" else url="$url&archive=no" fi if ifyes SURFRAW_debbugs_merge then url="$url&repeatmerged=no" fi if ifno SURFRAW_debbugs_statussort then url="$url&raw=yes" fi if ifno SURFRAW_debbugs_head then url="$url&show_list_header=no" fi if ifno SURFRAW_debbugs_foot then url="$url&show_list_footer=no" fi if ifyes SURFRAW_debbugs_revstat then url="$url&pend-rev=yes" fi if ifyes SURFRAW_debbugs_revsev then url="$url&sev-rev=yes" fi if ifyes SURFRAW_debbugs_revbugs then url="$url&bug-rev=yes" fi if [ "$SURFRAW_debbugs_incstatus" != "" ] then add=`echo "$SURFRAW_debbugs_incstatus"|perl -ne 's/pending/pending-fixed/g;s/open/pending/g;print(join("&pend-inc=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi if [ "$SURFRAW_debbugs_excstatus" != "" ] then add=`echo "$SURFRAW_debbugs_excstatus"|perl -ne 'print(join("&pend-exc=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi if [ "$SURFRAW_debbugs_incsev" != "" ] then add=`echo "$SURFRAW_debbugs_incsev"|perl -ne 'print(join("&sev-inc=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi if [ "$SURFRAW_debbugs_excsev" != "" ] then add=`echo "$SURFRAW_debbugs_excsev"|perl -ne 'print(join("&sev-exc=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi if [ "$SURFRAW_debbugs_inctag" != "" ] then add=`echo "$SURFRAW_debbugs_inctag"|perl -ne 'print(join("&include=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi if [ "$SURFRAW_debbugs_exctag" != "" ] then add=`echo "$SURFRAW_debbugs_exctag"|perl -ne 'print(join("&exclude=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi fi w3_browse_url "$url" fi diff --git a/elvi/debcodesearch b/elvi/debcodesearch index dbcfa6c..4805e82 100755 --- a/elvi/debcodesearch +++ b/elvi/debcodesearch @@ -1,23 +1,23 @@ #!/bin/sh # [email protected] 20130504 # elvis: debcodesearch -- Search debian source code . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search source code of debian packages EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://codesearch.debian.net" + w3_browse_url "https://codesearch.debian.net" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://codesearch.debian.net/search?q=${escaped_args}" + w3_browse_url "https://codesearch.debian.net/search?q=${escaped_args}" fi diff --git a/elvi/debcontents b/elvi/debcontents index b47275b..3dc65c3 100755 --- a/elvi/debcontents +++ b/elvi/debcontents @@ -1,155 +1,155 @@ #!/bin/sh # $Id$ # elvis: debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debcontents_arch i386 def SURFRAW_debcontents_distro stable def SURFRAW_debcontents_search "files" defyn SURFRAW_debcontents_ubuntu no defyn SURFRAW_debcontents_archive no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) Local options: -a Search archived debian releases -u Search ubuntu packages instead of debian -search= Type of search files | Packages that contain files named like this path | Paths ending with the keyword word | Packages that contain files or directories whose names contain the keyword Default: $SURFRAW_debcontents_search Environment: SURFRAW_debcontents_search -arch= Specialized search on architecture i386 | Intel x86 (all) powerpc | PowerPC (all) amd64 | AMD64 (all) m68k | Motorola 680x0 (debian, archive.debian) alpha | Alpha (debian, archive.debian) sparc | SPARC (debian, archive.debian) arm | ARM (debian, archive.debian) hppa | HP PA/RISC (debian, archive.debian) ia64 | Intel IA-64 (debian, archive.debian) mips | MIPS (debian, archive.debian) mipsel | MIPS (DEC) (debian, archive.debian) s390 | IBM S/390 (debian, archive.debian) hurd-i386 | Hurd (i386) (debian) kfreebsd-amd64 | kFreeBSD (amd64) (debian) kfreebsd-i386 kFreeBSD (i386) (debian) Default: $SURFRAW_debcontents_arch Environment: SURFRAW_debcontents_arch -distro= Specific distribution Debian: stable | Stable testing | Testing unstable | Unstable oldstable | Old Stable Archived Debian (-a): bo | 1.3.1 hamm | 2.0 slink | 2.1 potato | 2.2 woody | 3.0 sarge | 3.1 etch | 4.0 Ubuntu (-u): dapper | Dapper dapper-updates | Dapper Updates dapper-backports | Dapper Backports hardy | Hardy hardy-updates | Hardy Updates hardy-backports | Hardy Backports intrepid | Intrepid intrepid-updates | Intrepid Updates intrepid-backports| Intrepid Backports jaunty | Jaunty jaunty-updates | Jaunty Updates jaunty-backports | Jaunty Backports karmic | Karmic karmic-updates | Karmic Updates karmic-backports | Karmic Backports lucid | Lucid lucid-updates | Lucid Updates lucid-backports | Lucid Backports maverick | Maverick maverick-updates | Maverick Updates maverick-backports| Maverick Backports natty | Natty natty-updates | Natty Updates natty-backports | Natty Backports Default: $SURFRAW_debcontents_distro Environment: SURFRAW_debcontents_distro EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -arch=*) setopt SURFRAW_debcontents_arch $optarg ;; -distro=*) setopt SURFRAW_debcontents_distro $optarg ;; -search=*) setopt SURFRAW_debcontents_search $optarg ;; -u*) setoptyn SURFRAW_debcontents_ubuntu yes ;; -a*) setoptyn SURFRAW_debcontents_archive yes ;; -ca*) setoptyn SURFRAW_debcontents_usecase yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if ifyes SURFRAW_debcontents_ubuntu then searchpage="http://packages.ubuntu.com/#search_contents" searchurl="http://packages.ubuntu.com/search" elif ifyes SURFRAW_debcontents_archive then - searchpage="http://archive.debian.net/#search_contents" - searchurl="http://archive.debian.net/search" + searchpage="https://archive.debian.net/#search_contents" + searchurl="https://archive.debian.net/search" else - searchpage="http://packages.debian.org/#search_contents" - searchurl="http://packages.debian.org/search" + searchpage="https://packages.debian.org/#search_contents" + searchurl="https://packages.debian.org/search" fi if test -z "$w3_args"; then w3_browse_url "$searchpage" else escaped_args=`w3_url_of_arg $w3_args` if ifyes SURFRAW_debcontents_ubuntu then if [ "$SURFRAW_debcontents_distro" = "stable" ] then SURFRAW_debcontents_distro=raring fi fi url="$searchurl?keywords=${escaped_args}&searchon=contents" url="$url&arch=${SURFRAW_debcontents_arch}" url="$url&suite=${SURFRAW_debcontents_distro}" case "$SURFRAW_debcontents_search" in p*) if ifyes SURFRAW_debcontents_ubuntu || ifyes SURFRAW_debcontents_archive then searchmode="" else searchmode=path fi;; f*) searchmode=exactfilename ;; w*) searchmode=filename ;; *) err "Unknown search type" ;; esac url="${url}&mode=${searchmode}" w3_browse_url "$url" fi diff --git a/elvi/deblists b/elvi/deblists index 4a07cab..12a0243 100755 --- a/elvi/deblists +++ b/elvi/deblists @@ -1,104 +1,104 @@ #!/bin/sh # elvis: deblists -- Search debian mailing lists (lists.debian.org/search.html) # [email protected] 2003919 . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_deblists_matchany no defyn SURFRAW_deblists_searchmsgid no def SURFRAW_deblists_msgidsearchtype direct def SURFRAW_deblists_sort relevance def SURFRAW_deblists_results $SURFRAW_results } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search patterns]... Description: Surfraw search debian mailing lists (lists.debian.org/search.html) Local options: -results=NUM Number of search results returned Default: $SURFRAW_deblists_results Environment: SURFRAW_deblists_results -m|-msgid Search by message-id, jump to result -mv Search by message-id and show matches -ml Search by message-id and show links -any Match any word in search rather than all words -sort=relevance | How to sort the results date | revdate Default: $SURFRAW_deblists_sort Environment: SURFRAW_deblists_sort EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -result*=*) setopt SURFRAW_deblists_results $optarg ;; -mv) setoptyn SURFRAW_deblists_searchmsgid yes ; setopt SURFRAW_deblists_msgidsearchtype view ;; -ml) setoptyn SURFRAW_deblists_searchmsgid yes ; setopt SURFRAW_deblists_msgidsearchtype links ;; -m|-msg*) setoptyn SURFRAW_deblists_searchmsgid yes ;; -any) setoptyn SURFRAW_deblists_matchany yes ;; -sort*=*) setopt SURFRAW_deblists_sort $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then if ifyes SURFRAW_deblists_searchmsgid then - w3_browse_url "http://lists.debian.org/msgid-search" + w3_browse_url "https://lists.debian.org/msgid-search" else - w3_browse_url "http://lists.debian.org/search.html" + w3_browse_url "https://lists.debian.org/search.html" fi elif ifyes SURFRAW_deblists_searchmsgid then if [ "$SURFRAW_deblists_msgidsearchtype" = links ] then searchtype="&links=Query" elif [ "$SURFRAW_deblists_msgidsearchtype" = view ] then searchtype="" else searchtype="&firsthit=I%27m+feeling+lucky" fi escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://lists.debian.org/msgid-search/?m=${escaped_args}${searchtype}" + w3_browse_url "https://lists.debian.org/msgid-search/?m=${escaped_args}${searchtype}" else escaped_args=`w3_url_of_arg $w3_args` - url="http://lists.debian.org/cgi-bin/search?P=${escaped_args}" + url="https://lists.debian.org/cgi-bin/search?P=${escaped_args}" if ifyes SURFRAW_deblists_matchany then url="$url&DEFAULTOP=or" else url="$url&DEFAULTOP=and" fi case "$SURFRAW_deblists_sort" in rel*) SURFRAW_deblists_sort="relevance" ;; rev*) SURFRAW_deblists_sort="revdate" ;; d*) SURFRAW_deblists_sort="date" ;; *) err "Unknown sort method: $SURFRAW_deblists_sort" esac url="$url&sort=${SURFRAW_deblists_sort}" if [ "$SURFRAW_deblists_results" = "" ] then SURFRAW_deblists_results=10 fi url="$url&HITSPERPAGE=${SURFRAW_deblists_results}" w3_browse_url "$url" fi diff --git a/elvi/debpackages b/elvi/debpackages index 85d8ba6..e08e84f 100755 --- a/elvi/debpackages +++ b/elvi/debpackages @@ -1,148 +1,148 @@ #!/bin/sh # $Id$ # elvis: debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debian_release any def SURFRAW_debian_distro any def SURFRAW_debian_search pkg defyn SURFRAW_debian_ubuntu no defyn SURFRAW_debian_subwords yes defyn SURFRAW_debian_archive no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) Local options: -a Search archived debian distributions -u Search ubuntu packages instead of debian -release= Specialized search on release Debian: any | all releases main | main release contrib | contrib non-free | packages not meeting DFSG Ubuntu (-u): any | all releases main | restricted | universe | multiverse | Default: $SURFRAW_debian_release Environment: SURFRAW_debian_release -distro= Specific distribution Debian: any | All distributions stable | Stable testing | Testing unstable | Unstable oldstable | Old Stable experimental | Experimental Archived Debian (-a): bo | 1.3.1 hamm | 2.0 slink | 2.1 potato | 2.2 woody | 3.0 sarge | 3.1 etch | 4.0 Ubuntu (-u): any | All distributions dapper | dapper-updates | dapper-backports | hardy | hardy-updates | hardy-backports | intrepid | intrepid-updates | intrepid-backports| jaunty | jaunty-updates | jaunty-backports | karmic | karmic-updates | karmic-backports | lucid | lucid-updates | lucid-backports | maverick | maverick-updates | maverick-backports| natty | natty-updates | natty-backports Default: $SURFRAW_debian_distro Environment: SURFRAW_debian_distro -search= Field to search pkg | Package names only desc | Descriptions src | Source package names -nosub Don't allow subword matches (exact matches only) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -release=*) setopt SURFRAW_debian_release $optarg ;; -distro=*) setopt SURFRAW_debian_distro $optarg ;; -search=*) setopt SURFRAW_debian_search $optarg ;; -a*) setoptyn SURFRAW_debian_archive yes ;; -u*) setoptyn SURFRAW_debian_ubuntu yes ;; -nos*) setoptyn SURFRAW_debian_subwords no ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if ifyes SURFRAW_debian_ubuntu then searchpage="http://packages.ubuntu.com/" searchurl="http://packages.ubuntu.com/search" elif ifyes SURFRAW_debian_archive then searchpage="http://archive.debian.net/" searchurl="http://archive.debian.net/search" else - searchpage="http://packages.debian.org/#search_packages" - searchurl="http://packages.debian.org/search" + searchpage="https://packages.debian.org/#search_packages" + searchurl="https://packages.debian.org/search" fi if test -z "$w3_args"; then w3_browse_url "$searchpage" else escaped_args=`w3_url_of_arg $w3_args` if [ "${SURFRAW_debian_distro}" = "any" ]; then SURFRAW_debian_distro="all" fi if [ "${SURFRAW_debian_release}" = "any" ]; then SURFRAW_debian_release="all" fi url="$searchurl?keywords=${escaped_args}&suite=${SURFRAW_debian_distro}&section=${SURFRAW_debian_release}" case "$SURFRAW_debian_search" in pkg*) url="$url&searchon=names" ;; src*) url="$url&searchon=sourcenames" ;; desc*) url="$url&searchon=all" ;; *) err "Unknown search type" ;; esac if ifno SURFRAW_debian_subwords then url="$url&exact=1" fi w3_browse_url "$url" fi diff --git a/elvi/debpts b/elvi/debpts index 56bc57a..5321758 100755 --- a/elvi/debpts +++ b/elvi/debpts @@ -1,43 +1,43 @@ #!/bin/sh # $Id$ # elvis: debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) # [email protected] 20040729 . surfraw || exit 1 w3_config_hook () { def SURFRAW_debpts_viewdocs 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Debian Package Tracking System (packages.qa.debian.org) Local options: -doc View PTS documentation EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -d*) setopt SURFRAW_debpts_viewdocs 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ $SURFRAW_debpts_viewdocs -eq 1 ]; then - w3_browse_url "http://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system" + w3_browse_url "https://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system" elif test -z "$w3_args"; then - w3_browse_url "http://packages.qa.debian.org/common/index.html" + w3_browse_url "https://packages.qa.debian.org/common/index.html" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://packages.qa.debian.org/common/index.html?src=${escaped_args}" + w3_browse_url "https://packages.qa.debian.org/common/index.html?src=${escaped_args}" fi diff --git a/elvi/debsec b/elvi/debsec index c48c976..2489d61 100755 --- a/elvi/debsec +++ b/elvi/debsec @@ -1,23 +1,23 @@ #!/bin/sh # elvis: debsec -- Search the Debian Security Tracker for CVE ids or package names # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Search the Debian Security Tracker for CVE ids or package names EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then - w3_browse_url "http://security-tracker.debian.org/tracker" + w3_browse_url "https://security-tracker.debian.org/tracker" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://security-tracker.debian.org/tracker/${escaped_args}" + w3_browse_url "https://security-tracker.debian.org/tracker/${escaped_args}" fi diff --git a/elvi/debwiki b/elvi/debwiki index c3841ef..10778ef 100755 --- a/elvi/debwiki +++ b/elvi/debwiki @@ -1,71 +1,71 @@ #!/bin/sh # $Id$ # elvis: debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) # by Ian Beckwith <[email protected]> . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_debwiki_title 0 defyn SURFRAW_debwiki_context 1 defyn SURFRAW_debwiki_case 0 defyn SURFRAW_debwiki_direct 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Debian Wiki (wiki.debian.org) Local options: -c Make search case-sensitive. -n Don't show context of search result. -t Limit search to title. -d Go direct to page (or create it). EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -c) setoptyn SURFRAW_debwiki_case 1 ;; -n) setoptyn SURFRAW_debwiki_context 0 ;; -d) setoptyn SURFRAW_debwiki_direct 1 ;; -t) setoptyn SURFRAW_debwiki_title 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments -url="http://wiki.debian.org" +url="https://wiki.debian.org" if test -z "$w3_args" then w3_browse_url "$url" else escaped_args=`w3_url_of_arg $w3_args` url="${url}/FindPage?" if ifyes SURFRAW_debwiki_direct then url="${url}goto=${escaped_args}&submit=Go+To+Page" elif ifyes SURFRAW_debwiki_title then url="${url}action=fullsearch&titlesearch=1&value=${escaped_args}&submit=Search+Titles" else url="${url}action=fullsearch&titlesearch=0&value=${escaped_args}&submit=Search+Text" if ifyes SURFRAW_debwiki_context then url="${url}&context=160" fi if ifyes SURFRAW_debwiki_case then url="${url}&case=1" fi fi w3_browse_url "$url" fi diff --git a/elvi/deja b/elvi/deja index 262650f..a83f95d 100755 --- a/elvi/deja +++ b/elvi/deja @@ -1,48 +1,48 @@ #!/bin/sh # $Id$ # elvis: deja -- Search usenet using Google Groups (groups.google.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_deja_results $SURFRAW_results def SURFRAW_deja_style "normal" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search usenet using Google Groups (groups.google.com) Local options: -results=NUM Number of search results returned Default: $SURFRAW_deja_results Environment: SURFRAW_deja_results -m Search for Message-ID EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_deja_results $optarg ;; -m*) setopt SURFRAW_deja_style "message-id" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://groups.google.com/" + w3_browse_url "https://groups.google.com/" else escaped_args=`w3_url_of_arg $w3_args` if test "${SURFRAW_deja_style}" = "normal"; then - w3_browse_url "http://groups.google.com/groups?q=${escaped_args}&num=${SURFRAW_deja_results}" + w3_browse_url "https://groups.google.com/groups?q=${escaped_args}&num=${SURFRAW_deja_results}" else - w3_browse_url "http://groups.google.com/groups?as_umsgid=${escaped_args}&num=${SURFRAW_deja_results}" + w3_browse_url "https://groups.google.com/groups?as_umsgid=${escaped_args}&num=${SURFRAW_deja_results}" fi fi diff --git a/elvi/deli b/elvi/deli index d27cca0..96ffe8f 100755 --- a/elvi/deli +++ b/elvi/deli @@ -1,26 +1,26 @@ #!/bin/sh # elvis: deli -- Search Delicious bookmarks # Author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] -Description: Search Delicious bookmarks (www.delicious.com) +Description: Search Delicious bookmarks (del.icio.us) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains list of arguments # standard topic seach if [ -z "$w3_args" ]; then - w3_browse_url "http://www.delicious.com/discover" + w3_browse_url "https://www.del.icio.us/" else escaped_args=$(w3_url_of_arg $w3_args) - w3_browse_url "http://www.delicious.com/search?p=${escaped_args}" + w3_browse_url "https://del.icio.us/search?p=${escaped_args}" fi diff --git a/elvi/discogs b/elvi/discogs index 6ddbfc3..cef65be 100755 --- a/elvi/discogs +++ b/elvi/discogs @@ -1,53 +1,53 @@ #!/bin/sh # elvis: discogs -- Search the Discogs database of music information (www.discogs.com) # Patroklos Argyroudis, argp at domain cs.tcd.ie, 20060823 . surfraw || exit 1 w3_config_hook() { def SURFRAW_discogs_category all } w3_usage_hook() { cat << EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Discogs database of music information (www.discogs.com) Local options: -category= Category to search all | artists | labels | releases | catno Default: $SURFRAW_discogs_category Environment: SURFRAW_discogs_category EOF w3_global_usage } w3_parse_option_hook() { opt="$1" optarg="$2" case "$opt" in -category=*) setopt SURFRAW_discogs_category $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.discogs.com/" + w3_browse_url "https://www.discogs.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.discogs.com/search?type=${SURFRAW_discogs_category}&q=${escaped_args}&btn=Search" + w3_browse_url "https://www.discogs.com/search?type=${SURFRAW_discogs_category}&q=${escaped_args}&btn=Search" fi # EOF diff --git a/elvi/dmoz b/elvi/dmoz deleted file mode 100755 index 9ad0d43..0000000 --- a/elvi/dmoz +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -# $Id$ -# elvis: dmoz -- Search the Open Directory Project web directory (dmoz.org) -# [email protected] 20040910 -. surfraw || exit 1 - -w3_config_hook () { -def SURFRAW_dmoz_category "" -def SURFRAW_dmoz_searchtype "b" -defyn SURFRAW_dmoz_kids 0 -defyn SURFRAW_dmoz_teens 0 -defyn SURFRAW_dmoz_mteens 0 -} - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [URL] -Description: - Search the Open Directory Project web directory (dmoz.org) -Local options: - -cat=CATEGORY Search category - Default: all - Values: Arts, Business, Computers, Games, - Health, Home, Kids_and_Teens, News, - Recreation, Reference, Regional, - Science, Shopping, Society, Sports, - World, Adult - Environment: SURFRAW_dmoz_category - -type=SEARCHTYPE Search type - Default: b - Values: c - Categories Only - s - Sites only - b - Both - Environment: SURFRAW_dmoz_searchtype - -kids Sites for kids. - Environment: SURFRAW_dmoz_kids - -teens Sites for teens. - Environment: SURFRAW_dmoz_teens - -mteens Sites for mature teens. - Environment: SURFRAW_dmoz_mteens -EOF - w3_global_usage -} - -w3_parse_option_hook () { - opt="$1" - optarg="$2" - case "$opt" in - -cat*=*) setopt SURFRAW_dmoz_category "$optarg" ;; - -ty*=*) setopt SURFRAW_dmoz_searchtype "$optarg" ;; - -ki*) setoptyn SURFRAW_dmoz_kids 1 ;; - -te*) setoptyn SURFRAW_dmoz_teens 1 ;; - -mt*) setoptyn SURFRAW_dmoz_mteens 1 ;; - *) return 1 ;; - esac - return 0 -} - -w3_config -w3_parse_args "$@" -# w3_args now contains a list of arguments -if test -z "$w3_args"; then - w3_browse_url "http://dmoz.org/" -else - escaped_args=`w3_url_of_arg $w3_args` - url="http://search.dmoz.org/cgi-bin/search?search=${escaped_args}&all=no&cat=${SURFRAW_dmoz_category}&t=${SURFRAW_dmoz_searchtype}" - if [ $SURFRAW_dmoz_kids -eq 1 ] - then - url="${url}&Kids=1" - fi - if [ $SURFRAW_dmoz_teens -eq 1 ] - then - url="${url}&Teens=1" - fi - if [ $SURFRAW_dmoz_mteens -eq 1 ] - then - url="${url}&Mteens=1" - fi - - w3_browse_url "${url}" -fi diff --git a/elvi/ebay b/elvi/ebay index 75ed72d..75dcab1 100755 --- a/elvi/ebay +++ b/elvi/ebay @@ -1,122 +1,122 @@ #!/bin/sh # elvis: ebay -- Search the Ebay auction site # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_config_hook () { def SURFRAW_ebay_country "$SURFRAW_lang" def SURFRAW_ebay_results 50 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Ebay auction site Local options: -country= | -c= com | Main eBay site (default) ar | Argentina at | Austria au | Australia nl_BE | Belgium (Flemish) fr_BE | Belgium (French) br | Brazil ca | Canada ch | Switzerland cn | China de | Germany es | Spain fr | France hk | Hong Kong ie | Ireland in | India kr | Korea my | Malaysia mx | Mexico nl | Netherlands nz | New Zealand ph | Philippines pl | Poland sg | Singapore se | Sweden tw | Taiwan uk UK Environment: SURFRAW_ebay_country, SURFRAW_lang -results= | -r Amount of results per page Default: 50 Environment: SURFRAW_ebay_results Examples: $w3_argv0 -c=de sauerkraut EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -country=*) setopt SURFRAW_ebay_country $optarg ;; -c=*) setopt SURFRAW_ebay_country $optarg ;; -results=*) setopt SURFRAW_ebay_results $optarg ;; -r=*) setopt SURFRAW_ebay_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_ebay_country" in com|ar|at|be|br|ca|ch|\ de|es|fr|fr_BE|\ nl_BE|ie|in|kr|\ mx|nl|ph|pl) TLD="${SURFRAW_ebay_country}" ;; uk|nz) TLD="co.${SURFRAW_ebay_country}" ;; au|hk|sg|my) TLD="com.${SURFRAW_ebay_country}" ;; cn|zh|zt) TLD="com.cn" ;; # tw uses hk for searches tw) TLD="com.hk" ;; *) TLD="com" ;; esac if null "$w3_args"; then case "$SURFRAW_ebay_country" in br) url="http://www.mercadolivre.com.${TLD}" ;; ar|mx) url="http://www.mercadolibre.com.${TLD}" ;; kr) url="http://www.auction.co.kr" ;; fr_BE) url="http://www.befr.ebay.be" ;; nl_BE) url="http://www.benl.ebay.be" ;; se|sv) url="http://www.tradera.com" ;; tw) url="http://twexport.ebay.com" ;; - *) url="http://www.ebay.${TLD}" ;; + *) url="https://www.ebay.${TLD}" ;; esac w3_browse_url "$url" else if [ "$SURFRAW_ebay_country" = "nz" ] ; then # nz uses ebay.com, presumably using referrer to tell it is .nz # we can't affect referrer without getting browser-specific, so # just use ebay.com TLD=com fi escaped_args=`w3_url_of_arg $w3_args` - host="http://search.ebay.${TLD}" + host="http://ebay.${TLD}" pathstart="search/search.dll?MfcISAPICommand=GetResult&krd=1&ht=1&shortcut=4&SoftProperty=MetaEndSort&cgiurl=http%3A%2F%2Fcgi" pathend="%2Fws%2F&maxRecordsPerPage=$SURFRAW_ebay_results&st=2&ebaytag1code=77&query=${escaped_args}" case "$SURFRAW_ebay_country" in cn|zh|zt) url="http://search.eachnet.com/search/basicsearch.do?satitle=${escaped_args}&sacat=0" ;; br) url="http://www.mercadolivre.com.${TLD}/jm/search?as_pr_categ_id=&as_word=${escaped_args}" ;; ar|mx) url="http://www.mercadolibre.com.${TLD}/jm/search?as_pr_categ_id=&as_word=${escaped_args}" ;; kr) url="http://search.auction.co.kr/search/search.aspx?keyword=${escaped_args}&itemno=&seller=&dom=auction&isSuggestion=No&optSection=%C5%EB%C7%D5%B0%CB%BB%F6&txtKeyword=${escaped_args}&x=0&y=0" ;; se|sv) url="http://www.tradera.com/search/search_firstpage.aspx?search=${escaped_args}&search_category=-1" ;; nl_BE) url="http://search.benl.ebay.be/${pathstart}.benl.ebay.be${pathend}" ;; be|fr_BE) url="http://search.befr.ebay.be/${pathstart}.befr.ebay.be${pathend}" ;; *) url="${host}/${pathstart}.ebay.${TLD}${pathend}" ;; esac w3_browse_url "${url}" fi diff --git a/elvi/f5 b/elvi/f5 index c6efbd8..65d0cb6 100755 --- a/elvi/f5 +++ b/elvi/f5 @@ -1,56 +1,56 @@ #!/bin/sh # $Id$ # elvis: f5 -- Search F5 related information (www.f5.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_f5_dc no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search F5 related information Local options: -dc[=(yes|no)] Search F5 Devcentral Default: $SURFRAW_f5_dc Environment: SURFRAW_f5_dc Examples: $w3_argv0 Teleport to the F5 Knowledgebase $w3_argv0 -dc Teleport to the F5 Devcentral site EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -dc) setoptyn SURFRAW_f5_dc yes ;; -dc=*) setoptyn SURFRAW_f5_dc $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments test -z "$w3_args" || escaped_args=`w3_url_of_arg $w3_args` if ok SURFRAW_f5_dc; then if test -z "$escaped_args"; then w3_browse_url "https://devcentral.f5.com" else w3_browse_url "https://devcentral.f5.com/Default.aspx?tabid=37&cx=015798286719081439686:g38hs-tdy64&cof=FORID:11i&q=${escaped_args}" fi exit $? fi if test -z "$escaped_args"; then - w3_browse_url "http://www.f5.com" + w3_browse_url "https://www.f5.com" else - w3_browse_url "http://www.f5.com/search?q=${escaped_args}" + w3_browse_url "https://www.f5.com/search?q=${escaped_args}" fi exit $? diff --git a/elvi/foldoc b/elvi/foldoc index aed6b37..1813e01 100755 --- a/elvi/foldoc +++ b/elvi/foldoc @@ -1,27 +1,27 @@ #!/bin/sh # jbr20050112 # elvis: foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: The Free On-Line Dictionary Of Computing (foldoc.org) Example: foldoc pcmcia "Personal Computer Memory Card International Association(*). (Or People Can't Memorise Computer Industry Acronyms)." EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.foldoc.org/" + w3_browse_url "https://foldoc.org/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://foldoc.org/${escaped_args}" + w3_browse_url "https://foldoc.org/${escaped_args}" fi diff --git a/elvi/freebsd b/elvi/freebsd index f0ca558..4833917 100755 --- a/elvi/freebsd +++ b/elvi/freebsd @@ -1,200 +1,200 @@ #!/bin/sh # $Id$ # elvis: freebsd -- Search FreeBSD related information (www.freebsd.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_freebsd_mail no defyn SURFRAW_freebsd_pr no defyn SURFRAW_freebsd_cvs no defyn SURFRAW_freebsd_mid no defyn SURFRAW_freebsd_gg no defyn SURFRAW_freebsd_ps no defyn SURFRAW_freebsd_prs no defyn SURFRAW_freebsd_elogs no defyn SURFRAW_freebsd_portsearch no def SURFRAW_freebsd_portsearchtype all def SURFRAW_freebsd_portsearchsec all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search FreeBSD related information Local options: -mail[=(yes|no)] Search FreeBSD mailinglists Default: $SURFRAW_freebsd_mail Environment: SURFRAW_freebsd_mail -gg[=(yes|no)] Search FreeBSD mailinglists at Google Groups Default: $SURFRAW_freebsd_mail Environment: SURFRAW_freebsd_mail -pr[=(yes|no)] Query Problem Reports Default: $SURFRAW_freebsd_pr Environment: SURFRAW_freebsd_pr -cvs[=(yes|no)] Query cvsweb Default: $SURFRAW_freebsd_cvs Environment: SURFRAW_freebsd_cvs -mid[=(yes|no)] Query mailing lists by Message-ID Default: $SURFRAW_freebsd_mid Environment: SURFRAW_freebsd_mid -ps[=(yes|no)] Teleport to the Port Survey Page Default: $SURFRAW_freebsd_ps Environment: SURFRAW_freebsd_ps -psearch[=TYPE] Search of type TYPE in ports. all | All (default) name | Package Name text | Description pkgdescr | Long Description maintainer | Maintainer requires | Requires Default: $SURFRAW_freebsd_portsearchtype Environment: SURFRAW_freebsd_portsearchtype -psection[=SEC] Section of ports to search in. all, accessibility, afterstep, arabic, archivers, astro, audio, benchmarks, biology, cad, chinese, comms, converters, databases, deskutils, devel, dns, docs, editors, elisp, emulators, finance, french, ftp, games, geography, german, gnome, gnustep, graphics, hamradio, haskell, hebrew, hungarian, ipv6, irc, japanese, java, kde, kld, korean, lang, linux, lisp, mail, math, mbone, misc, multimedia, net, net-im, net-mgmt, net-p2p, news, palm, parallel, pear, perl5, plan9, polish, ports-mgmt, portuguese, print, python, ruby, rubygems, russian, scheme, science, security, shells, spanish, sysutils, tcl, textproc, tk, ukrainian, vietnamese, windowmaker, www, x11, x11-clocks, x11-drivers, x11-fm, x11-fonts, x11-servers, x11-themes, x11-toolkits, x11-wm, xfce, zope Default: $SURFRAW_freebsd_portsearchsec Environment: SURFRAW_freebsd_portsearchsec -prs[=(yes|no)] Teleport to the Problem Report Survey Page Default: $SURFRAW_freebsd_prs Environment: SURFRAW_freebsd_prs -elogs[=(yes|no)] Teleport to the Build Error Logs Page Default: $SURFRAW_freebsd_elogs Environment: SURFRAW_freebsd_elogs Examples: $w3_argv0 Teleport to the FreeBSD website $w3_argv0 mycroft Search FreeBSD website for odeur de mycroft $w3_argv0 -mail Teleport to the mail-index Query form $w3_argv0 -mail proff Search mailing-list archives for odeur de proff $w3_argv0 -gg Teleport to FreeBSD mailinglists at Google $w3_argv0 -gg proff Search Google archives for odeur de proff $w3_argv0 -pr Query Problem Report form $w3_argv0 -pr 666 Display PR 666 $w3_argv0 -cvs Query cvsweb $w3_argv0 -cvs ports/ Display cvsweb tree for ports/ $w3_argv0 -mid Query mailing lists by Message-ID $w3_argv0 -mid <x> Display message with ID <x> $w3_argv0 -ps Teleport to the Port Survey page $w3_argv0 -prs Teleport to the Port Report Survey page $w3_argv0 -psearch surfraw Search ports for surfraw $w3_argv0 -psearch=text perl Search port descriptions for perl EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -mail) setoptyn SURFRAW_freebsd_mail yes ;; -mail=*) setoptyn SURFRAW_freebsd_mail $optarg ;; -gg) setoptyn SURFRAW_freebsd_gg yes ;; -gg=*) setoptyn SURFRAW_freebsd_gg $optarg ;; -pr) setoptyn SURFRAW_freebsd_pr yes ;; -pr=*) setoptyn SURFRAW_freebsd_pr $optarg ;; -cvs) setoptyn SURFRAW_freebsd_cvs yes ;; -cvs=*) setoptyn SURFRAW_freebsd_cvs $optarg ;; -mid) setoptyn SURFRAW_freebsd_mid yes ;; -mid=*) setoptyn SURFRAW_freebsd_mid $optarg ;; -ps) setoptyn SURFRAW_freebsd_ps yes ;; -prs) setoptyn SURFRAW_freebsd_prs yes ;; -psea*=*) setoptyn SURFRAW_freebsd_portsearch yes; setopt SURFRAW_freebsd_portsearchtype $optarg ;; -psea*) setoptyn SURFRAW_freebsd_portsearch yes ;; -psec*=*) setoptyn SURFRAW_freebsd_portsearch yes; setopt SURFRAW_freebsd_portsec $optarg ;; -psec*) setoptyn SURFRAW_freebsd_portsearch yes ;; -elogs) setoptyn SURFRAW_freebsd_elogs yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments test -z "$w3_args" || escaped_args=`w3_url_of_arg $w3_args` if ok SURFRAW_freebsd_portsearch; then if test -z "$escaped_args"; then - w3_browse_url "http://www.freebsd.org/cgi/ports.cgi" + w3_browse_url "https://www.freebsd.org/cgi/ports.cgi" else - w3_browse_url "http://www.freebsd.org/cgi/ports.cgi?query=${escaped_args}&stype=${SURFRAW_freebsd_portsearchtype}&sektion=${SURFRAW_freebsd_portsec}" + w3_browse_url "https://www.freebsd.org/cgi/ports.cgi?query=${escaped_args}&stype=${SURFRAW_freebsd_portsearchtype}&sektion=${SURFRAW_freebsd_portsec}" fi exit $? fi if ok SURFRAW_freebsd_pr; then if test -z "$escaped_args"; then - w3_browse_url "http://www.freebsd.org/cgi/query-pr-summary.cgi?query" + w3_browse_url "https://www.freebsd.org/cgi/query-pr-summary.cgi?query" else - w3_browse_url "http://www.freebsd.org/cgi/query-pr.cgi?pr=${escaped_args}" + w3_browse_url "https://www.freebsd.org/cgi/query-pr.cgi?pr=${escaped_args}" fi exit $? fi if ok SURFRAW_freebsd_mail; then if test -z "$escaped_args"; then - w3_browse_url "http://docs.freebsd.org/mail/" + w3_browse_url "https://docs.freebsd.org/mail/" else - w3_browse_url "http://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&sort=score&index=recent&source=freebsd-questions" + w3_browse_url "https://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&sort=score&index=recent&source=freebsd-questions" fi exit $? fi if ok SURFRAW_freebsd_gg; then if test -z "$escaped_args"; then - w3_browse_url "http://groups.google.com/groups?hl=en&group=mailing.freebsd" + w3_browse_url "https://groups.google.com/groups?hl=en&group=mailing.freebsd" else - w3_browse_url "http://groups.google.com/groups?q=${escaped_args}&hl=en&meta=group%3Dmailing.freebsd.*" + w3_browse_url "https://groups.google.com/groups?q=${escaped_args}&hl=en&meta=group%3Dmailing.freebsd.*" fi exit $? fi if ok SURFRAW_freebsd_cvs; then if test -z "$escaped_args"; then - w3_browse_url "http://cvsweb.freebsd.org/" + w3_browse_url "https://cvsweb.freebsd.org/" else - w3_browse_url "http://cvsweb.freebsd.org/cgi/cvsweb.cgi?path=${escaped_args}" + w3_browse_url "https://cvsweb.freebsd.org/cgi/cvsweb.cgi?path=${escaped_args}" fi exit $? fi if ok SURFRAW_freebsd_mid; then if test -z "$escaped_args"; then - w3_browse_url "http://www.freebsd.org/search/search-mid.html" + w3_browse_url "https://www.freebsd.org/search/search-mid.html" else - w3_browse_url "http://www.freebsd.org/cgi/mid.cgi?id=${escaped_args}&db=mid" + w3_browse_url "https://www.freebsd.org/cgi/mid.cgi?id=${escaped_args}&db=mid" fi exit $? fi if ok SURFRAW_freebsd_ps; then - w3_browse_url "http://people.freebsd.org/~fenner/portsurvey/" + w3_browse_url "https://people.freebsd.org/~fenner/portsurvey/" exit $? fi if ok SURFRAW_freebsd_elogs; then - w3_browse_url "http://people.freebsd.org/~fenner/errorlogs/" + w3_browse_url "https://people.freebsd.org/~fenner/errorlogs/" exit $? fi if ok SURFRAW_freebsd_prs; then - w3_browse_url "http://people.freebsd.org/~fenner/ports-prs.html" + w3_browse_url "https://people.freebsd.org/~fenner/ports-prs.html" exit $? fi if test -z "$escaped_args"; then - w3_browse_url "http://www.freebsd.org/" + w3_browse_url "https://www.freebsd.org/" else - w3_browse_url "http://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&source=www" + w3_browse_url "https://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&source=www" fi exit $? diff --git a/elvi/freshmeat b/elvi/freshmeat index 9c27c40..9302f99 100755 --- a/elvi/freshmeat +++ b/elvi/freshmeat @@ -1,23 +1,23 @@ #!/bin/sh # $Id$ # elvis: freshmeat -- Search Freshmeat (www.freshmeat.net) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Freshmeat (www.freshmeat.net) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.freshmeat.net/" + w3_browse_url "http://www.freecode.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://freshmeat.net/search?q=${escaped_args}" + w3_browse_url "http://www.freecode.com/search?q=${escaped_args}" fi diff --git a/elvi/fsfdir b/elvi/fsfdir index ef620be..7c6b99d 100755 --- a/elvi/fsfdir +++ b/elvi/fsfdir @@ -1,24 +1,24 @@ #!/bin/sh # $Id$ # elvis: fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the FSF/UNESCO Free Software Directory (directory.fsf.org) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://directory.fsf.org/" + w3_browse_url "https://directory.fsf.org/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://directory.fsf.org/search/?query=${escaped_args}" + w3_browse_url "https://directory.fsf.org/search/?query=${escaped_args}" fi
JNRowe/surfraw
0d734a573ae35a2239556cad54b03716821e4598
Elvi cleanup: S-U
diff --git a/elvi/scholar b/elvi/scholar index 877da95..368907c 100755 --- a/elvi/scholar +++ b/elvi/scholar @@ -1,24 +1,24 @@ #!/bin/sh # $Id$ # elvis: scholar -- Search Google Scholar (scholar.google.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Google Scholar (scholar.google.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://scholar.google.com/" + w3_browse_url "https://scholar.google.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://scholar.google.com/scholar?q=${escaped_args}" + w3_browse_url "https://scholar.google.com/scholar?q=${escaped_args}" fi diff --git a/elvi/scicom b/elvi/scicom deleted file mode 100755 index 2be6caf..0000000 --- a/elvi/scicom +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# -# author: Wim Van Hoydonck -# -# elvis: scicom -- Search Scientific Commons -. surfraw || exit 1 - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [search-string] -Description: - Search Scientific Commons -Examples: - $w3_argv0 vortex pairs -EOF - w3_global_usage -} - - -w3_config -w3_parse_args "$@" -# w3_args now contains a list of arguments - -if null "$w3_args"; then - w3_browse_url "http://www.scientificcommons.org" -else - escaped_args=`w3_url_of_arg $w3_args` - url="http://www.scientificcommons.org/#search_string=${escaped_args}" - w3_browse_url "${url}" -fi - - diff --git a/elvi/scirus b/elvi/scirus deleted file mode 100755 index cf93ba9..0000000 --- a/elvi/scirus +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# elvis: scirus -- Search for science using Scirus (scirus.com) -. surfraw || exit 1 - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [search words]... -Description: - Surfraw search for science using Scirus (scirus.com) -EOF - w3_global_usage -} - -w3_config -w3_parse_args "$@" -# w3_args now contains a list of arguments - -if test -z "$w3_args"; then - w3_browse_url "http://www.scirus.com/" -else - escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://scirus.com/srsapp/search?q=${escaped_args}&t=all&sort=0&g=s" -fi diff --git a/elvi/scpan b/elvi/scpan index 9f0e183..8a5b23c 100755 --- a/elvi/scpan +++ b/elvi/scpan @@ -1,46 +1,52 @@ #!/bin/sh # $Id$ -# elvis: scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) +# elvis: scpan -- Search the Comprehensive Perl Archive Network (metacpan.org) # [email protected] 20030918 . surfraw || exit 1 w3_config_hook () { -def SURFRAW_scpan_search all +def SURFRAW_scpan_search "$SURFRAW_scpan_opts" } + w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: - Surfraw search the Comprehensive Perl Archive Network (search.cpan.org) + Surfraw search the Comprehensive Perl Archive Network (metacpan.org) Local options: -search= Search Type - all | All module | Modules dist | Distributions - author Authors - Default: $SURFRAW_scpan_search - Environment: SURFRAW_scpan_search + author | Authors + Default: All EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -search=*) setopt SURFRAW_scpan_search $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments +case "$SURFRAW_scpan_search" in + module) searchopts="modules::" ;; + dist) searchopts="dist::" ;; + author) searchopts="author::" ;; + all|*) searchopts="" ;; +esac + if test -z "$w3_args"; then - w3_browse_url "http://search.cpan.org/" + w3_browse_url "https://metacpan.org/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://search.cpan.org/search?query=${escaped_args}&mode=${SURFRAW_scpan_search}" + w3_browse_url "https://metacpan.org/search?q=${searchopts}${escaped_args}" fi diff --git a/elvi/slashdot b/elvi/slashdot index 823fde0..b5f19cf 100755 --- a/elvi/slashdot +++ b/elvi/slashdot @@ -1,23 +1,23 @@ #!/bin/sh # $Id$ # elvis: slashdot -- Search stories on Slashdot (www.slashdot.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search articles on Slashdot (www.slashdot.org) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.slashdot.org/" + w3_browse_url "https://www.slashdot.org/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.slashdot.org/index2.pl?fhfilter=${escaped_args}" + w3_browse_url "https://www.slashdot.org/index2.pl?fhfilter=${escaped_args}" fi diff --git a/elvi/slinuxdoc b/elvi/slinuxdoc index 50cfe00..18cce00 100755 --- a/elvi/slinuxdoc +++ b/elvi/slinuxdoc @@ -1,24 +1,24 @@ #!/bin/sh # $Id$ # elvis: slinuxdoc -- Search entries in LDP (www.linuxdoc.org) # version 0.1 by Ross Campbell [email protected] 8/1/2000 . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search entries in LDP (www.linuxdoc.org) EOF w3_custom_search_usage w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.tldp.org/" + w3_browse_url "https://www.tldp.org/" else w3_custom_search -s=tldp.org "$w3_shquoted_args" fi diff --git a/elvi/sourceforge b/elvi/sourceforge index e3cbdca..b6dbf9c 100755 --- a/elvi/sourceforge +++ b/elvi/sourceforge @@ -1,63 +1,63 @@ #!/bin/sh # elvis: sourceforge -- Search SourceForge (www.sourceforge.net) # $Id$ . surfraw || exit 1 # version 0.2 [email protected] 20030910 # added -exact and -type # version 0.1 # this great work has been achieved by Caiaphas Pechorin ([email protected]) w3_config_hook () { defyn SURFRAW_sourceforge_exact no def SURFRAW_sourceforge_searchtype soft } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search SourceForge (www.sourceforge.net) Local options: -exact=yes|no Require all words Default: $SURFRAW_sourceforge_exact Environment: SURFRAW_sourceforge_exact -type= soft | Software / Group people | People freshmeat Freshmeat Default: $SURFRAW_sourceforge_searchtype Environment: SURFRAW_sourceforge_searchtype EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -e*=*) setoptyn SURFRAW_sourceforge_exact $optarg ;; -e*) setoptyn SURFRAW_sourceforge_exact yes ;; -t*=*) setopt SURFRAW_sourceforge_searchtype $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.sourceforge.net/" + w3_browse_url "https://www.sourceforge.net/" else escaped_args=$(w3_url_of_arg $w3_args) if $(yesno SURFRAW_sourceforge_exact) then isexact=1 else isexact=0 fi - w3_browse_url "http://sourceforge.net/search/?words=${escaped_args}&exact=$isexact&typeofsearch=$SURFRAW_sourceforge_searchtype" + w3_browse_url "https://sourceforge.net/search/?words=${escaped_args}&exact=$isexact&typeofsearch=$SURFRAW_sourceforge_searchtype" fi diff --git a/elvi/springer b/elvi/springer index 692a06c..364d32f 100755 --- a/elvi/springer +++ b/elvi/springer @@ -1,62 +1,62 @@ #!/bin/sh # # author: Wim Van Hoydonck # # elvis: springer -- Search Springer for Books and Articles . surfraw || exit 1 w3_config_hook () { def SURFRAW_spinger_fields All } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search springer Local options: -fields=FIELD Subject field to search all | Seach all fields (default) author | Author name title | Title series | Series isbn | ISBN/ISSN Examples: $w3_argv0 -fields=author featherstone EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -fields=*) setopt SURFRAW_springer_fields $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_springer_fields" in all) field=all ;; author) field=authorEditor ;; title) field=title ;; series) field=bookSeries ;; isbn) field=all ;; *) field=all ;; esac if null "$w3_args"; then - w3_browse_url "http://www.springer.com" + w3_browse_url "https://www.springer.com" else escaped_args=`w3_url_of_arg $w3_args` - url="http://www.springer.com/?searchKey=easySearchKey&searchType=easy&visited=true&propagate=false&resultStart=1&resultCount=10&SGWID=5-102-14-0-0&queryText=${escaped_args}&easySearchOption=${field}&go.x=8&go.y=7" + url="https://www.springer.com/?searchKey=easySearchKey&searchType=easy&visited=true&propagate=false&resultStart=1&resultCount=10&SGWID=5-102-14-0-0&queryText=${escaped_args}&easySearchOption=${field}&go.x=8&go.y=7" w3_browse_url "${url}" fi diff --git a/elvi/stack b/elvi/stack index 56ee353..036a65e 100755 --- a/elvi/stack +++ b/elvi/stack @@ -1,85 +1,85 @@ #!/bin/sh # elvis: stack -- Search Stack Overflow # Author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_stack_categories "$SURFRAW_categories" def SURFRAW_stack_unix 0 def SURFRAW_stack_results 25 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: - Search Stack Overflow (http://stackoverflow.com) + Search Stack Overflow (https://stackoverflow.com) Combine search terms (tags) with a "+" eg., "bash+script" Local options: -sort=CATEGORIES -s=CATEGORIES new | Most recently asked (default) feat | Questions with open bounties vote | Questions with most votes active | Recently active null | No upvoted answers faq | Questions with the most links Default: new -u | Search Unix & Linux Exchange Default: no -num=NUMBER | Number of results per page Default: $SURFRAW_stack_results EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -sort=*) setopt SURFRAW_stack_categories $optarg ;; -s=*) setopt SURFRAW_stack_categories $optarg ;; -num=*) setopt SURFRAW_stack_results $optarg ;; -u) setoptyn SURFRAW_stack_unix 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains list of arguments case "$SURFRAW_stack_categories" in new) category="newest" ;; feat) category="featured" ;; vote) category="votes" ;; active) category="active" ;; null) category="unanswered" ;; faq) category="faq" ;; *) category="newest" ;; esac # Check for Unix & Linux Exchange if [ "$SURFRAW_stack_unix" = 1 ]; then - url="http://unix.stackexchange.com" + url="https://unix.stackexchange.com" else - url="http://stackoverflow.com" + url="https://stackoverflow.com" fi # No arguments passed if [ -z "$w3_args" ]; then w3_browse_url "$url" else escaped_args=$(w3_url_of_arg $w3_args) if [ -n "$SURFRAW_stack_categories" ]; then w3_browse_url "${url}/questions/tagged/${escaped_args}?sort=${category}&pagesize=${SURFRAW_stack_results}" else w3_browse_url "${url}/questions/tagged/${escaped_args}" fi fi diff --git a/elvi/stockquote b/elvi/stockquote index 7113fce..ab63996 100755 --- a/elvi/stockquote +++ b/elvi/stockquote @@ -1,66 +1,66 @@ #!/bin/sh # $Id$ # elvis: stockquote -- Get a single stock quote (multiple providers) . surfraw || exit 1 w3_config_hook () { def SURFRAW_stockquote_provider yahoo } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] STOCK Description: Surfraw fetch a single stock quote Local options: -provider= Quote provider to use yahoo quote.yahoo.com nasdaq nasdaq.com (InfoQuote) quote quote.com Default: $SURFRAW_stockquote_provider Environment: SURFRAW_stockquote_provider Examples: $w3_argv0 Provider's standard quote page $w3_argv0 -provider=nasdaq Use NASDAQ for quote $w3_argv0 BLDP Obtain quote for 'Ballard Power' EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -provider=*) setopt SURFRAW_stockquote_provider $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test "$SURFRAW_stockquote_provider" = "yahoo"; then if test -z "$w3_args"; then - w3_browse_url "http://quote.yahoo.com/" + w3_browse_url "https://quote.yahoo.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://quote.yahoo.com/q?s=${escaped_args}" + w3_browse_url "https://quote.yahoo.com/q?s=${escaped_args}" fi elif test "$SURFRAW_stockquote_provider" = "nasdaq"; then if test -z "$w3_args"; then - w3_browse_url "http://www.nasdaq.com/" + w3_browse_url "https://www.nasdaq.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://quotes.nasdaq.com/Quote.dll?mode=Stock&symbol=${escaped_args}&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&multi.x=44&multi.y=12" + w3_browse_url "https://quotes.nasdaq.com/Quote.dll?mode=Stock&symbol=${escaped_args}&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&symbol=&multi.x=44&multi.y=12" fi elif test "$SURFRAW_stockquote_provider" = "quote"; then if test -z "$w3_args"; then - w3_browse_url "http://www.quote.com/" + w3_browse_url "https://www.quote.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.quote.com/quotecom/stocks/quotes.asp?symbols=${escaped_args}" + w3_browse_url "https://www.quote.com/quotecom/stocks/quotes.asp?symbols=${escaped_args}" fi else err "-provider ${SURFRAW_stockquote_provider} unsupported" fi diff --git a/elvi/thesaurus b/elvi/thesaurus index 5d22798..0b057ac 100755 --- a/elvi/thesaurus +++ b/elvi/thesaurus @@ -1,25 +1,25 @@ #!/bin/sh # $Id$ -# elvis: thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) +# elvis: thesaurus -- Look up a synonym in Oxford's thesaurus (en.oxforddictionaries.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF -Usage: $w3_argv0 [options] [search words]... +Usage: $w3_argv0 [search words]... Description: - Look up word in Merriam-Webster's Thesaurus (www.m-w.com) + Look up a synonym in Oxford's thesaurus (en.oxforddictionaries.com) EOF w3_global_usage } w3_config # disable requoting, doesn't work with this elvi. SURFRAW_quote_ifs=0 w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.m-w.com/thesaurus.htm" + w3_browse_url "https://en.oxforddictionaries.com/english-thesaurus" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.m-w.com/cgi-bin/thesaurus?book=Thesaurus&va=${escaped_args}" + w3_browse_url "https://en.oxforddictionaries.com/thesaurus/${escaped_args}" fi diff --git a/elvi/translate b/elvi/translate index 02a346c..998fd5e 100755 --- a/elvi/translate +++ b/elvi/translate @@ -1,154 +1,154 @@ #!/bin/sh # $Id$ # elvis: translate -- Translate human languages . surfraw || exit 1 w3_config_hook () { def SURFRAW_translate_from "$SURFRAW_lang" def SURFRAW_translate_to "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [words|URI]... Description: Surfraw translate human language Local options: -from=LANGUAGE Source language Environment: SURFRAW_translate_from, SURFRAW_lang -to=LANGUAGE Destination language Environment: SURFRAW_translate_to, SURFRAW_lang Languages (any provider): nl Dutch en English fr French de German el Greek it Italian ja Japanese ko Korean pt Portuguese ru Russian es Spanish Languages (Systrans only): zh Chinese (Simplified) zt Chinese (Traditional) Languages (Google only): auto Automatically detect language af Afrikaans sq Albanian ar Arabic hy Armenian az Azerbaijani eu Basque be Belarusian bg Bulgarian ca Catalan zh-CN Chinese (Simplified) zh-TW Chinese (Traditional) hr Croatian cs Czech da Danish et Estonian tl Filipino fi Finnish gl Galician ka Georgian ht Hatian Creole iw Hebrew hi Hindi hu Hungarian is Icelandic id Indonesian ga Irish la Latin lv Latvian lt Lithuanian mk Macedonian ms Malay mt Maltese no Norwegian fa Persian pl Polish ro Romanian sr Serbian sk Slovak sl Slovenian sw Swahili sv Swedish th Thai tr Turkish uk Ukrainian ur Urdu vi Vietnamese cy Welsh yi Yiddish Examples: $w3_argv0 Provider's standard translation page $w3_argv0 -from=fr -to=en la verite vous liberera - $w3_argv0 -from=en -to=es http://tashian.com/multibabel + $w3_argv0 -from=en -to=es https://tashian.com/multibabel Translate the given Web page Bugs: Systrans derived providers only support the following translation combinations: English to Chinese English to French English to German English to Italian English to Japanese English to Korean English to Portuguese English to Spanish Chinese to English French to English French to German German to English German to French Italian to English Japanese to English Korean to English Portuguese to English Russian to English Spanish to English EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -from=*) setopt SURFRAW_translate_from $optarg ;; -to=*) setopt SURFRAW_translate_to $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args" - then w3_browse_url "http://translate.google.com/" + then w3_browse_url "https://translate.google.com/" else if [ -z "$SURFRAW_translate_to" ]; then SURFRAW_translate_to="en" fi if [ -z "$SURFRAW_translate_from" ]; then SURFRAW_translate_from="fr" fi escaped_args=`w3_url_of_arg $w3_args` case "$escaped_args" in - http*) w3_browse_url "http://translate.google.com/translate?&sl=${SURFRAW_translate_from}&tl=${SURFRAW_translate_to}&u=${escaped_args}" + http*) w3_browse_url "https://translate.google.com/translate?&sl=${SURFRAW_translate_from}&tl=${SURFRAW_translate_to}&u=${escaped_args}" ;; - *) w3_browse_url "http://translate.google.com/?&sl=${SURFRAW_translate_from}&tl=${SURFRAW_translate_to}&q=${escaped_args}" + *) w3_browse_url "https://translate.google.com/?&sl=${SURFRAW_translate_from}&tl=${SURFRAW_translate_to}&q=${escaped_args}" ;; esac fi exit $? diff --git a/elvi/urban b/elvi/urban index 6f764d6..e63419e 100755 --- a/elvi/urban +++ b/elvi/urban @@ -1,28 +1,28 @@ #!/bin/sh # # AUTHOR: J.R. Mauro # # DATE: Sat Nov 1 18:01:13 EDT 2008 # # DESC: Elvi to search The Urban Dictionary # elvis: urban -- Search urbandictionary.com for a definition . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Look up a term in the Urban Dictionary EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.urbandictionary.com" + w3_browse_url "https://www.urbandictionary.com" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.urbandictionary.com/define.php?term=${escaped_args}" + w3_browse_url "https://www.urbandictionary.com/define.php?term=${escaped_args}" fi diff --git a/test/scicom.test b/test/scicom.test deleted file mode 100644 index 97bc447..0000000 --- a/test/scicom.test +++ /dev/null @@ -1 +0,0 @@ -SKIP needs javascript diff --git a/test/scirus.test b/test/scirus.test deleted file mode 100644 index 527ee19..0000000 --- a/test/scirus.test +++ /dev/null @@ -1,2 +0,0 @@ -scirus cryptanalysis chaos cipher -chaos block cipher diff --git a/test/scpan.test b/test/scpan.test index be3ac4b..252a58c 100644 --- a/test/scpan.test +++ b/test/scpan.test @@ -1,2 +1,2 @@ scpan Acme -Results <b>1</b> - <b>10</b> of +The Base of Perfection diff --git a/test/stockquote.test b/test/stockquote.test index fd12abc..aca1b39 100644 --- a/test/stockquote.test +++ b/test/stockquote.test @@ -1,2 +1,2 @@ stockquote GOOG -Google Inc. +Alphabet Inc.
JNRowe/surfraw
01c43f5b5b5f9727b1c784a6377b913de001e061
Elvi cleanup (g-m).
diff --git a/elvi/gcache b/elvi/gcache index 8dae92a..6c4a428 100755 --- a/elvi/gcache +++ b/elvi/gcache @@ -1,49 +1,49 @@ #!/bin/sh # $Id$ # elvis: gcache -- Search the web using Google cache (www.google.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_cache_graphic 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [option] [URL]... Description: Surfraw shows the cached page using Google (www.google.com) Local option: -i, -images Retrieve the stored page WITH images and media. Default: textonly. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -i*) setoptyn SURFRAW_cache_graphic 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if !( test -n "$SURFRAW_lang" ); then SURFRAW_lang="en"; fi if test -z "$w3_args"; then - w3_browse_url "http://www.google.com/intl/$SURFRAW_lang/help/features_list.html#cached" + w3_browse_url "https://www.google.com/intl/$SURFRAW_lang/help/features_list.html#cached" else escaped_args=`w3_url_of_arg $w3_args` if [ "$SURFRAW_cache_graphic" = 1 ]; then - w3_browse_url "http://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang" + w3_browse_url "https://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang" else - w3_browse_url "http://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang&strip=1" + w3_browse_url "https://www.google.com/search?q=cache:${escaped_args}&hl=$SURFRAW_lang&strip=1" fi fi diff --git a/elvi/genbugs b/elvi/genbugs index c4f9c5b..457a128 100755 --- a/elvi/genbugs +++ b/elvi/genbugs @@ -1,24 +1,24 @@ #!/bin/sh # elvis: genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Surfraw search the Gentoo bug tracker (bugs.gentoo.org) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://bugs.gentoo.org/" + w3_browse_url "https://bugs.gentoo.org/" else escaped_args=`w3_url_of_arg $w3_args` terms=`echo $escaped_args | sed 's/%20/+/g'` - w3_browse_url "http://bugs.gentoo.org/buglist.cgi?quicksearch=${terms}" + w3_browse_url "https://bugs.gentoo.org/buglist.cgi?quicksearch=${terms}" fi diff --git a/elvi/genportage b/elvi/genportage index 61bfbe7..9e73f1c 100755 --- a/elvi/genportage +++ b/elvi/genportage @@ -1,28 +1,28 @@ #!/bin/sh # # Original Author: J.R. Mauro # # Modified to use Gentoo Portage Overlays # as gentoo-portage.com has gone -- ianb # # elvis: genportage -- Search gentoo-portage.com for packages . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search gentoo portage overlays for packages EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://gpo.zugaina.org" + w3_browse_url "https://gpo.zugaina.org" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://gpo.zugaina.org/Search?search=${escaped_args}" + w3_browse_url "https://gpo.zugaina.org/Search?search=${escaped_args}" fi diff --git a/elvi/gmane b/elvi/gmane index 23dc35e..a556d2a 100755 --- a/elvi/gmane +++ b/elvi/gmane @@ -1,85 +1,85 @@ #!/bin/sh # elvis: gmane -- Search mailing list with gmane (gmane.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_gmane_or 0 defyn SURFRAW_gmane_listsearch 0 def SURFRAW_gmane_list "" def SURFRAW_gmane_author "" def SURFRAW_gmane_sort "relevance" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search mailing lists with gmane (gmane.org) Local options: -list=LIST Search list(s) eg -l=gmane.os.openbsd.vax or -l="gmane.os.openbsd.*" -L Search by list name instead of contents -author=NAME Limit search to posts by NAME Default: $SURFRAW_gmane_results Environment: SURFRAW_gmane_results -sort= Sort by: relevance Relevance date Newest first revdate Oldest first -or OR search results instead of ANDing. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -li*=*) setopt SURFRAW_gmane_group "$optarg" ;; -au*=*) setopt SURFRAW_gmane_author "$optarg" ;; -so*=*) setopt SURFRAW_gmane_sort "$optarg" ;; -L) setoptyn SURFRAW_gmane_listsearch 1 ;; -or) setoptyn SURFRAW_gmane_or 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if test -z "$w3_args" then if ifyes SURFRAW_gmane_listsearch then - url=http://gmane.org/find.php + url=https://gmane.org/find.php else url=http://search.gmane.org/ fi else escaped_args=`w3_url_of_arg $w3_args` if ifyes SURFRAW_gmane_listsearch then url="http://dir.gmane.org/search.php?match=${escaped_args}" else url="http://search.gmane.org/?query=${escaped_args}&sort=${SURFRAW_gmane_sort}" if [ "$SURFRAW_gmane_author" != "" ] then url="${url}&author=${SURFRAW_gmane_author}" fi if ifyes SURFRAW_gmane_or then url="${url}&DEFAULTOP=or" else url="${url}&DEFAULTOP=and" fi if [ "${SURFRAW_gmane_group}" != "" ] then url="${url}&group=${SURFRAW_gmane_group}" fi fi fi w3_browse_url "$url" diff --git a/elvi/google b/elvi/google index df180c3..d2bba19 100755 --- a/elvi/google +++ b/elvi/google @@ -1,129 +1,129 @@ #!/bin/sh # $Id$ # elvis: google -- Search the web using Google (www.google.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_google_results "$SURFRAW_results" def SURFRAW_google_search search defyn SURFRAW_google_lucky 0 def SURFRAW_google_country us def SURFRAW_google_safe default } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Google (www.google.com) Local options: -l, -lucky Feeling lucky? Jump to first result. -results=NUM Number of search results returned Default: $SURFRAW_google_results Environment: SURFRAW_google_results -search= Specialized search on topic images | Images videos | Videos maps | Maps groups | groups news | News bsd | BSD linux | Linux mac | Apple Macintosh unclesam | U.S. Government Environment: SURFRAW_google_search -country= Select regional google site Default is us (google.com) <ISO 3166 alpha-2 code> Environment: SURFRAW_google_country -i, -images Image Search (same as -search=images) -v, -videos Video Search (same as -search=videos) -m, -maps Map Search (same as -search=maps) -n, -news News Search (same as -search=news) -G, -groups Groups Search (same as -search=groups) -safe= Safe Search level default | Default: $SURFRAW_google_safe off | Environment: SURFRAW_google_safe moderate | strict | EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -r*=*) setopt SURFRAW_google_results "$optarg" ;; -sa*=*) setopt SURFRAW_google_safe "$optarg" ;; -s*=*) setopt SURFRAW_google_search "$optarg" ;; -l|-lu*) setoptyn SURFRAW_google_lucky 1 ;; -c=*) setopt SURFRAW_google_country "$optarg" ;; -i*) setopt SURFRAW_google_search images ;; -v*) setopt SURFRAW_google_search videos ;; -m*) setopt SURFRAW_google_search maps ;; -n|-news) setopt SURFRAW_google_search news ;; -G|-gr|-groups) setopt SURFRAW_google_search groups ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments # Use SURFRAW_lang if present and the country has not been changed if test -n "$SURFRAW_lang" -a "$SURFRAW_google_country" = "us"; then SURFRAW_google_country="$SURFRAW_lang"; fi case "$SURFRAW_google_country" in af|ag|ai|ar|au|bd|bn|bo|br|bs|bw|by|bz|co|cu|do|ec|eg|et|fj|gi|gt|hk|jm|ly|mt|mx|my|na|nf|ng|ni|np|nz|om|pa|pe|ph|pk|pr|py|qa|sa|sb|sg|sv|tj|tr|tw|ua|ug|uy|vn) domain="com.${SURFRAW_google_country}" ;; cr|id|il|in|jp|ke|kh|kr|ls|ma|th|uk|uz|vc|ve|vg|vi|ck|yu|za|zm|zw) domain="co.${SURFRAW_google_country}" ;; us) domain="com";; *) domain="$SURFRAW_google_country" ;; esac safe="" case "$SURFRAW_google_safe" in strict) safe="&safe=strict" ;; moderate) safe="&safe=moderate" ;; off) safe="&safe=off" ;; esac -url="http://" +url="https://" if test -z "$w3_args" ; then case "$SURFRAW_google_search" in i*) url="${url}images" ;; m*) url="${url}maps" ;; g*) url="${url}groups" ;; n*) url="${url}news" ;; v*) url="${url}video" ;; *) url="${url}www" ;; esac url="${url}.google.${domain}" else search="$SURFRAW_google_search" case "$SURFRAW_google_search" in v*) url="${url}www"; search="search"; extra="&tbo=p&tbm=vid";; i*) url="${url}images" ; search="images";; m*) url="${url}maps" ; search=maps ;; g*) url="${url}groups" ; search=groups ;; n*) url="${url}news" ; search=news ;; *) url="${url}www" ;; esac url="${url}.google.${domain}/${search}" escaped_args=`w3_url_of_arg $w3_args` url="${url}?q=${escaped_args}&num=${SURFRAW_google_results}" if [ "$SURFRAW_google_lucky" = 1 ]; then button=`w3_url_escape "I'm Feeling Lucky"` url="${url}&btnI=$button" fi url="${url}${safe}${extra}" fi w3_browse_url "$url" diff --git a/elvi/gutenberg b/elvi/gutenberg index cbbae2a..d51e269 100755 --- a/elvi/gutenberg +++ b/elvi/gutenberg @@ -1,72 +1,72 @@ #!/bin/sh # $Id$ # elvis: gutenberg -- Search for books on Project Gutenberg (gutenberg.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_gutenberg_author 0 defyn SURFRAW_gutenberg_title 0 defyn SURFRAW_gutenberg_num 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search for books on Project Gutenberg (gutenberg.org) Local options: -title Search titles (default) -author Search authors -num Search etext numbers EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -a*) setoptyn SURFRAW_gutenberg_author 1 ;; -ti*) setoptyn SURFRAW_gutenberg_title 1 ;; -n*) setoptyn SURFRAW_gutenberg_num 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.gutenberg.org/" + w3_browse_url "https://www.gutenberg.org/" else escaped_args=`w3_url_of_arg $w3_args` if ifno SURFRAW_gutenberg_author && ifno SURFRAW_gutenberg_title && ifno SURFRAW_gutenberg_num then SURFRAW_gutenberg_title=1 fi - url="http://www.gutenberg.org/catalog/world/results?" + url="https://www.gutenberg.org/catalog/world/results?" if ifyes SURFRAW_gutenberg_author then url="$url&author=${escaped_args}" else url="$url&author=" fi if ifyes SURFRAW_gutenberg_title then url="$url&title=${escaped_args}" else url="$url&title=" fi if ifyes SURFRAW_gutenberg_num then url="$url&etextnr=${escaped_args}" else url="$url&etextnr=" fi w3_browse_url "$url" fi diff --git a/elvi/jamendo b/elvi/jamendo index eb0beb8..b2b2904 100755 --- a/elvi/jamendo +++ b/elvi/jamendo @@ -1,68 +1,68 @@ #!/bin/sh # elvis: jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_jamendo_lang "$SURFRAW_lang" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the web using Jamendo: free music with Creative Commons licenses (www.jamendo.com) Local options: -l= | -lang= Search with this l10n en|english fr|french de|german it|italian pt|portuguese pl|polish ru|russian es|spanish Default: English Environment: SURFRAW_jamendo_lang, SURFRAW_lang EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -l=*|-lang=*) setopt SURFRAW_jamendo_lang $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments # Use SURFRAW_lang if present if [ -z $SURFRAW_jamendo_lang ]; then SURFRAW_jamendo_lang="en"; fi if test -z "$w3_args"; then - w3_browse_url "http://www.jamendo.com/${SURFRAW_jamendo_lang}/search" + w3_browse_url "https://www.jamendo.com/${SURFRAW_jamendo_lang}/search" else case "$SURFRAW_jamendo_lang" in en|english) setopt SURFRAW_jamendo_lang en ;; fr|french) setopt SURFRAW_jamendo_lang fr ;; de|german) setopt SURFRAW_jamendo_lang de ;; it|italian) setopt SURFRAW_jamendo_lang it ;; pt|portuguese) setopt SURFRAW_jamendo_lang br;; pl|polish) setopt SURFRAW_jamendo_lang pl ;; ru|russian) setopt SURFRAW_jamendo_lang ru ;; es|spanish) setopt SURFRAW_jamendo_lang es ;; *) setopt SURFRAW_jamendo_lang en ;; esac escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.jamendo.com/${SURFRAW_jamendo_lang}/search?qs=q=${escaped_args}" + w3_browse_url "https://www.jamendo.com/${SURFRAW_jamendo_lang}/search?qs=q=${escaped_args}" fi diff --git a/elvi/jquery b/elvi/jquery index 195301e..b36111d 100755 --- a/elvi/jquery +++ b/elvi/jquery @@ -1,24 +1,24 @@ #!/bin/sh # elvis: jquery -- Search the jQuery documentation (api.jquery.com) # [email protected] 20130507 . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the jQuery documentation (api.jquery.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://api.jquery.com/" + w3_browse_url "https://api.jquery.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://api.jquery.com?s=${escaped_args}" + w3_browse_url "https://api.jquery.com?s=${escaped_args}" fi diff --git a/elvi/lastfm b/elvi/lastfm index 563ba61..6296426 100755 --- a/elvi/lastfm +++ b/elvi/lastfm @@ -1,45 +1,45 @@ #!/bin/sh # $Id$ # elvis: lastfm -- Search last.fm . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_lastfm_redirect 1 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search last.fm Local options: -l Show list even if exact match. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -l) setoptyn SURFRAW_lastfm_redirect 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://last.fm/" + w3_browse_url "https://last.fm/" else escaped_args=`w3_url_of_arg $w3_args` - url="http://last.fm/search?q=${escaped_args}" + url="https://last.fm/search?q=${escaped_args}" if ifno SURFRAW_lastfm_redirect then url="${url}&noredirect=1" fi w3_browse_url "${url}" fi diff --git a/elvi/leodict b/elvi/leodict index 6188a81..3f0c237 100755 --- a/elvi/leodict +++ b/elvi/leodict @@ -1,102 +1,102 @@ #!/bin/sh # elvis: leodict -- Search Leo's German <-> English dictionary (dict.leo.org) # $Id$ # surfraw plugin for the biggest English/German dictionary on # the WWW: dict.leo.org [email protected] # options added by Ian Beckwith <[email protected]> . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_leodict_link yes defyn SURFRAW_leodict_head yes defyn SURFRAW_leodict_grid yes def SURFRAW_leodict_to "either" def SURFRAW_leodict_spell "standard" def SURFRAW_leodict_tol "standard" def SURFRAW_leodict_lang "$SURFRAW_lang" } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -link*=*) setopt SURFRAW_leodict_link $optarg ;; -head*=*) setopt SURFRAW_leodict_head $optarg ;; -grid*=*) setopt SURFRAW_leodict_grid $optarg ;; -to=*) setopt SURFRAW_leodict_to $optarg ;; -spell*=*) setopt SURFRAW_leodict_spell $optarg ;; -tol*=*) setopt SURFRAW_leodict_tol $optarg ;; -lang*=*) setopt SURFRAW_leodict_lang $optarg ;; *) return 1 ;; esac return 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Surfraw search the German/English dictionary LEO (dict.leo.org) Local options: -to=de | en | either Language to translate to. Default: $SURFRAW_leodict_to Environment: SURFRAW_leodict_to -lang=en | de Language web page is in. Environment: SURFRAW_leodict_lang, SURFRAW_lang If above variables are not set, defaults to en, unless \$LANG is set and contains "de". -link=on | off Link results. Default: $SURFRAW_leodict_link Environment: SURFRAW_leodict_link -head=on | off Display headlines. Default: $SURFRAW_leodict_head Environment: SURFRAW_leodict_head -grid=on | off Show results in grid. Default: $SURFRAW_leodict_grid Environment: SURFRAW_leodict_grid -spell=off | standard | force Spelling tolerance Default: $SURFRAW_leodict_spell Environment: SURFRAW_leodict_spell -tol=off | standard | high Special characters tolerance Default: $SURFRAW_leodict_tol Environment: SURFRAW_leodict_tol EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then - w3_browse_url "http://dict.leo.org/" + w3_browse_url "https://dict.leo.org/" else escaped_args=`w3_url_of_arg $w3_args` - url="http://dict.leo.org/?search=${escaped_args}" + url="https://dict.leo.org/?search=${escaped_args}" case "$SURFRAW_leodict_lang" in en|de) ;; *) SURFRAW_leodict_lang=`perl -e 'if((exists($ENV{LANG})) && ($ENV{LANG}=~/de/i)) { print "de\n"; } else { print "en\n"; }'` ;; esac if yesno SURFRAW_leodict_link ; then url="$url&relink=on" else url="$url&relink=off";fi if yesno SURFRAW_leodict_head ; then url="$url&sectHdr=on" else url="$url&sectHdr=off";fi if yesno SURFRAW_leodict_grid ; then url="$url&tableBorder=1" else url="$url&tableBorder=0";fi if [ "$SURFRAW_leodict_to" = "de" ] ; then url="$url&searchLoc=-1" elif [ "$SURFRAW_leodict_to" = "en" ] ; then url="$url&searchLoc=1" else url="$url&searchLoc=0" ; fi if [ "$SURFRAW_leodict_spell" = "off" ] ; then url="$url&spellToler=off" elif [ "$SURFRAW_leodict_spell" = "force" ] ; then url="$url&spellToler=on" else url="$url&spellToler=standard" ; fi if [ "$SURFRAW_leodict_tol" = "high" ] ; then url="$url&cmpType=fuzzy" elif [ "$SURFRAW_leodict_tol" = "off" ] ; then url="$url&cmpType=exact" else url="$url&cmpType=relaxed" ; fi url="$url&lang=$SURFRAW_leodict_lang" w3_browse_url "$url" fi diff --git a/elvi/lsm b/elvi/lsm index 7d128bc..927a4a0 100755 --- a/elvi/lsm +++ b/elvi/lsm @@ -1,47 +1,47 @@ #!/bin/sh # $Id$ # elvis: lsm -- Search the Linux Software Map . surfraw || exit 1 w3_config_hook () { def SURFRAW_lsm_search title } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Linux Software Map (www.boutell.com/lsm/) Local options: -search= Specialized search on topic title | Title search (default) keyword Keyword search Environment: SURFRAW_lsm_search EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s*=*) setopt SURFRAW_lsm_search $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.boutell.com/lsm/" + w3_browse_url "https://www.boutell.com/lsm/" else escaped_args=`w3_url_of_arg $w3_args` if [ "$SURFRAW_lsm_search" = "keyword" ]; then - url="http://www.boutell.com/lsm/lsmbykey.cgi/submit?keyword=${escaped_args}" + url="https://www.boutell.com/lsm/lsmbykey.cgi/submit?keyword=${escaped_args}" else - url="http://www.boutell.com/lsm/lsmbytitle.cgi/submit?title=${escaped_args}" + url="https://www.boutell.com/lsm/lsmbytitle.cgi/submit?title=${escaped_args}" fi w3_browse_url "${url}" fi diff --git a/elvi/macports b/elvi/macports index 3b81d80..42ca42b 100755 --- a/elvi/macports +++ b/elvi/macports @@ -1,50 +1,50 @@ #!/bin/sh # elvis: macports -- Search macports packages (macports.org) # [email protected] 20091112 . surfraw || exit 1 w3_config_hook () { def SURFRAW_macports_by name } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search macports packages (macports.org) Local options: -by=TYPE Search by TYPE name | Software Title (default) category | Category maintainer | Maintainer variant | Variant platform | Platform Default: $SURFRAW_macports_by Environment: SURFRAW_macports_by EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -by*=*) setopt SURFRAW_macports_by $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) -url="http://www.macports.org/ports.php" +url="https://www.macports.org/ports.php" if [ -n "$escaped_args" ] then url="${url}?by=${SURFRAW_macports_by}&substr=${escaped_args}" fi w3_browse_url "$url" diff --git a/elvi/mdn b/elvi/mdn index d6ac037..c883b29 100755 --- a/elvi/mdn +++ b/elvi/mdn @@ -1,25 +1,25 @@ #!/bin/sh # [email protected] 20130923 # elvis: mdn -- Search the mozilla developer network (developer.mozilla.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Surfraw search the mozilla developer network (developer.mozilla.org) EOF w3_custom_search_usage w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args" then - w3_browse_url "http://developer.mozilla.org" + w3_browse_url "https://developer.mozilla.org" else w3_custom_search -s=developer.mozilla.org "$w3_shquoted_args" fi diff --git a/elvi/musicbrainz b/elvi/musicbrainz index 3f3b4b9..84b1fd0 100755 --- a/elvi/musicbrainz +++ b/elvi/musicbrainz @@ -1,165 +1,165 @@ #!/bin/sh # $Id$ # elvis: musicbrainz -- Search MusicBrainz (musicbrainz.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_musicbrainz_limit $SURFRAW_results def SURFRAW_musicbrainz_search artist def SURFRAW_musicbrainz_tagrelease "" def SURFRAW_musicbrainz_tagtrack "" def SURFRAW_musicbrainz_tagnum "" def SURFRAW_musicbrainz_taglen "" def SURFRAW_musicbrainz_tagpuid "" def SURFRAW_musicbrainz_tagfile "" defyn SURFRAW_musicbrainz_advanced 0 defyn SURFRAW_musicbrainz_direct 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search MusicBrainz (musicbrainz.org) Local options: -d Direct (old) search. -a Enable advanced query syntax. See: - http://musicbrainz.org/popup/TextSearchSyntax + https://musicbrainz.org/popup/TextSearchSyntax -results=NUM Number of search results returned Default: $SURFRAW_musicbrainz_results Environment: SURFRAW_musicbrainz_results 0 means all results. -search= Search type: artist | Artist [default] <*> release | Release (album) <*> release_group | Release Group label | Label <*> annotation | Annotation barcode | Barcode catno | Catalog number cdstub | CD Stub discid | Disc ID editor | Editor freedb | FreeDB freedb | FreeDB ID isrc | ISRC iswc | ISWC mbid | MBID puid | PUID recording | Recording trmid | TRM ID work | Work tag Tag Search With Tag Search, [search words] are treated as artist name, use -tag* below to specify other fields. <*> = supported by direct search (-d) Environment: SURFRAW_musicbrainz_search -tagrelease=ALBUM Album/Release tag search (implies -search=tag) -tagnum=TRACKNUM Track number tag search (implies -search=tag) -tagtrack=SONG Track tag search (implies -search=tag) -taglen=DURATION Track length tag search (implies -search=tag) -tagfile=FILENAME Filename tag search (implies -search=tag) -tagpuid=FILENAME PUID tag search (implies -search=tag) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_musicbrainz_results $optarg ;; -tagrel*=*) setopt SURFRAW_musicbrainz_tagrelease $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagnu*=*) setopt SURFRAW_musicbrainz_tagnum $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagtra*=*) setopt SURFRAW_musicbrainz_tagtrack $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagle*=*) setopt SURFRAW_musicbrainz_taglen $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagp*=*) setopt SURFRAW_musicbrainz_tagpuid $optarg setopt SURFRAW_musicbrainz_search tag ;; -tagf*=*) setopt SURFRAW_musicbrainz_tagfile $optarg setopt SURFRAW_musicbrainz_search tag ;; -a) setoptyn SURFRAW_musicbrainz_advanced 1 ;; -d) setoptyn SURFRAW_musicbrainz_direct 1 ;; -search=*) searchtype="$optarg" case "$searchtype" in ar*) setopt SURFRAW_musicbrainz_search artist ;; release_*) setopt SURFRAW_musicbrainz_search release_group ;; release|rel|al*) setopt SURFRAW_musicbrainz_search release ;; an*) setopt SURFRAW_musicbrainz_search annotation ;; ba*) setopt SURFRAW_musicbrainz_search barcode ;; ca*) setopt SURFRAW_musicbrainz_search catno ;; cd*) setopt SURFRAW_musicbrainz_search cdstub ;; d*) setopt SURFRAW_musicbrainz_search discid ;; e*) setopt SURFRAW_musicbrainz_search editor ;; freedb|fr) setopt SURFRAW_musicbrainz_search freedb ;; freedbid) setopt SURFRAW_musicbrainz_search freedbid ;; isr*) setopt SURFRAW_musicbrainz_search isrc ;; isw*) setopt SURFRAW_musicbrainz_search iswc ;; l*) setopt SURFRAW_musicbrainz_search label ;; m*) setopt SURFRAW_musicbrainz_search mbid ;; p*) setopt SURFRAW_musicbrainz_search puid ;; rec*) setopt SURFRAW_musicbrainz_search recording ;; tr*) setopt SURFRAW_musicbrainz_search trmid ;; w*) setopt SURFRAW_musicbrainz_search work ;; ta*) setopt SURFRAW_musicbrainz_search tag ;; *) err "Search type not known" esac ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args" && test -z "$SURFRAW_musicbrainz_tagrelease" && test -z "$SURFRAW_musicbrainz_tagnum" && test -z "$SURFRAW_musicbrainz_tagtrack" && test -z "$SURFRAW_musicbrainz_taglen" && test -z "$SURFRAW_musicbrainz_tagpuid" && test -z "$SURFRAW_musicbrainz_tagfile" then - w3_browse_url "http://musicbrainz.org/search.html" + w3_browse_url "https://musicbrainz.org/search.html" else escaped_args=`w3_url_of_arg $w3_args` - url="http://musicbrainz.org" + url="https://musicbrainz.org" if ifyes SURFRAW_musicbrainz_direct then case "$SURFRAW_musicbrainz_search" in artist|release|label) url="${url}/search/oldsearch.html?query=${escaped_args}&type=${SURFRAW_musicbrainz_search}&limit=${SURFAW_musicbrainz_results}&handlearguments=1" ;; *) err "Search type $SURFRAW_musicbrainz_search not supported by Direct Search (-d)" ;; esac else case "$SURFRAW_musicbrainz_search" in artist|release_group|release|recording|work| \ label|annotation|cdstub|editor| \ freedb) url="${url}/search?query=${escaped_args}&type=${SURFRAW_musicbrainz_search}&limit=${SURFRAW_musicbrainz_limit}" if ifyes SURFRAW_musicbrainz_advanced then url="${url}&adv=on" fi ;; catno|barcode|discid|freedbid|freedb| \ puid|trmid|isrc|iswc| \ discid) url="${url}/otherlookup?${SURFRAW_musicbrainz_search}=${escaped_args}" ;; mbid) url="${url}/release/${escaped_args}" ;; tag) url="${url}/taglookup?artist=${escaped_args}&release=${SURFRAW_musicbrainz_tagrelease}&track=${SURFRAW_musicbrainz_tagtrack}&tracknum=${SURFRAW_musicbrainz_tagnum}&duration=${SURFRAW_musicbrainz_taglen}&filename=${SURFRAW_musicbrainz_tagfile}&puid=${SURFRAW_musicbrainz_puid}" ;; *) err Unknown search type "${SURFRAW_musicbrainz_search}" ;; esac fi w3_browse_url "$url" fi diff --git a/elvi/mysqldoc b/elvi/mysqldoc index 4bd6917..efcd6d0 100755 --- a/elvi/mysqldoc +++ b/elvi/mysqldoc @@ -1,63 +1,63 @@ #!/bin/sh # [email protected] 20130923 # elvis: mysqldoc -- Search mysql documentation (dev.mysql.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_mysqldoc_version all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search mysql documentation (dev.mysql.com) Local options: -a Search all versions/docs -v=VERSION Search docs for mysql version VERSION Default: $SURFRAW_mysqldoc_version Environment: SURFRAW_mysqldoc_version EOF w3_custom_search_usage w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -a) setopt SURFRAW_mysqldoc_version "all" ;; -v*=*) setopt SURFRAW_mysqldoc_version "$optarg" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" if test -z "$w3_args" then case "$SURFRAW_mysqldoc_version" in all) inurl="/doc/" ;; *5.7*) inurl="/doc/refman/5.7/en/" ;; *5.6*) inurl="/doc/refman/5.6/en/" ;; *5.5*) inurl="/doc/refman/5.5/en/" ;; *5.0*) inurl="/doc/refman/5.0/en/" ;; *[34]*) inurl="/doc/refman/4.1/en/" ;; *) inurl="/doc/" esac - w3_browse_url "http://dev.mysql.com${inurl}" + w3_browse_url "https://dev.mysql.com${inurl}" else case "$SURFRAW_mysqldoc_version" in all) inurl="-u=doc" ;; *5.7*) inurl="-u=doc -u=refman -u=5.7" ;; *5.6*) inurl="-u=doc -u=refman -u=5.6" ;; *5.5*) inurl="-u=doc -u=refman -u=5.5" ;; *5.0*) inurl="-u=doc -u=refman -u=5.0" ;; *[34]*) inurl="-u=doc -u=refman -u=4.1" ;; *) inurl="-u=doc" ;; esac w3_custom_search -s=dev.mysql.com $inurl "$w3_shquoted_args" fi
JNRowe/surfraw
ebefc7bdcbd8732c35057b012d00f20fca53f50c
Clean up the dmoz and cablesearch removals.
diff --git a/README b/README index f6ac9a7..cec4b81 100644 --- a/README +++ b/README @@ -1,402 +1,400 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Home Page: http://surfraw.alioth.debian.org ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web New: http://surfraw.alioth.debian.org Old: http://surfraw.sourceforge.net/ Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS Surfraw now supports bookmarks. To add a bookmark, add it to to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/rhyme -method=perfect Julian OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers -cablesearch -- search for leaked diplomatic communications cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) deli -- Search Delicious bookmarks discogs -- Search the Discogs database of music information (www.discogs.com) -dmoz -- Search the Open Directory Project web directory (dmoz.org) duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) openports -- search openports for OpenBSD packages opensearch -- Search an OpenSearch-enabled website oraclesearch -- Search an OpenSearch-enabled website pasearch -- Search the unofficial Penny Arcade archives (pipefour.org/pa) pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) rhyme -- Search for rhymes et al using Lycos Rhyme (rhyme.lycos.com) rpmsearch -- Search for RPMs in various distros scholar -- Search Google Scholar (scholar.google.com) scicom -- Search Scientific Commons scirus -- Search for science using Scirus (scirus.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) wetandwild -- Real time weather information (many sources) wikipedia -- Search the free encyclopedia wikipedia woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org yacy -- Search YaCy P2P search, including ScienceNet yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) yubnub -- Use the social command-line for the web (yubnub.org) All elvi have useful low calorie help, for example: Usage: rhyme [options] [search words]... Description: Surfraw search for rhymes and other word correlations using Lycos Rhyme (rhyme.lycos.com) Example: $ rhyme Julian $ rhyme -method=rel surfer Results: Hurclean St. Julien. surfboarder, bather, natator, swimmer Local options: -method= Type of word correlation to search for prefect | Perfect rhyme syn | Synonyms hom | Homophones cons | Consonsant rhymes only rel | Semantically related words sub | Phrases spell | Similar spellings pic | Pictures shake | Match with Shakespeare archives def Find wordnet definition Default: perfect Environment: SURFRAW_rhyme_method Global options: -browser=EXECUTABLE Set browser Default: sensible-browser -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: yes Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: yes Environment: SURFRAW_graphical -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: no Environment: SURFRAW_new_window -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: no Environment: SURFRAW_quote_args -version Display Surfraw version (2.2.7) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________ diff --git a/elvi/Makefile.am b/elvi/Makefile.am index 44527e2..fa399a0 100644 --- a/elvi/Makefile.am +++ b/elvi/Makefile.am @@ -1,132 +1,130 @@ # $Id$ elvidir=$(ELVIDIR) dist_elvi_SCRIPTS = \ S \ W \ acronym \ ads \ alioth \ amazon \ archpkg \ archwiki \ arxiv \ ask \ aur \ austlii \ bing \ bbcnews \ bookfinder \ bugmenot \ bugzilla \ - cablesearch \ cia \ cisco \ cite \ cliki \ cnn \ comlaw \ commandlinefu \ ctan \ currency \ cve \ debbugs \ debcodesearch \ debcontents \ deblists \ deblogs \ debpackages \ debpkghome \ debpts \ debsec \ debvcsbrowse \ debwiki \ deja \ deli \ discogs \ - dmoz \ duckduckgo \ ebay \ etym \ excite \ f5 \ foldoc \ finkpkg \ freebsd \ freedb \ freshmeat \ fsfdir \ gcache \ genbugs \ genportage \ github \ gmane \ google \ gutenberg \ imdb \ ixquick \ jamendo \ javasun \ jquery \ l1sp \ lastfm \ leodict \ lsm \ macports \ mathworld \ mdn \ mininova \ musicbrainz \ mysqldoc \ netbsd \ nlab \ ntrs \ openbsd \ openports \ opensearch \ oraclesearch \ pasearch \ pgdoc \ pgpkeys \ phpdoc \ pin \ piratebay \ priberam \ pubmed \ rae \ rfc \ rhyme \ rpmsearch \ scholar \ scicom \ scirus \ scpan \ searx \ slashdot \ slinuxdoc \ sourceforge \ springer \ stack \ stockquote \ thesaurus \ translate \ urban \ w3css \ w3html \ w3link \ w3rdf \ wayback \ webster \ wetandwild \ wikipedia \ woffle \ wolfram \ worldwidescience \ yacy \ yahoo \ yandex \ youtube \ yubnub uninstall-local: -rmdir $(DESTDIR)$(PREFIX)/$(ELVIDIR) diff --git a/links.IN b/links.IN index bd9170a..6c3f555 100644 --- a/links.IN +++ b/links.IN @@ -1,120 +1,118 @@ elvi.1sr.gz @mandir@/man1/W.1.gz elvi.1sr.gz @mandir@/man1/S.1sr.gz elvi.1sr.gz @mandir@/man1/acronym.1sr.gz elvi.1sr.gz @mandir@/man1/ads.1sr.gz elvi.1sr.gz @mandir@/man1/alioth.1sr.gz elvi.1sr.gz @mandir@/man1/amazon.1sr.gz elvi.1sr.gz @mandir@/man1/archpkg.1sr.gz elvi.1sr.gz @mandir@/man1/archwiki.1sr.gz elvi.1sr.gz @mandir@/man1/arxiv.1sr.gz elvi.1sr.gz @mandir@/man1/ask.1sr.gz elvi.1sr.gz @mandir@/man1/aur.1sr.gz elvi.1sr.gz @mandir@/man1/austlii.1sr.gz elvi.1sr.gz @mandir@/man1/bing.1sr.gz elvi.1sr.gz @mandir@/man1/bbcnews.1sr.gz elvi.1sr.gz @mandir@/man1/bookfinder.1sr.gz elvi.1sr.gz @mandir@/man1/bugmenot.1sr.gz elvi.1sr.gz @mandir@/man1/bugzilla.1sr.gz -elvi.1sr.gz @mandir@/man1/cablesearch.1sr.gz elvi.1sr.gz @mandir@/man1/cite.1sr.gz elvi.1sr.gz @mandir@/man1/cia.1sr.gz elvi.1sr.gz @mandir@/man1/cliki.1sr.gz elvi.1sr.gz @mandir@/man1/cnn.1sr.gz elvi.1sr.gz @mandir@/man1/comlaw.1sr.gz elvi.1sr.gz @mandir@/man1/commandlinefu.1sr.gz elvi.1sr.gz @mandir@/man1/ctan.1sr.gz elvi.1sr.gz @mandir@/man1/currency.1sr.gz elvi.1sr.gz @mandir@/man1/cve.1sr.gz elvi.1sr.gz @mandir@/man1/debbugs.1sr.gz elvi.1sr.gz @mandir@/man1/debcodesearch.1sr.gz elvi.1sr.gz @mandir@/man1/debcontents.1sr.gz elvi.1sr.gz @mandir@/man1/deblists.1sr.gz elvi.1sr.gz @mandir@/man1/deblogs.1sr.gz elvi.1sr.gz @mandir@/man1/debpackages.1sr.gz elvi.1sr.gz @mandir@/man1/debpkghome.1sr.gz elvi.1sr.gz @mandir@/man1/debpts.1sr.gz elvi.1sr.gz @mandir@/man1/debsec.1sr.gz elvi.1sr.gz @mandir@/man1/debvcsbrowse.1sr.gz elvi.1sr.gz @mandir@/man1/debwiki.1sr.gz elvi.1sr.gz @mandir@/man1/deja.1sr.gz elvi.1sr.gz @mandir@/man1/deli.1sr.gz elvi.1sr.gz @mandir@/man1/discogs.1sr.gz -elvi.1sr.gz @mandir@/man1/dmoz.1sr.gz elvi.1sr.gz @mandir@/man1/duckduckgo.1sr.gz elvi.1sr.gz @mandir@/man1/ebay.1sr.gz elvi.1sr.gz @mandir@/man1/etym.1sr.gz elvi.1sr.gz @mandir@/man1/excite.1sr.gz elvi.1sr.gz @mandir@/man1/finkpkg.1sr.gz elvi.1sr.gz @mandir@/man1/foldoc.1sr.gz elvi.1sr.gz @mandir@/man1/freebsd.1sr.gz elvi.1sr.gz @mandir@/man1/freedb.1sr.gz elvi.1sr.gz @mandir@/man1/freshmeat.1sr.gz elvi.1sr.gz @mandir@/man1/fsfdir.1sr.gz elvi.1sr.gz @mandir@/man1/gcache.1sr.gz elvi.1sr.gz @mandir@/man1/genbugs.1sr.gz elvi.1sr.gz @mandir@/man1/genportage.1sr.gz elvi.1sr.gz @mandir@/man1/github.1sr.gz elvi.1sr.gz @mandir@/man1/google.1sr.gz elvi.1sr.gz @mandir@/man1/gutenberg.1sr.gz elvi.1sr.gz @mandir@/man1/imdb.1sr.gz elvi.1sr.gz @mandir@/man1/ixquick.1sr.gz elvi.1sr.gz @mandir@/man1/jamendo.1sr.gz elvi.1sr.gz @mandir@/man1/javasun.1sr.gz elvi.1sr.gz @mandir@/man1/lastfm.1sr.gz elvi.1sr.gz @mandir@/man1/leodict.1sr.gz elvi.1sr.gz @mandir@/man1/l1sp.1sr.gz elvi.1sr.gz @mandir@/man1/lsm.1sr.gz elvi.1sr.gz @mandir@/man1/macports.1sr.gz elvi.1sr.gz @mandir@/man1/mathworld.1sr.gz elvi.1sr.gz @mandir@/man1/mdn.1sr.gz elvi.1sr.gz @mandir@/man1/mininova.1sr.gz elvi.1sr.gz @mandir@/man1/musicbrainz.1sr.gz elvi.1sr.gz @mandir@/man1/mysqldoc.1sr.gz elvi.1sr.gz @mandir@/man1/netbsd.1sr.gz elvi.1sr.gz @mandir@/man1/ntrs.1sr.gz elvi.1sr.gz @mandir@/man1/openbsd.1sr.gz elvi.1sr.gz @mandir@/man1/openports.1sr.gz elvi.1sr.gz @mandir@/man1/opensearch.1sr.gz elvi.1sr.gz @mandir@/man1/oraclesearch.1sr.gz elvi.1sr.gz @mandir@/man1/pasearch.1sr.gz elvi.1sr.gz @mandir@/man1/pgdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pgpkeys.1sr.gz elvi.1sr.gz @mandir@/man1/phpdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pin.1sr.gz elvi.1sr.gz @mandir@/man1/piratebay.1sr.gz elvi.1sr.gz @mandir@/man1/priberam.1sr.gz elvi.1sr.gz @mandir@/man1/pubmed.1sr.gz elvi.1sr.gz @mandir@/man1/rae.1sr.gz elvi.1sr.gz @mandir@/man1/rfc.1sr.gz elvi.1sr.gz @mandir@/man1/rhyme.1sr.gz elvi.1sr.gz @mandir@/man1/rpmsearch.1sr.gz elvi.1sr.gz @mandir@/man1/scholar.1sr.gz elvi.1sr.gz @mandir@/man1/scicom.1sr.gz elvi.1sr.gz @mandir@/man1/scirus.1sr.gz elvi.1sr.gz @mandir@/man1/scpan.1sr.gz elvi.1sr.gz @mandir@/man1/searx.1sr.gz elvi.1sr.gz @mandir@/man1/slashdot.1sr.gz elvi.1sr.gz @mandir@/man1/slinuxdoc.1sr.gz elvi.1sr.gz @mandir@/man1/sourceforge.1sr.gz elvi.1sr.gz @mandir@/man1/springer.1sr.gz elvi.1sr.gz @mandir@/man1/stack.1sr.gz elvi.1sr.gz @mandir@/man1/stockquote.1sr.gz elvi.1sr.gz @mandir@/man1/thesaurus.1sr.gz elvi.1sr.gz @mandir@/man1/translate.1sr.gz elvi.1sr.gz @mandir@/man1/urban.1sr.gz elvi.1sr.gz @mandir@/man1/w3css.1sr.gz elvi.1sr.gz @mandir@/man1/w3html.1sr.gz elvi.1sr.gz @mandir@/man1/w3link.1sr.gz elvi.1sr.gz @mandir@/man1/w3rdf.1sr.gz elvi.1sr.gz @mandir@/man1/wayback.1sr.gz elvi.1sr.gz @mandir@/man1/webster.1sr.gz elvi.1sr.gz @mandir@/man1/wetandwild.1sr.gz elvi.1sr.gz @mandir@/man1/wikipedia.1sr.gz elvi.1sr.gz @mandir@/man1/woffle.1sr.gz elvi.1sr.gz @mandir@/man1/wolfram.1sr.gz elvi.1sr.gz @mandir@/man1/worldwidescience.1sr.gz elvi.1sr.gz @mandir@/man1/yacy.1sr.gz elvi.1sr.gz @mandir@/man1/yahoo.1sr.gz elvi.1sr.gz @mandir@/man1/yandex.1sr.gz elvi.1sr.gz @mandir@/man1/youtube.1sr.gz elvi.1sr.gz @mandir@/man1/yubnub.1sr.gz diff --git a/test/Makefile.am b/test/Makefile.am index 64009b1..2dd709b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,34 +1,34 @@ EXTRA_DIST = runtests elviwithouttests README COOKIES W.test S.test \ acronym.test ads.test alioth.test amazon.test archpkg.test \ archwiki.test arxiv.test ask.test aur.test austlii.test \ - bbcnews.test bing.test bookfinder.test bugmenot.test \ - bugzilla.test cablesearch.test cia.test cisco.test cite.test \ + bbcnews.test bing.test bookfinder.test bugmenot.test \ + bugzilla.test cia.test cisco.test cite.test \ cliki.test cnn.test comlaw.test ctan.test currency.test \ cve.test debbugs.test debcodesearch.test debcontents.test \ deblists.test deblogs.test debpackages.test debpkghome.test \ debpts.test debsec.test debvcsbrowse.test debwiki.test \ - deja.test deli.test discogs.test dmoz.test duckduckgo.test \ - ebay.test etym.test excite.test f5.test finkpkg.test \ - foldoc.test freebsd.test freedb.test freshmeat.test \ - fsfdir.test gcache.test genbugs.test genportage.test \ + deja.test deli.test discogs.test duckduckgo.test \ + ebay.test etym.test excite.test f5.test finkpkg.test \ + foldoc.test freebsd.test freedb.test freshmeat.test \ + fsfdir.test gcache.test genbugs.test genportage.test \ github.test gmane.test google.test gutenberg.test imdb.test \ - ixquick.test jamendo.test javasun.test jquery.test lastfm.test \ + ixquick.test jamendo.test javasun.test jquery.test lastfm.test \ leodict.test l1sp.test lsm.test macports.test mathworld.test \ mdn.test mininova.test musicbrainz.test mysqldoc.test \ - netbsd.test ntrs.test openbsd.test openports.test \ + netbsd.test ntrs.test openbsd.test openports.test \ opensearch.test oraclesearch.test pasearch.test pgdoc.test \ - phpdoc.test pin.test piratebay.test pgpkeys.test priberam.test \ + phpdoc.test pin.test piratebay.test pgpkeys.test priberam.test \ pubmed.test rae.test rfc.test rhyme.test rpmsearch.test \ - scholar.test scicom.test scirus.test scpan.test slashdot.test \ + scholar.test scicom.test scirus.test scpan.test slashdot.test \ slinuxdoc.test sourceforge.test springer.test stack.test \ stockquote.test thesaurus.test translate.test urban.test \ w3css.test w3html.test w3link.test w3rdf.test wayback.test \ webster.test wetandwild.test wikipedia.test wolfram.test \ woffle.test worldwidescience.test yacy.test yahoo.test \ yandex.test youtube.test yubnub.test test: ./runtests ./elviwithouttests diff --git a/test/cablesearch.test b/test/cablesearch.test deleted file mode 100644 index a8bc8ed..0000000 --- a/test/cablesearch.test +++ /dev/null @@ -1,2 +0,0 @@ -cablesearch america -Chile diff --git a/test/dmoz.test b/test/dmoz.test deleted file mode 100644 index 0da17d5..0000000 --- a/test/dmoz.test +++ /dev/null @@ -1,2 +0,0 @@ -dmoz foo -1-20 of \d+
JNRowe/surfraw
a3ebc6863d123a8962af06c7a045ef656a841866
Elvi cleanup (d-f).
diff --git a/elvi/debbugs b/elvi/debbugs index 2a46471..6ac05aa 100755 --- a/elvi/debbugs +++ b/elvi/debbugs @@ -1,235 +1,235 @@ #!/bin/sh # $Id$ # elvis: debbugs -- Search the debian BTS (bugs.debian.org) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debbugs_search pkg def SURFRAW_debbugs_version "" def SURFRAW_debbugs_dist "" defyn SURFRAW_debbugs_archive 0 defyn SURFRAW_debbugs_merge 0 defyn SURFRAW_debbugs_statussort 1 defyn SURFRAW_debbugs_head 1 defyn SURFRAW_debbugs_foot 1 def SURFRAW_debbugs_incstatus "" def SURFRAW_debbugs_excstatus "" def SURFRAW_debbugs_incsev "" def SURFRAW_debbugs_excsev "" def SURFRAW_debbugs_inctag "" def SURFRAW_debbugs_exctag "" defyn SURFRAW_debbugs_asmbox 0 defyn SURFRAW_debbugs_headers 0 defyn SURFRAW_debbugs_boring 0 defyn SURFRAW_debbugs_revstat 0 defyn SURFRAW_debbugs_revsev 0 defyn SURFRAW_debbugs_revbugs 0 defyn setsearch 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [package | bug number | maintainer email] Description: Surfraw search debian BTS (bugs.debian.org) Examples: debbugs 20000 | show report for bug #20000 debbugs [email protected] | show bugs for csurchi debbugs surfraw | show bugs for surfraw package debbugs -raw -rb surfraw | show surfraw bugs newest first Defaults if -search is not supplied: If arg is numeric, searches by bug number, If it contains '@', searches by maintainer, Otherwise, searches by package. Local options: -search= pkg | Search type. src | bug | (bug number) maint | tag | submitter | severity | tag -s Alias for -search=src -version=VERSION Package version. -dist=oldstable | Distribution stable | proposed-updates | testing | unstable | experimental | testing-proposed-updates -arc Show archived bugs. -raw Do not sort by status or severity. -rb Reverse order of bugs shown. -rst Reverse order of statuses shown. -rse Reverse order of severities shown. -merge Display merged bugs only once. -nohead Do not show table of contents header. -nofoot Do not show statistics in the footer. -mbox View results in mbox format. * -sh Show headers. * -boring Show boring messages. * (* = only when searching by bug number.) -incstat=stat1,stat2 Include given status list. -exstat=stat3,stat4 Exclude given status list. Available statuses: open, forwarded, pending, fixed, done. -incsev=sev1,sev2 Include given severities. -exsev=sev3,sev4 Exclude given severities. Available severities: critical, grave, serious, important, normal, minor, wishlist, fixed. -inctag=tag1,tag2 Include given tags. -extag=tag3,tag4 Exclude given tags. Available tags: potato, woody, sarge, sarge-ignore, etch, etch-ignore, sid, experimental, confirmed, d-i, fixed, fixed-in-experimental, fixed-upstream, help, l10n, moreinfo, patch, pending, security, unreproducible, upstream, wontfix, ipv6, lfs EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -s) setopt SURFRAW_debbugs_search src ; setoptyn setsearch 1 ;; -se*=*) setopt SURFRAW_debbugs_search $optarg; setoptyn setsearch 1 ;; -ve*=*) setopt SURFRAW_debbugs_version $optarg ;; -dis*=*) setopt SURFRAW_debbugs_dist $optarg ;; -arc*) setoptyn SURFRAW_debbugs_archive 1;; -mer*) setoptyn SURFRAW_debbugs_merge 1;; -raw*) setoptyn SURFRAW_debbugs_statussort 0;; -noh*) setoptyn SURFRAW_debbugs_head 0;; -nof*) setoptyn SURFRAW_debbugs_foot 0;; -in*stat*=*) setopt SURFRAW_debbugs_incstatus $optarg;; -ex*stat*=*) setopt SURFRAW_debbugs_excstatus $optarg;; -in*sev*=*) setopt SURFRAW_debbugs_incsev $optarg;; -ex*sev*=*) setopt SURFRAW_debbugs_excsev $optarg;; -in*tag*=*) setopt SURFRAW_debbugs_inctag $optarg;; -ex*tag*=*) setopt SURFRAW_debbugs_exctag $optarg;; -rb*) setoptyn SURFRAW_debbugs_revbugs 1;; -rst*) setoptyn SURFRAW_debbugs_revstat 1;; -rse*) setoptyn SURFRAW_debbugs_revsev 1;; -mb*) setoptyn SURFRAW_debbugs_asmbox 1;; -sh*) setoptyn SURFRAW_debbugs_headers 1;; -bo*) setoptyn SURFRAW_debbugs_boring 1;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://bugs.debian.org/" + w3_browse_url "https://www.debian.org/Bugs" else escaped_args=`w3_url_of_arg $w3_args` setoptyn donum 0 setoptyn domaint 0 case "$SURFRAW_debbugs_search" in bug*) setoptyn donum 1;; esac # default search unless searchtype set on cmdline if ifno setsearch then export escaped_args if perl -e 'if($ENV{escaped_args} =~/^((\#|\%23)(\s|\%20)*)?\d+$/) { exit 0; } exit 1;' then # %23 = uri escaped '#', %20=' ' setoptyn donum 1 elif perl -e 'if($ENV{escaped_args} =~/\%40|@/) { exit 0; } exit 1;' then # %40 = uri escaped '@' setopt SURFRAW_debbugs_search "maint" fi fi if ifyes donum then - url="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${escaped_args}" + url="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${escaped_args}" if yesno SURFRAW_debbugs_asmbox then url="$url&mbox=yes" fi if yesno SURFRAW_debbugs_headers then url="$url&trim=no" fi if yesno SURFRAW_debbugs_boring then url="$url&boring=yes" fi else - url="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=${SURFRAW_debbugs_search}&version=${SURFRAW_debbugs_version}&dist=${SURFRAW_debbugs_dist}&data=${escaped_args}" + url="https://bugs.debian.org/cgi-bin/pkgreport.cgi?which=${SURFRAW_debbugs_search}&version=${SURFRAW_debbugs_version}&dist=${SURFRAW_debbugs_dist}&data=${escaped_args}" if yesno SURFRAW_debbugs_archive then url="$url&archive=yes" else url="$url&archive=no" fi if ifyes SURFRAW_debbugs_merge then url="$url&repeatmerged=no" fi if ifno SURFRAW_debbugs_statussort then url="$url&raw=yes" fi if ifno SURFRAW_debbugs_head then url="$url&show_list_header=no" fi if ifno SURFRAW_debbugs_foot then url="$url&show_list_footer=no" fi if ifyes SURFRAW_debbugs_revstat then url="$url&pend-rev=yes" fi if ifyes SURFRAW_debbugs_revsev then url="$url&sev-rev=yes" fi if ifyes SURFRAW_debbugs_revbugs then url="$url&bug-rev=yes" fi if [ "$SURFRAW_debbugs_incstatus" != "" ] then add=`echo "$SURFRAW_debbugs_incstatus"|perl -ne 's/pending/pending-fixed/g;s/open/pending/g;print(join("&pend-inc=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi if [ "$SURFRAW_debbugs_excstatus" != "" ] then add=`echo "$SURFRAW_debbugs_excstatus"|perl -ne 'print(join("&pend-exc=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi if [ "$SURFRAW_debbugs_incsev" != "" ] then add=`echo "$SURFRAW_debbugs_incsev"|perl -ne 'print(join("&sev-inc=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi if [ "$SURFRAW_debbugs_excsev" != "" ] then add=`echo "$SURFRAW_debbugs_excsev"|perl -ne 'print(join("&sev-exc=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi if [ "$SURFRAW_debbugs_inctag" != "" ] then add=`echo "$SURFRAW_debbugs_inctag"|perl -ne 'print(join("&include=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi if [ "$SURFRAW_debbugs_exctag" != "" ] then add=`echo "$SURFRAW_debbugs_exctag"|perl -ne 'print(join("&exclude=","",split(/\s*,\s*/,$_)));'` url="${url}${add}" fi fi w3_browse_url "$url" fi diff --git a/elvi/debcodesearch b/elvi/debcodesearch index dbcfa6c..4805e82 100755 --- a/elvi/debcodesearch +++ b/elvi/debcodesearch @@ -1,23 +1,23 @@ #!/bin/sh # [email protected] 20130504 # elvis: debcodesearch -- Search debian source code . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search source code of debian packages EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://codesearch.debian.net" + w3_browse_url "https://codesearch.debian.net" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://codesearch.debian.net/search?q=${escaped_args}" + w3_browse_url "https://codesearch.debian.net/search?q=${escaped_args}" fi diff --git a/elvi/debcontents b/elvi/debcontents index b47275b..3dc65c3 100755 --- a/elvi/debcontents +++ b/elvi/debcontents @@ -1,155 +1,155 @@ #!/bin/sh # $Id$ # elvis: debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debcontents_arch i386 def SURFRAW_debcontents_distro stable def SURFRAW_debcontents_search "files" defyn SURFRAW_debcontents_ubuntu no defyn SURFRAW_debcontents_archive no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) Local options: -a Search archived debian releases -u Search ubuntu packages instead of debian -search= Type of search files | Packages that contain files named like this path | Paths ending with the keyword word | Packages that contain files or directories whose names contain the keyword Default: $SURFRAW_debcontents_search Environment: SURFRAW_debcontents_search -arch= Specialized search on architecture i386 | Intel x86 (all) powerpc | PowerPC (all) amd64 | AMD64 (all) m68k | Motorola 680x0 (debian, archive.debian) alpha | Alpha (debian, archive.debian) sparc | SPARC (debian, archive.debian) arm | ARM (debian, archive.debian) hppa | HP PA/RISC (debian, archive.debian) ia64 | Intel IA-64 (debian, archive.debian) mips | MIPS (debian, archive.debian) mipsel | MIPS (DEC) (debian, archive.debian) s390 | IBM S/390 (debian, archive.debian) hurd-i386 | Hurd (i386) (debian) kfreebsd-amd64 | kFreeBSD (amd64) (debian) kfreebsd-i386 kFreeBSD (i386) (debian) Default: $SURFRAW_debcontents_arch Environment: SURFRAW_debcontents_arch -distro= Specific distribution Debian: stable | Stable testing | Testing unstable | Unstable oldstable | Old Stable Archived Debian (-a): bo | 1.3.1 hamm | 2.0 slink | 2.1 potato | 2.2 woody | 3.0 sarge | 3.1 etch | 4.0 Ubuntu (-u): dapper | Dapper dapper-updates | Dapper Updates dapper-backports | Dapper Backports hardy | Hardy hardy-updates | Hardy Updates hardy-backports | Hardy Backports intrepid | Intrepid intrepid-updates | Intrepid Updates intrepid-backports| Intrepid Backports jaunty | Jaunty jaunty-updates | Jaunty Updates jaunty-backports | Jaunty Backports karmic | Karmic karmic-updates | Karmic Updates karmic-backports | Karmic Backports lucid | Lucid lucid-updates | Lucid Updates lucid-backports | Lucid Backports maverick | Maverick maverick-updates | Maverick Updates maverick-backports| Maverick Backports natty | Natty natty-updates | Natty Updates natty-backports | Natty Backports Default: $SURFRAW_debcontents_distro Environment: SURFRAW_debcontents_distro EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -arch=*) setopt SURFRAW_debcontents_arch $optarg ;; -distro=*) setopt SURFRAW_debcontents_distro $optarg ;; -search=*) setopt SURFRAW_debcontents_search $optarg ;; -u*) setoptyn SURFRAW_debcontents_ubuntu yes ;; -a*) setoptyn SURFRAW_debcontents_archive yes ;; -ca*) setoptyn SURFRAW_debcontents_usecase yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if ifyes SURFRAW_debcontents_ubuntu then searchpage="http://packages.ubuntu.com/#search_contents" searchurl="http://packages.ubuntu.com/search" elif ifyes SURFRAW_debcontents_archive then - searchpage="http://archive.debian.net/#search_contents" - searchurl="http://archive.debian.net/search" + searchpage="https://archive.debian.net/#search_contents" + searchurl="https://archive.debian.net/search" else - searchpage="http://packages.debian.org/#search_contents" - searchurl="http://packages.debian.org/search" + searchpage="https://packages.debian.org/#search_contents" + searchurl="https://packages.debian.org/search" fi if test -z "$w3_args"; then w3_browse_url "$searchpage" else escaped_args=`w3_url_of_arg $w3_args` if ifyes SURFRAW_debcontents_ubuntu then if [ "$SURFRAW_debcontents_distro" = "stable" ] then SURFRAW_debcontents_distro=raring fi fi url="$searchurl?keywords=${escaped_args}&searchon=contents" url="$url&arch=${SURFRAW_debcontents_arch}" url="$url&suite=${SURFRAW_debcontents_distro}" case "$SURFRAW_debcontents_search" in p*) if ifyes SURFRAW_debcontents_ubuntu || ifyes SURFRAW_debcontents_archive then searchmode="" else searchmode=path fi;; f*) searchmode=exactfilename ;; w*) searchmode=filename ;; *) err "Unknown search type" ;; esac url="${url}&mode=${searchmode}" w3_browse_url "$url" fi diff --git a/elvi/deblists b/elvi/deblists index 4a07cab..12a0243 100755 --- a/elvi/deblists +++ b/elvi/deblists @@ -1,104 +1,104 @@ #!/bin/sh # elvis: deblists -- Search debian mailing lists (lists.debian.org/search.html) # [email protected] 2003919 . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_deblists_matchany no defyn SURFRAW_deblists_searchmsgid no def SURFRAW_deblists_msgidsearchtype direct def SURFRAW_deblists_sort relevance def SURFRAW_deblists_results $SURFRAW_results } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search patterns]... Description: Surfraw search debian mailing lists (lists.debian.org/search.html) Local options: -results=NUM Number of search results returned Default: $SURFRAW_deblists_results Environment: SURFRAW_deblists_results -m|-msgid Search by message-id, jump to result -mv Search by message-id and show matches -ml Search by message-id and show links -any Match any word in search rather than all words -sort=relevance | How to sort the results date | revdate Default: $SURFRAW_deblists_sort Environment: SURFRAW_deblists_sort EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -result*=*) setopt SURFRAW_deblists_results $optarg ;; -mv) setoptyn SURFRAW_deblists_searchmsgid yes ; setopt SURFRAW_deblists_msgidsearchtype view ;; -ml) setoptyn SURFRAW_deblists_searchmsgid yes ; setopt SURFRAW_deblists_msgidsearchtype links ;; -m|-msg*) setoptyn SURFRAW_deblists_searchmsgid yes ;; -any) setoptyn SURFRAW_deblists_matchany yes ;; -sort*=*) setopt SURFRAW_deblists_sort $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then if ifyes SURFRAW_deblists_searchmsgid then - w3_browse_url "http://lists.debian.org/msgid-search" + w3_browse_url "https://lists.debian.org/msgid-search" else - w3_browse_url "http://lists.debian.org/search.html" + w3_browse_url "https://lists.debian.org/search.html" fi elif ifyes SURFRAW_deblists_searchmsgid then if [ "$SURFRAW_deblists_msgidsearchtype" = links ] then searchtype="&links=Query" elif [ "$SURFRAW_deblists_msgidsearchtype" = view ] then searchtype="" else searchtype="&firsthit=I%27m+feeling+lucky" fi escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://lists.debian.org/msgid-search/?m=${escaped_args}${searchtype}" + w3_browse_url "https://lists.debian.org/msgid-search/?m=${escaped_args}${searchtype}" else escaped_args=`w3_url_of_arg $w3_args` - url="http://lists.debian.org/cgi-bin/search?P=${escaped_args}" + url="https://lists.debian.org/cgi-bin/search?P=${escaped_args}" if ifyes SURFRAW_deblists_matchany then url="$url&DEFAULTOP=or" else url="$url&DEFAULTOP=and" fi case "$SURFRAW_deblists_sort" in rel*) SURFRAW_deblists_sort="relevance" ;; rev*) SURFRAW_deblists_sort="revdate" ;; d*) SURFRAW_deblists_sort="date" ;; *) err "Unknown sort method: $SURFRAW_deblists_sort" esac url="$url&sort=${SURFRAW_deblists_sort}" if [ "$SURFRAW_deblists_results" = "" ] then SURFRAW_deblists_results=10 fi url="$url&HITSPERPAGE=${SURFRAW_deblists_results}" w3_browse_url "$url" fi diff --git a/elvi/debpackages b/elvi/debpackages index 85d8ba6..e08e84f 100755 --- a/elvi/debpackages +++ b/elvi/debpackages @@ -1,148 +1,148 @@ #!/bin/sh # $Id$ # elvis: debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_debian_release any def SURFRAW_debian_distro any def SURFRAW_debian_search pkg defyn SURFRAW_debian_ubuntu no defyn SURFRAW_debian_subwords yes defyn SURFRAW_debian_archive no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) Local options: -a Search archived debian distributions -u Search ubuntu packages instead of debian -release= Specialized search on release Debian: any | all releases main | main release contrib | contrib non-free | packages not meeting DFSG Ubuntu (-u): any | all releases main | restricted | universe | multiverse | Default: $SURFRAW_debian_release Environment: SURFRAW_debian_release -distro= Specific distribution Debian: any | All distributions stable | Stable testing | Testing unstable | Unstable oldstable | Old Stable experimental | Experimental Archived Debian (-a): bo | 1.3.1 hamm | 2.0 slink | 2.1 potato | 2.2 woody | 3.0 sarge | 3.1 etch | 4.0 Ubuntu (-u): any | All distributions dapper | dapper-updates | dapper-backports | hardy | hardy-updates | hardy-backports | intrepid | intrepid-updates | intrepid-backports| jaunty | jaunty-updates | jaunty-backports | karmic | karmic-updates | karmic-backports | lucid | lucid-updates | lucid-backports | maverick | maverick-updates | maverick-backports| natty | natty-updates | natty-backports Default: $SURFRAW_debian_distro Environment: SURFRAW_debian_distro -search= Field to search pkg | Package names only desc | Descriptions src | Source package names -nosub Don't allow subword matches (exact matches only) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -release=*) setopt SURFRAW_debian_release $optarg ;; -distro=*) setopt SURFRAW_debian_distro $optarg ;; -search=*) setopt SURFRAW_debian_search $optarg ;; -a*) setoptyn SURFRAW_debian_archive yes ;; -u*) setoptyn SURFRAW_debian_ubuntu yes ;; -nos*) setoptyn SURFRAW_debian_subwords no ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if ifyes SURFRAW_debian_ubuntu then searchpage="http://packages.ubuntu.com/" searchurl="http://packages.ubuntu.com/search" elif ifyes SURFRAW_debian_archive then searchpage="http://archive.debian.net/" searchurl="http://archive.debian.net/search" else - searchpage="http://packages.debian.org/#search_packages" - searchurl="http://packages.debian.org/search" + searchpage="https://packages.debian.org/#search_packages" + searchurl="https://packages.debian.org/search" fi if test -z "$w3_args"; then w3_browse_url "$searchpage" else escaped_args=`w3_url_of_arg $w3_args` if [ "${SURFRAW_debian_distro}" = "any" ]; then SURFRAW_debian_distro="all" fi if [ "${SURFRAW_debian_release}" = "any" ]; then SURFRAW_debian_release="all" fi url="$searchurl?keywords=${escaped_args}&suite=${SURFRAW_debian_distro}&section=${SURFRAW_debian_release}" case "$SURFRAW_debian_search" in pkg*) url="$url&searchon=names" ;; src*) url="$url&searchon=sourcenames" ;; desc*) url="$url&searchon=all" ;; *) err "Unknown search type" ;; esac if ifno SURFRAW_debian_subwords then url="$url&exact=1" fi w3_browse_url "$url" fi diff --git a/elvi/debpts b/elvi/debpts index 56bc57a..5321758 100755 --- a/elvi/debpts +++ b/elvi/debpts @@ -1,43 +1,43 @@ #!/bin/sh # $Id$ # elvis: debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) # [email protected] 20040729 . surfraw || exit 1 w3_config_hook () { def SURFRAW_debpts_viewdocs 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Debian Package Tracking System (packages.qa.debian.org) Local options: -doc View PTS documentation EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -d*) setopt SURFRAW_debpts_viewdocs 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ $SURFRAW_debpts_viewdocs -eq 1 ]; then - w3_browse_url "http://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system" + w3_browse_url "https://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system" elif test -z "$w3_args"; then - w3_browse_url "http://packages.qa.debian.org/common/index.html" + w3_browse_url "https://packages.qa.debian.org/common/index.html" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://packages.qa.debian.org/common/index.html?src=${escaped_args}" + w3_browse_url "https://packages.qa.debian.org/common/index.html?src=${escaped_args}" fi diff --git a/elvi/debsec b/elvi/debsec index c48c976..2489d61 100755 --- a/elvi/debsec +++ b/elvi/debsec @@ -1,23 +1,23 @@ #!/bin/sh # elvis: debsec -- Search the Debian Security Tracker for CVE ids or package names # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: Search the Debian Security Tracker for CVE ids or package names EOF w3_global_usage } w3_config w3_parse_args "$@" if test -z "$w3_args"; then - w3_browse_url "http://security-tracker.debian.org/tracker" + w3_browse_url "https://security-tracker.debian.org/tracker" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://security-tracker.debian.org/tracker/${escaped_args}" + w3_browse_url "https://security-tracker.debian.org/tracker/${escaped_args}" fi diff --git a/elvi/debwiki b/elvi/debwiki index c3841ef..10778ef 100755 --- a/elvi/debwiki +++ b/elvi/debwiki @@ -1,71 +1,71 @@ #!/bin/sh # $Id$ # elvis: debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) # by Ian Beckwith <[email protected]> . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_debwiki_title 0 defyn SURFRAW_debwiki_context 1 defyn SURFRAW_debwiki_case 0 defyn SURFRAW_debwiki_direct 0 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Debian Wiki (wiki.debian.org) Local options: -c Make search case-sensitive. -n Don't show context of search result. -t Limit search to title. -d Go direct to page (or create it). EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -c) setoptyn SURFRAW_debwiki_case 1 ;; -n) setoptyn SURFRAW_debwiki_context 0 ;; -d) setoptyn SURFRAW_debwiki_direct 1 ;; -t) setoptyn SURFRAW_debwiki_title 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments -url="http://wiki.debian.org" +url="https://wiki.debian.org" if test -z "$w3_args" then w3_browse_url "$url" else escaped_args=`w3_url_of_arg $w3_args` url="${url}/FindPage?" if ifyes SURFRAW_debwiki_direct then url="${url}goto=${escaped_args}&submit=Go+To+Page" elif ifyes SURFRAW_debwiki_title then url="${url}action=fullsearch&titlesearch=1&value=${escaped_args}&submit=Search+Titles" else url="${url}action=fullsearch&titlesearch=0&value=${escaped_args}&submit=Search+Text" if ifyes SURFRAW_debwiki_context then url="${url}&context=160" fi if ifyes SURFRAW_debwiki_case then url="${url}&case=1" fi fi w3_browse_url "$url" fi diff --git a/elvi/deja b/elvi/deja index 262650f..a83f95d 100755 --- a/elvi/deja +++ b/elvi/deja @@ -1,48 +1,48 @@ #!/bin/sh # $Id$ # elvis: deja -- Search usenet using Google Groups (groups.google.com) . surfraw || exit 1 w3_config_hook () { def SURFRAW_deja_results $SURFRAW_results def SURFRAW_deja_style "normal" } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search usenet using Google Groups (groups.google.com) Local options: -results=NUM Number of search results returned Default: $SURFRAW_deja_results Environment: SURFRAW_deja_results -m Search for Message-ID EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -results=*) setopt SURFRAW_deja_results $optarg ;; -m*) setopt SURFRAW_deja_style "message-id" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://groups.google.com/" + w3_browse_url "https://groups.google.com/" else escaped_args=`w3_url_of_arg $w3_args` if test "${SURFRAW_deja_style}" = "normal"; then - w3_browse_url "http://groups.google.com/groups?q=${escaped_args}&num=${SURFRAW_deja_results}" + w3_browse_url "https://groups.google.com/groups?q=${escaped_args}&num=${SURFRAW_deja_results}" else - w3_browse_url "http://groups.google.com/groups?as_umsgid=${escaped_args}&num=${SURFRAW_deja_results}" + w3_browse_url "https://groups.google.com/groups?as_umsgid=${escaped_args}&num=${SURFRAW_deja_results}" fi fi diff --git a/elvi/deli b/elvi/deli index d27cca0..96ffe8f 100755 --- a/elvi/deli +++ b/elvi/deli @@ -1,26 +1,26 @@ #!/bin/sh # elvis: deli -- Search Delicious bookmarks # Author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] -Description: Search Delicious bookmarks (www.delicious.com) +Description: Search Delicious bookmarks (del.icio.us) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains list of arguments # standard topic seach if [ -z "$w3_args" ]; then - w3_browse_url "http://www.delicious.com/discover" + w3_browse_url "https://www.del.icio.us/" else escaped_args=$(w3_url_of_arg $w3_args) - w3_browse_url "http://www.delicious.com/search?p=${escaped_args}" + w3_browse_url "https://del.icio.us/search?p=${escaped_args}" fi diff --git a/elvi/discogs b/elvi/discogs index 6ddbfc3..cef65be 100755 --- a/elvi/discogs +++ b/elvi/discogs @@ -1,53 +1,53 @@ #!/bin/sh # elvis: discogs -- Search the Discogs database of music information (www.discogs.com) # Patroklos Argyroudis, argp at domain cs.tcd.ie, 20060823 . surfraw || exit 1 w3_config_hook() { def SURFRAW_discogs_category all } w3_usage_hook() { cat << EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search the Discogs database of music information (www.discogs.com) Local options: -category= Category to search all | artists | labels | releases | catno Default: $SURFRAW_discogs_category Environment: SURFRAW_discogs_category EOF w3_global_usage } w3_parse_option_hook() { opt="$1" optarg="$2" case "$opt" in -category=*) setopt SURFRAW_discogs_category $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.discogs.com/" + w3_browse_url "https://www.discogs.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.discogs.com/search?type=${SURFRAW_discogs_category}&q=${escaped_args}&btn=Search" + w3_browse_url "https://www.discogs.com/search?type=${SURFRAW_discogs_category}&q=${escaped_args}&btn=Search" fi # EOF diff --git a/elvi/dmoz b/elvi/dmoz deleted file mode 100755 index 9ad0d43..0000000 --- a/elvi/dmoz +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -# $Id$ -# elvis: dmoz -- Search the Open Directory Project web directory (dmoz.org) -# [email protected] 20040910 -. surfraw || exit 1 - -w3_config_hook () { -def SURFRAW_dmoz_category "" -def SURFRAW_dmoz_searchtype "b" -defyn SURFRAW_dmoz_kids 0 -defyn SURFRAW_dmoz_teens 0 -defyn SURFRAW_dmoz_mteens 0 -} - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [URL] -Description: - Search the Open Directory Project web directory (dmoz.org) -Local options: - -cat=CATEGORY Search category - Default: all - Values: Arts, Business, Computers, Games, - Health, Home, Kids_and_Teens, News, - Recreation, Reference, Regional, - Science, Shopping, Society, Sports, - World, Adult - Environment: SURFRAW_dmoz_category - -type=SEARCHTYPE Search type - Default: b - Values: c - Categories Only - s - Sites only - b - Both - Environment: SURFRAW_dmoz_searchtype - -kids Sites for kids. - Environment: SURFRAW_dmoz_kids - -teens Sites for teens. - Environment: SURFRAW_dmoz_teens - -mteens Sites for mature teens. - Environment: SURFRAW_dmoz_mteens -EOF - w3_global_usage -} - -w3_parse_option_hook () { - opt="$1" - optarg="$2" - case "$opt" in - -cat*=*) setopt SURFRAW_dmoz_category "$optarg" ;; - -ty*=*) setopt SURFRAW_dmoz_searchtype "$optarg" ;; - -ki*) setoptyn SURFRAW_dmoz_kids 1 ;; - -te*) setoptyn SURFRAW_dmoz_teens 1 ;; - -mt*) setoptyn SURFRAW_dmoz_mteens 1 ;; - *) return 1 ;; - esac - return 0 -} - -w3_config -w3_parse_args "$@" -# w3_args now contains a list of arguments -if test -z "$w3_args"; then - w3_browse_url "http://dmoz.org/" -else - escaped_args=`w3_url_of_arg $w3_args` - url="http://search.dmoz.org/cgi-bin/search?search=${escaped_args}&all=no&cat=${SURFRAW_dmoz_category}&t=${SURFRAW_dmoz_searchtype}" - if [ $SURFRAW_dmoz_kids -eq 1 ] - then - url="${url}&Kids=1" - fi - if [ $SURFRAW_dmoz_teens -eq 1 ] - then - url="${url}&Teens=1" - fi - if [ $SURFRAW_dmoz_mteens -eq 1 ] - then - url="${url}&Mteens=1" - fi - - w3_browse_url "${url}" -fi diff --git a/elvi/ebay b/elvi/ebay index 75ed72d..75dcab1 100755 --- a/elvi/ebay +++ b/elvi/ebay @@ -1,122 +1,122 @@ #!/bin/sh # elvis: ebay -- Search the Ebay auction site # Author: Moritz Muehlenhoff <[email protected]> . surfraw || exit 1 w3_config_hook () { def SURFRAW_ebay_country "$SURFRAW_lang" def SURFRAW_ebay_results 50 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search the Ebay auction site Local options: -country= | -c= com | Main eBay site (default) ar | Argentina at | Austria au | Australia nl_BE | Belgium (Flemish) fr_BE | Belgium (French) br | Brazil ca | Canada ch | Switzerland cn | China de | Germany es | Spain fr | France hk | Hong Kong ie | Ireland in | India kr | Korea my | Malaysia mx | Mexico nl | Netherlands nz | New Zealand ph | Philippines pl | Poland sg | Singapore se | Sweden tw | Taiwan uk UK Environment: SURFRAW_ebay_country, SURFRAW_lang -results= | -r Amount of results per page Default: 50 Environment: SURFRAW_ebay_results Examples: $w3_argv0 -c=de sauerkraut EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -country=*) setopt SURFRAW_ebay_country $optarg ;; -c=*) setopt SURFRAW_ebay_country $optarg ;; -results=*) setopt SURFRAW_ebay_results $optarg ;; -r=*) setopt SURFRAW_ebay_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" case "$SURFRAW_ebay_country" in com|ar|at|be|br|ca|ch|\ de|es|fr|fr_BE|\ nl_BE|ie|in|kr|\ mx|nl|ph|pl) TLD="${SURFRAW_ebay_country}" ;; uk|nz) TLD="co.${SURFRAW_ebay_country}" ;; au|hk|sg|my) TLD="com.${SURFRAW_ebay_country}" ;; cn|zh|zt) TLD="com.cn" ;; # tw uses hk for searches tw) TLD="com.hk" ;; *) TLD="com" ;; esac if null "$w3_args"; then case "$SURFRAW_ebay_country" in br) url="http://www.mercadolivre.com.${TLD}" ;; ar|mx) url="http://www.mercadolibre.com.${TLD}" ;; kr) url="http://www.auction.co.kr" ;; fr_BE) url="http://www.befr.ebay.be" ;; nl_BE) url="http://www.benl.ebay.be" ;; se|sv) url="http://www.tradera.com" ;; tw) url="http://twexport.ebay.com" ;; - *) url="http://www.ebay.${TLD}" ;; + *) url="https://www.ebay.${TLD}" ;; esac w3_browse_url "$url" else if [ "$SURFRAW_ebay_country" = "nz" ] ; then # nz uses ebay.com, presumably using referrer to tell it is .nz # we can't affect referrer without getting browser-specific, so # just use ebay.com TLD=com fi escaped_args=`w3_url_of_arg $w3_args` - host="http://search.ebay.${TLD}" + host="http://ebay.${TLD}" pathstart="search/search.dll?MfcISAPICommand=GetResult&krd=1&ht=1&shortcut=4&SoftProperty=MetaEndSort&cgiurl=http%3A%2F%2Fcgi" pathend="%2Fws%2F&maxRecordsPerPage=$SURFRAW_ebay_results&st=2&ebaytag1code=77&query=${escaped_args}" case "$SURFRAW_ebay_country" in cn|zh|zt) url="http://search.eachnet.com/search/basicsearch.do?satitle=${escaped_args}&sacat=0" ;; br) url="http://www.mercadolivre.com.${TLD}/jm/search?as_pr_categ_id=&as_word=${escaped_args}" ;; ar|mx) url="http://www.mercadolibre.com.${TLD}/jm/search?as_pr_categ_id=&as_word=${escaped_args}" ;; kr) url="http://search.auction.co.kr/search/search.aspx?keyword=${escaped_args}&itemno=&seller=&dom=auction&isSuggestion=No&optSection=%C5%EB%C7%D5%B0%CB%BB%F6&txtKeyword=${escaped_args}&x=0&y=0" ;; se|sv) url="http://www.tradera.com/search/search_firstpage.aspx?search=${escaped_args}&search_category=-1" ;; nl_BE) url="http://search.benl.ebay.be/${pathstart}.benl.ebay.be${pathend}" ;; be|fr_BE) url="http://search.befr.ebay.be/${pathstart}.befr.ebay.be${pathend}" ;; *) url="${host}/${pathstart}.ebay.${TLD}${pathend}" ;; esac w3_browse_url "${url}" fi diff --git a/elvi/f5 b/elvi/f5 index c6efbd8..65d0cb6 100755 --- a/elvi/f5 +++ b/elvi/f5 @@ -1,56 +1,56 @@ #!/bin/sh # $Id$ # elvis: f5 -- Search F5 related information (www.f5.com) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_f5_dc no } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search F5 related information Local options: -dc[=(yes|no)] Search F5 Devcentral Default: $SURFRAW_f5_dc Environment: SURFRAW_f5_dc Examples: $w3_argv0 Teleport to the F5 Knowledgebase $w3_argv0 -dc Teleport to the F5 Devcentral site EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -dc) setoptyn SURFRAW_f5_dc yes ;; -dc=*) setoptyn SURFRAW_f5_dc $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments test -z "$w3_args" || escaped_args=`w3_url_of_arg $w3_args` if ok SURFRAW_f5_dc; then if test -z "$escaped_args"; then w3_browse_url "https://devcentral.f5.com" else w3_browse_url "https://devcentral.f5.com/Default.aspx?tabid=37&cx=015798286719081439686:g38hs-tdy64&cof=FORID:11i&q=${escaped_args}" fi exit $? fi if test -z "$escaped_args"; then - w3_browse_url "http://www.f5.com" + w3_browse_url "https://www.f5.com" else - w3_browse_url "http://www.f5.com/search?q=${escaped_args}" + w3_browse_url "https://www.f5.com/search?q=${escaped_args}" fi exit $? diff --git a/elvi/foldoc b/elvi/foldoc index aed6b37..1813e01 100755 --- a/elvi/foldoc +++ b/elvi/foldoc @@ -1,27 +1,27 @@ #!/bin/sh # jbr20050112 # elvis: foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [search words]... Description: The Free On-Line Dictionary Of Computing (foldoc.org) Example: foldoc pcmcia "Personal Computer Memory Card International Association(*). (Or People Can't Memorise Computer Industry Acronyms)." EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.foldoc.org/" + w3_browse_url "https://foldoc.org/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://foldoc.org/${escaped_args}" + w3_browse_url "https://foldoc.org/${escaped_args}" fi diff --git a/elvi/freebsd b/elvi/freebsd index f0ca558..4833917 100755 --- a/elvi/freebsd +++ b/elvi/freebsd @@ -1,200 +1,200 @@ #!/bin/sh # $Id$ # elvis: freebsd -- Search FreeBSD related information (www.freebsd.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_freebsd_mail no defyn SURFRAW_freebsd_pr no defyn SURFRAW_freebsd_cvs no defyn SURFRAW_freebsd_mid no defyn SURFRAW_freebsd_gg no defyn SURFRAW_freebsd_ps no defyn SURFRAW_freebsd_prs no defyn SURFRAW_freebsd_elogs no defyn SURFRAW_freebsd_portsearch no def SURFRAW_freebsd_portsearchtype all def SURFRAW_freebsd_portsearchsec all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string | PR-number] Description: Surfraw search FreeBSD related information Local options: -mail[=(yes|no)] Search FreeBSD mailinglists Default: $SURFRAW_freebsd_mail Environment: SURFRAW_freebsd_mail -gg[=(yes|no)] Search FreeBSD mailinglists at Google Groups Default: $SURFRAW_freebsd_mail Environment: SURFRAW_freebsd_mail -pr[=(yes|no)] Query Problem Reports Default: $SURFRAW_freebsd_pr Environment: SURFRAW_freebsd_pr -cvs[=(yes|no)] Query cvsweb Default: $SURFRAW_freebsd_cvs Environment: SURFRAW_freebsd_cvs -mid[=(yes|no)] Query mailing lists by Message-ID Default: $SURFRAW_freebsd_mid Environment: SURFRAW_freebsd_mid -ps[=(yes|no)] Teleport to the Port Survey Page Default: $SURFRAW_freebsd_ps Environment: SURFRAW_freebsd_ps -psearch[=TYPE] Search of type TYPE in ports. all | All (default) name | Package Name text | Description pkgdescr | Long Description maintainer | Maintainer requires | Requires Default: $SURFRAW_freebsd_portsearchtype Environment: SURFRAW_freebsd_portsearchtype -psection[=SEC] Section of ports to search in. all, accessibility, afterstep, arabic, archivers, astro, audio, benchmarks, biology, cad, chinese, comms, converters, databases, deskutils, devel, dns, docs, editors, elisp, emulators, finance, french, ftp, games, geography, german, gnome, gnustep, graphics, hamradio, haskell, hebrew, hungarian, ipv6, irc, japanese, java, kde, kld, korean, lang, linux, lisp, mail, math, mbone, misc, multimedia, net, net-im, net-mgmt, net-p2p, news, palm, parallel, pear, perl5, plan9, polish, ports-mgmt, portuguese, print, python, ruby, rubygems, russian, scheme, science, security, shells, spanish, sysutils, tcl, textproc, tk, ukrainian, vietnamese, windowmaker, www, x11, x11-clocks, x11-drivers, x11-fm, x11-fonts, x11-servers, x11-themes, x11-toolkits, x11-wm, xfce, zope Default: $SURFRAW_freebsd_portsearchsec Environment: SURFRAW_freebsd_portsearchsec -prs[=(yes|no)] Teleport to the Problem Report Survey Page Default: $SURFRAW_freebsd_prs Environment: SURFRAW_freebsd_prs -elogs[=(yes|no)] Teleport to the Build Error Logs Page Default: $SURFRAW_freebsd_elogs Environment: SURFRAW_freebsd_elogs Examples: $w3_argv0 Teleport to the FreeBSD website $w3_argv0 mycroft Search FreeBSD website for odeur de mycroft $w3_argv0 -mail Teleport to the mail-index Query form $w3_argv0 -mail proff Search mailing-list archives for odeur de proff $w3_argv0 -gg Teleport to FreeBSD mailinglists at Google $w3_argv0 -gg proff Search Google archives for odeur de proff $w3_argv0 -pr Query Problem Report form $w3_argv0 -pr 666 Display PR 666 $w3_argv0 -cvs Query cvsweb $w3_argv0 -cvs ports/ Display cvsweb tree for ports/ $w3_argv0 -mid Query mailing lists by Message-ID $w3_argv0 -mid <x> Display message with ID <x> $w3_argv0 -ps Teleport to the Port Survey page $w3_argv0 -prs Teleport to the Port Report Survey page $w3_argv0 -psearch surfraw Search ports for surfraw $w3_argv0 -psearch=text perl Search port descriptions for perl EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -mail) setoptyn SURFRAW_freebsd_mail yes ;; -mail=*) setoptyn SURFRAW_freebsd_mail $optarg ;; -gg) setoptyn SURFRAW_freebsd_gg yes ;; -gg=*) setoptyn SURFRAW_freebsd_gg $optarg ;; -pr) setoptyn SURFRAW_freebsd_pr yes ;; -pr=*) setoptyn SURFRAW_freebsd_pr $optarg ;; -cvs) setoptyn SURFRAW_freebsd_cvs yes ;; -cvs=*) setoptyn SURFRAW_freebsd_cvs $optarg ;; -mid) setoptyn SURFRAW_freebsd_mid yes ;; -mid=*) setoptyn SURFRAW_freebsd_mid $optarg ;; -ps) setoptyn SURFRAW_freebsd_ps yes ;; -prs) setoptyn SURFRAW_freebsd_prs yes ;; -psea*=*) setoptyn SURFRAW_freebsd_portsearch yes; setopt SURFRAW_freebsd_portsearchtype $optarg ;; -psea*) setoptyn SURFRAW_freebsd_portsearch yes ;; -psec*=*) setoptyn SURFRAW_freebsd_portsearch yes; setopt SURFRAW_freebsd_portsec $optarg ;; -psec*) setoptyn SURFRAW_freebsd_portsearch yes ;; -elogs) setoptyn SURFRAW_freebsd_elogs yes ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments test -z "$w3_args" || escaped_args=`w3_url_of_arg $w3_args` if ok SURFRAW_freebsd_portsearch; then if test -z "$escaped_args"; then - w3_browse_url "http://www.freebsd.org/cgi/ports.cgi" + w3_browse_url "https://www.freebsd.org/cgi/ports.cgi" else - w3_browse_url "http://www.freebsd.org/cgi/ports.cgi?query=${escaped_args}&stype=${SURFRAW_freebsd_portsearchtype}&sektion=${SURFRAW_freebsd_portsec}" + w3_browse_url "https://www.freebsd.org/cgi/ports.cgi?query=${escaped_args}&stype=${SURFRAW_freebsd_portsearchtype}&sektion=${SURFRAW_freebsd_portsec}" fi exit $? fi if ok SURFRAW_freebsd_pr; then if test -z "$escaped_args"; then - w3_browse_url "http://www.freebsd.org/cgi/query-pr-summary.cgi?query" + w3_browse_url "https://www.freebsd.org/cgi/query-pr-summary.cgi?query" else - w3_browse_url "http://www.freebsd.org/cgi/query-pr.cgi?pr=${escaped_args}" + w3_browse_url "https://www.freebsd.org/cgi/query-pr.cgi?pr=${escaped_args}" fi exit $? fi if ok SURFRAW_freebsd_mail; then if test -z "$escaped_args"; then - w3_browse_url "http://docs.freebsd.org/mail/" + w3_browse_url "https://docs.freebsd.org/mail/" else - w3_browse_url "http://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&sort=score&index=recent&source=freebsd-questions" + w3_browse_url "https://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&sort=score&index=recent&source=freebsd-questions" fi exit $? fi if ok SURFRAW_freebsd_gg; then if test -z "$escaped_args"; then - w3_browse_url "http://groups.google.com/groups?hl=en&group=mailing.freebsd" + w3_browse_url "https://groups.google.com/groups?hl=en&group=mailing.freebsd" else - w3_browse_url "http://groups.google.com/groups?q=${escaped_args}&hl=en&meta=group%3Dmailing.freebsd.*" + w3_browse_url "https://groups.google.com/groups?q=${escaped_args}&hl=en&meta=group%3Dmailing.freebsd.*" fi exit $? fi if ok SURFRAW_freebsd_cvs; then if test -z "$escaped_args"; then - w3_browse_url "http://cvsweb.freebsd.org/" + w3_browse_url "https://cvsweb.freebsd.org/" else - w3_browse_url "http://cvsweb.freebsd.org/cgi/cvsweb.cgi?path=${escaped_args}" + w3_browse_url "https://cvsweb.freebsd.org/cgi/cvsweb.cgi?path=${escaped_args}" fi exit $? fi if ok SURFRAW_freebsd_mid; then if test -z "$escaped_args"; then - w3_browse_url "http://www.freebsd.org/search/search-mid.html" + w3_browse_url "https://www.freebsd.org/search/search-mid.html" else - w3_browse_url "http://www.freebsd.org/cgi/mid.cgi?id=${escaped_args}&db=mid" + w3_browse_url "https://www.freebsd.org/cgi/mid.cgi?id=${escaped_args}&db=mid" fi exit $? fi if ok SURFRAW_freebsd_ps; then - w3_browse_url "http://people.freebsd.org/~fenner/portsurvey/" + w3_browse_url "https://people.freebsd.org/~fenner/portsurvey/" exit $? fi if ok SURFRAW_freebsd_elogs; then - w3_browse_url "http://people.freebsd.org/~fenner/errorlogs/" + w3_browse_url "https://people.freebsd.org/~fenner/errorlogs/" exit $? fi if ok SURFRAW_freebsd_prs; then - w3_browse_url "http://people.freebsd.org/~fenner/ports-prs.html" + w3_browse_url "https://people.freebsd.org/~fenner/ports-prs.html" exit $? fi if test -z "$escaped_args"; then - w3_browse_url "http://www.freebsd.org/" + w3_browse_url "https://www.freebsd.org/" else - w3_browse_url "http://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&source=www" + w3_browse_url "https://www.freebsd.org/cgi/search.cgi?words=${escaped_args}&max=25&source=www" fi exit $? diff --git a/elvi/freshmeat b/elvi/freshmeat index 9c27c40..9302f99 100755 --- a/elvi/freshmeat +++ b/elvi/freshmeat @@ -1,23 +1,23 @@ #!/bin/sh # $Id$ # elvis: freshmeat -- Search Freshmeat (www.freshmeat.net) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Freshmeat (www.freshmeat.net) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.freshmeat.net/" + w3_browse_url "http://www.freecode.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://freshmeat.net/search?q=${escaped_args}" + w3_browse_url "http://www.freecode.com/search?q=${escaped_args}" fi diff --git a/elvi/fsfdir b/elvi/fsfdir index ef620be..7c6b99d 100755 --- a/elvi/fsfdir +++ b/elvi/fsfdir @@ -1,24 +1,24 @@ #!/bin/sh # $Id$ # elvis: fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the FSF/UNESCO Free Software Directory (directory.fsf.org) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://directory.fsf.org/" + w3_browse_url "https://directory.fsf.org/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://directory.fsf.org/search/?query=${escaped_args}" + w3_browse_url "https://directory.fsf.org/search/?query=${escaped_args}" fi
JNRowe/surfraw
6bcc1f4a904511082ade4d9d1280e660389cbfd0
Elvi cleanup (a-c).
diff --git a/elvi/alioth b/elvi/alioth index 680cd77..2a9f438 100755 --- a/elvi/alioth +++ b/elvi/alioth @@ -1,48 +1,48 @@ #!/bin/sh # $Id$ # elvis: alioth -- Search Alioth (alioth.debian.org) # [email protected] 20030910 # adapted from sourceforge elvi . surfraw || exit 1 w3_config_hook () { def SURFRAW_alioth_searchtype soft } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Alioth (alioth.debian.org) Local options: -type= soft | Software / Group skill | Skills people People Default: $SURFRAW_alioth_searchtype Environment: SURFRAW_alioth_searchtype EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -t*=*) setopt SURFRAW_alioth_searchtype $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://alioth.debian.org/" + w3_browse_url "https://alioth.debian.org/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://alioth.debian.org/search/?words=${escaped_args}&type_of_search=$SURFRAW_alioth_searchtype" + w3_browse_url "https://alioth.debian.org/search/?words=${escaped_args}&type_of_search=$SURFRAW_alioth_searchtype" fi diff --git a/elvi/amazon b/elvi/amazon index 0497ad7..be7ad96 100755 --- a/elvi/amazon +++ b/elvi/amazon @@ -1,244 +1,244 @@ #!/bin/sh # $Id$ # elvis: amazon -- Search the amazon.com bookstore . surfraw || exit 1 w3_config_hook () { def SURFRAW_amazon_country "$SURFRAW_lang" def SURFRAW_amazon_search all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search-string] Description: Search amazon Local options: -country=COUNTRY Two letter domain-style country code com | Main amazon.com site (default) ca | Canada cn | China de | Germany fr | France jp | Japan uk UK Environment: SURFRAW_amazon_country, SURFRAW_lang Default: $SURFRAW_amazon_country -search= Specialised search on topic all All Departments. amazon.com: apparel Apparel & Accessories automotive Automotive baby-products Baby beauty Beauty books Books wireless-aps Cell Phones & Service electronics Electronics misc Everything Else gourmet Gourmet Food grocery Grocery hpc Health & Personal Care garden Home & Garden tools Home Improvement industrial Industrial & Scientific jewelry Jewelry digital-text Kindle Store magazines Magazines dvd Movies & TV digital-music MP3 Downloads popular Music mi Musical Instruments office-products Office Products & Supplies shoes Shoes software Software sporting Sports & Outdoors toys-and-games Toys & Games vhs VHS videogames Video Games amazontv Video On Demand watches Watches uk: books Books electronics Electronics popular Music classical Classical Music digital-music MP3 Downloads dvd DVD vhs VHS software Software videogames Video Games software-videogames Software & Games diy DIY & Tools outdoor Garden & Outdoors kitchen Kitchen & Home drugstore Health & Beauty beauty Beauty toys Toys & Games sports Sports & Leisure jewelry-watches Jewellery & Watches clothing Clothing shoes Shoes & Accessories baby Baby fr: books Livres en français english-books Livres en anglais electronics High-tech popular Musique classical Musique classique dvd DVD & Vidéo blu-ray Blu-ray software Logiciels videogames Jeux vidéo toys Jeux et Jouets kitchen Cuisine & Maison jewelry-watches Montres & Bijoux de: books Bücher english-books Englische Bücher magazines Zeitschriften popular Musik classical Klassische Musik dvd DVD blu-ray Blu-ray electronics Elektronik & Foto computer Computer photo Kamera & Foto kitchen Küche & Haushalt diy Baumarkt automotive Auto & Motorrad outdoor Garten & Freizeit drugstore Drogerie & Bad beauty Parfümerie & Kosmetik software Software videogames Games toys Spielzeug sports Sport & Freizeit jewelry-watches Uhren & Schmuck baby Babyausstattung clothing Bekleidung shoes Schuhe & Handtaschen ca: books Books popular Music classical Classical Music dvd DVD vhs VHS electronics Electronics software Software videogames Video Games jp: books a書 english-books m酪 electronics 痩d&塔Jメラ kitchen zメ[ム&Lャb\`ャ popular 塔~ュ[<WbャN classical Nャ宴VbャN音y dvd DVD software PC潟\tャg videogames Qメ[ム toys おもちゃ&zャr[ sporting <X|メ[c&ャAEャghャA hpc wャ泣X&rャ[eャB[ beauty <RXャ food-beverage $Hi&譜料 watch 時v baby 激xrメ[&}ャ^jャeB apparel ャApャ激&æ³£t@ャbVャ梼G貨 cn: 1 图书 2 音乐 3 影视 5 手机 6 家电 7 化妆 8 厨具 9 家居 10 运动健康 11 玩具 12 钟表首饰 14 个人护理 15 软件 16 游戏/娱乐 17 礼品箱包 20 摄影摄像 21 Mp3/Mp4 22 视听设备 23 电脑配件 25 教育音像 Default: $SURFRAW_amazon_search Environment: SURFRAW_amazon_search Examples: $w3_argv0 -search=books -country=uk -q The Lotus and The Robot EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -search=*) setopt SURFRAW_amazon_search $optarg ;; -country=*) setopt SURFRAW_amazon_country $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments case "$SURFRAW_amazon_country" in uk) host=www.amazon.co.uk ;; de) host=www.amazon.de ;; fr) host=www.amazon.fr ;; jp) host=www.amazon.co.jp ;; ca) host=www.amazon.ca ;; cn|zh|zt) host=www.amazon.cn ;; *) host=www.amazon.com ;; esac if null "$w3_args"; then - w3_browse_url "http://${host}/" + w3_browse_url "https://${host}/" else escaped_args=`w3_url_of_arg $w3_args` if [ "$SURFRAW_amazon_search" = books ] ; then SURFRAW_amazon_search=stripbooks elif [ "$SURFRAW_amazon_search" = all ] ; then SURFRAW_amazon_search=aps fi case "$host" in www.amazon.cn) path="mn/searchApp" if [ "$SURFRAW_amazon_search" = "aps" ] ;then SURFRAW_amazon_search="" fi args="ix=sunray&pageletid=headsearch&searchType=${SURFRAW_amazon_search}&keywords=${escaped_args}&Go.x=0&Go.y=0&bestSaleNum=0" break;; www.amazon.co.jp) path="s/ref=nb_ss_gw" args="__mk_ja_JP=%83J%83%5E%83J%83i&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.co.uk) path="s/ref=nb_ss_w_h_" args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.fr) path="s/ref=nb_ss_w" args="__mk_fr_FR=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.de) path="s/ref=nb_ss_w" args="__mk_de_DE=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; www.amazon.ca) path="s/ref=nb_ss_gw" args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" break;; *) path="s/ref=nb_ss_gw" args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}" esac - w3_browse_url "http://${host}/${path}?${args}" + w3_browse_url "https://${host}/${path}?${args}" fi diff --git a/elvi/archpkg b/elvi/archpkg index 5358c51..0b73410 100755 --- a/elvi/archpkg +++ b/elvi/archpkg @@ -1,98 +1,98 @@ #!/bin/sh # elvis: archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) # Author: jason ryan • http://jasonwryan.com . surfraw || exit 1 w3_config_hook () { def SURFRAW_arch_ix "$SURFRAW_ix" def SURFRAW_arch_repo "$SURFRAW_repo" def SURFRAW_arch_date "$SURFRAW_date" def SURFRAW_arch_results 25 } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search string] Description: Surfraw search Arch Linux packages (www.archlinux.org) Local options: -arch=ARCHITECTURES | -a=ARCHITECTURES any | Any (default) i686 | i686 x86_64 | x86_64 -repo=REPOSITORIES | -r=REPOSITORIES comm | Community commtest | Community-Testing core | Core extra | Extra multi | Multilib multitest | Multilib-Testing test | Testing Default: All -date=UPDATED | -d=UPDATED (format: YYYY-MM-DD) -num=NUMBER | Number of results per page Default: $SURFRAW_arch_results EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -a*=*) setopt SURFRAW_arch_ix $optarg ;; -r*=*) setopt SURFRAW_arch_repo $optarg ;; -d*=*) setopt SURFRAW_arch_date $optarg ;; -n*=*) setopt SURFRAW_arch_results $optarg ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # selected repository case "$SURFRAW_arch_repo" in comm) repo="Community" ;; commtest) repo="Community-Testing" ;; core) repo="Core" ;; extra) repo="Extra" ;; multi) repo="Multilib" ;; multitest)repo="Multilib-Testing" ;; test) repo="Testing" ;; *) repo="" ;; esac # no arguments present if [ -z "$w3_args" ]; then - w3_browse_url "http://www.archlinux.org/packages/" + w3_browse_url "https://www.archlinux.org/packages/" else # if w3_args contains a list of arguments escaped_args=$(w3_url_of_arg $w3_args) -base="http://www.archlinux.org/packages/?sort=" +base="https://www.archlinux.org/packages/?sort=" # repository and architecture if [ -n "$SURFRAW_arch_repo" -a "$SURFRAW_arch_ix" ]; then w3_browse_url "${base}&arch=${SURFRAW_arch_ix}&repo=${repo}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" # check for repository elif [ -n "$SURFRAW_arch_repo" ]; then w3_browse_url "${base}&repo=${repo}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" # just architecture elif [ -n "$SURFRAW_arch_ix" ]; then w3_browse_url "${base}&arch=${SURFRAW_arch_ix}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" # none of the above... else w3_browse_url "${base}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}" fi fi diff --git a/elvi/arxiv b/elvi/arxiv index 44f5fa9..0fa54af 100755 --- a/elvi/arxiv +++ b/elvi/arxiv @@ -1,141 +1,141 @@ #!/bin/sh # # $Id$ # # elvis: arxiv -- Search arXiv E-Print Archive for articles # # 2008-June-03 - By John Gruenenfelder ([email protected]) # Rewrote 'xxx' script to allow searching arXiv site by various # means. # . surfraw || exit 1 w3_config_hook () { def SURFRAW_arxiv_scope all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search terms] Description: Surfraw the Los Alamos Science E-Print Archive (arXiv) Local options: -scope= Limit scope of arXiv search all | Search all fields title | Search article titles author | Search article authors abstract | Search article abstracts fulltext Search the full text of articles Default: $SURFRAW_arxiv_scope Environment: SURFRAW_arxiv_scope EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -scope=*) setopt SURFRAW_arxiv_scope $optarg ;; *) return 1 ;; esac return 0 } # Parse config w3_config # Parse search terms SURFRAW_escape_url_args=no w3_parse_args "$@" # Mangle search terms into something useable terms="" cnt=0 if [ ! -z "$w3_args" ]; then case $SURFRAW_arxiv_scope in all | title | abstract) if [ `w3_url_of_arg $w3_args | cut -c1` = \" ]; then terms="+EXACT+"`echo $w3_args | sed -e 's/ /_/g'` else for w in $w3_args ; do terms="+"`w3_url_of_arg $w`$terms cnt=$((cnt + 1)) if [ $cnt -gt 1 ]; then terms="+AND"$terms fi done fi terms=`echo $terms | sed -e 's/"//g'` ;; author) # Names without commas need to be reversed echo "$w3_args" | grep -q "," if [ $? -eq 0 ]; then # Name already in last, first format. terms=`echo "$w3_args" | sed -e "s/,/_/g" -e "s/ //g"` terms="+"`w3_url_of_arg $terms` else # Name in first last format. Need to reverse. first="" last="" for n in $w3_args ; do if [ -z $first ]; then first=$n elif [ -z $last ]; then last=$n fi done terms="" if [ -n "$last" ]; then terms="${last}_" fi terms="$terms$first" terms="+"`w3_url_of_arg $terms` fi ;; fulltext) terms=`w3_url_escape $w3_args` ;; *) return 1 ;; esac fi # Form URL if [ -z "$w3_args" ]; then - url="http://arXiv.org/" + url="https://arXiv.org/" else case $SURFRAW_arxiv_scope in all) - url="http://arXiv.org/find/all/1/all:"$terms"/0/1/0/all/0/1" + url="https://arXiv.org/find/all/1/all:"$terms"/0/1/0/all/0/1" ;; title) - url="http://arXiv.org/find/all/1/ti:"$terms"/0/1/0/all/0/1" + url="https://arXiv.org/find/all/1/ti:"$terms"/0/1/0/all/0/1" ;; abstract) - url="http://arXiv.org/find/all/1/abs:"$terms"/0/1/0/all/0/1" + url="https://arXiv.org/find/all/1/abs:"$terms"/0/1/0/all/0/1" ;; author) - url="http://arXiv.org/find/all/1/au:"$terms"/0/1/0/all/0/1" + url="https://arXiv.org/find/all/1/au:"$terms"/0/1/0/all/0/1" ;; fulltext) - url="http://search.arXiv.org:8081/?query="$terms"&in=" + url="https://search.arXiv.org:8081/?query="$terms"&in=" ;; *) return 1 ;; esac fi w3_browse_url $url diff --git a/elvi/bing b/elvi/bing index 206ee6c..cd2173a 100755 --- a/elvi/bing +++ b/elvi/bing @@ -1,28 +1,28 @@ #!/bin/sh # # AUTHOR: tczy, based on piratebay by J.R. Mauro # # DATE: Mon, 18 Jan 2010 13:37:00 +0100 # # DESC: Elvi to search the web using Microsoft's Bing # elvis: bing -- Search the web using Microsoft's Bing (www.bing.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the web using Microsoft's Bing (www.bing.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.bing.com/" + w3_browse_url "https://www.bing.com/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.bing.com/search?q=${escaped_args}&go=&form=QBLH&filt=all" + w3_browse_url "https://www.bing.com/search?q=${escaped_args}&go=&form=QBLH&filt=all" fi diff --git a/elvi/bugzilla b/elvi/bugzilla index b28cab8..7a4692b 100755 --- a/elvi/bugzilla +++ b/elvi/bugzilla @@ -1,88 +1,87 @@ #!/bin/sh # elvis: bugzilla -- Search for bugs on Bugzilla bugtrackers . surfraw || exit 1 w3_config_hook () { def SURFRAW_bugzilla_site kernel def SURFRAW_bugzilla_status open def SURFRAW_bugzilla_product all } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search for bugs on Bugzilla bugtrackers Local options: -site=URL Bugzilla site to search The site URL can be specified, or the following aliases can be used: kernel, mozilla, gnome, kde, apache, freedesktop, eclipse, redhat, mandriva, gentoo, novell Default: $SURFRAW_bugzilla_site Environment: SURFRAW_bugzilla_site - Examples: bugzilla -s=http://bugs.kde.org ipv6 + Examples: bugzilla -s=https://bugs.kde.org ipv6 bugzilla -s=kde ipv6 -status=open | Bug status closed | all Default: $SURFRAW_bugzilla_status Environment: SURFRAW_bugzilla_status -product=all | Product to search for bugs in. <product name> Default: $SURFRAW_bugzilla_product Environment: SURFRAW_bugzilla_product EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -st*=*) setopt SURFRAW_bugzilla_status "$optarg" ;; -s*=*) setopt SURFRAW_bugzilla_site "$optarg" ;; -p*=*) setopt SURFRAW_bugzilla_product "$(w3_url_of_arg "$optarg")" ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if [ "$SURFRAW_bugzilla_product" = all ] ; then setopt SURFRAW_bugzilla_product "" fi case "$SURFRAW_bugzilla_status" in open) setopt SURFRAW_bugzilla_status "__open__" ;; closed) setopt SURFRAW_bugzilla_status "__closed__" ;; all) setopt SURFRAW_bugzilla_status "__all__" ;; esac case "$SURFRAW_bugzilla_site" in kernel) setopt SURFRAW_bugzilla_site "https://bugzilla.kernel.org" ;; - mozilla) setopt SURFRAW_bugzilla_site "http://bugzilla.mozilla.org" ;; - gnome) setopt SURFRAW_bugzilla_site "http://bugzilla.gnome.org" ;; - kde) setopt SURFRAW_bugzilla_site "http://bugs.kde.org" ;; - apache) setopt SURFRAW_bugzilla_site "http://issues.apache.org/bugzilla" ;; - freedesktop) setopt SURFRAW_bugzilla_site "http://bugs.freedesktop.org" ;; + mozilla) setopt SURFRAW_bugzilla_site "https://bugzilla.mozilla.org" ;; + gnome) setopt SURFRAW_bugzilla_site "https://bugzilla.gnome.org" ;; + kde) setopt SURFRAW_bugzilla_site "https://bugs.kde.org" ;; + apache) setopt SURFRAW_bugzilla_site "https://issues.apache.org/bugzilla" ;; + freedesktop) setopt SURFRAW_bugzilla_site "https://bugs.freedesktop.org" ;; eclipse) setopt SURFRAW_bugzilla_site "https://bugs.eclipse.org/bugs" ;; - redhat) setopt SURFRAW_bugzilla_site "http://bugzilla.redhat.com/bugzilla" ;; - mandriva) setopt SURFRAW_bugzilla_site "http://qa.mandriva.com" ;; - gentoo) setopt SURFRAW_bugzilla_site "http://bugs.gentoo.org" ;; + redhat) setopt SURFRAW_bugzilla_site "https://bugzilla.redhat.com/" ;; + gentoo) setopt SURFRAW_bugzilla_site "https://bugs.gentoo.org" ;; novell) setopt SURFRAW_bugzilla_site "https://bugzilla.novell.com" ;; esac if test -z "$w3_args"; then w3_browse_url "${SURFRAW_bugzilla_site}/query.cgi?format=advanced" else escaped_args=`w3_url_of_arg $w3_args` # params="short_desc_type=allwordssubstr&short_desc=${escaped_args}&bug_status=${SURFRAW_bugzilla_status}" params="content=${escaped_args}&bug_status=${SURFRAW_bugzilla_status}" params="${params}&product=${SURFRAW_bugzilla_product}" w3_browse_url "${SURFRAW_bugzilla_site}/buglist.cgi?${params}" fi diff --git a/elvi/cablesearch b/elvi/cablesearch deleted file mode 100755 index 982beae..0000000 --- a/elvi/cablesearch +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# elvis: cablesearch -- search for leaked diplomatic communications -# [email protected] 20110105 -. surfraw || exit 1 - -w3_config_hook () { - # for when I figured out how to parse json in surfraw... - def SURFRAW_cablesearch_api "http://cablegatesearch.net/cable/api/search" - def SURFRAW_cablesearch "http://cablegatesearch.net/" -} - -w3_usage_hook () { - cat <<EOF -Usage: $w3_argv0 [options] [search words]... -Description: - Search leaked diplomatic cables. -Local options: - If you can read this, it means your hard drive has already been wiped and - the NSA alerted to your conniving schemes. -EOF - w3_global_usage -} - -w3_config -w3_parse_args "$@" -# w3_args now contains a list of arguments - -escaped_args=`w3_url_of_arg $w3_args` - -url="${SURFRAW_cablesearch}?q=${escaped_args}" -w3_browse_url $url diff --git a/elvi/cisco b/elvi/cisco index c33867e..024d9b1 100755 --- a/elvi/cisco +++ b/elvi/cisco @@ -1,25 +1,25 @@ #!/bin/sh # $Id$ # elvis: cisco -- Search Cisco documentation (www.cisco.com) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Cisco documentation (www.cisco.com) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://tools.cisco.com/" + w3_browse_url "https://tools.cisco.com/" else escaped_args=`w3_url_of_arg $w3_args` -# w3_browse_url "http://tools.cisco.com/search/JSP/search-results.get?strQueryText=${escaped_args}&Search+All+cisco.com=cisco.com" - w3_browse_url "http://tools.cisco.com/search/results/en/us/get?q=${escaped_args}&js=0" +# w3_browse_url "https://tools.cisco.com/search/JSP/search-results.get?strQueryText=${escaped_args}&Search+All+cisco.com=cisco.com" + w3_browse_url "https://tools.cisco.com/search/results/en/us/get?q=${escaped_args}&js=0" fi diff --git a/elvi/comlaw b/elvi/comlaw index ad77032..3a052f3 100755 --- a/elvi/comlaw +++ b/elvi/comlaw @@ -1,23 +1,23 @@ #!/bin/sh # $Id$ # elvis: comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) . surfraw || exit 1 w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search Australian Law using Comlaw (www.comlaw.gov.au) EOF w3_global_usage } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.comlaw.gov.au/" + w3_browse_url "http://www.legislation.gov.au/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.comlaw.gov.au/Search/${escaped_args}" + w3_browse_url "http://www.legislation.gov.au/Search/${escaped_args}" fi diff --git a/elvi/commandlinefu b/elvi/commandlinefu index d3de574..e981b2c 100755 --- a/elvi/commandlinefu +++ b/elvi/commandlinefu @@ -1,65 +1,65 @@ #!/bin/sh # $Id$ # elvis: commandlinefu -- search on www.commandlinefu.com # The API of the site is described at http://www.commandlinefu.com/site/api. . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_commandlinefu_votes 1 def SURFRAW_commandlinefu_format html } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Surfraw search www.commandlinefu.com Local options: -html get results as html -txt get results as plain text -json get results as json -rss get results as rss data Default: $SURFRAW_commandlinefu_format -v, -s, -votes, -sort sort results by votes -u, -n, -unsort, -nosort do not sort results Default: $SURFRAW_commandlinefu_votes EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -json) setopt SURFRAW_commandlinefu_format json ;; -html) setopt SURFRAW_commandlinefu_format html ;; -rss) setopt SURFRAW_commandlinefu_format rss ;; -txt) setopt SURFRAW_commandlinefu_format plaintext ;; -v|-votes|-s|-sort) setoptyn SURFRAW_commandlinefu_votes 1 ;; -u|-unsort|-n|-nosort) setoptyn SURFRAW_commandlinefu_votes 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments -url=http://www.commandlinefu.com/commands/matching +url=https://www.commandlinefu.com/commands/matching # The next part of the url is a normalized plaintext version of the search # query. It seems to be unused by the CGI but it needs to be present. So we # normalize to "x". url=$url/x # What is really used is the base64 encoded query. (echo -n is not portable) url=$url/"`printf %s "$w3_args" | base64`" # possibly add the sorting option if test $SURFRAW_commandlinefu_votes -eq 1; then url="$url/sort-by-votes" fi # add the output format option if test $SURFRAW_commandlinefu_format != html; then url="$url/$SURFRAW_commandlinefu_format" fi w3_browse_url "$url" diff --git a/elvi/ctan b/elvi/ctan index 52ef65c..72ed27b 100755 --- a/elvi/ctan +++ b/elvi/ctan @@ -1,70 +1,70 @@ #!/bin/sh # $Id$ # elvis: ctan -- Search the Comprehensive TeX Archive Network (ctan.org) . surfraw || exit 1 w3_config_hook () { defyn SURFRAW_ctan_topics 0 defyn SURFRAW_ctan_desc 0 defyn SURFRAW_ctan_authors 0 def SURFRAW_ctan_results $SURFRAW_results } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Search the Comprehensive TeX Archive Network (ctan.org) Local options: -desc Search descriptions (default) -topics Search by filename -authors Search package identifiers Options can be combined to search multiple types at once. EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -top*) setoptyn SURFRAW_ctan_topics 1 ;; -d*) setoptyn SURFRAW_ctan_desc 1 ;; -au*) setoptyn SURFRAW_ctan_authors 1 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.ctan.org/" + w3_browse_url "https://www.ctan.org/" else escaped_args=`w3_url_of_arg $w3_args` if ifno SURFRAW_ctan_topics && ifno SURFRAW_ctan_desc && ifno SURFRAW_ctan_authors then SURFRAW_ctan_desc=1 fi - url="http://www.ctan.org/search/?x=1&PORTAL=on" + url="https://www.ctan.org/search/?x=1&PORTAL=on" url="${url}&phrase=${escaped_args}&max=${SURFRAW_results}" if ifyes SURFRAW_ctan_topics then url="${url}&TOPICS=on" fi if ifyes SURFRAW_ctan_desc then url="${url}&PKG=on" fi if ifyes SURFRAW_ctan_authors then url="${url}&AUTHORS=on" fi w3_browse_url "$url" fi diff --git a/elvi/currency b/elvi/currency index 559d22f..4787780 100755 --- a/elvi/currency +++ b/elvi/currency @@ -1,382 +1,382 @@ #!/bin/sh # $Id$ # elvis: currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) . surfraw || exit 1 list_currency_symbols () { cat <<EOT Symbol Country and Currency AFA Afghanistan, Afghani ALL Albania, Lek DZD Algeria, Dinar USD America (United States), Dollar USD American Samoa, United States Dollar EUR Andorra, Euro AOA Angola, Kwanza XCD Anguilla, East Caribbean Dollar XCD Antigua and Barbuda, East Caribbean Dollar ARS Argentina, Peso AMD Armenia, Dram AWG Aruba, Guilder AUD Ashmore and Cartier Islands, Australia Dollar AUD Australia, Dollar EUR Austria, Euro ATS Austria, Schilling [obsolete] AZM Azerbaijan, Manat EUR Azores, Euro BSD Bahamas, Dollar BHD Bahrain, Dinar BBD Bajan (Barbados), Dollar EUR Balearic Islands, Euro BDT Bangladesh, Taka BBD Barbados, Dollar BYR Belarus, Ruble EUR Belgium, Euro BEF Belgium, Franc [obsolete] BZD Belize, Dollar XOF Benin, CFA Franc BCEAO BMD Bermuda, Dollar INR Bhutan, India Rupee BTN Bhutan, Ngultrum BOB Bolivia, Boliviano ANG Bonaire, Netherlands Antilles Guilder BAM Bosnia and Herzegovina, Convertible Marka BWP Botswana, Pula BRL Brazil, Real GBP Britain (United Kingdom), Pound GBP British Indian Ocean Territory, United Kingdom Pound USD British Indian Ocean Territory, United States Dollar USD British Virgin Islands, United States Dollar BND Brunei, Dollar SGD Brunei, Singapore Dollar BGN Bulgaria, Lev XOF Burkina Faso, CFA Franc BCEAO MMK Burma (Myanmar), Kyat BIF Burundi, Franc KHR Cambodia, Riel XAF Cameroon, CFA Franc BEAC CAD Canada, Dollar EUR Canary Islands, Euro CVE Cape Verde, Escudo KYD Cayman Islands, Dollar XAF Central African Republic, CFA Franc BEAC XAF CFA Communauté Financière Africaine BEAC Franc XOF CFA Communauté Financière Africaine BCEAO Franc XAF Chad, CFA Franc BEAC CLP Chile, Peso CNY China, Yuan Renminbi AUD Christmas Island, Australia Dollar AUD Cocos (Keeling Islands, Australia Dollar COP Colombia, Peso XAF Communauté Financière Africaine BEAC Franc XOF Communauté Financière Africaine BCEAO Franc KMF Comoros, Franc XPF Comptoirs Français du Pacifique Franc XAF Congo/Brazzaville, CFA Franc BEAC CDF Congo/Kinshasa, Franc NZD Cook Islands, New Zealand Dollar AUD Coral Sea Islands, Australia Dollar CRC Costa Rica, Colon XOF Côte d'Ivoire, CFA Franc BCEAO HRK Croatia, Kuna CUC Cuba, Convertible Peso CUP Cuba, Peso ANG Curaço, Netherlands Antilles Guilder CYP Cyprus, Pound CZK Czech Republic, Koruna DKK Denmark, Krone DJF Djibouti, Franc XCD Dominica, East Caribbean Dollar DOP Dominican Republic, Peso EUR Dutch (Netherlands), Euro NLG Dutch (Netherlands), Guilder [obsolete] XCD East Caribbean Dollar USD East Timor, United States Dollar USD Ecuador, United States Dollar EGP Egypt, Pound SVC El Salvador, Colon GBP England (United Kingdom), Pound XAF Equatorial Guinea, CFA Franc BEAC ERN Eritrea, Nakfa EEK Estonia, Kroon ETB Ethiopia, Birr EUR Euro EUR Europa Island, Euro FKP Falkland Islands, Pound DKK Faroe Islands, Denmark Krone FJD Fiji, Dollar EUR Finland, Euro FIM Finland, Markka [obsolete] EUR France, Euro FRF France, Franc [obsolete] EUR French Guiana, Euro XPF French Polynesia, Comptoirs Français du Pacifique Franc EUR French Polynesia, Euro EUR French Southern and Antarctic Lands, Euro XAF Gabon, CFA Franc BEAC GMD Gambia, Dalasi ILS Gaza Strip, Israel New Shekel GEL Georgia, Lari DEM Germany, Deutsche Mark [obsolete] EUR Germany, Euro GHC Ghana, Cedi GIP Gibraltar, Pound XAU Gold Ounce GBP Great Britain (United Kingdom), Pound EUR Greece, Euro GRD Greece, Drachma [obsolete] DKK Greenland, Denmark Krone XCD Grenada, East Caribbean Dollar EUR Guadeloupe, Euro USD Guam, United States Dollar GTQ Guatemala, Quetzal GGP Guernsey, Pound GNF Guinea, Franc XOF Guinea-Bissau, CFA Franc BCEAO GYD Guyana, Dollar HTG Haiti, Gourde EUR Holland (Netherlands), Euro NLG Holland (Netherlands), Guilder [obsolete] EUR Holy See (Vatican City), Euro VAL Holy See (Vatican City), Lira [obsolete] HNL Honduras, Lempira HKD Hong Kong, Dollar HUF Hungary, Forint ISK Iceland, Krona INR India, Rupee IDR Indonesia, Rupiah XDR International Monetary Fund Special Drawing Right IRR Iran, Rial IQD Iraq, Dinar EUR Ireland, Euro IEP Ireland, Pound [obsolete] FKP Islas Malvinas (Falkland Islands), Pound IMP Isle of Man, Pound ILS Israel, New Shekel EUR Italy, Euro ITL Italy, Lira [obsolete] XOF Ivory Coast (Côte d'Ivoire), CFA Franc BCEAO JMD Jamaica, Dollar JPY Japan, Yen JEP Jersey, Pound USD Johnson, United States Dollar JOD Jordan, Dinar EUR Juan de Nova, Euro KZT Kazakhstan, Tenge KES Kenya, Shilling AUD Kiribati, Australia Dollar KWD Kuwait, Dinar KGS Kyrgyzstan, Som LAK Laos, Kip LVL Latvia, Lat LBP Lebanon, Pound LSL Lesotho, Loti LRD Liberia, Dollar LYD Libya, Dinar CHF Liechtenstein, Switzerland Franc LTL Lithuania, Litas EUR Luxembourg, Euro LUF Luxembourg, Franc [obsolete] MOP Macau, Pataca MKD Macedonia, Denar MGA Madagascar, Ariary MGF Madagascar, Franc [obsolete] EUR Madeira Islands, Euro MWK Malawi, Kwacha MYR Malaysia, Ringgit MVR Maldives, Rufiyaa XOF Mali, CFA Franc BCEAO MTL Malta, Lira FKP Malvinas (Falkland Islands), Pound USD Marshall Islands, United States Dollar EUR Martinique, Euro MRO Mauritania, Ouguiya MUR Mauritius, Rupee EUR Mayotte, Euro MXN Mexico, Peso USD Micronesia, United States Dollar USD Midway Islands, United States Dollar MDL Moldova, Leu EUR Monaco, Euro MNT Mongolia, Tughrik EUR Montenegro, Euro XCD Montserrat, East Caribbean Dollar MAD Morocco, Dirham MZM Mozambique, Metical MMK Myanmar (Burma), Kyat NAD Namibia, Dollar AUD Nauru, Australia Dollar HTG Navassa, Haiti Gourde USD Navassa, United States Dollar CNY Nepal, China Yuan Renminbi NPR Nepal, Rupee ANG Netherlands Antilles, Guilder EUR Netherlands, Euro NLG Netherlands, Guilder [obsolete] XPF New Caledonia, Comptoirs Français du Pacifique Franc NZD New Zealand, Dollar NIO Nicaragua, Cordoba XOF Niger, CFA Franc BCEAO NGN Nigeria, Naira NZD Niue, New Zealand Dollar AUD Norfolk Island, Australia Dollar KPW North Korea, Won USD Northern Mariana Islands, United States Dollar NOK Norway, Krone OMR Oman, Rial PKR Pakistan, Rupee USD Palau, United States Dollar XPD Palladium Ounce PAB Panama, Balboa USD Panama, United States Dollar PGK Papua New Guinea, Kina CNY Paracel Islands, China Yuan Renminbi VND Paracel Islands, Vietnam Dong PYG Paraguay, Guarani PEN Peru, Nuevo Sol PHP Philippines, Peso NZD Pitcairn, New Zealand Dollar XPT Platinum Ounce PLN Poland, Zloty EUR Portugal, Euro PTE Portugal, Escudo [obsolete] USD Puerto Rico, United States Dollar QAR Qatar, Riyal EUR Reunion, Euro ROL Romania, Leu RUB Russia, Ruble RWF Rwanda, Franc ANG Saba, Netherlands Antilles Guilder SHP Saint Helena, Pound XCD Saint Kitts and Nevis, East Caribbean Dollar XCD Saint Lucia, East Caribbean Dollar EUR Saint Pierre and Miquelon, Euro XCD Saint Vincent and The Grenadines, East Caribbean Dollar EUR Saint-Martin, Euro WST Samoa, Tala EUR San Marino, Euro STD São Tome and Principe, Dobra SAR Saudi Arabia, Riyal GBP Scotland (United Kingdom), Pound SPL Seborga, Luigino XOF Senegal, CFA Franc BCEAO CSD Serbia, Dinar SCR Seychelles, Rupee SLL Sierra Leone, Leone XAG Silver Ounce SGD Singapore, Dollar ANG Sint Eustatius, Netherlands Antilles Guilder ANG Sint Maarten, Netherlands Antilles Guilder SKK Slovakia, Koruna SIT Slovenia, Tolar SBD Solomon Islands, Dollar SOS Somalia, Shilling ZAR South Africa, Rand GBP South Georgia, United Kingdom Pound KRW South Korea, Won GBP South Sandwich Islands, United Kingdom Pound EUR Spain, Euro ESP Spain, Peseta [obsolete] LKR Sri Lanka, Rupee SDD Sudan, Dinar SRD Suriname, Dollar SRG Suriname, Guilder NOK Svalbard and Jan Mayen, Norway Krone SZL Swaziland, Lilangeni ZAR Swaziland, South Africa Rand SEK Sweden, Krona CHF Switzerland, Franc SYP Syria, Pound TWD Taiwan, New Dollar TJS Tajikistan, Somoni RUB Tajikistan, Russia Ruble TZS Tanzania, Shilling THB Thailand, Baht XOF Togo, CFA Franc BCEAO NZD Tokelau, New Zealand Dollar TOP Tonga, Pa'anga MDL Transnistria, Moldova Leu TTD Trinidad and Tobago, Dollar TND Tunisia, Dinar TRY Turkey, New Lira TRL Turkey, Lira TMM Turkmenistan, Manat USD Turks and Caicos Islands, United States Dollar AUD Tuvalu, Australia Dollar TVD Tuvalu, Dollar UGX Uganda, Shilling UAH Ukraine, Hryvna AED United Arab Emirates, Dirham GBP United Kingdom, Pound USD United States, Dollar UYU Uruguay, Peso UZS Uzbekistan, Som VUV Vanuatu, Vatu EUR Vatican City, Euro VAL Vatican City, Lira [obsolete] VEB Venezuela, Bolivar VND Vietnam, Dong USD Virgin Islands, United States Dollar USD Wake Island, United States Dollar XPF Wallis and Futuna Islands, Comptoirs Français du Pacifique Franc ILS West Bank, Israel New Shekel JOD West Bank, Jordan Dinar MAD Western Sahara, Morocco Dirham WST Western Samoa (Samoa), Tala YER Yemen, Rial ZMK Zambia, Kwacha ZWD Zimbabwe, Dollar EOT } w3_config_hook () { def SURFRAW_currency_from USD def SURFRAW_currency_to EUR } w3_usage_hook () { cat <<EOF Usage: $w3_argv0 [options] [search words]... Description: Convert currencies with the Universal Currency Converter (www.xe.net/ucc) Local options: -l List all known currency symbols. -from=SYM Symbol for currency to convert from. Default: $SURFRAW_currency_from Environment: SURFRAW_currency_from -to=SYM Symbol for currency to convert to. Default: $SURFRAW_currency_to Environment: SURFRAW_currency_to Example currency symbols: EUR (Euro), USD (US Dollars), GBP (UK Pounds), CAD (Canada Dollars), AUD (Australia Dollars), JPY (Japan Yen), INR (India Rupees), NZD (New Zealand Dollars), CHF (Switzerland Francs), ZAR (South Africa Rand) EOF w3_global_usage } w3_parse_option_hook () { opt="$1" optarg="$2" case "$opt" in -from=*) setopt SURFRAW_currency_from $optarg ;; -to=*) setopt SURFRAW_currency_to $optarg ;; -l) list_currency_symbols; exit 0 ;; *) return 1 ;; esac return 0 } w3_config w3_parse_args "$@" # w3_args now contains a list of arguments if test -z "$w3_args"; then - w3_browse_url "http://www.xe.net/ucc/" + w3_browse_url "http://www.xe.com/currencyconverter/" else escaped_args=`w3_url_of_arg $w3_args` - w3_browse_url "http://www.xe.com/ucc/convert.cgi?Amount=${escaped_args}&From=${SURFRAW_currency_from}&To=${SURFRAW_currency_to}&submit=Perform+Currency+Conversion" + w3_browse_url "http://www.xe.com/currencyconverter/Amount=${escaped_args}&From=${SURFRAW_currency_from}&To=${SURFRAW_currency_to}&submit=Perform+Currency+Conversion" fi
JNRowe/surfraw
941713969153b074490112154f21979f7fe6f4df
fix some tests
diff --git a/elvi/commandlinefu b/elvi/commandlinefu old mode 100644 new mode 100755 diff --git a/test/bbcnews.test b/test/bbcnews.test index 86aea09..fa3e34a 100644 --- a/test/bbcnews.test +++ b/test/bbcnews.test @@ -1,4 +1,4 @@ bbcnews minister -\d+ results +Prime Minister diff --git a/test/bookfinder.test b/test/bookfinder.test index f81e0d0..d6ee4ea 100644 --- a/test/bookfinder.test +++ b/test/bookfinder.test @@ -1,6 +1,6 @@ bookfinder 1984 Nineteen Eighty-Four bookfinder -search=isbn 1556229119 -Publisher: Wordware, 2002 +Publisher:.*Jones.*Bartlett bookfinder -search=author Carl Sagan Pale Blue Dot diff --git a/test/bugmenot.test b/test/bugmenot.test index ff70491..42fc676 100644 --- a/test/bugmenot.test +++ b/test/bugmenot.test @@ -1,2 +1,2 @@ -bugmenot smh.com.au -Account Details +bugmenot latimes.com +Username: diff --git a/test/lastfm.test b/test/lastfm.test index 5f30722..cb72046 100644 --- a/test/lastfm.test +++ b/test/lastfm.test @@ -1,2 +1,2 @@ -lastfm people make me sick -Rope to the Sky +lastfm freedom has come and gone +Ring Them Bells diff --git a/test/pubmed.test b/test/pubmed.test index b7690bc..7ea7a48 100644 --- a/test/pubmed.test +++ b/test/pubmed.test @@ -1,2 +1,2 @@ pubmed fluoxetine -Results: 1 to 20 of \d+ +Items: 1 to 20 of \d+ diff --git a/test/webster.test b/test/webster.test index 34fe0b6..9c6c1eb 100644 --- a/test/webster.test +++ b/test/webster.test @@ -1,2 +1,2 @@ webster quotidian -<div class="example-sentences"><h2><span>Examples of <em>QUOTIDIAN</em></span> +Examples of.*quotidian
JNRowe/surfraw
afe8435ac7f1cea88aaff599dede1ba3baab50dc
Default to $BROWSER if no listed ones found
diff --git a/surfraw.conf.IN b/surfraw.conf.IN index e059b20..4821fd2 100644 --- a/surfraw.conf.IN +++ b/surfraw.conf.IN @@ -1,92 +1,92 @@ # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # $Id$ # # (c) 2000-2001 Julian Assange, all rights reserved. # (c) 2001 Australian Institute for Collaborative Research, all rights reserved. # (c) 2000 Melbourne Institute for Advanced Study, all rights reserved. # # see the file COPYING for further copyright details # # this file is shell script # # defintion commands: # # def -- define configuration variable unless already defined # (i.e by the environment) # defyn -- define boolean configuration variable unless # already defined # # WARNING: This file has a different format to that of $HOME/.surfraw.conf! # $HOME/.surfraw.conf entries should always be written sh style: # # SURFRAW_text_browser=w3m # etc # autoconf guessed prefix prefix=@prefix@ # graphical browser? defaults to yes for meatminds. text browser users can # work it out how to change it. defyn SURFRAW_graphical yes # name/path of text browser executable # e.g links, lynx, w3m def SURFRAW_text_browser @TEXTBROWSER@ # name/path of browser executable -# e.g mozilla, netscape etc -def SURFRAW_graphical_browser @GRAPHICALBROWSER@ +# e.g mozilla, netscape etc. Default to $BROWSER if no listed ones found +def SURFRAW_graphical_browser "${BROWSER:-@GRAPHICALBROWSER@}" # text browser arguments, or "none" def SURFRAW_text_browser_args none # graphical browser arguments, or "none" def SURFRAW_graphical_browser_args none # use -remote openURL for graphical browser defyn SURFRAW_graphical_remote no # when using the -remote, open a new window? defyn SURFRAW_new_window no # name of screen command to run def SURFRAW_screen screen # If surfraw is running under screen(1), start a new screen # for each text browser invocation? defyn SURFRAW_new_screen no # arguments for the screen command def SURFRAW_screen_args "" # "quote" arguments defyn SURFRAW_quote_args no # requote arguments if they have spaces in # ie so: # sr google foo "bar baz" bam # works. defyn SURFRAW_quote_ifs yes # default number of results to return def SURFRAW_results 30 # escape [% "@$%&+,/:;<=>?@@[\^{|}~'] characters in command line arguments # subsequently used to construct a url defyn SURFRAW_escape_url_args yes # just print search url? defyn SURFRAW_print no # Fetch and dump url? defyn SURFRAW_dump no # Language/country (for elvi that support it) # Should be a 2-letter iso country code def SURFRAW_lang "" # provider for searches that use a search engine # with (eg) site: specifiers # supported: google duckduckgo def SURFRAW_customsearch_provider duckduckgo
JNRowe/surfraw
90b4199a59fd5886c0e0b208e5c88472f5fc1768
Use awk instead of sed for listing elvi.
diff --git a/ChangeLog b/ChangeLog index a0cacce..f5bd63a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,512 +1,518 @@ +2015-09-13 Kyle Isom <[email protected]> + + * use awk instead of sed for listing elvi + + This provides better cross-platform behaviour. + 2015-08-23 Jason Ryan <[email protected]> * new elvi: searx 2014-09-20 Lucas Hoffmann <l-m-h at web.de> * new elvi: commandlinefu 2104-06-04 Jason Ryan <[email protected]> * new elvi: nlab 2013-12-10 Ian Beckwith <[email protected]> * yandex: disabled test: redirects to captcha when used with LWP. * Fix make distcheck: remove last traces of codesearch and scitopia. 2013-12-09 Ian Beckwith <[email protected]> * deja: disable tests, google groups now requires javascript. * gmane: fix test. * codesearch: removed, service shut down. * scitopia: removed, service shut down. * scicom: down, status unknown, made note in NEWS. 2013-12-08 Ian Beckwith <[email protected]> * new elvi: gmane * openbsd -mail: use gmane (directly, not via gmane elvi) * fix tests: ads, pgdoc, pin, yacy 2013-10-27 Ian Beckwith <[email protected]> * surfraw.IN: w3_custom_search_google: don't give full path to surfraw. * pgdoc, wayback: fixed tests. 2013-10-20 Ian Beckwith <[email protected]> * new elvi: yacy: search using yacy p2p search. -S searches ScienceNet, a yacy-based science search engine. * rae: fix url, remove -tipo option (no longer supported), disable test as there is now gratuitous javascript. 2013-10-06 Ian Beckwith <[email protected]> * Replaced phpdoc with version posted back in 2011 by Jon Yamokoski <[email protected]> Thanks, and apologies for missing it! * S: add test. * Include debian packaging in upstream tarball. 2013-10-05 Ian Beckwith <[email protected]> * ask, cisco: fix elvi. * new elvi: + oraclesearch - Replaces removed sunonesearch <sigh>. + S - search using w3_custom_search. * google: -g for groups clashed with -g for graphical browser. Invoke groups with -G, -gr, -groups or -search=groups. * mdn: site invokes google custom search via gratuitous javascript, so switch to w3_custom_search. * alioth: changed test to SKIP:, works OK but won't talk to LWP, hence test breaks. * discogs, openbsd: fixed tests. * mdn, mysqldoc, pgdoc, phpdoc: added tests. * w3_custom_search: + document in README. + remove documentation for ixquick support. It still works(ish), but doesn't support enough features to support (eg) mysqldoc -v=. + add -custom-search= commandline option. * updated copyright years to 2013. 2013-09-30 Ian Beckwith <[email protected]> * new elvi: mdn, mysqldoc, pgdoc, phpdoc * new function: w3_custom_search Is used by elvi that use a generic search engine with (eg) site: or inurl: to narrow down the search. Pass it -s=site -u=url for site: and inurl: args plus the quoted search args * new environment variable: SURFRAW_customsearch_provider to set provider used by w3_custom_search can be set to: google, duckduckgo or ixquick. Currently affects: mysqldoc, netbsd(*), openbsd(*), pgdoc, phpdoc, mysqldoc. (*) = only used by some options of elvi. * new internal variable w3_shquoted_args, contains arguments 'quoted' 'like this' for passing to w3_custom_search * Fixed url-encoding for '\' 2013-05-07 Ian Beckwith <[email protected]> * new elvi: jquery 2013-05-04 Ian Beckwith <[email protected]> * bump version to 2.2.9 * rae: fixed, at least as far as the test passing. Could really do with some love from someone who actually speaks spanish. * ctan: fixed search, updated options. Note command-line options have changed. * genportage: switch to gpo.zugaina.org * debcodesearch: new (trivial) elvi for codesearch.debian.net * jamendo: fix url, disable test (search now javascript) * deli: fix url; remove options; disable test (search now javascript) 2013-04-28 Ian Beckwith <[email protected]> * musicbrainz: fixed mbid search. * springer: fixed test. 2013-04-27 Ian Beckwith <[email protected]> * javasun: fixed test. 2013-04-24 Ian Beckwith <[email protected]> * Rewrote deblists for new xapian search. + -author, -lists, -lang no longer supported. + added -ml and -mv to show message id links and list view. * Removed happypenguin. Currently defunct and they are talking about a rewrite, so when it is back it will need fixing anyway. 2012-10-22 Ian Beckwith <[email protected]> * Fixed elvi: cisco, slashdot, slinuxdoc. * Removed elvi: scroogle (site gone). * Fixed tests: acronym, bbcnews, bugzilla, cisco, cite[1], currency, discogs, excite, fsfdir, gcache, github, imdb, ixquick, lastfm, leodict, openbsd[2], scholar. * test/Makefile.am: Added missing tests to EXTRA_DIST 2012-06-28 Manolo Martínez <[email protected]> * examples/hooks.lua: Added elinks integration script 2012-06-28 Ivy Foster <[email protected]> * Further simplified searchable bookmarks 2012-06-28 Thomas Zervogiannis <[email protected]> * Simplified searchable bookmarks 2012-06-27 Ivy Foster <[email protected]> * Fixed arg parsing in searchable bookmarks * New variable: SURFRAW_bookmark_search_elvis + When using searchable bookmarks, if all else fails run this elvis. Defaults to google * Updated manual to reflect changes to bookmarks * duckduckgo: Removed -p option. -safe still works. + Prevents clobbering global option -p[rint]. 2012-06-27 Thomas Zervogiannis <[email protected]> * Added searchable bookmarks + Bookmarks can now be searchable by adding '%s' to the url string. 2012-06-01 Jason Ryan <[email protected]> * New elvi: github (search github.com) 2012-03-17 Ivy Foster <[email protected]> * Fix a typo in duckduckgo code. 2012-03-17 Ivy Foster <[email protected]> * Keep duckduckgo's -l[ucky] from clobbering -lh 2012-01-10 Ivy Foster <[email protected]> * aur: now uses HTTPS by default + On the AUR, connecting via HTTP disables login. + Added switch -no-https to enable connection via plain HTTP 2011-10-10 Ian Beckwith <[email protected]> * surfraw.IN: test_elvi(): tweak sed regex * add tests for f5, cisco and pin. 2011-10-10 Shain Singh <[email protected]> * New elvi: f5, cisco 2011-10-10 Jason Ryan <[email protected]> * New elvi: pin (search pinboard.in). 2011-09-09 Kyle Isom <[email protected]> * New elvi: wolfram - query Wolfram Alpha * Author: Kyle Isom <[email protected]> * Added test for wolfram. 2011-08-09 Ian Beckwith <[email protected]> * New elvi: priberam - search Portuguese dictionary. Author: Paulo Almeida <[email protected]> * Added test for priberam. 2011-07-11 Ian Beckwith <[email protected]> * netbsd: fix normal & mail search. google custom searches were complaining I was a bot, so I switched to normal google searches with site:{mail-index,}.netbsd.org. * cia: fix search URL 2011-06-17 Ian Beckwith <[email protected]> * arxiv: fix -scope=author with single-word queries. Thanks to Nikos Apostolakis. * btw, note about entry below, netbsd make *does* support '$<', but only in suffix rules. 2011-06-16 Ian Beckwith <[email protected]> * Fix more make(1) portability problems. Either I am horribly confused or netbsd make (or at least pmake in debian) doesn't support '$<'. Switched to '$?'. * Also switched submit-lsm rule to '$?'. Thanks to Kyle Isom. * Removed long-obsolete commented-out sourceforge upload rules. 2011-06-15 Ian Beckwith <[email protected]> * scitopia, worldwidescience: fixed URLs. * Fixed make portability problems. We cannot portably combine single suffix rules (foo.IN->foo) and separated dependencies so we have to explicitly specify all the .IN rules. The solution we used for this until now was specific to GNU make. * Removed Makefile.include, no longer used. * './configure --enable-opensearch' now only controls installation of the (direct) dependencies for opensearch, not opensearch itself, as opensearch now falls back to using a remote reflector if opensearch-discover(1) and opensearch-genquery(1) aren't found. * yandex: fix test. 2011-06-14 Ian Beckwith <[email protected]> * musicbrainz, codesearch, rpmsearch: Fixed URLs, options and tests. The sites have all changed significantly which means both new options and no-longer-supported options. Codesearch has gone all ajaxy, so I've implemented the options via the search string, e.g. adding " package:foo". Disabled codesearch.test, as it now needs javascript. Codesearch on both google.com and google.co.uk was acting up, so I've pointed it at google.fr. * Removed filesearching elvi, it now requires a 'Referer:' header to work. There is no browser-portable way to specify a 'Refer[r]er:' header, plus we should probably take it as a hint. * Tweaked debian packaging. * Updated NEWS. 2011-06-13 Ian Beckwith <[email protected]> * w3link: fixed URLs. 2011-06-10 Ian Beckwith <[email protected]> * Fixed ctan. Option -doc has been replaced by -id. Options are no longer mutually exclusive, you can now do (eg) ctan -d -i -n texlive. 2011-06-09 Ian Beckwith <[email protected]> * fixed tests: debwiki, ntrs, wayback. 2011-06-07 Ian Beckwith <[email protected]> * Default to surfraw_graphical_remote=no, as chromium doesn't support "-remote openURL". 2011-05-31 Jason Ryan <[email protected]> * Add options to archpkg. 2011-05-12 Sara Fauzia <[email protected]> * Fix archpkg URL. 2011-05-12 Ian Beckwith <[email protected]> * surfraw.IN: + if elvi doesn't exist, send usage to stderr not stdout. + bookmark names: do exact match not substring match. * Added tests for archwiki, deli & stack. * README: + added INTEGRATION section on uzbl and pentadactyl. + upcased section headings for clarity. 2011-05-12 Jason Ryan <[email protected]> * New elvi: + archwiki: search the arch wiki. + deli: search delicious.com. + stack: search stackoverflow.com and friends. 2011-03-21 Ian Beckwith <[email protected]> * google: Added -safe=default|off|moderate|strict option for Safe Search. 2011-03-21 Ivy Foster <[email protected]> * Added Google Translate to elvi/translate. 2011-03-03 Ian Beckwith <[email protected]> * opensearch: new option -r, uses redirector at http://erislabs.net/ianb/webtools/opensearch/ instead of calling opensearch-discover and opensearch-genquery. -r is selected automatically if those tools are not installed. This enables us to ship opensearch in the main surfraw package and it still functions if the dependencies are not installed. See debian/changelog. * wikipedia: new options: + -d, uses a redirector at http://erislabs.net/ianb/webtools/wpdp/ This redirector searches for a page with that name at wikipedia. If not found, it searches deletionpedia, if not found there it falls back to a normal wikipedia search. + -f=w|d, -fallback=wikipedia|deletionpedia Implies -d. If page not found at either wikipedia or deletionpedia, whether to fallback to wikipedia search or deletionpedia search. * google: + support video, maps and news. + new options -i, -v, -m, -n, shortcuts for -search={images,videos,maps,news}. * debcontents, debpackages: update docs for new arches and distributions. * bugzilla: + fix url so it works with redhat & eclipse bugzillas too. + enable -s=redhat. * ixquick, w3css: fix tests. * opensearch, wikipedia: add redirector tests. 2011-02-20 Ian Beckwith <[email protected]> * New elvi: bugzilla - searches various bugzillas, defaults to kernel. * pgpkeys: add more options, support more keyservers, default to sks-keyservers.net. * bump version to 2.2.8. * test/Makefile.am: add cablesearch.test. 2011-02-19 Ian Beckwith <[email protected]> * lastfm: fix url to avoid a redirect that mangled args with spaces. * debbugs: add -s as an alias for -search=src. * surfraw.IN: (finally) update copyright year to 2011. * remove traces of port elvi from build system. 2011-02-09 Kyle Isom <[email protected]> * fix a number of tests to match current site formats 2011-01-12 Kyle Isom <[email protected]> * New elvi: + cablesearch - search wikileaks cables + duckduckgo - replace with better implementation + openports - search openbsd ports 2010-12-04 Jakob <[email protected]> * new elvis: pasearch. 2010-12-08 Ian Beckwith <[email protected]> * arxiv: Thanks to MT <[email protected]> for patch that fixes: 1. Search queries with more than two terms would fail, e.g. 'supermassive black hole'. 2. Full text search was broken, it works now. 3. Enhancement: quoting the query now does an exact string match. 2010-10-29 Ian Beckwith <[email protected]> * wayback: advanced search is broken, rip out all options and use basic search. * w3_url_escape: add /g to '/'->'%2F' replacement. * uzbl_load_url_from_surfraw: use @AWK@ to pick up ./configure's choice of awk implementation. 2010-10-28 Ian Beckwith <[email protected]> * Support -local-help, --local-help or -lh to get elvi-specific help without displaying the global options. This works for all elvi and the main surfraw script. * google, duckduckgo, opensearch, wayback: tweak overbroad option parsing so it doesn't interfere with -lh. * Support -h as a synonym for -help. 2010-10-25 Ian Beckwith <[email protected]> * new elvi: scirus, scitopia, worldwidescience. * yahoo: reduced query string to just p and n options. * openbsd: support -misc and -tech. Thanks to Sunil Nimmagadda for the patch. * removed cddb: gracenote made the "hard decision" to remove the website search. sigh. * removed altavista: is now just a front-end to yahoo. * removed fast: another yahoo front-end. * imdb: fix test. * javasun: oracleized URLs. * w3link: fixed URL. 2010-08-22 Jameson Rollins <[email protected]> * surfraw.IN: Improve listing of elvi. 2010-08-20 James Rowe <[email protected]> * new elvi: ads. Thanks to Jameson Rollins. 2010-07-02 Ian Beckwith <[email protected]> * new elvi: yandex. Thanks to Uspenskiy Andrey. 2010-05-06 Ian Beckwith <[email protected]> * uzbl_load_url_from_surfraw: fix menu. Thanks to Sumant Oemrawsingh. * Fixed tests: deblists google openbsd. 2010-04-28 Ian Beckwith <[email protected]> * configure.in: test for google-chrome, opera and links2. 2010-04-22 Ian Beckwith <[email protected]> * debwiki: remove -w, Debian Women wiki is now being merged into main wiki. Thanks to Simone Fittabile. * debwiki.test: stop testing -w option. * surfraw.IN: change an awk to @AWK@. 2010-04-21 Ian Beckwith <[email protected]> * New elvi: jamendo - Search Jamendo: free music with Creative Commons licenses (www.jamendo.com). Thanks to Simone Fittabile. * wikipedia, ixquick: Support https. Thanks to Simone Fittabile. * wikipedia: tweak Simone's patch to support https for start page and document the SURFRAW_wikipedia_ssl variable. * ixquick: add -nossl option. * javasun.test: revert to previous test, works again. 2010-04-19 James Rowe <[email protected]> * genpkg: removed, use genportage. 2010-04-16 Ian Beckwith <[email protected]> * New elvi: + scroogle: Search Google anonymously via www.scroogle.org. + duckduckgo: Search the web via duckduckgo.com. * Fix tests: excite, javasun, musicbrainz, yahoo. 2010-03-03 James Rowe <[email protected]> * bookfinder: fix ISBN search test. 2010-03-01 Ian Beckwith <[email protected]> * Removed autotools-generated files from git repo use ./prebuild to regenerate. * Lower required automake version to 1.10. * prebuild: try and find a sane set of autotools, then call autoreconf -vi * Add autotools-generated files to .gitignore * Bump version to 2.2.7 * cnn: fix URL. * cnn.test: Disable. Bloody CNN now needs javascript for search, so should be tested manually. * W, yahoo: fix tests. * Remove unused '-quiet' option. * Update AUTHORS. * Add a note to appendix 1 of HACKING about updating AUTHORS. * runtests: explicitly use elvi and config from source tree, now works when surfraw is not installed (but you need to have run make). * test/Makefile.am: fix bookfinder typo, add bing.test. * remove leading 'sr ' from command lines for following tests: acronym aur bing cliki gcache genportage google javasun l1sp lsm mathworld mininova piratebay youtube * HACKING, README, test/README: document autotools and test suite changes. * Makefile.am: add surfraw.conf to BUILT_SOURCES so it is made by 'make'. This may be a misuse of BUILT_SOURCES. 2010-02-22 Ivy Foster <[email protected]> * Added `-ns|-newscreen' switch for setting $SURFRAW_new_screen. 2010-02-15 James Rowe <[email protected]> * elvi/imdb: Fixes for upstream search changes. Thanks to Sadako. * New elvi: bookfinder, thanks to Ivy Foster. 2010-02-14 James Rowe <[email protected]> * Added $SURFRAW_screen_args for passing arguments to the defined screen diff --git a/surfraw.IN b/surfraw.IN index 0de3c96..8471216 100755 --- a/surfraw.IN +++ b/surfraw.IN @@ -1,693 +1,693 @@ #!/bin/sh # Surfraw -- Shell Users' Revolutionary Front Against the World wide web # # Copyright (c) 2003-2013 The Surfraw-Devel Team # <[email protected]> # Copyright (c) 2000-2001 Julian Assange, placed into the public domain # Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain # # see the file COPYING for further copyright details # surfraw_version=@VERSION@ surfraw_api_version=1.0 w3_argv0=`basename "$0"` elvidir="@ELVIDIR@" # defaults w3_config_hook () { return 1 } find_global_conf () { base="$1" local conf OIFS conf="" if test -n "$XDG_CONFIG_DIRS"; then OIFS="$IFS" IFS=: set $XDG_CONFIG_DIRS IFS="$OIFS" for i in "$@"; do if test -r "$i/surfraw/$base"; then conf="$i/surfraw/$base" break fi done elif test -r "@sysconfdir@/xdg/surfraw/$base"; then # XDG default conf="@sysconfdir@/xdg/surfraw/$base" elif test -r "@sysconfdir@/surfraw.$base"; then # old surfraw default conf="@sysconfdir@/surfraw.$base" fi echo "$conf" } load_global_conf () { local conf if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then conf="$SURFRAW_global_conf" else conf=$(find_global_conf conf) fi if test -z "$conf" || ! test -r "$conf"; then err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS" fi . "$conf" } find_local_conf () { base="$1" if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then echo "$XDG_CONFIG_HOME/surfraw/$base" elif test -n "$HOME"; then if test -r "$HOME/.config/surfraw/$base"; then echo "$HOME/.config/surfraw/$base" elif test -r "$HOME/.surfraw.$base"; then echo "$HOME/.surfraw.$base" fi fi } load_local_conf () { local conf conf="" if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then conf="$SURFRAW_conf" else conf="$(find_local_conf conf)" fi if test -n "$conf" && test -r "$conf"; then . $conf fi } get_local_elvi_dir () { if test -n "$XDG_CONFIG_HOME";then echo "$XDG_CONFIG_HOME/surfraw/elvi" elif test -n "$HOME";then echo "$HOME/.config/surfraw/elvi" fi } w3_config () { load_global_conf w3_config_hook load_local_conf } warn () { echo "$w3_argv0 WARNING: ""$@" >&2 } err () { echo "$w3_argv0 ERROR: ""$@" >&2 exit 1 } yesno () { eval value=\$${1} case `echo "$value" | tr A-Z a-z` in yes|true|on|1) return 0 ;; no|false|off|0) return 1 ;; *) err "\"$1\" is not set correctly. Should be (yes|on|1|no|off|0). Is \"$value\"" ;; esac } ifyes () { yesno "$@" && return 0 return 1 } ifno () { yesno "$@" && return 1 return 0 } ok () { yesno "$@" } null () { test -z "$@" && return 0 return 1 } def () { eval value=\$${1} test -z "$value" || return 0 eval ${1}="$2" return 0 } defyn () { eval value=\$${1} test -z "$value" && eval ${1}="$2" yesno "$1" } setopt () { eval value=\$${1} eval ${1}="$2" } setoptyn () { eval value=\$${1} eval ${1}="$2" yesno "$1" } quote_ifs () { if [ -z "$1" ]; then return; fi perl -e '$ifs=$ENV{IFS} || " "; $arg=shift;if($arg =~/[$ifs]/) { $arg="\"$arg\""; } print "$arg\n"; ' -- "$1" } bookmark_file_search () { search="$1" file="$2" if [ -r "$file" ] then @AWK@ -v search="$search" '$1 == search { for (nLoop = 2;nLoop <= NF; nLoop++) printf("%s ", $nLoop); print ""; }' $file | head -n 1 fi } bookmark_lookup () { search="$1" file=$(find_local_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") if [ -z "$lookup" ] then file=$(find_global_conf bookmarks) lookup=$(bookmark_file_search "$search" "$file") fi if [ -n "$lookup" ] then echo "$lookup" fi } w3_find_prog () { prog="$1" old_ifs="${IFS:-\" \"}" IFS=":" path_ifs="$PATH" for dir in $path_ifs; do test -z "$dir" && dir=. if test -e "$dir/$prog"; then echo "$dir/$prog" IFS="$old_ifs" return 0 fi done IFS="$old_ifs" return 1 } w3_url_escape () { echo "$@" | sed 's/%/%25/g; s/+/%2B/g; # s/ /+/g; s/ /%20/g; s/(/%28/g; s/)/%29/g; s/"/%22/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/,/%2C/g; # s/\./%2E/g; sx/x%2Fxg; s/:/%3A/g; s/;/%3B/g; s/</%3C/g; s/=/%3D/g; s/>/%3E/g; s/?/%3F/g; s/@/%40/g; s/\[/%5B/g; s/\\/%5C/g; s/\]/%5D/g; s/\^/%5E/g; s/{/%7B/g; s/|/%7C/g; s/}/%7D/g; s/~/%7E/g; s/`/%60/g; '"s/'/%27/g" } w3_url_of_arg () { if ok SURFRAW_quote_args; then args=\""$@"\" else args="$@" fi if ok SURFRAW_escape_url_args; then w3_url_escape "$args" else echo "$args" fi } true () { return 0 } false () { return 1 } w3_global_usage () { defyn SURFRAW_local_help no if ifyes SURFRAW_local_help; then return; fi # style: keep sorted #-------------------------------------79 cols---------------------------------- cat <<EOF Global options: -bookmark-search-elvis=ELVIS If args are passed to a non-searchable bookmark, search with this elvis instead. Default: $SURFRAW_bookmark_search_elvis Environment: SURFRAW_bookmark_search_elvis -browser=EXECUTABLE Set browser Default: $SURFRAW_browser -custom-search=PROVIDER Use PROVIDER for custom searches. Supported: google, duckduckgo Default: $SURFRAW_customsearch_provider Environment: SURFRAW_customsearch_provider -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: $SURFRAW_escape_url_args Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: $SURFRAW_graphical Environment: SURFRAW_graphical -h | -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: $SURFRAW_new_window Environment: SURFRAW_new_window -ns[=yes|no] Start in a new screen | -newscreen[=yes|no] Default: $SURFRAW_new_screen Environment: SURFRAW_new_screen -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: $SURFRAW_quote_args Environment: SURFRAW_quote_args -version Display Surfraw version ($surfraw_version) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study EOF } w3_usage_hook () { echo "Usage: $w3_argv0 [options] [args...]" w3_global_usage } w3_bad_option () { err "bad option \"${opt}\". Try ${w3_argv0} -help for usage information" } w3_parse_option_hook () { return 1 } list_elvi() { - local dir="$1" - sed -n 's/^.*elvis:[ ]\+\(.*\)$/\1/p' $(find "$dir" ! -type d ! -type l ! -name '*~' | sort) - for script in $(find "$dir" ! -type d -type l | sort) ; do + local_dir="$1" + awk '/^#[ ]+elvis:[ ]+/{ sub("^# elvis: ",""); print $0; }' $(find "$local_dir/" ! -type d ! -type l ! -name '*~' | sort | xargs) + for script in $(find "$local_dir/" ! -type d -type l | sort) ; do printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}")) done } w3_parse_option () { opt="$1" case "$opt" in -*=*) optarg=`echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//'` esac w3_parse_option_hook "$opt" "$optarg" && return 0 case "$opt" in -bookmark-search-elvis=*) setopt SURFRAW_bookmark_search_elvis $optarg ;; -browser=*) setopt SURFRAW_browser $optarg ;; -elvi) echo " GLOBAL ELVI:" list_elvi "$elvidir" localelvidir=$(get_local_elvi_dir) if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then echo " LOCAL ELVI:" list_elvi "$localelvidir" fi exit 0 ;; -escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;; -g | -graphical) setoptyn SURFRAW_graphical yes ;; -help | --help |-h) do_help=1 ;; -local-help | \ --local-help |-lh ) do_help=1 ;setoptyn SURFRAW_local_help yes ;; -q | -quote) setoptyn SURFRAW_quote_args yes ;; -new) setoptyn SURFRAW_new_window yes ;; -new=*) setoptyn SURFRAW_new_window $optarg ;; -ns | -newscreen) setoptyn SURFRAW_new_screen yes ;; -ns=* | -newscreen=*) setoptyn SURFRAW_new_screen $optarg ;; -custom-search=*) setopt SURFRAW_customsearch_provider $optarg ;; -o) setoptyn SURFRAW_dump yes ;; -o=*) setoptyn SURFRAW_dump yes setopt SURFRAW_dump_file $optarg ;; -t | -text) unset DISPLAY setoptyn SURFRAW_graphical no ;; -version) echo $surfraw_version; exit 0 ;; -p | -print) setoptyn SURFRAW_print yes ;; --) setoptyn SURFRAW_end_of_args yes ;; -*) w3_bad_option "$opt" ;; *) return 1 ;; esac return 0 } w3_parse_args () { w3_args= w3_shquoted_args= def SURFRAW_browser none def SURFRAW_browser_args none defyn SURFRAW_quote_ifs yes defyn SURFRAW_end_of_args no do_help=0 mode=unknown for arg in "$@"; do isarg=1 if ifno SURFRAW_end_of_args then w3_parse_option "$arg" isarg=$? fi if [ $isarg -eq 1 ] then if [ -z "$w3_shquoted_args" ] then w3_shquoted_args="`quote "$arg"`" else w3_shquoted_args="$w3_shquoted_args `quote "$arg"`" fi if ok SURFRAW_quote_ifs then arg=`quote_ifs "$arg"` fi if [ -n "$w3_args" ] then w3_args="$w3_args $arg" else w3_args="$arg" fi fi done if test $SURFRAW_browser = none; then if ok SURFRAW_graphical && test -n "$DISPLAY"; then SURFRAW_browser=$SURFRAW_graphical_browser SURFRAW_browser_args=$SURFRAW_graphical_browser_args mode=graphical else SURFRAW_browser=$SURFRAW_text_browser SURFRAW_browser_args=$SURFRAW_text_browser_args mode=text fi fi if ok do_help; then w3_usage_hook exit 0 fi } w3_dump () { if test -z "$SURFRAW_dump_file"; then SURFRAW_dump_file="-" fi if test -x "$(which curl)"; then curl -o "$SURFRAW_dump_file" "$@" elif test -x "$(which wget)"; then wget -q -O "$SURFRAW_dump_file" "$@" elif test -x "$(which GET)"; then if test "$SURFRAW_dump_file" = "-"; then GET "$@" else GET "$@" > "$SURFRAW_dump_file" fi else err "No URL fetcher found: install curl, wget or libwww-perl" fi } w3_browse_url () { if ok SURFRAW_new_screen && test `echo $TERM | cut -c 1-6` = "screen" && test $mode = text; then screen=yes else screen=no fi if ok SURFRAW_dump; then w3_dump "$@" elif ok SURFRAW_print; then echo "$@" elif ok screen; then if [ "$SURFRAW_screen" = "tmux" ]; then if test "$SURFRAW_browser_args" = "none"; then $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser \"$@\"" else $SURFRAW_screen $SURFRAW_screen_args "$SURFRAW_browser $SURFRAW_browser_args \"$@\"" fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser "$@" else $SURFRAW_screen $SURFRAW_screen_args $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi else if ok SURFRAW_graphical_remote && test $mode = graphical; then if ok SURFRAW_new_window; then newwin=", new-window" else newwin="" fi if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser "$@" & else $SURFRAW_browser -remote "openURL($*$newwin)" 2>/dev/null || $SURFRAW_browser $SURFRAW_browser_args "$@" & fi else if test $SURFRAW_browser_args = "none"; then $SURFRAW_browser "$@" else $SURFRAW_browser $SURFRAW_browser_args "$@" fi fi fi } w3_custom_search_usage() { echo "Custom search:" echo " To choose which search engine gets used for custom searches," echo " configure SURFRAW_customsearch_provider" echo " or use -custom-search=PROVIDER" echo " supported: google, duckduckgo" echo " default: $SURFRAW_customsearch_provider" } w3_custom_search() { case "$SURFRAW_customsearch_provider" in google) w3_custom_search_google "$@" ;; duckduckgo) w3_custom_search_duckduckgo "$@" ;; ixquick) w3_custom_search_ixquick "$@" ;; *) w3_custom_search_duckduckgo "$@" ;; esac } w3_custom_search_google() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) params=$(eval w3_custom_search_inurl_quote_dots $params) url="$(eval surfraw google -p $params )" w3_browse_url "$url" } w3_custom_search_duckduckgo() { params=$(eval w3_custom_search_mangle -s site: $*) params=$(eval w3_custom_search_mangle -u inurl: $params) url="$(eval surfraw duckduckgo -p $params )" w3_browse_url "$url" } w3_custom_search_ixquick() { params=$(eval w3_custom_search_mangle -s host: $*) params=$(eval w3_custom_search_mangle -u url: $params) url="$(eval surfraw ixquick -p $params )" w3_browse_url "$url" } w3_custom_search_mangle() { search="$1" replace="$2" shift shift for arg in "$@" do quote "$(echo "$arg" | sed "s/^${search}=\(.*\)/${replace}\1/")" done } w3_custom_search_inurl_quote_dots() { for arg in "$@" do if echo "$arg" | grep -q -- inurl: then quote "$(echo "$arg" | sed 's/\./\\./g;')" else quote "$arg" fi done } quote () { quoted=`echo "$1"|sed "s/'/'\\\\\''/g"` echo "'$quoted'" } surfraw_usage() { cat <<EOF Usage: $w3_argv0 [-help] [-elvi] elvis [elvioptions] [search terms] $w3_argv0 [options] bookmark [search terms] If you wish to run the elvi directly, run "surfraw-update-path" to append $elvidir to your \$PATH in your shell's config files. See surfraw-update-path(1) for details Options: -elvi List elvi -help This help sr is an alias for surfraw EOF w3_global_usage } # Browse URL or perform a search on URL(s) if search terms # are provided (use the user's elvis of choice if URL has no # %s field or multiple if multiple URLs are provided) parse_bookmark() { if [ -z "$w3_args" ]; then case "$bookmark" in *"%s"*) # Keep only the domain address, the rest contains %s which should be filtered. bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}') ;; *) # Keep the first URL (if multiple-URL bookmark) as-is, no %s here... bookmark=$(echo $bookmark | cut -f 1 -d ' ') ;; esac else escaped_args=$(w3_url_of_arg $w3_args) case "$bookmark" in *"%s"*) bookmark="$(echo $bookmark | sed "s|\%s|$escaped_args|")" ;; *) [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google bookmark=$(echo $bookmark | sed -e 's|^|site:|' \ -e 's|\ |\ OR\ site:|g' \ -e "s|^|$w3_args |" \ -e "s|^|$SURFRAW_bookmark_search_elvis |") ;; esac fi echo $bookmark } if [ "$w3_argv0" = "surfraw" -o "$w3_argv0" = "sr" ] then w3_config opts="" unquoted_opts="" unquoted_searchterms="" elvi="" searchterms="" do_help=0 for arg in "$@" do # if it is an option if [ "$(echo "$arg" | sed 's/^\(.\).*/\1/;' )" = "-" ] then # if option before elvi if [ -z "$elvi" ] then case "$arg" in -help | --help |-h) do_help=1 ;; -local-help | \ --local-help | \ -lh | -\? ) do_help=1 ; setoptyn SURFRAW_local_help yes ;; -elvi*) w3_parse_option -elvi; exit 0 ;; esac fi if ok do_help then surfraw_usage exit 0 fi if [ -z "$opts" ] then opts="`quote "$arg"`" unquoted_opts="$arg" else opts="$opts `quote "$arg"`" unquoted_opts="$unquoted_opts $arg" fi elif [ -z "$elvi" ] then elvi="$arg" else if [ -z "$searchterms" ] then searchterms="`quote "$arg"`" unquoted_searchterms="$arg" else searchterms="$searchterms `quote "$arg"`" unquoted_searchterms="$unquoted_searchterms $arg" fi fi done if [ -z "$elvi" ] then surfraw_usage exit 0 else localelvidir=$(get_local_elvi_dir) if [ -x "$localelvidir/$elvi" ] then sh -c "$localelvidir/$elvi $opts $searchterms" elif [ -x "$elvidir/$elvi" ] then sh -c "$elvidir/$elvi $opts $searchterms" else bookmark=`bookmark_lookup $elvi` if [ -n "$bookmark" ] then w3_parse_args $unquoted_opts $unquoted_searchterms bookmark=$(parse_bookmark) w3_browse_url "$bookmark" exit 0 else echo "`basename $0`: $elvi: No elvis or bookmark with that name" echo "Passing everything to browser and hoping for the best..." $BROWSER "$elvi $opts $unquoted_searchterms" exit 0 fi fi fi fi
JNRowe/surfraw
6658ccf894875bb7dac2e7b440f50dff78dbc5af
New elvis: searx
diff --git a/AUTHORS b/AUTHORS index f25b9fe..bd2636b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,168 +1,171 @@ AUTHORS Julian Assange <[email protected]> original author Christian Surchi <[email protected]> original debian maintainer elvi: debcontents, debbugs, debpackages Ian Beckwith <[email protected]> current debian maintainer elvi: alioth, bbcnews, bugzilla, deblists, freedb, imdb, scpan, codesearch, debwiki, lastfm, musicbrainz, opensearch, scholar, ctan, fsfdir, gutenberg, wayback, dmoz, w3html, w3link, w3css, w3rdf, debpts, rfc, lsm, finkpkg, rpmsearch, macports, debpkghome, debvcsbrowse, scroogle, scirus, scitopia, worldwidescience, debcodesearch, jquery, mdn, mysqldoc, pgdoc, oraclesearch, S, yacy, gmane plus various tweaks/bugfixes/features. Moritz Muehlenhoff <[email protected]> elvi: debsec, ebay, leodict, wikipedia, sharereactor, pgpkeys, happypenguin plus various patches/maintenance. Thomas Smith <[email protected]> Bugfixes, uploading. Stephen Stafford <[email protected]> Bug fixes Kevin Kreamer <[email protected]> Bug fixes Christian Weisgerber <[email protected]> elvi: fast, thesaurus, webster Jason Harris <[email protected]> elvi: freebsd, openbsd, filesearching, ftpfind Ruben Pollan <[email protected]> elvi: rae Ian Broadfoot <[email protected]> elvi: yubnub James Rowe <[email protected]> plus useful patches/maintenance. Aparna Jaitly <[email protected]> elvi: ixquick Justin B. Rye <[email protected]> elvi: cia, deblogs, etym, foldoc plus useful patches. Patroklos Argyroudis <[email protected]> elvi: discogs Simon Ernst <[email protected]> elvi: archpkg Ivy Foster <[email protected]> elvi: bookfinder, bugmenot plus various patches/maintenance Sumant Oemrawsingh <[email protected]> elvi: cliki, l1sp, mathworth, mininova, youtube plus patches, including the uzbl examples. Sadako <[email protected]> imdb fixes tczy <[email protected]> elvi: bing Simone Fittabile <[email protected]> elvi: acronym, gcache, jamendo plus patches. Micah Anderson <[email protected]> various patches René Reigel <[email protected]> elvi: aur J.R. Mauro <[email protected]> elvi: urban, piratebay, genportage Wim van Hoydonck <[email protected]> elvi: ntrs, springer, sc John Briggs <[email protected]> patch to google John Gruenenfelder <[email protected]> elvi: arxiv csh patch James TD Smith <[email protected]> elvi: javasun google country-specific options Charles Twardy <[email protected]> fixed cia Uspenskiy Andrey <[email protected]> elvi: yandex Jameson Rollins <[email protected]> elvi: ads plus tweaks. Jakob <[email protected]> elvi: pasearch Kyle Isom <[email protected]> elvi: cablesearch, duckduckgo, openports, wolfram plus various fixes/maintenance. Jason Ryan <[email protected]> elvi: archwiki, deli, github, stack, pin plus various fixes/maintenance Sara Fauzia <[email protected]> archpkg fix. Thomas Zervogiannis <[email protected]> Searchable bookmarks. Paulo Almeida <[email protected]> elvi: priberam Shain Singh <[email protected]> elvi: cisco, f5 Manolo Martínez <[email protected]> examples: elinks integration (hooks.lua) Jon Yamokoski <[email protected]> elvi: phpdoc Lucas Hoffmann <l-m-h at web.de> elvi: commandlinefu +Nils <[email protected]> + elvi: searx + THANKS TO Brian Nelson <[email protected]> Christian Garbs <[email protected]> Hector Blanco <[email protected]> Jeff Bailey <[email protected]> Mark W. Eichin <[email protected]> Teófilo Ruiz Suárez <[email protected]> Maru Dubshinki <[email protected]> Matt Kraai <[email protected]> Brian Mcdonald <[email protected]> Carl Fredrik Hammar <[email protected]> Andy Valencia <[email protected]> Philip Armstrong <[email protected]> Dan Jacobson <[email protected]> Sunil Nimmagadda <[email protected]> Michel <[email protected]> Nikos Apostolakis <[email protected]> Facundo Aguirre <[email protected]> Raphael Geissert <[email protected]> If we've missed anyone, let us know. diff --git a/ChangeLog b/ChangeLog index 2b19208..a0cacce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,512 +1,516 @@ +2015-08-23 Jason Ryan <[email protected]> + + * new elvi: searx + 2014-09-20 Lucas Hoffmann <l-m-h at web.de> * new elvi: commandlinefu 2104-06-04 Jason Ryan <[email protected]> * new elvi: nlab 2013-12-10 Ian Beckwith <[email protected]> * yandex: disabled test: redirects to captcha when used with LWP. * Fix make distcheck: remove last traces of codesearch and scitopia. 2013-12-09 Ian Beckwith <[email protected]> * deja: disable tests, google groups now requires javascript. * gmane: fix test. * codesearch: removed, service shut down. * scitopia: removed, service shut down. * scicom: down, status unknown, made note in NEWS. 2013-12-08 Ian Beckwith <[email protected]> * new elvi: gmane * openbsd -mail: use gmane (directly, not via gmane elvi) * fix tests: ads, pgdoc, pin, yacy 2013-10-27 Ian Beckwith <[email protected]> * surfraw.IN: w3_custom_search_google: don't give full path to surfraw. * pgdoc, wayback: fixed tests. 2013-10-20 Ian Beckwith <[email protected]> * new elvi: yacy: search using yacy p2p search. -S searches ScienceNet, a yacy-based science search engine. * rae: fix url, remove -tipo option (no longer supported), disable test as there is now gratuitous javascript. 2013-10-06 Ian Beckwith <[email protected]> * Replaced phpdoc with version posted back in 2011 by Jon Yamokoski <[email protected]> Thanks, and apologies for missing it! * S: add test. * Include debian packaging in upstream tarball. 2013-10-05 Ian Beckwith <[email protected]> * ask, cisco: fix elvi. * new elvi: + oraclesearch - Replaces removed sunonesearch <sigh>. + S - search using w3_custom_search. * google: -g for groups clashed with -g for graphical browser. Invoke groups with -G, -gr, -groups or -search=groups. * mdn: site invokes google custom search via gratuitous javascript, so switch to w3_custom_search. * alioth: changed test to SKIP:, works OK but won't talk to LWP, hence test breaks. * discogs, openbsd: fixed tests. * mdn, mysqldoc, pgdoc, phpdoc: added tests. * w3_custom_search: + document in README. + remove documentation for ixquick support. It still works(ish), but doesn't support enough features to support (eg) mysqldoc -v=. + add -custom-search= commandline option. * updated copyright years to 2013. 2013-09-30 Ian Beckwith <[email protected]> * new elvi: mdn, mysqldoc, pgdoc, phpdoc * new function: w3_custom_search Is used by elvi that use a generic search engine with (eg) site: or inurl: to narrow down the search. Pass it -s=site -u=url for site: and inurl: args plus the quoted search args * new environment variable: SURFRAW_customsearch_provider to set provider used by w3_custom_search can be set to: google, duckduckgo or ixquick. Currently affects: mysqldoc, netbsd(*), openbsd(*), pgdoc, phpdoc, mysqldoc. (*) = only used by some options of elvi. * new internal variable w3_shquoted_args, contains arguments 'quoted' 'like this' for passing to w3_custom_search * Fixed url-encoding for '\' 2013-05-07 Ian Beckwith <[email protected]> * new elvi: jquery 2013-05-04 Ian Beckwith <[email protected]> * bump version to 2.2.9 * rae: fixed, at least as far as the test passing. Could really do with some love from someone who actually speaks spanish. * ctan: fixed search, updated options. Note command-line options have changed. * genportage: switch to gpo.zugaina.org * debcodesearch: new (trivial) elvi for codesearch.debian.net * jamendo: fix url, disable test (search now javascript) * deli: fix url; remove options; disable test (search now javascript) 2013-04-28 Ian Beckwith <[email protected]> * musicbrainz: fixed mbid search. * springer: fixed test. 2013-04-27 Ian Beckwith <[email protected]> * javasun: fixed test. 2013-04-24 Ian Beckwith <[email protected]> * Rewrote deblists for new xapian search. + -author, -lists, -lang no longer supported. + added -ml and -mv to show message id links and list view. * Removed happypenguin. Currently defunct and they are talking about a rewrite, so when it is back it will need fixing anyway. 2012-10-22 Ian Beckwith <[email protected]> * Fixed elvi: cisco, slashdot, slinuxdoc. * Removed elvi: scroogle (site gone). * Fixed tests: acronym, bbcnews, bugzilla, cisco, cite[1], currency, discogs, excite, fsfdir, gcache, github, imdb, ixquick, lastfm, leodict, openbsd[2], scholar. * test/Makefile.am: Added missing tests to EXTRA_DIST 2012-06-28 Manolo Martínez <[email protected]> * examples/hooks.lua: Added elinks integration script 2012-06-28 Ivy Foster <[email protected]> * Further simplified searchable bookmarks 2012-06-28 Thomas Zervogiannis <[email protected]> * Simplified searchable bookmarks 2012-06-27 Ivy Foster <[email protected]> * Fixed arg parsing in searchable bookmarks * New variable: SURFRAW_bookmark_search_elvis + When using searchable bookmarks, if all else fails run this elvis. Defaults to google * Updated manual to reflect changes to bookmarks * duckduckgo: Removed -p option. -safe still works. + Prevents clobbering global option -p[rint]. 2012-06-27 Thomas Zervogiannis <[email protected]> * Added searchable bookmarks + Bookmarks can now be searchable by adding '%s' to the url string. 2012-06-01 Jason Ryan <[email protected]> * New elvi: github (search github.com) 2012-03-17 Ivy Foster <[email protected]> * Fix a typo in duckduckgo code. 2012-03-17 Ivy Foster <[email protected]> * Keep duckduckgo's -l[ucky] from clobbering -lh 2012-01-10 Ivy Foster <[email protected]> * aur: now uses HTTPS by default + On the AUR, connecting via HTTP disables login. + Added switch -no-https to enable connection via plain HTTP 2011-10-10 Ian Beckwith <[email protected]> * surfraw.IN: test_elvi(): tweak sed regex * add tests for f5, cisco and pin. 2011-10-10 Shain Singh <[email protected]> * New elvi: f5, cisco 2011-10-10 Jason Ryan <[email protected]> * New elvi: pin (search pinboard.in). 2011-09-09 Kyle Isom <[email protected]> * New elvi: wolfram - query Wolfram Alpha * Author: Kyle Isom <[email protected]> * Added test for wolfram. 2011-08-09 Ian Beckwith <[email protected]> * New elvi: priberam - search Portuguese dictionary. Author: Paulo Almeida <[email protected]> * Added test for priberam. 2011-07-11 Ian Beckwith <[email protected]> * netbsd: fix normal & mail search. google custom searches were complaining I was a bot, so I switched to normal google searches with site:{mail-index,}.netbsd.org. * cia: fix search URL 2011-06-17 Ian Beckwith <[email protected]> * arxiv: fix -scope=author with single-word queries. Thanks to Nikos Apostolakis. * btw, note about entry below, netbsd make *does* support '$<', but only in suffix rules. 2011-06-16 Ian Beckwith <[email protected]> * Fix more make(1) portability problems. Either I am horribly confused or netbsd make (or at least pmake in debian) doesn't support '$<'. Switched to '$?'. * Also switched submit-lsm rule to '$?'. Thanks to Kyle Isom. * Removed long-obsolete commented-out sourceforge upload rules. 2011-06-15 Ian Beckwith <[email protected]> * scitopia, worldwidescience: fixed URLs. * Fixed make portability problems. We cannot portably combine single suffix rules (foo.IN->foo) and separated dependencies so we have to explicitly specify all the .IN rules. The solution we used for this until now was specific to GNU make. * Removed Makefile.include, no longer used. * './configure --enable-opensearch' now only controls installation of the (direct) dependencies for opensearch, not opensearch itself, as opensearch now falls back to using a remote reflector if opensearch-discover(1) and opensearch-genquery(1) aren't found. * yandex: fix test. 2011-06-14 Ian Beckwith <[email protected]> * musicbrainz, codesearch, rpmsearch: Fixed URLs, options and tests. The sites have all changed significantly which means both new options and no-longer-supported options. Codesearch has gone all ajaxy, so I've implemented the options via the search string, e.g. adding " package:foo". Disabled codesearch.test, as it now needs javascript. Codesearch on both google.com and google.co.uk was acting up, so I've pointed it at google.fr. * Removed filesearching elvi, it now requires a 'Referer:' header to work. There is no browser-portable way to specify a 'Refer[r]er:' header, plus we should probably take it as a hint. * Tweaked debian packaging. * Updated NEWS. 2011-06-13 Ian Beckwith <[email protected]> * w3link: fixed URLs. 2011-06-10 Ian Beckwith <[email protected]> * Fixed ctan. Option -doc has been replaced by -id. Options are no longer mutually exclusive, you can now do (eg) ctan -d -i -n texlive. 2011-06-09 Ian Beckwith <[email protected]> * fixed tests: debwiki, ntrs, wayback. 2011-06-07 Ian Beckwith <[email protected]> * Default to surfraw_graphical_remote=no, as chromium doesn't support "-remote openURL". 2011-05-31 Jason Ryan <[email protected]> * Add options to archpkg. 2011-05-12 Sara Fauzia <[email protected]> * Fix archpkg URL. 2011-05-12 Ian Beckwith <[email protected]> * surfraw.IN: + if elvi doesn't exist, send usage to stderr not stdout. + bookmark names: do exact match not substring match. * Added tests for archwiki, deli & stack. * README: + added INTEGRATION section on uzbl and pentadactyl. + upcased section headings for clarity. 2011-05-12 Jason Ryan <[email protected]> * New elvi: + archwiki: search the arch wiki. + deli: search delicious.com. + stack: search stackoverflow.com and friends. 2011-03-21 Ian Beckwith <[email protected]> * google: Added -safe=default|off|moderate|strict option for Safe Search. 2011-03-21 Ivy Foster <[email protected]> * Added Google Translate to elvi/translate. 2011-03-03 Ian Beckwith <[email protected]> * opensearch: new option -r, uses redirector at http://erislabs.net/ianb/webtools/opensearch/ instead of calling opensearch-discover and opensearch-genquery. -r is selected automatically if those tools are not installed. This enables us to ship opensearch in the main surfraw package and it still functions if the dependencies are not installed. See debian/changelog. * wikipedia: new options: + -d, uses a redirector at http://erislabs.net/ianb/webtools/wpdp/ This redirector searches for a page with that name at wikipedia. If not found, it searches deletionpedia, if not found there it falls back to a normal wikipedia search. + -f=w|d, -fallback=wikipedia|deletionpedia Implies -d. If page not found at either wikipedia or deletionpedia, whether to fallback to wikipedia search or deletionpedia search. * google: + support video, maps and news. + new options -i, -v, -m, -n, shortcuts for -search={images,videos,maps,news}. * debcontents, debpackages: update docs for new arches and distributions. * bugzilla: + fix url so it works with redhat & eclipse bugzillas too. + enable -s=redhat. * ixquick, w3css: fix tests. * opensearch, wikipedia: add redirector tests. 2011-02-20 Ian Beckwith <[email protected]> * New elvi: bugzilla - searches various bugzillas, defaults to kernel. * pgpkeys: add more options, support more keyservers, default to sks-keyservers.net. * bump version to 2.2.8. * test/Makefile.am: add cablesearch.test. 2011-02-19 Ian Beckwith <[email protected]> * lastfm: fix url to avoid a redirect that mangled args with spaces. * debbugs: add -s as an alias for -search=src. * surfraw.IN: (finally) update copyright year to 2011. * remove traces of port elvi from build system. 2011-02-09 Kyle Isom <[email protected]> * fix a number of tests to match current site formats 2011-01-12 Kyle Isom <[email protected]> * New elvi: + cablesearch - search wikileaks cables + duckduckgo - replace with better implementation + openports - search openbsd ports 2010-12-04 Jakob <[email protected]> * new elvis: pasearch. 2010-12-08 Ian Beckwith <[email protected]> * arxiv: Thanks to MT <[email protected]> for patch that fixes: 1. Search queries with more than two terms would fail, e.g. 'supermassive black hole'. 2. Full text search was broken, it works now. 3. Enhancement: quoting the query now does an exact string match. 2010-10-29 Ian Beckwith <[email protected]> * wayback: advanced search is broken, rip out all options and use basic search. * w3_url_escape: add /g to '/'->'%2F' replacement. * uzbl_load_url_from_surfraw: use @AWK@ to pick up ./configure's choice of awk implementation. 2010-10-28 Ian Beckwith <[email protected]> * Support -local-help, --local-help or -lh to get elvi-specific help without displaying the global options. This works for all elvi and the main surfraw script. * google, duckduckgo, opensearch, wayback: tweak overbroad option parsing so it doesn't interfere with -lh. * Support -h as a synonym for -help. 2010-10-25 Ian Beckwith <[email protected]> * new elvi: scirus, scitopia, worldwidescience. * yahoo: reduced query string to just p and n options. * openbsd: support -misc and -tech. Thanks to Sunil Nimmagadda for the patch. * removed cddb: gracenote made the "hard decision" to remove the website search. sigh. * removed altavista: is now just a front-end to yahoo. * removed fast: another yahoo front-end. * imdb: fix test. * javasun: oracleized URLs. * w3link: fixed URL. 2010-08-22 Jameson Rollins <[email protected]> * surfraw.IN: Improve listing of elvi. 2010-08-20 James Rowe <[email protected]> * new elvi: ads. Thanks to Jameson Rollins. 2010-07-02 Ian Beckwith <[email protected]> * new elvi: yandex. Thanks to Uspenskiy Andrey. 2010-05-06 Ian Beckwith <[email protected]> * uzbl_load_url_from_surfraw: fix menu. Thanks to Sumant Oemrawsingh. * Fixed tests: deblists google openbsd. 2010-04-28 Ian Beckwith <[email protected]> * configure.in: test for google-chrome, opera and links2. 2010-04-22 Ian Beckwith <[email protected]> * debwiki: remove -w, Debian Women wiki is now being merged into main wiki. Thanks to Simone Fittabile. * debwiki.test: stop testing -w option. * surfraw.IN: change an awk to @AWK@. 2010-04-21 Ian Beckwith <[email protected]> * New elvi: jamendo - Search Jamendo: free music with Creative Commons licenses (www.jamendo.com). Thanks to Simone Fittabile. * wikipedia, ixquick: Support https. Thanks to Simone Fittabile. * wikipedia: tweak Simone's patch to support https for start page and document the SURFRAW_wikipedia_ssl variable. * ixquick: add -nossl option. * javasun.test: revert to previous test, works again. 2010-04-19 James Rowe <[email protected]> * genpkg: removed, use genportage. 2010-04-16 Ian Beckwith <[email protected]> * New elvi: + scroogle: Search Google anonymously via www.scroogle.org. + duckduckgo: Search the web via duckduckgo.com. * Fix tests: excite, javasun, musicbrainz, yahoo. 2010-03-03 James Rowe <[email protected]> * bookfinder: fix ISBN search test. 2010-03-01 Ian Beckwith <[email protected]> * Removed autotools-generated files from git repo use ./prebuild to regenerate. * Lower required automake version to 1.10. * prebuild: try and find a sane set of autotools, then call autoreconf -vi * Add autotools-generated files to .gitignore * Bump version to 2.2.7 * cnn: fix URL. * cnn.test: Disable. Bloody CNN now needs javascript for search, so should be tested manually. * W, yahoo: fix tests. * Remove unused '-quiet' option. * Update AUTHORS. * Add a note to appendix 1 of HACKING about updating AUTHORS. * runtests: explicitly use elvi and config from source tree, now works when surfraw is not installed (but you need to have run make). * test/Makefile.am: fix bookfinder typo, add bing.test. * remove leading 'sr ' from command lines for following tests: acronym aur bing cliki gcache genportage google javasun l1sp lsm mathworld mininova piratebay youtube * HACKING, README, test/README: document autotools and test suite changes. * Makefile.am: add surfraw.conf to BUILT_SOURCES so it is made by 'make'. This may be a misuse of BUILT_SOURCES. 2010-02-22 Ivy Foster <[email protected]> * Added `-ns|-newscreen' switch for setting $SURFRAW_new_screen. 2010-02-15 James Rowe <[email protected]> * elvi/imdb: Fixes for upstream search changes. Thanks to Sadako. * New elvi: bookfinder, thanks to Ivy Foster. 2010-02-14 James Rowe <[email protected]> * Added $SURFRAW_screen_args for passing arguments to the defined screen tool, thanks to Ivy Foster. * Support for using tmux as $SURFRAW_screen, thanks once again to Ivy Foster. * New elvi: bugmenot, thanks to Ivy Foster. diff --git a/README b/README index ac4f0bc..f6ac9a7 100644 --- a/README +++ b/README @@ -1,401 +1,402 @@ Surfraw - Shell Users' Revolutionary Front Rage Against the Web Home Page: http://surfraw.alioth.debian.org ______ _ _ ______ _______ ______ _______ _ _ _ / _____)(_) (_)(_____ \ (_______)(_____ \ (_______)(_)(_)(_) ( (____ _ _ _____) ) _____ _____) ) _______ _ _ _ \____ \ | | | || __ / | ___) | __ / | ___ || || || | _____) )| |___| || | \ \ | | | | \ \ | | | || || || | (______/ \_____/ |_| |_||_| |_| |_||_| |_| \_____/ Surfraw - Shell Users' Revolutionary Front Rage Against the Web New: http://surfraw.alioth.debian.org Old: http://surfraw.sourceforge.net/ Oh Baybe I need some Deep Linking Let us go Surfin' in the raw! Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell. Surfraw abstracts the browser away from input. Doing so lets it get on with what it's good at. Browsing. Interpretation of linguistic forms is handed back to the shell, which is what it, and human beings are good at. Combined with netscape-remote or incremental text browsers, such as links (http://artax.karlin.mff.cuni.cz/~mikulas/links/), w3m (http://www.w3m.org/), and screen(1) a Surfraw liberateur is capable of navigating speeds that leave GUI tainted idolaters agape with fear and wonder. Surfraw consists of a collection of elvi, each of which knows how to search a specific web site. To see the list of elvi type: surfraw -elvi Note that sr is an alias for surfraw, so that could equally be sr -elvi To search using an elvis use: sr elviname [options] search terms.. For example, to search google for information on Debian ports, using the "I'm feeling lucky" option: sr google -l debian ports Note that putting quotes round arguments works now, so you can do, for example: sr google foo "bar baz" bam and the quoting is passed on to the search engine. ADDING THE ELVI TO YOUR PATH If you are a regular user of surfraw, you will probably get sick of typing sr or surfraw each time. You can regain the old behaviour of running the elvi directly by adding the elvi directory (usually /usr/lib/surfraw or /usr/local/lib/surfraw/) to your path, either manually or using surfraw-update-path(1). CONFIG FILES Surfraw implements the XDG basedir spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) Essentially this means global config will be in /etc/xdg/surfraw/ and local config will be in $HOME/.config/surfraw/. This can be modified by setting $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME, see the spec for more details. If your system has a different sysconfdir set during configure, that will be used instead of /etc (for instance, /usr/local/etc). In the documentation below, only the default paths will be referred to. LOCAL ELVI Surfraw can use your own private elvi, store them in $HOME/.config/surfraw/elvi/. Local elvi will be listed separately at the end of 'surfraw -elvi'. Use existing elvi (e.g. google) as a template. If you think your elvi may be useful to others, consider submitting them to [email protected]. BOOKMARKS Surfraw now supports bookmarks. To add a bookmark, add it to to the global bookmark list in /etc/xdg/surfraw/bookmarks or to your personal bookmark list in $HOME/.config/surfraw/bookmarks The format of the bookmarks file is simple, each bookmark is on a separate line, with the bookmark and URL separated by whitespace, eg: ntk http://www.ntk.net/ To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead. There are some example bookmarks in /etc/xdg/surfraw/bookmarks CUSTOM SEARCH Several elvi use a search engine with site: and inurl: keywords. The search engine used can be customized by setting the environment variable SURFRAW_customsearch_provider or using the command-line argument -customsearch= Currently google and duckduckgo are supported Examples: SURFRAW_customsearch_provider=duckduckgo sr mysqldoc -v=5.5 select sr pgdoc -customsearch=google -v=9.1 select The default is to use duckduckgo. Currently affected elvi: mdn mysqldoc netbsd openbsd pgdoc slinuxdoc INSTALLATION Surfraw is installed with the standard ./configure; make; make install procedure. See INSTALL for more details. If you obtained surfraw direct from the git repository rather than a release tarball, run ./prebuild to generate the autotools build files *before* running ./configure. Note that the opensearch elvis depends on the perl libraries WWW::OpenSearch, HTML::Parser and LWP (libwww-perl). If you don't want to install opensearch, use ./configure --disable-opensearch. Surfraw supports the following options to ./configure: --with-text-browser=BROWSER Use BROWSER as text-mode browser --with-graphical-browser=BROWSER Use BROWSER as graphical-mode browser --with-elvidir=DIR Use DIR as location for storing elvi --disable-opensearch Disable OpenSearch support --disable-sr Disable installing sr alias By default, the text and graphical browsers are detected from a list of installed browsers at configure time. elvidir defaults to $(libdir)/surfraw (probably /usr/local/lib/surfraw). EXAMPLES $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin? $ sr wikipedia surfraw $ sr austlii -method=phrase dog like $ /usr/lib/surfraw/rhyme -method=perfect Julian OPTIONS Global options are common to all Surfraw elvi (clients). You can get a list of the currently installed elvi by just typing `surfraw -elvi'. For example: $ surfraw -elvi GLOBAL ELVI: W -- Activate Surfraw defined web-browser acronym -- Look for acronyms definitions (www.acronymfinder.com) ads -- Search SAO/NASA Astrophysics Data System alioth -- Search Alioth (alioth.debian.org) amazon -- Search the amazon.com bookstore archpkg -- Search Arch Linux Packages (www.archlinux.org/packages/) archwiki -- Search the Arch Linux Wiki arxiv -- Search arXiv E-Print Archive for articles ask -- Question the web using Ask Jeeves (www.ask.com) aur -- Search aur.archlinux.org for PKGBUILDs austlii -- Search Australian Law docs (www.austlii.edu.au) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) bookfinder -- Search for books using www.bookfinder.com bugmenot -- Bypass compulsory web registration with bugmenot.com bugzilla -- Search for bugs on Bugzilla bugtrackers cablesearch -- search for leaked diplomatic communications cia -- Search CIA documents at www.cia.gov cisco -- Search Cisco documentation (www.cisco.com) cite -- Search computer science papers (citeseerx.ist.psu.edu) cliki -- Search the common lisp wiki cnn -- Search on CNN (cnn.com) comlaw -- Search Australian Law using Comlaw (www.comlaw.gov.au) commandlinefu -- Search on www.commandlinefu.com ctan -- Search the Comprehensive TeX Archive Network (ctan.org) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) cve -- Search for CAN assignments in CVE debbugs -- Search the debian BTS (bugs.debian.org) debcodesearch -- Search debian source code debcontents -- Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) deblists -- Search debian mailing lists (lists.debian.org/search.html) deblogs -- Show changelogs for a package in Debian main (changelogs.debian.net) debpackages -- Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com) debpkghome -- Visit the home page for a Debian package debpts -- Search the Debian Package Tracking System (packages.qa.debian.org) debsec -- Search the Debian Security Tracker for CVE ids or package names debvcsbrowse -- Browse the VCS repository for a Debian package debwiki -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki) deja -- Search usenet using Google Groups (groups.google.com) deli -- Search Delicious bookmarks discogs -- Search the Discogs database of music information (www.discogs.com) dmoz -- Search the Open Directory Project web directory (dmoz.org) duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) ebay -- Search the Ebay auction site etym -- Look up word origins at www.etymonline.com excite -- Search on Excite (www.excite.com) f5 -- Search F5 related information (www.f5.com) finkpkg -- Search Fink packages (pdb.finkproject.org) foldoc -- The Free On-Line Dictionary Of Computing (foldoc.org) freebsd -- Search FreeBSD related information (www.freebsd.org) freedb -- Search for cd track listings in FreeDB (www.freedb.org) freshmeat -- Search Freshmeat (www.freshmeat.net) fsfdir -- Search the FSF/UNESCO Free Software Directory (directory.fsf.org) gcache -- Search the web using Google cache (www.google.com) genbugs -- Search the Gentoo bug tracker (bugs.gentoo.org) genportage -- Search gentoo-portage.com for packages github -- Search GitHub (https://github.com) gmane -- Search mailing list with gmane (gmane.org) google -- Search the web using Google (www.google.com) gutenberg -- Search for books on Project Gutenberg (gutenberg.org) imdb -- Search the Internet Movie Database (www.imdb.com) ixquick -- Search the web using ixquick [HTTPS] (www.ixquick.com) jamendo -- Search Jamendo: free music with Creative Commons licenses (www.jamendo.com) javasun -- Search Java API docs (java.sun.com) jquery -- Search the jQuery documentation (api.jquery.com) l1sp -- Search lisp documentation lastfm -- Search last.fm leodict -- Search Leo's German <-> English dictionary (dict.leo.org) lsm -- Search the Linux Software Map macports -- Search macports packages (macports.org) mathworld -- Search Wolfram MathWorld mdn -- Search the mozilla developer network (developer.mozilla.org) mininova -- Search the mininova bittorent source. musicbrainz -- Search MusicBrainz (musicbrainz.org) mysqldoc -- Search mysql documentation (dev.mysql.com) netbsd -- Search NetBSD related information (www.netbsd.org) nlab -- Search the nLab wiki (http://ncatlab.org) ntrs -- Search the NASA Technical Report Server openbsd -- Search OpenBSD related information (www.openbsd.org) openports -- search openports for OpenBSD packages opensearch -- Search an OpenSearch-enabled website oraclesearch -- Search an OpenSearch-enabled website pasearch -- Search the unofficial Penny Arcade archives (pipefour.org/pa) pgdoc -- Search postgres documentation (www.pgdoc.com) pgpkeys -- Search the PGP key database phpdoc -- Search php documentation (php.net) pin -- Search Pinboard bookmarks (http://pinboard.in) piratebay -- Search The Pirate Bay (http://thepiratebay.org) priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo) pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov) rae -- Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary) rfc -- Search RFCs (internet standards documents) rhyme -- Search for rhymes et al using Lycos Rhyme (rhyme.lycos.com) rpmsearch -- Search for RPMs in various distros scholar -- Search Google Scholar (scholar.google.com) scicom -- Search Scientific Commons scirus -- Search for science using Scirus (scirus.com) scpan -- Search the Comprehensive Perl Archive Network (search.cpan.org) +searx -- Search using searx metasearch engine instances (searx.me) slashdot -- Search stories on Slashdot (www.slashdot.org) slinuxdoc -- Search entries in LDP (www.linuxdoc.org) sourceforge -- Search SourceForge (www.sourceforge.net) springer -- Search Springer for Books and Articles stack -- Search Stack Overflow stockquote -- Get a single stock quote (multiple providers) thesaurus -- Look up word in Merriam-Webster's Thesaurus (www.m-w.com) translate -- Translate human languages urban -- Search urbandictionary.com for a definition w3css -- Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator) w3html -- Validate a web page URL with the w3c validator (validator.w3.org) w3link -- Check web page links with the w3c linkchecker (validator.w3.org/checklink) w3rdf -- Validate a RDF URL with the w3c RDF validator (validator.w3.org) wayback -- Search The Internet Archive's Wayback Machine for a URL (archive.org) webster -- Look up word in Merriam-Webster's Dictionary (www.m-w.com) wetandwild -- Real time weather information (many sources) wikipedia -- Search the free encyclopedia wikipedia woffle -- Search the web using Woffle (localhost:8080) wolfram -- Ask questions of the computational knowledge engine worldwidescience -- Search for science with www.worldwidescience.org yacy -- Search YaCy P2P search, including ScienceNet yahoo -- Search Yahoo categories (www.yahoo.com) yandex -- Search the web using Yandex (yandex.ru) youtube -- Search YouTube (www.youtube.com) yubnub -- Use the social command-line for the web (yubnub.org) All elvi have useful low calorie help, for example: Usage: rhyme [options] [search words]... Description: Surfraw search for rhymes and other word correlations using Lycos Rhyme (rhyme.lycos.com) Example: $ rhyme Julian $ rhyme -method=rel surfer Results: Hurclean St. Julien. surfboarder, bather, natator, swimmer Local options: -method= Type of word correlation to search for prefect | Perfect rhyme syn | Synonyms hom | Homophones cons | Consonsant rhymes only rel | Semantically related words sub | Phrases spell | Similar spellings pic | Pictures shake | Match with Shakespeare archives def Find wordnet definition Default: perfect Environment: SURFRAW_rhyme_method Global options: -browser=EXECUTABLE Set browser Default: sensible-browser -elvi List Surfraw mechanisms for conquering evil -escape-url-args=yes|no Apply url escaping to arguments Default: yes Environment: SURFRAW_escape_url_args -g | -graphical Get some windowed sin Default: yes Environment: SURFRAW_graphical -help What you're reading now, dude -lh | -local-help Just show elvi-specific help, not the global options -p | -print Just print search URL, don't pass to browser -o | -o=FILE Fetch URL and dump to stdout or FILE. -new[=yes|no] Start in a new window Default: no Environment: SURFRAW_new_window -t | -text Back to the yellow brick road -q | -quote Quote arguments with " characters Default: no Environment: SURFRAW_quote_args -version Display Surfraw version (2.2.7) -- End of options Copyright: Copyright (c) 2003-2013 The Surfraw-Devel Team <[email protected]> Copyright (c) 2000-2001 Julian Assange <[email protected]> Copyright (c) 2001 Australian Institute for Collaborative Research Copyright (c) 2000 Melbourne Institute for Advanced Study If you just want to see the elvi-specific help, use elvi -lh or -local-help. The system wide configuration file can usually be found in /etc/xdg/surfraw/conf (but see 'Config files' above). This can be overridden by setting the environment variable SURFRAW_global_conf. Each user can also specify their own overrides, usually in $HOME/.config/surfraw/conf (again, see 'Config files' above). This can be overridden by setting SURFRAW_conf, either in the environment or the global config file. e.g SURFRAW_graphical_remote=yes SURFRAW_graphical_browser=mozilla SURFRAW_text_browser=w3m SURFRAW_pgpkeys_sigs=on INTEGRATION There is a browser plugin for Pentadactyl (a vimperator fork) at http://code.google.com/p/dactyl/issues/detail?id=320 For details, see: http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-April/000916.html Code to integrate with uzbl is in examples/uzbl_load_url_from_surfraw RADICALIZATION Read HACKING. Surfrawize the soul of your favourite internet wonder. Join the Shell Users' Revolutionary Front Against the WWW by submitting code. Reclaim heathen lands. Bear witness to the truth. Its love will set you free. Join us on [email protected] _________________________________________________________________ README originally by Julian Assange Updated by Ian Beckwith _________________________________________________________________ See NEWS, and ChangeLog for a summary of changes. _________________________________________________________________ diff --git a/elvi/Makefile.am b/elvi/Makefile.am index 6dec47e..44527e2 100644 --- a/elvi/Makefile.am +++ b/elvi/Makefile.am @@ -1,131 +1,132 @@ # $Id$ elvidir=$(ELVIDIR) dist_elvi_SCRIPTS = \ S \ W \ acronym \ ads \ alioth \ amazon \ archpkg \ archwiki \ arxiv \ ask \ aur \ austlii \ bing \ bbcnews \ bookfinder \ bugmenot \ bugzilla \ cablesearch \ cia \ cisco \ cite \ cliki \ cnn \ comlaw \ commandlinefu \ ctan \ currency \ cve \ debbugs \ debcodesearch \ debcontents \ deblists \ deblogs \ debpackages \ debpkghome \ debpts \ debsec \ debvcsbrowse \ debwiki \ deja \ deli \ discogs \ dmoz \ duckduckgo \ ebay \ etym \ excite \ f5 \ foldoc \ finkpkg \ freebsd \ freedb \ freshmeat \ fsfdir \ gcache \ genbugs \ genportage \ github \ gmane \ google \ gutenberg \ imdb \ ixquick \ jamendo \ javasun \ jquery \ l1sp \ lastfm \ leodict \ lsm \ macports \ mathworld \ mdn \ mininova \ musicbrainz \ mysqldoc \ netbsd \ nlab \ ntrs \ openbsd \ openports \ opensearch \ oraclesearch \ pasearch \ pgdoc \ pgpkeys \ phpdoc \ pin \ piratebay \ priberam \ pubmed \ rae \ rfc \ rhyme \ rpmsearch \ scholar \ scicom \ scirus \ scpan \ + searx \ slashdot \ slinuxdoc \ sourceforge \ springer \ stack \ stockquote \ thesaurus \ translate \ urban \ w3css \ w3html \ w3link \ w3rdf \ wayback \ webster \ wetandwild \ wikipedia \ woffle \ wolfram \ worldwidescience \ yacy \ yahoo \ yandex \ youtube \ yubnub uninstall-local: -rmdir $(DESTDIR)$(PREFIX)/$(ELVIDIR) diff --git a/elvi/searx b/elvi/searx new file mode 100755 index 0000000..d8c5010 --- /dev/null +++ b/elvi/searx @@ -0,0 +1,87 @@ +#!/bin/sh +# elvis: searx -- Search using searx metasearch engine instances (https://searx.me and others) +# author: krosos -- contact: krosos.sdf.org +# 2015-08-04 + +. surfraw || exit 1 + +w3_config_hook () { + def SURFRAW_searx_categories "$SURFRAW_categories" + def SURFRAW_searx_base_url "$SURFRAW_url" +} + +w3_usage_hook () { + cat <<EOF + +Usage: $w3_argv0 [options] [search words]... +Description: + Use the searx metasearch engine + + -category,c=CATEGORIES + + Local options: + default | search category "general" (default) + vid | search category "videos" + socialm | search category "social+media" + news | search category "news" + music | search category "music" + map | search category "map" + it | search category "it" + img | search category "images" + files | search category "files" + Default: general + + -url,u=URL + + Local options: + 1 | https://searx.me + 2 | https://searx.laquadrature.net + 3 | https://www.privatesearch.io + o1 | http://searchb5a7tmimez.onion (laquadrature) + o2 | http://ulrn6sryqaifefld.onion (searx.me) + cjdns | fc00:59dd:3bb2:d592:4083:c138:5489:560a + Default: https://searx.me + +EOF + w3_global_usage +} + +w3_parse_option_hook () { + opt="$1" + optarg="$2" + case "$opt" in + -c*=*) setopt SURFRAW_searx_categories $optarg ;; + -u*=*) setopt SURFRAW_searx_base_url $optarg ;; + *) return 1 ;; + esac + return 0 +} + +w3_config +w3_parse_args "$@" + +case "$SURFRAW_searx_categories" in + default*) category="general" ;; + vid*) category="videos" ;; + socialm*) category="social+media" ;; + news*) category="news" ;; + music*) category="music" ;; + map*) category="map" ;; + it*) category="it" ;; + img*) category="images" ;; + files*) category="files" ;; + *) category="general" ;; +esac +case "$SURFRAW_searx_base_url" in + 1*) searx_url="https://searx.me" ;; + 2*) searx_url="https://searx.laquadrature.net" ;; + 3*) searx_url="https://www.privatesearch.io" ;; + o1*) searx_url="http://searchb5a7tmimez.onion" ;; + o2*) searx_url="http://ulrn6sryqaifefld.onion" ;; + cjdns*) searx_url="fc00:59dd:3bb2:d592:4083:c138:5489:560a" ;; + *) searx_url="https://searx.me" ;; +esac +# w3_args now contains a list of arguments +escaped_args=$(w3_url_of_arg $w3_args) + +w3_browse_url "${searx_url}/?q=${escaped_args}&categories=${category}" diff --git a/links.IN b/links.IN index 80db370..bd9170a 100644 --- a/links.IN +++ b/links.IN @@ -1,119 +1,120 @@ elvi.1sr.gz @mandir@/man1/W.1.gz elvi.1sr.gz @mandir@/man1/S.1sr.gz elvi.1sr.gz @mandir@/man1/acronym.1sr.gz elvi.1sr.gz @mandir@/man1/ads.1sr.gz elvi.1sr.gz @mandir@/man1/alioth.1sr.gz elvi.1sr.gz @mandir@/man1/amazon.1sr.gz elvi.1sr.gz @mandir@/man1/archpkg.1sr.gz elvi.1sr.gz @mandir@/man1/archwiki.1sr.gz elvi.1sr.gz @mandir@/man1/arxiv.1sr.gz elvi.1sr.gz @mandir@/man1/ask.1sr.gz elvi.1sr.gz @mandir@/man1/aur.1sr.gz elvi.1sr.gz @mandir@/man1/austlii.1sr.gz elvi.1sr.gz @mandir@/man1/bing.1sr.gz elvi.1sr.gz @mandir@/man1/bbcnews.1sr.gz elvi.1sr.gz @mandir@/man1/bookfinder.1sr.gz elvi.1sr.gz @mandir@/man1/bugmenot.1sr.gz elvi.1sr.gz @mandir@/man1/bugzilla.1sr.gz elvi.1sr.gz @mandir@/man1/cablesearch.1sr.gz elvi.1sr.gz @mandir@/man1/cite.1sr.gz elvi.1sr.gz @mandir@/man1/cia.1sr.gz elvi.1sr.gz @mandir@/man1/cliki.1sr.gz elvi.1sr.gz @mandir@/man1/cnn.1sr.gz elvi.1sr.gz @mandir@/man1/comlaw.1sr.gz elvi.1sr.gz @mandir@/man1/commandlinefu.1sr.gz elvi.1sr.gz @mandir@/man1/ctan.1sr.gz elvi.1sr.gz @mandir@/man1/currency.1sr.gz elvi.1sr.gz @mandir@/man1/cve.1sr.gz elvi.1sr.gz @mandir@/man1/debbugs.1sr.gz elvi.1sr.gz @mandir@/man1/debcodesearch.1sr.gz elvi.1sr.gz @mandir@/man1/debcontents.1sr.gz elvi.1sr.gz @mandir@/man1/deblists.1sr.gz elvi.1sr.gz @mandir@/man1/deblogs.1sr.gz elvi.1sr.gz @mandir@/man1/debpackages.1sr.gz elvi.1sr.gz @mandir@/man1/debpkghome.1sr.gz elvi.1sr.gz @mandir@/man1/debpts.1sr.gz elvi.1sr.gz @mandir@/man1/debsec.1sr.gz elvi.1sr.gz @mandir@/man1/debvcsbrowse.1sr.gz elvi.1sr.gz @mandir@/man1/debwiki.1sr.gz elvi.1sr.gz @mandir@/man1/deja.1sr.gz elvi.1sr.gz @mandir@/man1/deli.1sr.gz elvi.1sr.gz @mandir@/man1/discogs.1sr.gz elvi.1sr.gz @mandir@/man1/dmoz.1sr.gz elvi.1sr.gz @mandir@/man1/duckduckgo.1sr.gz elvi.1sr.gz @mandir@/man1/ebay.1sr.gz elvi.1sr.gz @mandir@/man1/etym.1sr.gz elvi.1sr.gz @mandir@/man1/excite.1sr.gz elvi.1sr.gz @mandir@/man1/finkpkg.1sr.gz elvi.1sr.gz @mandir@/man1/foldoc.1sr.gz elvi.1sr.gz @mandir@/man1/freebsd.1sr.gz elvi.1sr.gz @mandir@/man1/freedb.1sr.gz elvi.1sr.gz @mandir@/man1/freshmeat.1sr.gz elvi.1sr.gz @mandir@/man1/fsfdir.1sr.gz elvi.1sr.gz @mandir@/man1/gcache.1sr.gz elvi.1sr.gz @mandir@/man1/genbugs.1sr.gz elvi.1sr.gz @mandir@/man1/genportage.1sr.gz elvi.1sr.gz @mandir@/man1/github.1sr.gz elvi.1sr.gz @mandir@/man1/google.1sr.gz elvi.1sr.gz @mandir@/man1/gutenberg.1sr.gz elvi.1sr.gz @mandir@/man1/imdb.1sr.gz elvi.1sr.gz @mandir@/man1/ixquick.1sr.gz elvi.1sr.gz @mandir@/man1/jamendo.1sr.gz elvi.1sr.gz @mandir@/man1/javasun.1sr.gz elvi.1sr.gz @mandir@/man1/lastfm.1sr.gz elvi.1sr.gz @mandir@/man1/leodict.1sr.gz elvi.1sr.gz @mandir@/man1/l1sp.1sr.gz elvi.1sr.gz @mandir@/man1/lsm.1sr.gz elvi.1sr.gz @mandir@/man1/macports.1sr.gz elvi.1sr.gz @mandir@/man1/mathworld.1sr.gz elvi.1sr.gz @mandir@/man1/mdn.1sr.gz elvi.1sr.gz @mandir@/man1/mininova.1sr.gz elvi.1sr.gz @mandir@/man1/musicbrainz.1sr.gz elvi.1sr.gz @mandir@/man1/mysqldoc.1sr.gz elvi.1sr.gz @mandir@/man1/netbsd.1sr.gz elvi.1sr.gz @mandir@/man1/ntrs.1sr.gz elvi.1sr.gz @mandir@/man1/openbsd.1sr.gz elvi.1sr.gz @mandir@/man1/openports.1sr.gz elvi.1sr.gz @mandir@/man1/opensearch.1sr.gz elvi.1sr.gz @mandir@/man1/oraclesearch.1sr.gz elvi.1sr.gz @mandir@/man1/pasearch.1sr.gz elvi.1sr.gz @mandir@/man1/pgdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pgpkeys.1sr.gz elvi.1sr.gz @mandir@/man1/phpdoc.1sr.gz elvi.1sr.gz @mandir@/man1/pin.1sr.gz elvi.1sr.gz @mandir@/man1/piratebay.1sr.gz elvi.1sr.gz @mandir@/man1/priberam.1sr.gz elvi.1sr.gz @mandir@/man1/pubmed.1sr.gz elvi.1sr.gz @mandir@/man1/rae.1sr.gz elvi.1sr.gz @mandir@/man1/rfc.1sr.gz elvi.1sr.gz @mandir@/man1/rhyme.1sr.gz elvi.1sr.gz @mandir@/man1/rpmsearch.1sr.gz elvi.1sr.gz @mandir@/man1/scholar.1sr.gz elvi.1sr.gz @mandir@/man1/scicom.1sr.gz elvi.1sr.gz @mandir@/man1/scirus.1sr.gz elvi.1sr.gz @mandir@/man1/scpan.1sr.gz +elvi.1sr.gz @mandir@/man1/searx.1sr.gz elvi.1sr.gz @mandir@/man1/slashdot.1sr.gz elvi.1sr.gz @mandir@/man1/slinuxdoc.1sr.gz elvi.1sr.gz @mandir@/man1/sourceforge.1sr.gz elvi.1sr.gz @mandir@/man1/springer.1sr.gz elvi.1sr.gz @mandir@/man1/stack.1sr.gz elvi.1sr.gz @mandir@/man1/stockquote.1sr.gz elvi.1sr.gz @mandir@/man1/thesaurus.1sr.gz elvi.1sr.gz @mandir@/man1/translate.1sr.gz elvi.1sr.gz @mandir@/man1/urban.1sr.gz elvi.1sr.gz @mandir@/man1/w3css.1sr.gz elvi.1sr.gz @mandir@/man1/w3html.1sr.gz elvi.1sr.gz @mandir@/man1/w3link.1sr.gz elvi.1sr.gz @mandir@/man1/w3rdf.1sr.gz elvi.1sr.gz @mandir@/man1/wayback.1sr.gz elvi.1sr.gz @mandir@/man1/webster.1sr.gz elvi.1sr.gz @mandir@/man1/wetandwild.1sr.gz elvi.1sr.gz @mandir@/man1/wikipedia.1sr.gz elvi.1sr.gz @mandir@/man1/woffle.1sr.gz elvi.1sr.gz @mandir@/man1/wolfram.1sr.gz elvi.1sr.gz @mandir@/man1/worldwidescience.1sr.gz elvi.1sr.gz @mandir@/man1/yacy.1sr.gz elvi.1sr.gz @mandir@/man1/yahoo.1sr.gz elvi.1sr.gz @mandir@/man1/yandex.1sr.gz elvi.1sr.gz @mandir@/man1/youtube.1sr.gz elvi.1sr.gz @mandir@/man1/yubnub.1sr.gz diff --git a/test/searx.test b/test/searx.test new file mode 100644 index 0000000..df64dfe --- /dev/null +++ b/test/searx.test @@ -0,0 +1,7 @@ +searx surfraw +Shell Users Revolutionary Front Rage Against the Web +searx -c=music john coltrane +Giant Steps +searx -u=3 -c=vid rick astley +Never Gonna Give You Up +