Skip to content

Commit 930b6fe

Browse files
author
lkassianik
committed
DRAFT - throw together Phurl skeleton.
Summary: DRAFT - throw together Phurl skeleton. Test Plan: The idea is that `some/long/url` will become `install/Udet4d` and can be viewed and edited at `install/Udet4d/view` and `install/Udet4d/edit`, respectively? Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: joshuaspence, chad, epriestley, Korvin Maniphest Tasks: T6049 Differential Revision: https://secure.phabricator.com/D13681
1 parent 2ada395 commit 930b6fe

24 files changed

+1463
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TABLE {$NAMESPACE}_phurl.phurl_url (
2+
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
3+
phid VARBINARY(64) NOT NULL,
4+
name VARCHAR(255) NOT NULL COLLATE {$COLLATE_TEXT},
5+
longURL VARCHAR(2047) NOT NULL COLLATE {$COLLATE_TEXT},
6+
description VARCHAR(2047) NOT NULL COLLATE {$COLLATE_TEXT},
7+
viewPolicy VARBINARY(64) NOT NULL,
8+
editPolicy VARBINARY(64) NOT NULL,
9+
spacePHID varbinary(64) DEFAULT NULL
10+
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CREATE TABLE {$NAMESPACE}_phurl.phurl_urltransaction (
2+
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
3+
phid VARBINARY(64) NOT NULL,
4+
authorPHID VARBINARY(64) NOT NULL,
5+
objectPHID VARBINARY(64) NOT NULL,
6+
viewPolicy VARBINARY(64) NOT NULL,
7+
editPolicy VARBINARY(64) NOT NULL,
8+
commentPHID VARBINARY(64) DEFAULT NULL,
9+
commentVersion INT UNSIGNED NOT NULL,
10+
transactionType VARCHAR(32) COLLATE {$COLLATE_TEXT} NOT NULL,
11+
oldValue LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL,
12+
newValue LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL,
13+
contentSource LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL,
14+
metadata LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL,
15+
dateCreated INT UNSIGNED NOT NULL,
16+
dateModified INT UNSIGNED NOT NULL,
17+
UNIQUE KEY `key_phid` (`phid`),
18+
KEY `key_object` (`objectPHID`)
19+
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CREATE TABLE {$NAMESPACE}_phurl.phurl_urltransaction_comment (
2+
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
3+
phid VARBINARY(64) NOT NULL,
4+
transactionPHID VARBINARY(64) DEFAULT NULL,
5+
authorPHID VARBINARY(64) NOT NULL,
6+
viewPolicy VARBINARY(64) NOT NULL,
7+
editPolicy VARBINARY(64) NOT NULL,
8+
commentVersion INT UNSIGNED NOT NULL,
9+
content LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL,
10+
contentSource LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL,
11+
isDeleted TINYINT(1) NOT NULL,
12+
dateCreated INT UNSIGNED NOT NULL,
13+
dateModified INT UNSIGNED NOT NULL,
14+
UNIQUE KEY `key_phid` (`phid`),
15+
UNIQUE KEY `key_version` (`transactionPHID`,`commentVersion`)
16+
) ENGINE=InnoDB COLLATE {$COLLATE_TEXT}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE {$NAMESPACE}_phurl.phurl_url
2+
ADD dateCreated int unsigned NOT NULL,
3+
ADD dateModified int unsigned NOT NULL;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CREATE TABLE {$NAMESPACE}_phurl.edge (
2+
src VARBINARY(64) NOT NULL,
3+
type INT UNSIGNED NOT NULL,
4+
dst VARBINARY(64) NOT NULL,
5+
dateCreated INT UNSIGNED NOT NULL,
6+
seq INT UNSIGNED NOT NULL,
7+
dataID INT UNSIGNED,
8+
PRIMARY KEY (src, type, dst),
9+
KEY `src` (src, type, dateCreated, seq),
10+
UNIQUE KEY `key_dst` (dst, type, src)
11+
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
12+
13+
CREATE TABLE {$NAMESPACE}_phurl.edgedata (
14+
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
15+
data LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}
16+
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE {$NAMESPACE}_phurl.phurl_url
2+
ADD alias VARCHAR(64) COLLATE {$COLLATE_SORT};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ALTER TABLE {$NAMESPACE}_phurl.phurl_url
2+
ADD authorPHID VARBINARY(64) NOT NULL;
3+
4+
ALTER TABLE {$NAMESPACE}_phurl.phurl_url
5+
CHANGE description description LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT},
6+
CHANGE longURL longURL LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT};

src/__phutil_library_map__.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,6 +2476,21 @@
24762476
'PhabricatorPhrequentConfigOptions' => 'applications/phrequent/config/PhabricatorPhrequentConfigOptions.php',
24772477
'PhabricatorPhrictionApplication' => 'applications/phriction/application/PhabricatorPhrictionApplication.php',
24782478
'PhabricatorPhrictionConfigOptions' => 'applications/phriction/config/PhabricatorPhrictionConfigOptions.php',
2479+
'PhabricatorPhurlApplication' => 'applications/phurl/application/PhabricatorPhurlApplication.php',
2480+
'PhabricatorPhurlController' => 'applications/phurl/controller/PhabricatorPhurlController.php',
2481+
'PhabricatorPhurlDAO' => 'applications/phurl/storage/PhabricatorPhurlDAO.php',
2482+
'PhabricatorPhurlSchemaSpec' => 'applications/phurl/storage/PhabricatorPhurlSchemaSpec.php',
2483+
'PhabricatorPhurlURL' => 'applications/phurl/storage/PhabricatorPhurlURL.php',
2484+
'PhabricatorPhurlURLEditController' => 'applications/phurl/controller/PhabricatorPhurlURLEditController.php',
2485+
'PhabricatorPhurlURLEditor' => 'applications/phurl/editor/PhabricatorPhurlURLEditor.php',
2486+
'PhabricatorPhurlURLListController' => 'applications/phurl/controller/PhabricatorPhurlURLListController.php',
2487+
'PhabricatorPhurlURLPHIDType' => 'applications/phurl/phid/PhabricatorPhurlURLPHIDType.php',
2488+
'PhabricatorPhurlURLQuery' => 'applications/phurl/query/PhabricatorPhurlURLQuery.php',
2489+
'PhabricatorPhurlURLSearchEngine' => 'applications/phurl/query/PhabricatorPhurlURLSearchEngine.php',
2490+
'PhabricatorPhurlURLTransaction' => 'applications/phurl/storage/PhabricatorPhurlURLTransaction.php',
2491+
'PhabricatorPhurlURLTransactionComment' => 'applications/phurl/storage/PhabricatorPhurlURLTransactionComment.php',
2492+
'PhabricatorPhurlURLTransactionQuery' => 'applications/phurl/query/PhabricatorPhurlURLTransactionQuery.php',
2493+
'PhabricatorPhurlURLViewController' => 'applications/phurl/controller/PhabricatorPhurlURLViewController.php',
24792494
'PhabricatorPlatformSite' => 'aphront/site/PhabricatorPlatformSite.php',
24802495
'PhabricatorPolicies' => 'applications/policy/constants/PhabricatorPolicies.php',
24812496
'PhabricatorPolicy' => 'applications/policy/storage/PhabricatorPolicy.php',
@@ -6364,6 +6379,32 @@
63646379
'PhabricatorPhrequentConfigOptions' => 'PhabricatorApplicationConfigOptions',
63656380
'PhabricatorPhrictionApplication' => 'PhabricatorApplication',
63666381
'PhabricatorPhrictionConfigOptions' => 'PhabricatorApplicationConfigOptions',
6382+
'PhabricatorPhurlApplication' => 'PhabricatorApplication',
6383+
'PhabricatorPhurlController' => 'PhabricatorController',
6384+
'PhabricatorPhurlDAO' => 'PhabricatorLiskDAO',
6385+
'PhabricatorPhurlSchemaSpec' => 'PhabricatorConfigSchemaSpec',
6386+
'PhabricatorPhurlURL' => array(
6387+
'PhabricatorPhurlDAO',
6388+
'PhabricatorPolicyInterface',
6389+
'PhabricatorProjectInterface',
6390+
'PhabricatorApplicationTransactionInterface',
6391+
'PhabricatorSubscribableInterface',
6392+
'PhabricatorTokenReceiverInterface',
6393+
'PhabricatorDestructibleInterface',
6394+
'PhabricatorMentionableInterface',
6395+
'PhabricatorFlaggableInterface',
6396+
'PhabricatorSpacesInterface',
6397+
),
6398+
'PhabricatorPhurlURLEditController' => 'PhabricatorPhurlController',
6399+
'PhabricatorPhurlURLEditor' => 'PhabricatorApplicationTransactionEditor',
6400+
'PhabricatorPhurlURLListController' => 'PhabricatorPhurlController',
6401+
'PhabricatorPhurlURLPHIDType' => 'PhabricatorPHIDType',
6402+
'PhabricatorPhurlURLQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
6403+
'PhabricatorPhurlURLSearchEngine' => 'PhabricatorApplicationSearchEngine',
6404+
'PhabricatorPhurlURLTransaction' => 'PhabricatorApplicationTransaction',
6405+
'PhabricatorPhurlURLTransactionComment' => 'PhabricatorApplicationTransactionComment',
6406+
'PhabricatorPhurlURLTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
6407+
'PhabricatorPhurlURLViewController' => 'PhabricatorPhurlController',
63676408
'PhabricatorPlatformSite' => 'PhabricatorSite',
63686409
'PhabricatorPolicies' => 'PhabricatorPolicyConstants',
63696410
'PhabricatorPolicy' => array(
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
final class PhabricatorPhurlApplication extends PhabricatorApplication {
4+
5+
public function getName() {
6+
return pht('Phurl');
7+
}
8+
9+
public function getShortDescription() {
10+
return pht('URL Shortener');
11+
}
12+
13+
public function getFlavorText() {
14+
return pht('Shorten your favorite URL.');
15+
}
16+
17+
public function getBaseURI() {
18+
return '/phurl/';
19+
}
20+
21+
public function getFontIcon() {
22+
return 'fa-compress';
23+
}
24+
25+
public function isPrototype() {
26+
return true;
27+
}
28+
29+
public function getRoutes() {
30+
return array(
31+
'/U(?P<id>[1-9]\d*)' => 'PhabricatorPhurlURLViewController',
32+
'/phurl/' => array(
33+
'(?:query/(?P<queryKey>[^/]+)/)?'
34+
=> 'PhabricatorPhurlURLListController',
35+
'url/' => array(
36+
'create/'
37+
=> 'PhabricatorPhurlURLEditController',
38+
'edit/(?P<id>[1-9]\d*)/'
39+
=> 'PhabricatorPhurlURLEditController',
40+
),
41+
),
42+
);
43+
}
44+
45+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
abstract class PhabricatorPhurlController extends PhabricatorController {
4+
5+
protected function buildApplicationCrumbs() {
6+
$crumbs = parent::buildApplicationCrumbs();
7+
$crumbs->addAction(
8+
id(new PHUIListItemView())
9+
->setName(pht('Shorten URL'))
10+
->setHref($this->getApplicationURI().'url/create/')
11+
->setIcon('fa-plus-square'));
12+
13+
return $crumbs;
14+
}
15+
}

0 commit comments

Comments
 (0)