On Tue, Oct 09, 2001 at 03:46:52PM +0300, Mikko Kurki-Suonio wrote:
> > To me that sounds like a logical combination of -r -np -p?
> > Any correction appreciated.
>
> Doesn't work, apparently because -np overrides -p.
>
> I.e. with -np set, no document outside the selected subtree will be
> loaded, whether it is referred to through regular link-traversal or as a
> page-requisite element.
>
> My guess is that -p adds those links to the list of documents to load, but
> -np later rejects them because they're not within the selected subtree.
>
> What I'd basically like is a setting that loads page-requisites REGARDLESS
> OF ALL OTHER SETTINGS. I.e. you use the myriad of settings to fine tune
> the exact set of pages requested, and then request "all requisites for the
> selected set of pages".
Try this patch. It should make -p _always_ get pre-requisites,
even if you have -np on (which was the reason why i wrote the
patch). I originally wrote it against 1.6, but I'm pretty sure
(99%) that it still works now. If you do try it, can you let me
know how it goes?
I've had it floating around for quite a while now, but I haven't
committed it to the CVS tree yet because I haven't bothered to
clean it up yet. You'll need to get wget from CVS and apply this
patch; I think I have a patch against the 1.7 series too floating
around somewhere :). I'll have a look for it if you want that one
instead.
--
#ozone/algorithm <[EMAIL PROTECTED]> - trust.in.love.to.save
diff -u -r wget/src/html-url.c wget-andrep/src/html-url.c
--- wget/src/html-url.c Mon May 28 05:35:02 2001
+++ wget-andrep/src/html-url.c Wed Jun 6 19:28:03 2001
@@ -299,7 +299,7 @@
static void
handle_link (struct collect_urls_closure *closure, const char *link_uri,
- struct taginfo *tag, int attrid)
+ struct taginfo *tag, int attrid, int is_external)
{
int no_proto = !has_proto (link_uri);
urlpos *newel;
@@ -308,7 +308,7 @@
char *complete_uri;
char *fragment = strrchr (link_uri, '#');
-
+
if (fragment)
{
/* Nullify the fragment identifier, i.e. everything after the
@@ -348,6 +348,10 @@
newel->url = complete_uri;
newel->pos = tag->attrs[attrid].value_raw_beginning - closure->text;
newel->size = tag->attrs[attrid].value_raw_size;
+ /* ozone start */
+ if (is_external)
+ newel->is_external = 1;
+ /* ozone end */
/* A URL is relative if the host and protocol are not named, and the
name does not start with `/'. */
@@ -409,7 +413,7 @@
only 9. */
attr_value = find_attr (tag, url_tag_attr_map[i].attr_name, &id);
if (attr_value)
- handle_link (closure, attr_value, tag, id);
+ handle_link (closure, attr_value, tag, id, url_tag_attr_map[i].flags);
}
}
break;
@@ -449,7 +453,7 @@
as they refer to external documents. */
if (!closure->dash_p_leaf_HTML
|| (rel && !strcasecmp (rel, "stylesheet")))
- handle_link (closure, href, tag, id);
+ handle_link (closure, href, tag, id, url_tag_attr_map[tagid].flags);
}
}
break;
@@ -488,7 +492,7 @@
offset = p - refresh;
tag->attrs[id].value_raw_beginning += offset;
tag->attrs[id].value_raw_size -= offset;
- handle_link (closure, p, tag, id);
+ handle_link (closure, p, tag, id, url_tag_attr_map[tagid].flags);
}
else if (name && !strcasecmp (name, "robots"))
{
diff -u -r wget/src/recur.c wget-andrep/src/recur.c
--- wget/src/recur.c Fri Jun 15 07:48:00 2001
+++ wget-andrep/src/recur.c Thu Aug 9 18:44:20 2001
@@ -301,9 +301,11 @@
if (!inl && opt.no_parent
/* If the new URL is FTP and the old was not, ignore
opt.no_parent. */
- && !(!this_url_ftp && u->proto == URLFTP))
+ && !(!this_url_ftp && u->proto == URLFTP)
+ /* Only kill link if we are using -p and this link is external */
+ && (opt.page_requisites && cur_url->is_external == 1))
{
- /* Check for base_dir first. */
+ /* Check for base_dir. */
if (!(base_dir && frontcmp (base_dir, u->dir)))
{
/* Failing that, check for parent dir. */
diff -u -r wget/src/url.h wget-andrep/src/url.h
--- wget/src/url.h Mon May 28 05:35:11 2001
+++ wget-andrep/src/url.h Wed Jun 6 19:28:08 2001
@@ -62,6 +62,8 @@
char *url; /* linked URL, after it has been
merged with the base */
char *local_name; /* Local file to which it was saved */
+ int is_external; /* This URL is an external link (to
+ another HTML file) */
/* Information about the original link: */
int link_relative_p; /* was the link relative? */