git: 9front

Download patch

ref: 9bf140a3503d9001f9f17d2c44ca1eab47be0f16
parent: a1f8c46a3822674e4439e6fd9d5bf89608b6ba08
author: stanley lieber <stanley.lieber@gmail.com>
date: Tue Sep 27 08:54:39 EDT 2011

mothra: add menu option to save url

--- a/sys/man/1/mothra
+++ b/sys/man/1/mothra
@@ -91,6 +91,10 @@
 .B paste
 Paste the current snarf buffer at the current cursor position.
 .TP
+.B save url
+Save the currently selected URL as a file. Directory indexes are saved in a file named
+.I index.
+.TP
 .B save hit
 Save the current URL to the hit list.
 .TP
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -92,6 +92,7 @@
 	"alt display",
 	"snarf url",
 	"paste",
+	"save url",
 	"save hit",
 	"hit list",
 	"exit",
@@ -1048,6 +1049,7 @@
 }
 void hit3(int button, int item){
 	char name[NNAME];
+	char file[128];
 	Panel *swap;
 	int fd;
 	USED(button);
@@ -1073,6 +1075,16 @@
 		paste(cmd);
 		break;
 	case 3:
+		if(strrchr(selection->reltext, '/')){
+			snprint(file, sizeof(file), "%s", strrchr(selection->reltext, '/')+1);
+			if(file[0]==0)
+				strcpy(file, "index");
+		} else
+			snprint(file, sizeof(file), "%s", selection->reltext);
+		save(selection, file);
+		message("saved %s", file);
+		break;
+	case 4:
 		snprint(name, sizeof(name), "%s/hit.html", home);
 		fd=open(name, OWRITE);
 		if(fd==-1){
@@ -1089,11 +1101,11 @@
 			selection->fullname, selection->fullname);
 		close(fd);
 		break;
-	case 4:
+	case 5:
 		snprint(name, sizeof(name), "file:%s/hit.html", home);
 		geturl(name, GET, 0, 1, 0);
 		break;
-	case 5:
+	case 6:
 		if(confirm(3)){
 			draw(screen, screen->r, display->white, 0, ZP);
 			exits(0);
--