about summary refs log tree commit diff
path: root/app/views/api/v1
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-27 16:58:23 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-27 16:59:08 +0200
commit4f9b7432dd4d323ac6cc4efceeae2efaffe62e7d (patch)
treeacae9e59bd6971885f7cb7b7ed45c4c9d1af4fca /app/views/api/v1
parent3f75f522856954690d92358107e78bafd0db0baa (diff)
Fix #52 - Add API versioning (v1)
Diffstat (limited to 'app/views/api/v1')
-rw-r--r--app/views/api/v1/accounts/followers.rabl2
-rw-r--r--app/views/api/v1/accounts/following.rabl2
-rw-r--r--app/views/api/v1/accounts/relationship.rabl5
-rw-r--r--app/views/api/v1/accounts/relationships.rabl2
-rw-r--r--app/views/api/v1/accounts/show.rabl10
-rw-r--r--app/views/api/v1/accounts/statuses.rabl2
-rw-r--r--app/views/api/v1/apps/create.rabl4
-rw-r--r--app/views/api/v1/follows/show.rabl2
-rw-r--r--app/views/api/v1/media/create.rabl5
-rw-r--r--app/views/api/v1/statuses/context.rabl13
-rw-r--r--app/views/api/v1/statuses/home.rabl2
-rw-r--r--app/views/api/v1/statuses/mentions.rabl2
-rw-r--r--app/views/api/v1/statuses/show.rabl31
13 files changed, 82 insertions, 0 deletions
diff --git a/app/views/api/v1/accounts/followers.rabl b/app/views/api/v1/accounts/followers.rabl
new file mode 100644
index 000000000..c54b0487e
--- /dev/null
+++ b/app/views/api/v1/accounts/followers.rabl
@@ -0,0 +1,2 @@
+collection @followers
+extends('api/v1/accounts/show')
diff --git a/app/views/api/v1/accounts/following.rabl b/app/views/api/v1/accounts/following.rabl
new file mode 100644
index 000000000..87b454ffa
--- /dev/null
+++ b/app/views/api/v1/accounts/following.rabl
@@ -0,0 +1,2 @@
+collection @following
+extends('api/v1/accounts/show')
diff --git a/app/views/api/v1/accounts/relationship.rabl b/app/views/api/v1/accounts/relationship.rabl
new file mode 100644
index 000000000..3e5bf882c
--- /dev/null
+++ b/app/views/api/v1/accounts/relationship.rabl
@@ -0,0 +1,5 @@
+object @account
+attribute :id
+node(:following)   { |account| @following[account.id]   || false }
+node(:followed_by) { |account| @followed_by[account.id] || false }
+node(:blocking)    { |account| @blocking[account.id]    || false }
diff --git a/app/views/api/v1/accounts/relationships.rabl b/app/views/api/v1/accounts/relationships.rabl
new file mode 100644
index 000000000..022ea2ac4
--- /dev/null
+++ b/app/views/api/v1/accounts/relationships.rabl
@@ -0,0 +1,2 @@
+collection @accounts
+extends 'api/v1/accounts/relationship'
diff --git a/app/views/api/v1/accounts/show.rabl b/app/views/api/v1/accounts/show.rabl
new file mode 100644
index 000000000..4f6a3ff99
--- /dev/null
+++ b/app/views/api/v1/accounts/show.rabl
@@ -0,0 +1,10 @@
+object @account
+
+attributes :id, :username, :acct, :display_name, :note
+
+node(:url)             { |account| TagManager.instance.url_for(account) }
+node(:avatar)          { |account| full_asset_url(account.avatar.url(:large, false)) }
+node(:header)          { |account| full_asset_url(account.header.url(:medium, false)) }
+node(:followers_count) { |account| account.followers.count }
+node(:following_count) { |account| account.following.count }
+node(:statuses_count)  { |account| account.statuses.count  }
diff --git a/app/views/api/v1/accounts/statuses.rabl b/app/views/api/v1/accounts/statuses.rabl
new file mode 100644
index 000000000..0a0ed13c5
--- /dev/null
+++ b/app/views/api/v1/accounts/statuses.rabl
@@ -0,0 +1,2 @@
+collection @statuses
+extends('api/v1/statuses/show')
diff --git a/app/views/api/v1/apps/create.rabl b/app/views/api/v1/apps/create.rabl
new file mode 100644
index 000000000..1ff6469a4
--- /dev/null
+++ b/app/views/api/v1/apps/create.rabl
@@ -0,0 +1,4 @@
+object @app
+attributes :id, :redirect_uri
+node(:client_id) { |app| app.uid }
+node(:client_secret) { |app| app.secret }
diff --git a/app/views/api/v1/follows/show.rabl b/app/views/api/v1/follows/show.rabl
new file mode 100644
index 000000000..e07106164
--- /dev/null
+++ b/app/views/api/v1/follows/show.rabl
@@ -0,0 +1,2 @@
+object @account
+extends('api/v1/accounts/show')
diff --git a/app/views/api/v1/media/create.rabl b/app/views/api/v1/media/create.rabl
new file mode 100644
index 000000000..803a93094
--- /dev/null
+++ b/app/views/api/v1/media/create.rabl
@@ -0,0 +1,5 @@
+object @media
+attribute :id, :type
+node(:url) { |media| full_asset_url(media.file.url) }
+node(:preview_url) { |media| full_asset_url(media.file.url(:small)) }
+node(:text_url) { |media| medium_url(media) }
diff --git a/app/views/api/v1/statuses/context.rabl b/app/views/api/v1/statuses/context.rabl
new file mode 100644
index 000000000..e9176dc29
--- /dev/null
+++ b/app/views/api/v1/statuses/context.rabl
@@ -0,0 +1,13 @@
+object false
+
+node :ancestors do
+  @ancestors.map do |status|
+    partial('api/v1/statuses/show', object: status)
+  end
+end
+
+node :descendants do
+  @descendants.map do |status|
+    partial('api/v1/statuses/show', object: status)
+  end
+end
diff --git a/app/views/api/v1/statuses/home.rabl b/app/views/api/v1/statuses/home.rabl
new file mode 100644
index 000000000..0a0ed13c5
--- /dev/null
+++ b/app/views/api/v1/statuses/home.rabl
@@ -0,0 +1,2 @@
+collection @statuses
+extends('api/v1/statuses/show')
diff --git a/app/views/api/v1/statuses/mentions.rabl b/app/views/api/v1/statuses/mentions.rabl
new file mode 100644
index 000000000..0a0ed13c5
--- /dev/null
+++ b/app/views/api/v1/statuses/mentions.rabl
@@ -0,0 +1,2 @@
+collection @statuses
+extends('api/v1/statuses/show')
diff --git a/app/views/api/v1/statuses/show.rabl b/app/views/api/v1/statuses/show.rabl
new file mode 100644
index 000000000..3595bafb4
--- /dev/null
+++ b/app/views/api/v1/statuses/show.rabl
@@ -0,0 +1,31 @@
+object @status
+attributes :id, :created_at, :in_reply_to_id
+
+node(:uri)              { |status| TagManager.instance.uri_for(status) }
+node(:content)          { |status| Formatter.instance.format(status) }
+node(:url)              { |status| TagManager.instance.url_for(status) }
+node(:reblogs_count)    { |status| status.reblogs_count }
+node(:favourites_count) { |status| status.favourites_count }
+node(:favourited)       { |status| current_account.favourited?(status) }
+node(:reblogged)        { |status| current_account.reblogged?(status) }
+
+child :reblog => :reblog do
+  extends('api/v1/statuses/show')
+end
+
+child :account do
+  extends('api/v1/accounts/show')
+end
+
+child :media_attachments, object_root: false do
+  attributes :id, :remote_url, :type
+
+  node(:url)         { |media| full_asset_url(media.file.url) }
+  node(:preview_url) { |media| full_asset_url(media.file.url(:small)) }
+end
+
+child :mentions, object_root: false do
+  node(:url)  { |mention| TagManager.instance.url_for(mention.account) }
+  node(:acct) { |mention| mention.account.acct }
+  node(:id)   { |mention| mention.account_id }
+end