Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rxd
AI
Commits
29db51d3
Commit
29db51d3
authored
2 years ago
by
rxd
Browse files
Options
Downloads
Patches
Plain Diff
pagination added
parent
0b5df2c4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
MemeGenerator/templates/index.html
+1
-1
1 addition, 1 deletion
MemeGenerator/templates/index.html
MemeGenerator/templates/search_res.html
+21
-1
21 additions, 1 deletion
MemeGenerator/templates/search_res.html
MemeGenerator/views/index.py
+18
-4
18 additions, 4 deletions
MemeGenerator/views/index.py
with
40 additions
and
6 deletions
MemeGenerator/templates/index.html
+
1
−
1
View file @
29db51d3
...
...
@@ -5,7 +5,7 @@
<div
class=
"card-header"
>
Your next Viral Meme starts here...
</div>
<div
class=
"card-body"
>
<div
class=
"form-center"
>
<form
action=
"
/search
"
method=
"GET"
>
<form
action=
"
{{url_for("
show_search
",
page=
1)}}
"
method=
"GET"
>
<input
type=
"text"
value=
"{{ query }}"
name=
"q"
/>
<input
type=
"submit"
value=
"Search"
/>
</form>
...
...
This diff is collapsed.
Click to expand it.
MemeGenerator/templates/search_res.html
+
21
−
1
View file @
29db51d3
...
...
@@ -8,7 +8,7 @@
<img
src=
"{{item.url}}"
class=
"card-img-top"
alt=
"meme"
>
<div
class=
"card-body"
>
<div
class=
'form-center'
>
<form
action=
"
/setup
"
method=
"GET"
>
<form
action=
"
{{url_for("
show_search
",
page=
current)
}}
"
method=
"GET"
>
<input
type=
"hidden"
value=
"{{ item.url }}"
name=
"url"
/>
<input
type=
"submit"
value=
"This One!"
/>
</form>
...
...
@@ -17,5 +17,25 @@
</div>
</div>
{% endfor %}
<div
class=
"prev-next-btn"
>
<div
class=
'row'
>
<div
class=
'col-6'
>
<div
class=
"form-center"
>
<form
action=
"{{url_for("
show_search
",
page=
prev)}}"
method=
"GET"
>
<input
type=
"hidden"
value=
"{{ query }}"
name=
"q"
/>
<input
type=
"submit"
value=
"prev"
/>
</form>
</div>
</div>
<div
class=
'col-6'
>
<div
class=
"form-center"
>
<form
action=
"{{url_for("
show_search
",
page=
next)}}"
method=
"GET"
>
<input
type=
"hidden"
value=
"{{ query }}"
name=
"q"
/>
<input
type=
"submit"
value=
"next"
/>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
MemeGenerator/views/index.py
+
18
−
4
View file @
29db51d3
...
...
@@ -21,16 +21,30 @@ def show_index():
"""
Show index page
"""
return
flask
.
render_template
(
'
index.html
'
)
@MemeGenerator.app.route
(
'
/search
'
)
def
show_search
():
@MemeGenerator.app.route
(
'
/search
/<page>
'
)
def
show_search
(
page
=
1
):
"""
Show result search page.
"""
query
=
flask
.
request
.
args
.
get
(
'
q
'
)
page
=
int
(
page
)
if
page
<
1
:
page
=
1
search_resutlts
=
flickr
.
photos
.
search
(
text
=
query
,
page
=
1
,
page
=
page
,
per_page
=
20
,
safe_search
=
1
,
sort
=
'
relevance
'
)[
'
photos
'
]
[
'
photo
'
]
sort
=
'
relevance
'
)[
'
photos
'
]
context
=
defaultdict
(
list
)
pages
=
search_resutlts
[
'
pages
'
]
search_resutlts
=
search_resutlts
[
'
photo
'
]
# flip the searches, check for boundary conditions
context
[
'
next
'
]
=
page
context
[
'
prev
'
]
=
page
if
page
+
1
<
pages
:
context
[
'
next
'
]
=
page
+
1
if
page
-
1
>
0
:
context
[
'
prev
'
]
=
page
-
1
context
[
'
query
'
]
=
query
context
[
'
current
'
]
=
page
for
one
in
search_resutlts
:
url
=
'
https://live.staticflickr.com/{}/{}_{}.jpg
'
.
format
(
one
[
'
server
'
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment