git.cweiske.de
/
shpub.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
059c6ab
)
Support --html everywhere
author
Christian Weiske
<cweiske@cweiske.de>
Thu, 15 Sep 2016 20:44:52 +0000
(22:44 +0200)
committer
Christian Weiske
<cweiske@cweiske.de>
Thu, 15 Sep 2016 20:44:52 +0000
(22:44 +0200)
src/shpub/Command/AbstractProps.php
patch
|
blob
|
history
src/shpub/Command/Article.php
patch
|
blob
|
history
src/shpub/Command/Bookmark.php
patch
|
blob
|
history
src/shpub/Command/Note.php
patch
|
blob
|
history
src/shpub/Command/Reply.php
patch
|
blob
|
history
src/shpub/Command/Rsvp.php
patch
|
blob
|
history
src/shpub/Request.php
patch
|
blob
|
history
diff --git
a/src/shpub/Command/AbstractProps.php
b/src/shpub/Command/AbstractProps.php
index c9ea8bb1a5c323876da182ebe2c1f455afdd2ff7..b581f3c33e64378e8eeb9b5483c0e1122f08c3af 100644
(file)
--- a/
src/shpub/Command/AbstractProps.php
+++ b/
src/shpub/Command/AbstractProps.php
@@
-107,6
+107,20
@@
class Command_AbstractProps
static::addOptJson($cmd);
}
static::addOptJson($cmd);
}
+ protected static function addOptHtml(\Console_CommandLine_Command $cmd)
+ {
+ $cmd->addOption(
+ 'html',
+ array(
+ 'short_name' => '-h',
+ 'long_name' => '--html',
+ 'description' => 'Text content is HTML',
+ 'action' => 'StoreTrue',
+ 'default' => false,
+ )
+ );
+ }
+
protected static function addOptJson(\Console_CommandLine_Command $cmd)
{
$cmd->addOption(
protected static function addOptJson(\Console_CommandLine_Command $cmd)
{
$cmd->addOption(
diff --git
a/src/shpub/Command/Article.php
b/src/shpub/Command/Article.php
index 8445af49e7471eab0d803ad81c7fc03e41a37f07..c657b2c74c3279d66b749b3c0a3621f97e3145a8 100644
(file)
--- a/
src/shpub/Command/Article.php
+++ b/
src/shpub/Command/Article.php
@@
-6,16
+6,7
@@
class Command_Article extends Command_AbstractProps
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('article');
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('article');
- $cmd->addOption(
- 'html',
- array(
- 'short_name' => '-h',
- 'long_name' => '--html',
- 'description' => 'Text content is HTML',
- 'action' => 'StoreTrue',
- 'default' => false,
- )
- );
+ static::addOptHtml($cmd);
static::optsGeneric($cmd);
$cmd->addArgument(
'title',
static::optsGeneric($cmd);
$cmd->addArgument(
'title',
@@
-40,13
+31,7
@@
class Command_Article extends Command_AbstractProps
$req = new Request($this->cfg->host, $this->cfg);
$req->setType('entry');
$req->addProperty('name', $cmdRes->args['title']);
$req = new Request($this->cfg->host, $this->cfg);
$req->setType('entry');
$req->addProperty('name', $cmdRes->args['title']);
- if ($cmdRes->options['html']) {
- $req->addProperty(
- 'content', ['html' => $cmdRes->args['text']]
- );
- } else {
- $req->addProperty('content', $cmdRes->args['text']);
- }
+ $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
$this->handleGenericOptions($cmdRes, $req);
$res = $req->send();
$this->handleGenericOptions($cmdRes, $req);
$res = $req->send();
diff --git
a/src/shpub/Command/Bookmark.php
b/src/shpub/Command/Bookmark.php
index bdbe0f3fffc5a92c2a46dafc4f60b2623c18e458..0116cb51068c752c5e926140410ddc34e890d190 100644
(file)
--- a/
src/shpub/Command/Bookmark.php
+++ b/
src/shpub/Command/Bookmark.php
@@
-6,6
+6,7
@@
class Command_Bookmark extends Command_AbstractProps
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('bookmark');
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('bookmark');
+ static::addOptHtml($cmd);
static::optsGeneric($cmd);
$cmd->addArgument(
'url',
static::optsGeneric($cmd);
$cmd->addArgument(
'url',
@@
-36,7
+37,7
@@
class Command_Bookmark extends Command_AbstractProps
$req->addProperty('bookmark-of', $url);
if ($cmdRes->args['text']) {
$req->addProperty('bookmark-of', $url);
if ($cmdRes->args['text']) {
- $req->add
Property('content', $cmdRes->args['text
']);
+ $req->add
Content($cmdRes->args['text'], $cmdRes->options['html
']);
}
}
diff --git
a/src/shpub/Command/Note.php
b/src/shpub/Command/Note.php
index c7683f3b7a289f5052e571b2e3754b0ba6e77db7..1694243ef9cb3fa534900bffadb4b713d20c77c6 100644
(file)
--- a/
src/shpub/Command/Note.php
+++ b/
src/shpub/Command/Note.php
@@
-6,6
+6,7
@@
class Command_Note extends Command_AbstractProps
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('note');
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('note');
+ static::addOptHtml($cmd);
static::optsGeneric($cmd);
$cmd->addArgument(
'text',
static::optsGeneric($cmd);
$cmd->addArgument(
'text',
@@
-21,7
+22,7
@@
class Command_Note extends Command_AbstractProps
{
$req = new Request($this->cfg->host, $this->cfg);
$req->setType('entry');
{
$req = new Request($this->cfg->host, $this->cfg);
$req->setType('entry');
- $req->add
Property('content', $cmdRes->args['text
']);
+ $req->add
Content($cmdRes->args['text'], $cmdRes->options['html
']);
$this->handleGenericOptions($cmdRes, $req);
$res = $req->send();
$this->handleGenericOptions($cmdRes, $req);
$res = $req->send();
diff --git
a/src/shpub/Command/Reply.php
b/src/shpub/Command/Reply.php
index 6b3bc94cd336238cd2479af242b304b847804103..aa193e037c864de544e866097e2b6a4993e06194 100644
(file)
--- a/
src/shpub/Command/Reply.php
+++ b/
src/shpub/Command/Reply.php
@@
-6,6
+6,7
@@
class Command_Reply extends Command_AbstractProps
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('reply');
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('reply');
+ static::addOptHtml($cmd);
static::optsGeneric($cmd);
$cmd->addArgument(
'url',
static::optsGeneric($cmd);
$cmd->addArgument(
'url',
@@
-18,7
+19,7
@@
class Command_Reply extends Command_AbstractProps
'text',
[
'optional' => false,
'text',
[
'optional' => false,
- 'multiple' =>
tru
e,
+ 'multiple' =>
fals
e,
'description' => 'Reply text',
]
);
'description' => 'Reply text',
]
);
@@
-33,8
+34,8
@@
class Command_Reply extends Command_AbstractProps
$req = new Request($this->cfg->host, $this->cfg);
$req->setType('entry');
$req = new Request($this->cfg->host, $this->cfg);
$req->setType('entry');
- $req->addProperty('content', implode(' ', $cmdRes->args['text']));
$req->addProperty('in-reply-to', $url);
$req->addProperty('in-reply-to', $url);
+ $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
$this->handleGenericOptions($cmdRes, $req);
$res = $req->send();
$this->handleGenericOptions($cmdRes, $req);
$res = $req->send();
diff --git
a/src/shpub/Command/Rsvp.php
b/src/shpub/Command/Rsvp.php
index 69602d93ad3fd4affafbe09fdbf0140f8e5c0da0..4e67e9b1dbc3f8858adea5f1e7426f23ab78ed57 100644
(file)
--- a/
src/shpub/Command/Rsvp.php
+++ b/
src/shpub/Command/Rsvp.php
@@
-9,6
+9,7
@@
class Command_Rsvp extends Command_AbstractProps
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('rsvp');
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('rsvp');
+ static::addOptHtml($cmd);
static::optsGeneric($cmd);
$cmd->addArgument(
'url',
static::optsGeneric($cmd);
$cmd->addArgument(
'url',
@@
-50,8
+51,8
@@
class Command_Rsvp extends Command_AbstractProps
$req->setType('h', 'entry');
$req->addProperty('in-reply-to', $url);
$req->addProperty('rsvp', $rsvp);
$req->setType('h', 'entry');
$req->addProperty('in-reply-to', $url);
$req->addProperty('rsvp', $rsvp);
- if ($cmdRes->args['text']
!= ''
) {
- $req->add
Property('content', $cmdRes->args['text
']);
+ if ($cmdRes->args['text']) {
+ $req->add
Content($cmdRes->args['text'], $cmdRes->options['html
']);
}
$this->handleGenericOptions($cmdRes, $req);
}
$this->handleGenericOptions($cmdRes, $req);
diff --git
a/src/shpub/Request.php
b/src/shpub/Request.php
index 0cadc484c6d5391ddde586c107033ec3411e1562..544962b8e061c133467e4bd3312cf247559eefda 100644
(file)
--- a/
src/shpub/Request.php
+++ b/
src/shpub/Request.php
@@
-122,6
+122,18
@@
class Request
return $this->req->addUpload($fieldName, $filename);
}
return $this->req->addUpload($fieldName, $filename);
}
+ public function addContent($text, $isHtml)
+ {
+ if ($isHtml) {
+ $this->addProperty(
+ 'content', ['html' => $text]
+ );
+ } else {
+ $this->addProperty('content', $text);
+ }
+
+ }
+
/**
* Adds a micropub property to the request.
*
/**
* Adds a micropub property to the request.
*