Difference between revisions of "Template:Mainpage-rssfeeds"

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search
m
(Usage:)
Line 30: Line 30:
 
</nowiki>
 
</nowiki>
  
* charset=...             The charset used by the feed. iconv is used to convert this.
+
{|
* short                   Do not show the description text for each news item.
+
|-
* max=x                   Shows x most recent headlines.
+
||charset=...   ||        The charset used by the feed. iconv is used to convert this.
* highlight= term1 term2 The terms separated by a space are highlighted.
+
|-
* filter= term1 term2    Show only rss items containing at least one of the terms.
+
|| short         ||          Do not show the description text for each news item.
* reverse                display the rss items in reverse order.
+
|-
* title=x                display an alternative title instead of chanel name.
+
|| max=x         ||        Shows x most recent headlines.
* title = none            dont display any title.
+
|-
 +
|| highlight= term1 term2 || The terms separated by a space are highlighted.
 +
|-
 +
|| filter= term1 term2    ||Show only rss items containing at least one of the terms.
 +
|-
 +
|| reverse                ||display the rss items in reverse order.
 +
|-
 +
|| title=x                ||display an alternative title instead of chanel name.
 +
|-
 +
|| title = none            ||dont display any title.
 +
|}
  
 
===Example:===  
 
===Example:===  

Revision as of 16:27, 29 July 2006

UNIQ97651798b01abcdd-rss-00000000-QINU UNIQ97651798b01abcdd-rss-00000001-QINU

GISWiki/RSS

Uses an extension from: http://meta.wikimedia.org/wiki/GISWiki/RSS

RSS-Feed Mediawiki extension

  • original by mutante 25.03.2005
  • extended by Duesentrieb 30.04.2005
  • extended by Rdb78 07.07.2005
  • extended by Mafs 10.07.2005, 24.07.2005
  • extended by User:Arcy 07.09.2005
  • Updated for MediaWiki 1.6 by User:piku 13.06.2006
  • Update for Wikicode output, by User:cogdog 14.jul.2006

Requires:

Installation:

  • put this file (rss.php) into the extension directory of your mediawiki installation
  • add the following to the end of LocalSettings.php: include("extensions/rss.php");
  • make sure magpie can be found by PHP.

Usage:

Use one section between <rss>-tags for each feed. The rss section may contain parameters separated by a pipe ("|"), just like links and templates. These parameters are supported:

charset=... The charset used by the feed. iconv is used to convert this.
short Do not show the description text for each news item.
max=x Shows x most recent headlines.
highlight= term1 term2 The terms separated by a space are highlighted.
filter= term1 term2 Show only rss items containing at least one of the terms.
reverse display the rss items in reverse order.
title=x display an alternative title instead of chanel name.
title = none dont display any title.

Example:

<rss>http://slashdot.org/slashdot.rss|charset=UTF-8|short|max=5</rss>

The Moral Dilemma of Driverless Cars: Save The Driver or Save The Crowd?

Wed, 29 Jun 2016 03:30:00

HughPickens.com writes: What should a driverless car with one rider do if it is faced with the choice of swerving off the road into a tree or hitting a crowd of 10 pedestrians? The answer depends on whether you are the rider in the car or someone else is, writes Peter Dizikes at MIT News. According to recent research most people prefer autonomous vehicles to minimize casualties in situations of extreme danger -- except for the vehicles they would be riding in. "Most people want to live in in a world where cars will minimize casualties," says Iyad Rahwan. "But everybody wants their own car to protect them at all costs." The result is what the researchers call a "social dilemma," in which people could end up making conditions less safe for everyone by acting in their own self-interest. "If everybody does that, then we would end up in a tragedy whereby the cars will not minimize casualties," says Rahwan. Researchers conducted six surveys, using the online Mechanical Turk public-opinion tool, between June 2015 and November 2015. The results consistently showed that people will take a utilitarian approach to the ethics of autonomous vehicles, one emphasizing the sheer number of lives that could be saved. For instance, 76 percent of respondents believe it is more moral for an autonomous vehicle, should such a circumstance arise, to sacrifice one passenger rather than 10 pedestrians. But the surveys also revealed a lack of enthusiasm for buying or using a driverless car programmed to avoid pedestrians at the expense of its own passengers. "This is a challenge that should be on the mind of carmakers and regulators alike," the researchers write. "For the time being, there seems to be no easy way to design algorithms that would reconcile moral values and personal self-interest."

Share on Google+


Read more of this story at Slashdot.

Volkswagen Agrees To Record $14.7B Settlement Over Emissions Cheating

Wed, 29 Jun 2016 01:25:00

An anonymous reader quotes a report from CNNMoney: Volkswagen's deliberate cheating on emissions tests will cost it a record $14.7 billion. And that's just the start of its problems. The settlement is only a preliminary step in the case; the automaker still faces possible criminal charges, as well as civil penalties for Clean Air Act violations. The Department of Justice is investigating possible criminal charges against both the company and individuals, said Deputy Attorney General Sally Yates. Up to $10 billion of the funds will be paid out to owners of the 487,000 affected diesel cars in the U.S., sold under the VW or luxury Audi brands. How much an owner gets will depend on whether an owner chooses to fix their car or just have VW buy it back -- they have until May 2018 to decide. Repurchasing the cars will cost VW between $12,500 to $44,000 per car. The $14.7 billion settlement estimate assumes that all the cars are repurchased. Owners who elect to get their vehicles fixed will also get a cash payment of between $5,100 and $10,000 to compensate them for the lost value of the cars, as well as for Volkswagen's deceptive promise of "clean diesel." Most of the buyers paid extra for a car with a diesel engine. In addition to the customer payments, Volkswagen will pay $2.7 billion for environmental cleanup and $2 billion to promote zero-emission vehicles. The clean up money will be used by individual states to cut other diesel emissions by replacing older, government-owned trucks, buses and other diesel engines now in use. Volkswagen is betting big on electric vehicles after this emissions scandal. It plans to deliver 30 electric plug-in models by 2025.

Share on Google+


Read more of this story at Slashdot.

Tesla Owner Makes 'Solid Metal Snake' Self-Charging System That Elon Musk Promised

Wed, 29 Jun 2016 00:45:00

An anonymous reader writes: Nearly two years ago, Elon Musk teased us with a robotic snake that would automatically plug-in and charge your Model S. Well, many months have passed and there has yet to be an official "solid metal snake" available for Tesla owners. So, one Tesla owner decided to make his own autonomous charging station, as spotted by Electrek, that will automatically guide the Model S's charging cable into the waiting receptacle with no human intervention required. The inventor Deepak Mital posted a video showing how it works, and while it's incredibly slow, it does work. Compared to the demo video of the system teased by Elon Musk last year, this version appears much less threatening. Mital calls it the "Evtron," which is controlled with a Raspberry Pi and swings from one side to another before sliding forward to make the connection with the car.

Share on Google+


Read more of this story at Slashdot.

Florida Man Sues Apple For $10+ Billion, Says He Invented iPhone Before Apple

Wed, 29 Jun 2016 00:05:00

An anonymous reader writes from a report via MacRumors: A Florida resident that goes by the name of Thomas S. Ross has filed a lawsuit against Apple this week, claiming that the iPhone, iPad, and iPod infringe upon his 1992 invention of a hand-drawn "Electronic Reading Device" (ERD). The court filing claims the plaintiff was "first to file a device so designed and aggregated," nearly 15 years before the first iPhone. MacRumors reports: "Between May 23, 1992 and September 10, 1992, Ross designed three hand-drawn technical drawings of the device, primarily consisting of flat rectangular panels with rounded corners that "embodied a fusion of design and function in a way that never existed prior to 1992." Ross applied for a utility patent to protect his invention in November 1992, but the application was declared abandoned in April 1995 by the U.S. Patent and Trademark Office after he failed to pay the required application fees. He also filed to copyright his technical drawings with the U.S. Copyright Office in 2014. While the plaintiff claims that he continues to experience "great and irreparable injury that cannot fully be compensated or measured in money," he has demanded a jury trial and is seeking restitution no less than $10 billion and a royalty of up to 1.5% on Apple's worldwide sales of infringing devices." MacRumors commenter Sunday Ironfoot suggests this story may be "The mother of all 'Florida Man' stories." Apple has been awarded a patent today that prohibits smartphone users from taking photos and videos at concerts, movies theaters and other events where people tend to ignore such restrictions.

Share on Google+


Read more of this story at Slashdot.

RIP Xbox Fitness: Users Will Soon Lose Access To Workout Videos They Bought

Tue, 28 Jun 2016 23:25:00

insitus quotes a report from Ars Technica: Xbox users who purchased training videos through the Xbox Fitness app probably thought they were buying a workout program they'd be able to use regularly for the life of the Xbox One, at the very least. Instead, those videos will soon be completely unavailable to those who paid for them up front, according to a "sunset" plan announced by Microsoft yesterday evening. Xbox Fitness first launched in late 2013 with the console, offering a Kinect-powered health app that uses the 3D camera to evaluate users' form as they perform the exercises demoed by on-screen video trainers. The app, which provided 30 basic routines for free with an Xbox Live Gold account, will be coming to an end on December 15. The paid content associated with the app will also no longer be available for purchase, and those who purchased it previously will be able to use it for over one more year before the app becomes completely unavailable to download or use on July 1, 2017. What some have found especially upsetting with the news is that Microsoft has yet to announce any plans to compensate users who have paid for content or to provide downloadable versions of paid workouts that can be used after the phase-out date. Thus, many upset users have taken to the sunset announcement post and various other outlets to speak their mind on the situation. "I bought 140$+ worth of content just this year... I don't want a refund, I want to be able to continue to use what I PAID for !!!!!!!!!!!" Xbox Live user QuickSilver wrote.

Share on Google+


Read more of this story at Slashdot.


===rss.php=== 

<?php
# RSS-Feed Mediawiki extension
# 
# original by mutante 25.03.2005
# extended by Duesentrieb 30.04.2005
# extended by Rdb78 07.07.2005
# extended by Mafs  10.07.2005, 24.07.2005
# extended by User:Arcy  07.09.2005
# Updated for MediaWiki 1.6 by User:piku 13.06.2006
# Update for Wikicode output, by User:cogdog 14.jul.2006
#
# Requires: 
#  * magpie rss parser <http://magpierss.sourceforge.net/>
#  * iconv <http://www.gnu.org/software/libiconv/>, see also <http://www.php.net/iconv>
#
# Installation:
#  * put this file (rss.php) into the extension directory of your mediawiki installation 
#  * add the following to the end of LocalSettings.php: include("extensions/rss.php");
#  * make sure magpie can be found by PHP.
#
# Usage:
#  Use one section between <rss>-tags for each feed. The rss section may contain parameters
#  separated by a pipe ("|"), just like links and templates. These parameters are supported:
#
#    * charset=...             The charset used by the feed. iconv is used to convert this.
#    * short                   Do not show the description text for each news item.
#    * max=x                   Shows x most recent headlines.
#    * highlight= term1 term2  The terms separated by a space are highlighted.
#    * filter= term1 term2     Show only rss items containing at least one of the terms.
#    * reverse                 display the rss items in reverse order.
#    * title=x                 display an alternative title instead of chanel name.
#    * title = none            dont display any title.
#
# Example: 
#    <rss>http://slashdot.org/slashdot.rss|charset=UTF-8|short|max=5</rss>
#

#change this according to your magpie installation!
require_once('rss_fetch.inc'); 

#install extension hook
$wgExtensionFunctions[] = "wfRssExtension"; 

#extension hook callback function
function wfRssExtension() { 
  global $wgParser;

  #install parser hook for <rss> tags
  $wgParser->setHook( "rss", "renderRss" );
}

#parser hook callback function
function renderRss($input, $argv, $parser = null) {
  if (!$parser) $parser =& $GLOBALS['wgParser'];
  global $wgOutputEncoding;

  $DefaultEncoding = "ISO-8859-1";
  $DisableCache = true;

  # $input = mysql_escape_string($input);

  if (!$input) return ""; #if <rss>-section is empty, return nothing

  #parse fields in rss-section
  $fields= explode("|",$input);
  $url= @$fields[0];

  $args= array();
  for ($i=1; $i<sizeof($fields); $i++) {
    $f= $fields[$i];

    if (strpos($f,"=")===False) $args[strtolower(trim($f))]= False;
    else {
      list($k,$v)= explode("=",$f,2);
      if (trim($v)==False) $args[strtolower(trim($k))] = False; 
      else $args[strtolower(trim($k))]= trim($v);
    }
  }

  #get charset from argument-array    
  $charset= @$args["charset"];
  if (!$charset) $charset= $DefaultEncoding;

  #get max number of headlines from argument-array
  $maxheads = @$args["max"];
  $headcnt = 0;

  #get short-flag from argument-array
  #if short is set, no description text is printed
  if (isset($args["short"])) $short = True; else $short = False;

  #get reverse-flag from argument-array
  if (isset($args["reverse"])) $reverse = True; else $reverse = False;

  #get highlight terms from argument-array    
  $rssHighlight= @$args["highlight"];
  $rssHighlight= str_replace("  "," ", $rssHighlight);
  $rssHighlight= explode(" ", trim($rssHighlight));

  #get filter terms from argument-array    
  $rssFilter= @$args["filter"];
  $rssFilter= str_replace("  "," ", $rssFilter);
  $rssFilter= explode(" ", trim($rssFilter));    

  #fetch rss. may be cached locally.
  #Refer to the documentation of magpie for details.
  $rss = @fetch_rss($url);


  #check for errors.
  if ($rss->ERROR) {
     # return "Feed error"; #localize...
      #return "<div>Failed to load RSS feed from $url: ".$rss->ERROR."</div>"; #localize...
  }

  if (!is_array($rss->items)) {
     # return "Feed error"; #localize...
      #return "<div>Failed to load RSS feed from $url!</div>"; #localize...
  }

  #Bild title line    
  #get title from argument-array    
  
  $rssTitle= @$args["title"];
  $rssTitle= trim($rssTitle);

  if ($rssTitle !=='none') {
    if ($rssTitle=='') {
        $title= iconv($charset,$wgOutputEncoding,$rss->channel['title']);
        if ($rss->channel['link']) $title= "[".$rss->channel['link']." $title]";
        $output = "=== $title ===\n";
    }
    else
    {
      $title= "[".$rss->channel['link']." $rssTitle]";
      $output="=== $title ===\n";
    }
  } else {
      $output="\n\n\n";
  }
  
  if ($reverse) $rss->items = array_reverse($rss->items);

  $description = False; 
  foreach ($rss->items as $item) {
      if ($item['description']) {$description = True; break;}
  }

  #Bild items
  if (!$short and $description) { #full item list

    $output.="";
    foreach ($rss->items as $item) {

      $d_text = true;
      $d_title = true;

      $href = trim(iconv($charset,$wgOutputEncoding,$item['link']));
      $title = trim(iconv($charset,$wgOutputEncoding,$item['title']));

      $d_title = wfRssFilter ($title, $rssFilter);
      $title= wfRssHighlight($title, $rssHighlight);

      #bild description text if desired
      if ($item["description"]) {
        $text= trim(iconv($charset,$wgOutputEncoding,$item['description']));

        #avoid pre-tags
        $text= str_replace("\r"," ",$text);
        $text= str_replace("\n"," ",$text);
        $text= str_replace("\t"," ",$text);

        $d_text = wfRssFilter ($text, $rssFilter);
        $text= wfRssHighlight($text, $rssHighlight);

        $display = $d_text or $d_title;

      }
        else   {
          $text = "";
          $display = $d_title;
        }       

      if ($display) {
        $output.="* [$href $title]";
        if ($text) $output.="<br>$text";
        $output .= "\n";
      }

    #Cut off output when maxheads is reached:
    if (++$headcnt == $maxheads)  break;

    }
    # $output.="</dl>";
  }
  else { #short item list
   #  $output.="<ul>";
    foreach ($rss->items as $item) {
      $href = trim(iconv($charset,$wgOutputEncoding,$item['link']));
      $title = trim(iconv($charset,$wgOutputEncoding,$item['title']));

        $d_title = wfRssFilter ($title, $rssFilter);
        $title= wfRssHighlight($title, $rssHighlight);

        if ($d_title ) $output.="* [$href $title]\n";

      #Cut off output when maxheads is reached:
      if (++$headcnt == $maxheads)  break;
    }
    # $output.="</ul>";
  }


  if ($DisableCache) {

    global $wgVersion;

    # Do not cache this wiki page.
    # for details see http://public.kitware.com/Wiki/User:Barre/MediaWiki/Extensions
    global $wgTitle, $wgDBprefix;
    $ts = mktime();
    $now = gmdate("YmdHis", $ts + 120);
    $ns = $wgTitle->getNamespace();
    $ti = wfStrencode($wgTitle->getDBkey());

    $version = preg_replace("/^([1-9]).([1-9]).*/", "\\1\\2", $wgVersion);
    if ($version>14) $sql = "UPDATE $wgDBprefix"."page SET page_touched='$now' WHERE page_namespace=$ns AND page_title='$ti'";
    else             $sql = "UPDATE $wgDBprefix"."cur SET cur_touched='$now' WHERE cur_namespace=$ns AND cur_title='$ti'";

    wfQuery($sql, DB_WRITE, "");
  }

  $out = $parser->parse ($output, $parser->mTitle,$parser->mOptions, true, false);
  return $out->getText();
}


function wfRssFilter ($text, $rssFilter) {

  $display = true;

  if (is_array($rssFilter)) {
    foreach($rssFilter as $term) {

      if ($term) {
        $display = false;
        if (preg_match("|$term|i", $text, $a))  {  $display = true; return $display; }
      }
    if ($display) break;
    }
  }
  return $display;
}


function wfRssHighlight($text, $rssHighlight) {

  $i=0;
  $starttag = "v8x5u3t3u8h";
  $endtag   = "q8n4f6n4n4x";

  $color[]="coral";
  $color[]="greenyellow";
  $color[]="lightskyblue";
  $color[]="gold";
  $color[]="violet";

  $count_color = count($color);

  if (is_array($rssHighlight)) {
    foreach($rssHighlight as $term) {
      if ($term) {
        $text = preg_replace("|\b(\w*?".$term."\w*?)\b|i", "$starttag"."_".$i."\\1$endtag", $text);
        $i++;
        if ($i == $count_color) $i=0;
        }
      }
    }
  # to avoid trouble should someone wants to highlight the terms "span", "style", ...
  for ($i=0; $i<5; $i++) {
    $text = preg_replace("|$starttag"."_".$i."|", "<span style=\"background-color:".$color[$i]."; font-weight: bold;\">", $text);
    $text = preg_replace("|$endtag|", "</span>", $text);
    }

  return $text;
}

?>