Skip to content

Commit

Permalink
feat: Copy-edit project listing
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Sep 25, 2023
1 parent 3e8825e commit 4ae46f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions scrapyd/tests/test_website.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def test_render_home(self, txrequest, site_no_egg):
content = site_no_egg.children[b''].render_GET(txrequest)
expect_headers = {
b'Content-Type': [b'text/html; charset=utf-8'],
b'Content-Length': [b'704'],
b'Content-Length': [b'714'],
}
if site_no_egg.local_items:
expect_headers[b'Content-Length'] = [b'740']
expect_headers[b'Content-Length'] = [b'751']

headers = dict(txrequest.responseHeaders.getAllRawHeaders())

Expand Down
16 changes: 7 additions & 9 deletions scrapyd/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def render_GET(self, txrequest):
vars = {
'base_path': self.get_base_path(txrequest),
}
s = """
s = """\
<html>
<head><title>Scrapyd</title></head>
<body>
Expand All @@ -82,21 +82,19 @@ def render_GET(self, txrequest):
<li><a href="%(base_path)s/jobs">Jobs</a></li>
"""
if self.local_items:
s += '<li><a href="%(base_path)s/items/">Items</a></li>'
s += """
s += '<li><a href="%(base_path)s/items/">Items</a></li>\n'
s += """\
<li><a href="%(base_path)s/logs/">Logs</a></li>
<li><a href="https://scrapyd.readthedocs.io/en/latest/">Documentation</a></li>
</ul>
<p>Available projects:<p>
""" % vars
if self.root.scheduler.list_projects():
s += '<ul>'
s += '<p>Available projects:<p>\n<ul>\n'
for project_name in sorted(self.root.scheduler.list_projects()):
s += '<li>' + project_name + '</li>'
s += '</ul>'
s += f'<li>{project_name}</li>\n'
s += '</ul>\n'
else:
s += '<b>no projects</b>'
s += '<p>No projects available.</p>\n'
s += """
<h2>How to schedule a spider?</h2>
Expand Down

0 comments on commit 4ae46f4

Please sign in to comment.