Memory Alpha
Memory Alpha
No edit summary
m (lk fixes)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Ten Forward Thread Nav}}
+
{{Ten Forward Thread Nav||archived}}
 
<!-- <nowiki>Please always sign your post with "-- ~~~~". See "[[Help:Talk page]]". Please do not overwrite any of this text, and write your comment below. </nowiki> -->
 
<!-- <nowiki>Please always sign your post with "-- ~~~~". See "[[Help:Talk page]]". Please do not overwrite any of this text, and write your comment below. </nowiki> -->
 
Greetings, is there any way at all of generating a simple plain-text return of the first section of a Memory-Alpha article?
 
Greetings, is there any way at all of generating a simple plain-text return of the first section of a Memory-Alpha article?
Line 8: Line 8:
 
<pre><nowiki>
 
<pre><nowiki>
 
{{sidebar starship|
 
{{sidebar starship|
Image= USS Enterprise-A quarter.jpg
+
image= USS Enterprise-A quarter.jpg
 
| Name= USS ''Enterprise''
 
| Name= USS ''Enterprise''
 
| Class= {{ShipClass|Constitution}} ([[refit]])
 
| Class= {{ShipClass|Constitution}} ([[refit]])
Line 38: Line 38:
   
 
:If the meta-content description contains what you need, then why don't you just have your utility request the regular version of the article and grab the value of exactly that attribute? :) -- [[User:Cid Highwind|Cid Highwind]] 12:30, September 14, 2010 (UTC)
 
:If the meta-content description contains what you need, then why don't you just have your utility request the regular version of the article and grab the value of exactly that attribute? :) -- [[User:Cid Highwind|Cid Highwind]] 12:30, September 14, 2010 (UTC)
  +
  +
Very fair question! I know, right, especially since my program can ''already'' do that!? But... it's not for me it's for [[James T. Kirk]], it's for [[Worf]], it's for [[William T. Riker|Riker]] & [[Jean-Luc Picard|Picard]] too (not to mention '''Star Trek parodies and pop culture references (television)''' ([[Special:LongPages|and all the rest]]). It seems inefficient and wasteful to download all of Worf's 91.97 KB page, when all I want is 0.85 KB (or less than 870 bytes). Quite piggy of me to ask for everything when all I want is a sample.
  +
  +
My application is still pretty fast but why be 108% greedy? And well, it could be that my server has been lagging on the DL a bit. -- [[User:Eipy|Eipy]] 17:10, September 14, 2010 (UTC)
  +
  +
:OK, that's sensible. I found the additional parameter "templates=expand" in the index.php documentation - this at least partially resolves the template issue: http://memory-alpha.org/index.php?title=USS_Enterprise_(NCC-1701-A)&action=raw&templates=expand&ctype=text/css&prop=sections&section=0 -- [[User:Cid Highwind|Cid Highwind]] 18:15, September 14, 2010 (UTC)
  +
::Hm, that's different but still not quite down to plain-text. Though, I realize, maybe stripping the wiki-text formatting mightn't be '''that''' hard (famous last words). It seems I could strip all non-single apostrophes, HTML tags, square brackets and anything in the first parameter, all content in curly brackets. I'll wait to see if there are other suggestions before I try and mock that up. [[User:Eipy|Eipy]] 18:39, September 14, 2010 (UTC)

Latest revision as of 17:17, 6 February 2012

Forums ForumsTen Forward → Accessing Plaintext Description of Article (replywatch)
This forum discussion has been archived
This forum discussion has been archived and should not be added to. Please visit the Forums to begin a new topic in the relevant location.

Greetings, is there any way at all of generating a simple plain-text return of the first section of a Memory-Alpha article?

This is as close a construction as I've been able to come: http://memory-alpha.org/index.php?title=USS_Enterprise_(NCC-1701-A)&action=raw&ctype=text/css&prop=sections&section=0

but that generates: (last-line description linebreaks added to avoid horizontal scrollbar of death)

{{sidebar starship|
        image= USS Enterprise-A quarter.jpg
|        Name= USS ''Enterprise''
|       Class= {{ShipClass|Constitution}} ([[refit]])
|    Registry= NCC-1701-A
| Affiliation= [[United Federation of Planets|Federation]] [[Starfleet]]
|    Launched= [[2286]]
|      Speed=Warp 8, Emergency Speed Warp 9.15
|    Status= Decommissioned
|  Datestatus= 2293
}}
The '''USS ''Enterprise'' (NCC-1701-A)''' was the second {{ShipClass|Constitution}}
 [[starship]] commissioned by the [[Federation]] with the name ''Enterprise''.
 She was constructed at the [[San Francisco Fleet Yards]]
 and commissioned at the [[Earth Spacedock]] facility in [[2286]].

When I'd prefer to have the plain-text that meta-content "description" generates of the regular page header. Which is:

The USS Enterprise (NCC-1701-A) was the second Constitution-class
 starship commissioned by the Federation with the name Enterprise.
 She was constructed at the San Francisco Fleet Yards and commissioned
 at the Earth Spacedock facility in 2286.

Yes, I am "lazy" and don't want to have to build a wiki-formatting stripper/parser (keep Constitution but throwout ShipClass, keep possessive apostrophes but not the rest, etc). All I want is that first smidgen of the article in plain-text but my research into the API and index.php?action=raw don't seem to indicate a method of achieving that.

For those curious. I would like a utility that does a lookup of a Memory-Alpha article and returns a plain-text brief description (usually the first paragraph fits the bill) and a link to the full article.

Help is appreciated, thanks. -- Eipy 09:22, September 14, 2010 (UTC)

If the meta-content description contains what you need, then why don't you just have your utility request the regular version of the article and grab the value of exactly that attribute? :) -- Cid Highwind 12:30, September 14, 2010 (UTC)

Very fair question! I know, right, especially since my program can already do that!? But... it's not for me it's for James T. Kirk, it's for Worf, it's for Riker & Picard too (not to mention Star Trek parodies and pop culture references (television) (and all the rest). It seems inefficient and wasteful to download all of Worf's 91.97 KB page, when all I want is 0.85 KB (or less than 870 bytes). Quite piggy of me to ask for everything when all I want is a sample.

My application is still pretty fast but why be 108% greedy? And well, it could be that my server has been lagging on the DL a bit. -- Eipy 17:10, September 14, 2010 (UTC)

OK, that's sensible. I found the additional parameter "templates=expand" in the index.php documentation - this at least partially resolves the template issue: http://memory-alpha.org/index.php?title=USS_Enterprise_(NCC-1701-A)&action=raw&templates=expand&ctype=text/css&prop=sections&section=0 -- Cid Highwind 18:15, September 14, 2010 (UTC)
Hm, that's different but still not quite down to plain-text. Though, I realize, maybe stripping the wiki-text formatting mightn't be that hard (famous last words). It seems I could strip all non-single apostrophes, HTML tags, square brackets and anything in the first parameter, all content in curly brackets. I'll wait to see if there are other suggestions before I try and mock that up. Eipy 18:39, September 14, 2010 (UTC)