lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lynx-dev] Adding fragment identifier(#) by RULE:Redirect to jump to mai


From: KIHARA Hideto
Subject: [Lynx-dev] Adding fragment identifier(#) by RULE:Redirect to jump to main content
Date: Sun, 11 Oct 2009 10:31:03 +0900
User-agent: Mutt/1.5.20 (2009-06-14)

I wrote following RULE in lynx.cfg to automatically jump
to main content of each article, because I'm annoyed about finding
beginning of content by typing space (page-down) key many times
or searching "Skip to Content" link and selecting it
to skip menu area of each article.  (For example, select link 1,
<type space three times or select "Skip to Content" link>, read content,
back to previous page, select link 2,
<type space three times or select "Skip to Content" link>, read content, ...)

RULE:Redirect http://www.engadget.com/* http://www.engadget.com/*#content 
unless redirected

With this RULE, I expect following redirect action.
If I select this link for example,
  http://www.engadget.com/2009/10/10/cellphones-thinner-than-ever/
I expect to be redirected to this link which has fragment identifier #content.
  http://www.engadget.com/2009/10/10/cellphones-thinner-than-ever/#content

But with this RULE, I cannot view http://www.engadget.com/.

$ lynx -cfg ~/lib/lynx/lynx.cfg http://www.engadget.com/
lynx: Start file could not be found or is not text/html or text/plain
      Exiting...

This is because '#' is treated as start of comment for RULE.

I'm using following patch to be able to use '#' in RULE.
Using this patch, '#' is treated as start of comment only if preceded
by a space character (cf. LYReadCFG.c:do_read_cfg(), line 1949).

In this patch, I added while loop to check trailing comment
after use of '#' for fragment identifier like this line:
RULE:Redirect http://www.engadget.com/* http://www.engadget.com/*#content 
unless redirected # add #content

# And I configure --enable-internal-links to be able to get updated content
# by reloading "http://www.engadget.com/#content";,
# otherwise reloading is only jump to #content position.

--- WWW/Library/Implementation/HTRules.c.orig   2009-02-02 10:41:02.000000000 
+0900
+++ WWW/Library/Implementation/HTRules.c        2009-10-03 12:24:12.000000000 
+0900
@@ -462,10 +462,16 @@ int HTSetConfiguration(char *config)
 
     StrAllocCopy(line, config);
     {
-       char *p = strchr(line, '#');    /* Chop off comments */
-
-       if (p)
-           *p = 0;
+       char *p = line; 
+       /* Chop off comments */
+       while ((p = strchr(p, '#'))) {
+           if (p == line || isspace(UCH(*(p-1)))) {
+               *p = 0;
+               break;
+           } else {
+               p++;
+           }
+       }
     }
     pointer = line;
     word1 = HTNextField(&pointer);


Here are some RULE:Redirect settings in my lynx.cfg
to add fragment identifier or to skip intermediate page.
With these rules, I can reduce the number of page-down operation
and find easily beginning of content.

RULE:Redirect http://www.engadget.com/* http://www.engadget.com/*#content 
unless redirected
RULE:Redirect http://news.yahoo.com/* http://news.yahoo.com/*#bd unless 
redirected
# Japanese news sites
RULE:Redirect http://slashdot.jp/* http://slashdot.jp/*#main-articles unless 
redirected
RULE:Redirect http://japan.cnet.com/*.htm http://japan.cnet.com/*.htm#sbm_top 
unless redirected
RULE:Redirect http://headlines.yahoo.co.jp/hl?* 
http://headlines.yahoo.co.jp/hl?*#main unless redirected
RULE:Redirect http://journal.mycom.co.jp/* 
http://journal.mycom.co.jp/*#mainContent unless redirected
RULE:Redirect http://www.asahi.com/* http://www.asahi.com/*#Contents unless 
redirected
RULE:Redirect http://sankei.jp.msn.com/*.htm 
http://sankei.jp.msn.com/*.htm#articleTextnews1 unless redirected
RULE:Redirect http://www.yomiuri.co.jp/* http://www.yomiuri.co.jp/*#main unless 
redirected
RULE:Redirect http://www.nikkei.co.jp/news/* 
http://www.nikkei.co.jp/news/*#topnews unless redirected
RULE:Redirect http://gigazine.net/index.php?/news/comments/2*/ 
http://gigazine.net/index.php?/news/comments/2*/#maincol unless redirected
RULE:Redirect http://blogs.itmedia.co.jp/* 
http://blogs.itmedia.co.jp/*#contents unless redirected

# skip summary page, jump to "Read More" link target page
RULE:Redirect http://ascii.jp/elem/*/summary.html?rss http://ascii.jp/elem/*/
RULE:Redirect http://it.nikkei.co.jp/mobile/news/index.aspx?n=*&landing=True 
http://it.nikkei.co.jp/mobile/news/index.aspx?n=*&landing=Next
RULE:Redirect http://it.nikkei.co.jp/pc/news/index.aspx?n=*&landing=True 
http://it.nikkei.co.jp/pc/news/index.aspx?n=*&landing=Next
RULE:Redirect http://it.nikkei.co.jp/security/news/index.aspx?n=*&landing=True 
http://it.nikkei.co.jp/security/news/index.aspx?n=*&landing=Next
RULE:Redirect http://it.nikkei.co.jp/business/news/index.aspx?n=*&landing=True 
http://it.nikkei.co.jp/business/news/index.aspx?n=*&landing=Next
RULE:Redirect http://it.nikkei.co.jp/internet/news/index.aspx?n=*&landing=True 
http://it.nikkei.co.jp/internet/news/index.aspx?n=*&landing=Next
RULE:Redirect http://it.nikkei.co.jp/digital/news/index.aspx?n=*&landing=True 
http://it.nikkei.co.jp/digital/news/index.aspx?n=*&landing=Next

# skip redirect server
RULE:Redirect http://ime.st/* http://*
RULE:Redirect http://ime.nu/* http://*





reply via email to

[Prev in Thread] Current Thread [Next in Thread]