Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18737383
D16173.id38905.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D16173.id38905.diff
View Options
diff --git a/resources/sql/autopatches/20160623.phame.blog.fulldomain.1.sql b/resources/sql/autopatches/20160623.phame.blog.fulldomain.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160623.phame.blog.fulldomain.1.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_phame.phame_blog
+ ADD domainFullURI VARCHAR(128) NOT NULL COLLATE {$COLLATE_TEXT};
diff --git a/resources/sql/autopatches/20160623.phame.blog.fulldomain.2.sql b/resources/sql/autopatches/20160623.phame.blog.fulldomain.2.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160623.phame.blog.fulldomain.2.sql
@@ -0,0 +1,3 @@
+UPDATE {$NAMESPACE}_phame.phame_blog
+ SET domainFullURI = CONCAT('http://', domain, '/')
+ WHERE domain IS NOT NULL;
diff --git a/src/applications/phame/controller/blog/PhameBlogManageController.php b/src/applications/phame/controller/blog/PhameBlogManageController.php
--- a/src/applications/phame/controller/blog/PhameBlogManageController.php
+++ b/src/applications/phame/controller/blog/PhameBlogManageController.php
@@ -97,12 +97,11 @@
$properties = id(new PHUIPropertyListView())
->setUser($viewer);
- $domain = $blog->getDomain();
- if (!$domain) {
- $domain = phutil_tag('em', array(), pht('No external domain'));
+ $full_domain = $blog->getDomainFullURI();
+ if (!$full_domain) {
+ $full_domain = phutil_tag('em', array(), pht('No external domain'));
}
-
- $properties->addProperty(pht('Domain'), $domain);
+ $properties->addProperty(pht('Full Domain'), $full_domain);
$parent_site = $blog->getParentSite();
if (!$parent_site) {
diff --git a/src/applications/phame/editor/PhameBlogEditEngine.php b/src/applications/phame/editor/PhameBlogEditEngine.php
--- a/src/applications/phame/editor/PhameBlogEditEngine.php
+++ b/src/applications/phame/editor/PhameBlogEditEngine.php
@@ -94,13 +94,13 @@
->setTransactionType(PhameBlogTransaction::TYPE_DESCRIPTION)
->setValue($object->getDescription()),
id(new PhabricatorTextEditField())
- ->setKey('domain')
- ->setLabel(pht('Custom Domain'))
- ->setDescription(pht('Blog domain name.'))
- ->setConduitDescription(pht('Change the blog domain.'))
- ->setConduitTypeDescription(pht('New blog domain.'))
- ->setValue($object->getDomain())
- ->setTransactionType(PhameBlogTransaction::TYPE_DOMAIN),
+ ->setKey('domainFullURI')
+ ->setLabel(pht('Full Domain URI'))
+ ->setDescription(pht('Blog full domain URI.'))
+ ->setConduitDescription(pht('Change the blog full domain URI.'))
+ ->setConduitTypeDescription(pht('New blog full domain URI.'))
+ ->setValue($object->getDomainFullURI())
+ ->setTransactionType(PhameBlogTransaction::TYPE_FULLDOMAIN),
id(new PhabricatorTextEditField())
->setKey('parentSite')
->setLabel(pht('Parent Site'))
diff --git a/src/applications/phame/editor/PhameBlogEditor.php b/src/applications/phame/editor/PhameBlogEditor.php
--- a/src/applications/phame/editor/PhameBlogEditor.php
+++ b/src/applications/phame/editor/PhameBlogEditor.php
@@ -17,7 +17,7 @@
$types[] = PhameBlogTransaction::TYPE_NAME;
$types[] = PhameBlogTransaction::TYPE_SUBTITLE;
$types[] = PhameBlogTransaction::TYPE_DESCRIPTION;
- $types[] = PhameBlogTransaction::TYPE_DOMAIN;
+ $types[] = PhameBlogTransaction::TYPE_FULLDOMAIN;
$types[] = PhameBlogTransaction::TYPE_PARENTSITE;
$types[] = PhameBlogTransaction::TYPE_PARENTDOMAIN;
$types[] = PhameBlogTransaction::TYPE_STATUS;
@@ -38,8 +38,8 @@
return $object->getSubtitle();
case PhameBlogTransaction::TYPE_DESCRIPTION:
return $object->getDescription();
- case PhameBlogTransaction::TYPE_DOMAIN:
- return $object->getDomain();
+ case PhameBlogTransaction::TYPE_FULLDOMAIN:
+ return $object->getDomainFullURI();
case PhameBlogTransaction::TYPE_PARENTSITE:
return $object->getParentSite();
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
@@ -61,7 +61,7 @@
case PhameBlogTransaction::TYPE_PARENTSITE:
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
return $xaction->getNewValue();
- case PhameBlogTransaction::TYPE_DOMAIN:
+ case PhameBlogTransaction::TYPE_FULLDOMAIN:
$domain = $xaction->getNewValue();
if (!strlen($xaction->getNewValue())) {
return null;
@@ -81,8 +81,11 @@
return $object->setSubtitle($xaction->getNewValue());
case PhameBlogTransaction::TYPE_DESCRIPTION:
return $object->setDescription($xaction->getNewValue());
- case PhameBlogTransaction::TYPE_DOMAIN:
- return $object->setDomain($xaction->getNewValue());
+ case PhameBlogTransaction::TYPE_FULLDOMAIN:
+ $uri = new PhutilURI($xaction->getNewValue());
+ $domain = $uri->getDomain();
+ $object->setDomain($domain);
+ return $object->setDomainFullURI($xaction->getNewValue());
case PhameBlogTransaction::TYPE_STATUS:
return $object->setStatus($xaction->getNewValue());
case PhameBlogTransaction::TYPE_PARENTSITE:
@@ -102,7 +105,7 @@
case PhameBlogTransaction::TYPE_NAME:
case PhameBlogTransaction::TYPE_SUBTITLE:
case PhameBlogTransaction::TYPE_DESCRIPTION:
- case PhameBlogTransaction::TYPE_DOMAIN:
+ case PhameBlogTransaction::TYPE_FULLDOMAIN:
case PhameBlogTransaction::TYPE_PARENTSITE:
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
case PhameBlogTransaction::TYPE_STATUS:
@@ -156,7 +159,7 @@
$errors[] = $error;
}
break;
- case PhameBlogTransaction::TYPE_DOMAIN:
+ case PhameBlogTransaction::TYPE_FULLDOMAIN:
if (!$xactions) {
continue;
}
diff --git a/src/applications/phame/storage/PhameBlog.php b/src/applications/phame/storage/PhameBlog.php
--- a/src/applications/phame/storage/PhameBlog.php
+++ b/src/applications/phame/storage/PhameBlog.php
@@ -18,6 +18,7 @@
protected $subtitle;
protected $description;
protected $domain;
+ protected $domainFullURI;
protected $parentSite;
protected $parentDomain;
protected $configData;
@@ -46,6 +47,7 @@
'subtitle' => 'text64',
'description' => 'text',
'domain' => 'text128?',
+ 'domainFullURI' => 'text128',
'parentSite' => 'text128',
'parentDomain' => 'text128',
'status' => 'text32',
@@ -112,34 +114,29 @@
*
* @return string
*/
- public function validateCustomDomain($custom_domain) {
- $example_domain = 'blog.example.com';
+ public function validateCustomDomain($domain_full_uri) {
+ $example_domain = 'http://blog.example.com/';
$label = pht('Invalid');
// note this "uri" should be pretty busted given the desired input
// so just use it to test if there's a protocol specified
- $uri = new PhutilURI($custom_domain);
- if ($uri->getProtocol()) {
- return array(
- $label,
- pht(
- 'The custom domain should not include a protocol. Just provide '.
- 'the bare domain name (for example, "%s").',
- $example_domain),
- );
- }
+ $uri = new PhutilURI($domain_full_uri);
+ $domain = $uri->getDomain();
+ $protocol = $uri->getProtocol();
+ $path = $uri->getPath();
+ $supported_protocols = array('http', 'https');
- if ($uri->getPort()) {
+ if (!in_array($protocol, $supported_protocols)) {
return array(
$label,
pht(
- 'The custom domain should not include a port number. Just provide '.
- 'the bare domain name (for example, "%s").',
+ 'The custom domain should include a valid protocol in the URI '.
+ '(for example, "%s"). Valid protocols are "http" or "https".',
$example_domain),
- );
+ );
}
- if (strpos($custom_domain, '/') !== false) {
+ if (strlen($path) && $path != '/') {
return array(
$label,
pht(
@@ -150,7 +147,7 @@
);
}
- if (strpos($custom_domain, '.') === false) {
+ if (strpos($domain, '.') === false) {
return array(
$label,
pht(
@@ -191,7 +188,8 @@
}
public function getExternalLiveURI() {
- $uri = new PhutilURI('http://'.$this->getDomain().'/');
+ $uri = new PhutilURI($this->getDomainFullURI());
+ PhabricatorEnv::requireValidRemoteURIForLink($uri);
return (string)$uri;
}
diff --git a/src/applications/phame/storage/PhameBlogTransaction.php b/src/applications/phame/storage/PhameBlogTransaction.php
--- a/src/applications/phame/storage/PhameBlogTransaction.php
+++ b/src/applications/phame/storage/PhameBlogTransaction.php
@@ -7,6 +7,7 @@
const TYPE_SUBTITLE = 'phame.blog.subtitle';
const TYPE_DESCRIPTION = 'phame.blog.description';
const TYPE_DOMAIN = 'phame.blog.domain';
+ const TYPE_FULLDOMAIN = 'phame.blog.full.domain';
const TYPE_STATUS = 'phame.blog.status';
const TYPE_PARENTSITE = 'phame.blog.parent.site';
const TYPE_PARENTDOMAIN = 'phame.blog.parent.domain';
@@ -47,6 +48,7 @@
break;
case self::TYPE_DESCRIPTION:
case self::TYPE_DOMAIN:
+ case self::TYPE_FULLDOMAIN:
return 'fa-pencil';
case self::TYPE_STATUS:
if ($new == PhameBlog::STATUS_ARCHIVED) {
@@ -86,6 +88,7 @@
case self::TYPE_SUBTITLE:
case self::TYPE_DESCRIPTION:
case self::TYPE_DOMAIN:
+ case self::TYPE_FULLDOMAIN:
case self::TYPE_PARENTSITE:
case self::TYPE_PARENTDOMAIN:
$tags[] = self::MAILTAG_DETAILS;
@@ -146,6 +149,12 @@
$this->renderHandleLink($author_phid),
$new);
break;
+ case self::TYPE_FULLDOMAIN:
+ return pht(
+ '%s updated the blog\'s full domain to "%s".',
+ $this->renderHandleLink($author_phid),
+ $new);
+ break;
case self::TYPE_PARENTSITE:
if ($old === null) {
return pht(
@@ -236,6 +245,12 @@
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
break;
+ case self::TYPE_FULLDOMAIN:
+ return pht(
+ '%s updated the full domain for %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($object_phid));
+ break;
case self::TYPE_PARENTSITE:
return pht(
'%s updated the parent site for %s.',
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 2 2025, 10:25 AM (15 w, 23 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8812112
Default Alt Text
D16173.id38905.diff (10 KB)
Attached To
Mode
D16173: Allow PhameBlog to take a full URI instead of just a domain name
Attached
Detach File
Event Timeline
Log In to Comment