Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
0c5e5569
Commit
0c5e5569
authored
Sep 03, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1360 from NARKOZ/api
API pagination
parents
cc03600b
76e4d94d
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
10 deletions
+30
-10
Gemfile.lock
Gemfile.lock
+4
-5
config/initializers/kaminari_config.rb
config/initializers/kaminari_config.rb
+10
-0
doc/api/README.md
doc/api/README.md
+7
-0
lib/api/helpers.rb
lib/api/helpers.rb
+4
-0
lib/api/issues.rb
lib/api/issues.rb
+2
-2
lib/api/milestones.rb
lib/api/milestones.rb
+1
-1
lib/api/projects.rb
lib/api/projects.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+1
-1
No files found.
Gemfile.lock
View file @
0c5e5569
...
...
@@ -198,7 +198,7 @@ GEM
httparty (0.8.3)
multi_json (~> 1.0)
multi_xml
i18n (0.6.
0
)
i18n (0.6.
1
)
journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
...
...
@@ -206,11 +206,10 @@ GEM
jquery-ui-rails (0.5.0)
jquery-rails
railties (>= 3.1.0)
json (1.7.
4
)
kaminari (0.1
3
.0)
json (1.7.
5
)
kaminari (0.1
4
.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
kgio (2.7.4)
launchy (2.1.0)
addressable (~> 2.2.6)
...
...
@@ -348,7 +347,7 @@ GEM
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.1
5.4
)
thor (0.1
6.0
)
tilt (1.3.3)
treetop (1.4.10)
polyglot
...
...
config/initializers/kaminari_config.rb
0 → 100644
View file @
0c5e5569
Kaminari
.
configure
do
|
config
|
config
.
default_per_page
=
20
config
.
max_per_page
=
100
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
end
doc/api/README.md
View file @
0c5e5569
...
...
@@ -23,6 +23,13 @@ GET http://example.com/api/v2/projects?private_token=QVy1PB7sTxfy4pqfZM1U
The API uses JSON to serialize data. You don't need to specify
`.json`
at the end of API URL.
#### Pagination
When listing resources you can pass the following parameters:
+
`page`
(default:
`1`
) - page number
+
`per_page`
(default:
`20`
, max:
`100`
) - how many items to list per page
## Contents
+
[
Users
](
https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/users.md
)
...
...
lib/api/helpers.rb
View file @
0c5e5569
...
...
@@ -14,6 +14,10 @@ module Gitlab
@project
end
def
paginate
(
object
)
object
.
page
(
params
[
:page
]).
per
(
params
[
:per_page
].
to_i
)
end
def
authenticate!
error!
({
'message'
=>
'401 Unauthorized'
},
401
)
unless
current_user
end
...
...
lib/api/issues.rb
View file @
0c5e5569
...
...
@@ -9,7 +9,7 @@ module Gitlab
# Example Request:
# GET /issues
get
do
present
current_user
.
issues
,
with:
Entities
::
Issue
present
paginate
(
current_user
.
issues
)
,
with:
Entities
::
Issue
end
end
...
...
@@ -21,7 +21,7 @@ module Gitlab
# Example Request:
# GET /projects/:id/issues
get
":id/issues"
do
present
user_project
.
issues
,
with:
Entities
::
Issue
present
paginate
(
user_project
.
issues
)
,
with:
Entities
::
Issue
end
# Get a single project issue
...
...
lib/api/milestones.rb
View file @
0c5e5569
...
...
@@ -11,7 +11,7 @@ module Gitlab
# Example Request:
# GET /projects/:id/milestones
get
":id/milestones"
do
present
user_project
.
milestones
,
with:
Entities
::
Milestone
present
paginate
(
user_project
.
milestones
)
,
with:
Entities
::
Milestone
end
# Get a single project milestone
...
...
lib/api/projects.rb
View file @
0c5e5569
...
...
@@ -9,7 +9,7 @@ module Gitlab
# Example Request:
# GET /projects
get
do
@projects
=
current_user
.
projects
@projects
=
paginate
current_user
.
projects
present
@projects
,
with:
Entities
::
Project
end
...
...
lib/api/users.rb
View file @
0c5e5569
...
...
@@ -9,7 +9,7 @@ module Gitlab
# Example Request:
# GET /users
get
do
@users
=
User
.
all
@users
=
paginate
User
present
@users
,
with:
Entities
::
User
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment