about summary refs log tree commit diff
path: root/app/views
diff options
context:
space:
mode:
authorEvan Minto <evan.minto@gmail.com>2017-04-22 20:21:10 -0700
committerEugen <eugen@zeonfederated.com>2017-04-23 05:21:10 +0200
commit66fd8e782182390df81f1ed46f3a04f3a01d681e (patch)
treef8f6ffb3bfc220e3e8e7efaf273e285b932f1962 /app/views
parent83e35381814baf4ae5f420531d83c0450716f875 (diff)
ActivityPub: Add basic, read-only support for Outboxes, Notes, and Create/Announce Activities (#2197)
* Clean up collapsible components

* Expose user Outboxes and AS2 representations of statuses

* Save work thus far.

* Fix bad merge.

* Save my work

* Clean up pagination.

* First test working.

* Add tests.

* Add Forbidden error template.

* Revert yarn.lock changes.

* Fix code style deviations and use localized instead of hardcoded English text.
Diffstat (limited to 'app/views')
-rw-r--r--app/views/accounts/show.activitystreams2.rabl1
-rw-r--r--app/views/activitypub/types/announce.activitystreams2.rabl3
-rw-r--r--app/views/activitypub/types/collection.activitystreams2.rabl5
-rw-r--r--app/views/activitypub/types/create.activitystreams2.rabl3
-rw-r--r--app/views/activitypub/types/note.activitystreams2.rabl3
-rw-r--r--app/views/activitypub/types/ordered_collection.activitystreams2.rabl3
-rw-r--r--app/views/activitypub/types/ordered_collection_page.activitystreams2.rabl4
-rw-r--r--app/views/api/activitypub/activities/_show_status.activitystreams2.rabl4
-rw-r--r--app/views/api/activitypub/activities/show_status_announce.activitystreams2.rabl8
-rw-r--r--app/views/api/activitypub/activities/show_status_create.activitystreams2.rabl8
-rw-r--r--app/views/api/activitypub/notes/show.activitystreams2.rabl11
-rw-r--r--app/views/api/activitypub/outbox/show.activitystreams2.rabl23
-rw-r--r--app/views/errors/403.html.haml5
13 files changed, 81 insertions, 0 deletions
diff --git a/app/views/accounts/show.activitystreams2.rabl b/app/views/accounts/show.activitystreams2.rabl
index dabae3f29..2c0a4ad3a 100644
--- a/app/views/accounts/show.activitystreams2.rabl
+++ b/app/views/accounts/show.activitystreams2.rabl
@@ -6,3 +6,4 @@ attributes display_name: :name, username: :preferredUsername, note: :summary
 
 node(:icon)   { |account| full_asset_url(account.avatar.url(:original)) }
 node(:image)  { |account| full_asset_url(account.header.url(:original)) }
+node(:outbox) { |account| api_activitypub_outbox_url(account.id) }
diff --git a/app/views/activitypub/types/announce.activitystreams2.rabl b/app/views/activitypub/types/announce.activitystreams2.rabl
new file mode 100644
index 000000000..4a29aa134
--- /dev/null
+++ b/app/views/activitypub/types/announce.activitystreams2.rabl
@@ -0,0 +1,3 @@
+extends 'activitypub/intransient.activitystreams2.rabl'
+
+node(:type) { 'Announce' }
diff --git a/app/views/activitypub/types/collection.activitystreams2.rabl b/app/views/activitypub/types/collection.activitystreams2.rabl
new file mode 100644
index 000000000..9e7e14e2b
--- /dev/null
+++ b/app/views/activitypub/types/collection.activitystreams2.rabl
@@ -0,0 +1,5 @@
+extends 'activitypub/intransient.activitystreams2.rabl'
+
+node(:type)       { 'Collection' }
+node(:items)      { [] }
+node(:totalItems) { 0 }
diff --git a/app/views/activitypub/types/create.activitystreams2.rabl b/app/views/activitypub/types/create.activitystreams2.rabl
new file mode 100644
index 000000000..e41a056a7
--- /dev/null
+++ b/app/views/activitypub/types/create.activitystreams2.rabl
@@ -0,0 +1,3 @@
+extends 'activitypub/intransient.activitystreams2.rabl'
+
+node(:type) { 'Create' }
diff --git a/app/views/activitypub/types/note.activitystreams2.rabl b/app/views/activitypub/types/note.activitystreams2.rabl
new file mode 100644
index 000000000..39c74d4ba
--- /dev/null
+++ b/app/views/activitypub/types/note.activitystreams2.rabl
@@ -0,0 +1,3 @@
+extends 'activitypub/intransient.activitystreams2.rabl'
+
+node(:type) { 'Note' }
diff --git a/app/views/activitypub/types/ordered_collection.activitystreams2.rabl b/app/views/activitypub/types/ordered_collection.activitystreams2.rabl
new file mode 100644
index 000000000..2cda6f4d0
--- /dev/null
+++ b/app/views/activitypub/types/ordered_collection.activitystreams2.rabl
@@ -0,0 +1,3 @@
+extends 'activitypub/types/collection.activitystreams2.rabl'
+
+node(:type) { 'OrderedCollection' }
diff --git a/app/views/activitypub/types/ordered_collection_page.activitystreams2.rabl b/app/views/activitypub/types/ordered_collection_page.activitystreams2.rabl
new file mode 100644
index 000000000..f498fe8e5
--- /dev/null
+++ b/app/views/activitypub/types/ordered_collection_page.activitystreams2.rabl
@@ -0,0 +1,4 @@
+extends 'activitypub/types/ordered_collection.activitystreams2.rabl'
+
+node(:type)     { 'OrderedCollectionPage' }
+node(:current)  { request.original_url }
diff --git a/app/views/api/activitypub/activities/_show_status.activitystreams2.rabl b/app/views/api/activitypub/activities/_show_status.activitystreams2.rabl
new file mode 100644
index 000000000..472bf5dbd
--- /dev/null
+++ b/app/views/api/activitypub/activities/_show_status.activitystreams2.rabl
@@ -0,0 +1,4 @@
+object @status
+
+node(:actor)     { |status| TagManager.instance.url_for(status.account) }
+node(:published) { |status| status.created_at.to_time.xmlschema }
\ No newline at end of file
diff --git a/app/views/api/activitypub/activities/show_status_announce.activitystreams2.rabl b/app/views/api/activitypub/activities/show_status_announce.activitystreams2.rabl
new file mode 100644
index 000000000..44ac1ba2f
--- /dev/null
+++ b/app/views/api/activitypub/activities/show_status_announce.activitystreams2.rabl
@@ -0,0 +1,8 @@
+extends 'activitypub/types/announce.activitystreams2.rabl'
+extends 'api/activitypub/activities/_show_status.activitystreams2.rabl'
+
+object @status
+
+node(:name)   { |status| t('activitypub.activity.announce.name', account_name: account_name(status.account)) }
+node(:url)    { |status| TagManager.instance.url_for(status) }
+node(:object) { |status| api_activitypub_status_url(status.reblog_of_id) }
diff --git a/app/views/api/activitypub/activities/show_status_create.activitystreams2.rabl b/app/views/api/activitypub/activities/show_status_create.activitystreams2.rabl
new file mode 100644
index 000000000..ff4d39eca
--- /dev/null
+++ b/app/views/api/activitypub/activities/show_status_create.activitystreams2.rabl
@@ -0,0 +1,8 @@
+extends 'activitypub/types/create.activitystreams2.rabl'
+extends 'api/activitypub/activities/_show_status.activitystreams2.rabl'
+
+object @status
+
+node(:name)   { |status| t('activitypub.activity.create.name', account_name: account_name(status.account)) }
+node(:url)    { |status| TagManager.instance.url_for(status) }
+node(:object) { |status| api_activitypub_note_url(status) }
diff --git a/app/views/api/activitypub/notes/show.activitystreams2.rabl b/app/views/api/activitypub/notes/show.activitystreams2.rabl
new file mode 100644
index 000000000..d962f4438
--- /dev/null
+++ b/app/views/api/activitypub/notes/show.activitystreams2.rabl
@@ -0,0 +1,11 @@
+extends 'activitypub/types/note.activitystreams2.rabl'
+
+object @status
+
+attributes :content
+
+node(:name)         { |status| status.content }
+node(:url)          { |status| TagManager.instance.url_for(status) }
+node(:attributedTo) { |status| TagManager.instance.url_for(status.account) }
+node(:inReplyTo)    { |status| api_activitypub_note_url(status.thread) } if @status.thread
+node(:published)    { |status| status.created_at.to_time.xmlschema }
diff --git a/app/views/api/activitypub/outbox/show.activitystreams2.rabl b/app/views/api/activitypub/outbox/show.activitystreams2.rabl
new file mode 100644
index 000000000..a498f74bc
--- /dev/null
+++ b/app/views/api/activitypub/outbox/show.activitystreams2.rabl
@@ -0,0 +1,23 @@
+if @paginated
+  extends 'activitypub/types/ordered_collection_page.activitystreams2.rabl'
+else
+  extends 'activitypub/types/ordered_collection.activitystreams2.rabl'
+end
+
+object @account
+
+node(:items) do
+  @statuses.map { |status| api_activitypub_status_url(status) }
+end
+
+node(:totalItems) { @statuses.count }
+node(:next)       { @next_path } if @next_path
+node(:prev)       { @prev_path } if @prev_path
+
+node(:name)       { |account| t('activitypub.outbox.name', account_name: account_name(account)) }
+node(:summary)    { |account| t('activitypub.outbox.summary', account_name: account_name(account)) }
+node(:updated) do |account|
+  times = @statuses.map { |status| status.updated_at.to_time }
+  times << account.created_at.to_time
+  times.max.xmlschema
+end
diff --git a/app/views/errors/403.html.haml b/app/views/errors/403.html.haml
new file mode 100644
index 000000000..c6e421f4f
--- /dev/null
+++ b/app/views/errors/403.html.haml
@@ -0,0 +1,5 @@
+- content_for :page_title do
+  = t('errors.403')
+
+- content_for :content do
+  = t('errors.403')
\ No newline at end of file