summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
da9250b)
Tweeper by default shows multimedia contents like Twitter and Instagram
images in items descriptions.
However sometimes just having multimedia contents in the <enclosure/>
element may be enough, so make it optional to also have the content in
the item description.
Keep the current default behavior for backwards compatibility.
* Enables showing the username in front of the content for multi-user
* sites (enabled by default). Only some stylesheets supports this
* functionality (twitter, instagram, pump.io).
* Enables showing the username in front of the content for multi-user
* sites (enabled by default). Only some stylesheets supports this
* functionality (twitter, instagram, pump.io).
+ * @param bool $show_multimedia
+ * Enables showing multimedia content (images, videos) directly in the
+ * item description (enabled by default). Only some stylesheets supports
+ * this functionality (twitter, instagram, dilbert).
- public function __construct($generate_enclosure = FALSE, $show_usernames = TRUE) {
+ public function __construct($generate_enclosure = FALSE, $show_usernames = TRUE, $show_multimedia = TRUE) {
$this->generate_enclosure = $generate_enclosure;
$this->show_usernames = $show_usernames;
$this->generate_enclosure = $generate_enclosure;
$this->show_usernames = $show_usernames;
+ $this->show_multimedia = $show_multimedia;
$xsltProcessor->registerPHPFunctions();
$xsltProcessor->setParameter('', 'generate-enclosure', $this->generate_enclosure);
$xsltProcessor->setParameter('', 'show-usernames', $this->show_usernames);
$xsltProcessor->registerPHPFunctions();
$xsltProcessor->setParameter('', 'generate-enclosure', $this->generate_enclosure);
$xsltProcessor->setParameter('', 'show-usernames', $this->show_usernames);
+ $xsltProcessor->setParameter('', 'show-multimedia', $this->show_multimedia);
$xsltProcessor->importStylesheet($xslDoc);
return $xsltProcessor;
$xsltProcessor->importStylesheet($xslDoc);
return $xsltProcessor;
exclude-result-prefixes="php">
<xsl:param name="generate-enclosure"/>
exclude-result-prefixes="php">
<xsl:param name="generate-enclosure"/>
+ <xsl:param name="show-multimedia"/>
<xsl:output method="xml" indent="yes"/>
<xsl:output method="xml" indent="yes"/>
</pubDate>
<description>
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
</pubDate>
<description>
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
- <img src="{$picture-url}" alt="{$picture-title}"/>
+ <xsl:if test="$show-multimedia = 1">
+ <img src="{$picture-url}" alt="{$picture-title}"/>
+ </xsl:if>
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</description>
<xsl:if test="$generate-enclosure = 1">
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</description>
<xsl:if test="$generate-enclosure = 1">
<xsl:param name="generate-enclosure"/>
<xsl:param name="show-usernames"/>
<xsl:param name="generate-enclosure"/>
<xsl:param name="show-usernames"/>
+ <xsl:param name="show-multimedia"/>
<xsl:output method="xml" indent="yes"/>
<xsl:output method="xml" indent="yes"/>
</xsl:if>
<xsl:value-of select="$item-content-caption"/>
</p><br />
</xsl:if>
<xsl:value-of select="$item-content-caption"/>
</p><br />
- <a href="{$item-permalink}"><img src="{$item-content-image}" style="max-width: 100%"/></a>
+ <xsl:if test="$show-multimedia = 1">
+ <a href="{$item-permalink}"><img src="{$item-content-image}" style="max-width: 100%"/></a>
+ </xsl:if>
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</description>
<xsl:if test="$generate-enclosure = 1">
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</description>
<xsl:if test="$generate-enclosure = 1">
<xsl:param name="generate-enclosure"/>
<xsl:param name="show-usernames"/>
<xsl:param name="generate-enclosure"/>
<xsl:param name="show-usernames"/>
+ <xsl:param name="show-multimedia"/>
<xsl:output method="xml" indent="yes"/>
<xsl:output method="xml" indent="yes"/>
too instead of the t.co redirections.
-->
<xsl:template match="a[@data-pre-embedded='true']">
too instead of the t.co redirections.
-->
<xsl:template match="a[@data-pre-embedded='true']">
- <!-- Prepend and append a white space for aestethic reasons -->
- <xsl:text> </xsl:text>
- <a>
- <xsl:attribute name="href">
+ <xsl:if test="$show-multimedia = 1">
+ <!-- Prepend and append a white space for aestethic reasons -->
+ <xsl:text> </xsl:text>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat('https://', .)"/>
+ </xsl:attribute>
<xsl:value-of select="concat('https://', .)"/>
<xsl:value-of select="concat('https://', .)"/>
- </xsl:attribute>
- <xsl:value-of select="concat('https://', .)"/>
- </a>
- <xsl:text> </xsl:text>
+ </a>
+ <xsl:text> </xsl:text>
+ </xsl:if>
</xsl:template>
<!-- Present images in a more convenient way -->
</xsl:template>
<!-- Present images in a more convenient way -->
<xsl:attribute name="style">white-space: pre-wrap;</xsl:attribute>
<xsl:apply-templates select="$item-content/node()"/>
</xsl:element>
<xsl:attribute name="style">white-space: pre-wrap;</xsl:attribute>
<xsl:apply-templates select="$item-content/node()"/>
</xsl:element>
- <xsl:apply-templates select="$item-media/node()"/>
+ <xsl:if test="$show-multimedia = 1">
+ <xsl:apply-templates select="$item-media/node()"/>
+ </xsl:if>
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</description>
<xsl:if test="$generate-enclosure = 1">
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</description>
<xsl:if test="$generate-enclosure = 1">
*-e*::
show links to supported media files in the RSS <enclosure/> element
*-e*::
show links to supported media files in the RSS <enclosure/> element
+*-m <0|1>*::
+ enable or disable showing multimedia content (e.g. Twitter or Instagram
+ pictures) directly inside the item description. Default is 1 (enable).
+
*-u <0|1>*::
enable or disable showing usernames in front of the item for hosts which
supports it (Twitter.com/Instagram.com). Default is 1 (enable).
*-u <0|1>*::
enable or disable showing usernames in front of the item for hosts which
supports it (Twitter.com/Instagram.com). Default is 1 (enable).
*/
function usage($argv) {
if (is_cli()) {
*/
function usage($argv) {
if (is_cli()) {
- $usage = "{$argv[0]} [-e|-u <0|1>|-h|--help] <src_url>\n";
+ $usage = "{$argv[0]} [-e|-m <0|1>|-u <0|1>|-h|--help] <src_url>\n";
- $usage = htmlentities("{$_SERVER['SCRIPT_NAME']}?src_url=<src_url>&generate_enclosure=<0|1>&show_usernames=<0|1>");
+ $usage = htmlentities("{$_SERVER['SCRIPT_NAME']}?src_url=<src_url>&generate_enclosure=<0|1>&show_usernames=<0|1>&show_multimedia=<0|1>");
}
return "usage: $usage";
}
return "usage: $usage";
$options = array(
'generate_enclosure' => FALSE,
'show_usernames' => TRUE,
$options = array(
'generate_enclosure' => FALSE,
'show_usernames' => TRUE,
+ 'show_multimedia' => TRUE,
);
if ($argc < 2) {
return $options;
}
);
if ($argc < 2) {
return $options;
}
- $cli_options = getopt("eu:h", array("help"));
+ $cli_options = getopt("em:u:h", array("help"));
foreach ($cli_options as $opt => $val) {
switch ($opt) {
case 'e':
$options['generate_enclosure'] = TRUE;
break;
foreach ($cli_options as $opt => $val) {
switch ($opt) {
case 'e':
$options['generate_enclosure'] = TRUE;
break;
+ case 'm':
+ $ret = filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
+ if (NULL === $ret) {
+ fwrite(STDERR, "Invalid argument for the -m option.\n");
+ fwrite(STDERR, usage($argv));
+ exit(1);
+ }
+ $options['show_multimedia'] = $val;
+ break;
+
case 'u':
$ret = filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
if (NULL === $ret) {
case 'u':
$ret = filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
if (NULL === $ret) {
$options = array(
'generate_enclosure' => FALSE,
'show_usernames' => TRUE,
$options = array(
'generate_enclosure' => FALSE,
'show_usernames' => TRUE,
+ 'show_multimedia' => TRUE,
);
if (isset($_GET['src_url'])) {
);
if (isset($_GET['src_url'])) {
$options['generate_enclosure'] = $_GET['generate_enclosure'] == 1;
}
$options['generate_enclosure'] = $_GET['generate_enclosure'] == 1;
}
+ if (isset($_GET['show_multimedia'])) {
+ $options['show_multimedia'] = $_GET['show_multimedia'] != 0;
+ }
+
if (isset($_GET['show_usernames'])) {
$options['show_usernames'] = $_GET['show_usernames'] != 0;
}
if (isset($_GET['show_usernames'])) {
$options['show_usernames'] = $_GET['show_usernames'] != 0;
}
-$tweeper = new Tweeper($options['generate_enclosure'], $options['show_usernames']);
+$tweeper = new Tweeper($options['generate_enclosure'], $options['show_usernames'], $options['show_multimedia']);
$output = $tweeper->tweep($options['src_url']);
if (is_null($output)) {
exit(1);
$output = $tweeper->tweep($options['src_url']);
if (is_null($output)) {
exit(1);