Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transparent list of projects #493 #495

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
18 changes: 12 additions & 6 deletions scrapyd/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,31 @@ def __init__(self, root, local_items):

def render_GET(self, txrequest):
vars = {
'projects': ', '.join(self.root.scheduler.list_projects()),
'base_path': self.get_base_path(txrequest),
}
s = """
s = """\
<html>
<head><title>Scrapyd</title></head>
<body>
<h1>Scrapyd</h1>
<p>Available projects: <b>%(projects)s</b></p>
<ul>
<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>

""" % vars
if self.root.scheduler.list_projects():
s += '<p>Available projects:<p>\n<ul>\n'
for project_name in sorted(self.root.scheduler.list_projects()):
s += f'<li>{project_name}</li>\n'
s += '</ul>\n'
else:
s += '<p>No projects available.</p>\n'
s += """
<h2>How to schedule a spider?</h2>

<p>To schedule a spider you need to use the API (this web UI is only for
Expand Down