Title: [253721] trunk/Tools
Revision
253721
Author
[email protected]
Date
2019-12-18 14:22:24 -0800 (Wed, 18 Dec 2019)

Log Message

results.webkit.org: Serve files in uploaded archive
https://bugs.webkit.org/show_bug.cgi?id=201654

Reviewed by Stephanie Lewis.

* resultsdbpy/resultsdbpy/controller/configuration.py:
(Configuration.to_query): Conver a configuration object to a query string.
* resultsdbpy/resultsdbpy/controller/configuration_unittest.py:
(ConfigurationUnittest):
(ConfigurationUnittest.test_to_query):
* resultsdbpy/resultsdbpy/flask_support/util.py:
(query_as_string): Convert the current query to a string.
* resultsdbpy/resultsdbpy/model/archive_context.py:
(ArchiveContext._files_for_archive): Python's shutil creates archives which
don't have have a root directory.
(ArchiveContext.file): We need to add query parameters to relative links
In the returned file.
* resultsdbpy/resultsdbpy/view/archive_view.py: Added.
(ArchiveView):
(ArchiveView.__init__):
(ArchiveView.list): Return html which lists and links to the provided paths.
(ArchiveView.extract): Endpoint which extracts a file from an archive matching
the provided arguments.
* resultsdbpy/resultsdbpy/view/archive_view_unittest.py: Added.
(ArchiveViewUnittest):
(ArchiveViewUnittest.register_archive):
(ArchiveViewUnittest.test_directory):
(ArchiveViewUnittest.test_file):
* resultsdbpy/resultsdbpy/view/templates/archive_list.html: Added.
* resultsdbpy/resultsdbpy/view/view_routes.py:
(ViewRoutes.__init__): Add archive endpoints.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (253720 => 253721)


--- trunk/Tools/ChangeLog	2019-12-18 22:20:55 UTC (rev 253720)
+++ trunk/Tools/ChangeLog	2019-12-18 22:22:24 UTC (rev 253721)
@@ -1,3 +1,37 @@
+2019-12-18  Jonathan Bedard  <[email protected]>
+
+        results.webkit.org: Serve files in uploaded archive
+        https://bugs.webkit.org/show_bug.cgi?id=201654
+
+        Reviewed by Stephanie Lewis.
+
+        * resultsdbpy/resultsdbpy/controller/configuration.py:
+        (Configuration.to_query): Conver a configuration object to a query string.
+        * resultsdbpy/resultsdbpy/controller/configuration_unittest.py:
+        (ConfigurationUnittest):
+        (ConfigurationUnittest.test_to_query):
+        * resultsdbpy/resultsdbpy/flask_support/util.py:
+        (query_as_string): Convert the current query to a string.
+        * resultsdbpy/resultsdbpy/model/archive_context.py:
+        (ArchiveContext._files_for_archive): Python's shutil creates archives which
+        don't have have a root directory.
+        (ArchiveContext.file): We need to add query parameters to relative links
+        In the returned file.
+        * resultsdbpy/resultsdbpy/view/archive_view.py: Added.
+        (ArchiveView):
+        (ArchiveView.__init__):
+        (ArchiveView.list): Return html which lists and links to the provided paths.
+        (ArchiveView.extract): Endpoint which extracts a file from an archive matching
+        the provided arguments.
+        * resultsdbpy/resultsdbpy/view/archive_view_unittest.py: Added.
+        (ArchiveViewUnittest):
+        (ArchiveViewUnittest.register_archive):
+        (ArchiveViewUnittest.test_directory):
+        (ArchiveViewUnittest.test_file):
+        * resultsdbpy/resultsdbpy/view/templates/archive_list.html: Added.
+        * resultsdbpy/resultsdbpy/view/view_routes.py:
+        (ViewRoutes.__init__): Add archive endpoints.
+
 2019-12-18  Matt Lewis  <[email protected]>
 
         Update WebGL bot hostname

Modified: trunk/Tools/resultsdbpy/resultsdbpy/controller/configuration.py (253720 => 253721)


--- trunk/Tools/resultsdbpy/resultsdbpy/controller/configuration.py	2019-12-18 22:20:55 UTC (rev 253720)
+++ trunk/Tools/resultsdbpy/resultsdbpy/controller/configuration.py	2019-12-18 22:22:24 UTC (rev 253721)
@@ -184,6 +184,23 @@
     def to_json(self, pretty_print=False):
         return json.dumps(self, cls=self.Encoder, sort_keys=pretty_print, indent=4 if pretty_print else None)
 
+    def to_query(self):
+        query = ''
+        for member in self.REQUIRED_MEMBERS + self.OPTIONAL_MEMBERS + self.FILTERING_MEMBERS:
+            value = getattr(self, member)
+            if value is None:
+                continue
+
+            if member == 'version':
+                query += f'{member}={self.integer_to_version(value)}&'
+            elif member == 'is_simulator':
+                query += f"{member}={'True' if value else 'False'}&"
+            else:
+                query += f'{member}={value}&'
+        if query:
+            return query[:-1]
+        return ''
+
     class Encoder(FlaskJSONEncoder):
 
         def default(self, obj):

Modified: trunk/Tools/resultsdbpy/resultsdbpy/controller/configuration_unittest.py (253720 => 253721)


--- trunk/Tools/resultsdbpy/resultsdbpy/controller/configuration_unittest.py	2019-12-18 22:20:55 UTC (rev 253720)
+++ trunk/Tools/resultsdbpy/resultsdbpy/controller/configuration_unittest.py	2019-12-18 22:22:24 UTC (rev 253721)
@@ -78,3 +78,21 @@
         for config in configs:
             converted_config = Configuration.from_json(config.to_json())
             self.assertEqual(config, converted_config)
+
+    def test_to_query(self):
+        self.assertEqual(
+            Configuration(platform='Mac', version='10.14', is_simulator=False, architecture='x86_64', style='Debug', flavor='wk2').to_query(),
+            'platform=Mac&is_simulator=False&version=10.14.0&architecture=x86_64&style=Debug&flavor=wk2',
+        )
+        self.assertEqual(
+            Configuration(platform='Mac', version='10.14', style='Production', flavor='wk2').to_query(),
+            'platform=Mac&version=10.14.0&style=Production&flavor=wk2',
+        )
+        self.assertEqual(
+            Configuration(platform='iOS', version='11', is_simulator=True, architecture='x86_64', style='Debug').to_query(),
+            'platform=iOS&is_simulator=True&version=11.0.0&architecture=x86_64&style=Debug',
+        )
+        self.assertEqual(
+            Configuration(platform='iOS', version='12', is_simulator=False, architecture='arm64', style='Release').to_query(),
+            'platform=iOS&is_simulator=False&version=12.0.0&architecture=arm64&style=Release',
+        )

Modified: trunk/Tools/resultsdbpy/resultsdbpy/flask_support/util.py (253720 => 253721)


--- trunk/Tools/resultsdbpy/resultsdbpy/flask_support/util.py	2019-12-18 22:20:55 UTC (rev 253720)
+++ trunk/Tools/resultsdbpy/resultsdbpy/flask_support/util.py	2019-12-18 22:22:24 UTC (rev 253721)
@@ -75,6 +75,14 @@
     return decorator
 
 
+def query_as_string():
+    query = '?'
+    for key, values in request.args.to_dict(flat=False).items():
+        for value in values:
+            query += f'{key}={value}&'
+    return query[:-1]
+
+
 def boolean_query(*args):
 
     def func(string):

Modified: trunk/Tools/resultsdbpy/resultsdbpy/model/archive_context.py (253720 => 253721)


--- trunk/Tools/resultsdbpy/resultsdbpy/model/archive_context.py	2019-12-18 22:20:55 UTC (rev 253720)
+++ trunk/Tools/resultsdbpy/resultsdbpy/model/archive_context.py	2019-12-18 22:22:24 UTC (rev 253721)
@@ -221,6 +221,9 @@
     def _files_for_archive(cls, archive):
         master = None
         files = set()
+
+        archive_list = []
+        is_mastered = True
         for item in archive.namelist():
             if item.startswith('__'):
                 continue
@@ -227,9 +230,26 @@
 
             if not master:
                 master = item
-                continue
+            else:
+                if is_mastered and not item.startswith(master):
+                    is_mastered = False
+                    archive_list.append(master)
+                archive_list.append(item)
 
-            files.add(item[len(master):])
+        if not is_mastered:
+            master = None
+        for item in archive_list:
+            if master:
+                item_to_add = item[len(master):]
+            else:
+                item_to_add = item
+
+            files.add(item_to_add)
+            built = ''
+            for partial in item_to_add.split('/')[:-1]:
+                built = f'{built}{partial}/'
+                files.add(built)
+
         return master, sorted([*files])
 
     def ls(self, *args, **kwargs):
@@ -264,8 +284,29 @@
                     elif path[-1] == '/':
                         file = [f[len(path):] for f in files if f.startswith(path)]
                     elif path in files:
-                        file = unpacked.open(master + path).read()
+                        file = unpacked.open('{}{}'.format(master or '', path)).read()
+                        query = f'?{config.to_query()}'
+                        if len(query) > 1:
+                            query += '&'
+                        if archive['uuid']:
+                            query += f"uuid={archive['uuid']}&"
+                        if archive['start_time']:
+                            query += f"after_time={archive['start_time']}&before_time={archive['start_time']}&"
 
+                        query = query[:-1]
+
+                        # If we find references to other files in the archive, we need to replace those references
+                        # with references that include the query
+                        parent_path = '/'.join(path.split('/')[:-1])
+                        for f in files:
+                            if f[-1] == '/' or f == path or not query:
+                                continue
+                            if f.startswith(parent_path):
+                                file = file.replace(f[len(parent_path):].encode('utf-8'), f'{f[len(parent_path):]}{query}'.encode('utf-8'))
+                            else:
+                                file = file.replace(f.encode('utf-8'), f'{f}{query}'.encode('utf-8'))
+
+
                 if file:
                     result[config].append(dict(
                         uuid=archive['uuid'],

Added: trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view.py (0 => 253721)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view.py	                        (rev 0)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view.py	2019-12-18 22:22:24 UTC (rev 253721)
@@ -0,0 +1,136 @@
+# Copyright (C) 2019 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import json
+
+from flask import abort, jsonify, request, Response
+from resultsdbpy.controller.commit_controller import uuid_range_for_query, HasCommitContext
+from resultsdbpy.controller.configuration_controller import configuration_for_query
+from resultsdbpy.controller.suite_controller import time_range_for_query
+from resultsdbpy.flask_support.util import AssertRequest, query_as_kwargs, limit_for_query, boolean_query, query_as_string
+from resultsdbpy.view.site_menu import SiteMenu
+
+
+class ArchiveView(HasCommitContext):
+    DEFAULT_LIMIT = 10
+    FORMAT = dict(
+        json='application/json',
+        css='text/css',
+        html='text/html',
+        txt='text/plain',
+        png='image/png',
+        jpeg='image/jpeg',
+    )
+
+    def __init__(self, environment, archive_controller, site_menu=None):
+        super(ArchiveView, self).__init__(archive_controller.commit_context)
+        self.environment = environment
+
+        self.archive_context = archive_controller.archive_context
+        self.upload_context = archive_controller.upload_context
+        self.site_menu = site_menu
+
+    @SiteMenu.render_with_site_menu()
+    def list(self, path, values, **kwargs):
+        return self.environment.get_template('archive_list.html').render(
+            title=f'{self.site_menu.title}: archive/f{path or ""}',
+            path=path or '', values=values,
+            query=query_as_string(),
+            **kwargs)
+
+    @query_as_kwargs()
+    @uuid_range_for_query()
+    @limit_for_query(DEFAULT_LIMIT)
+    @configuration_for_query()
+    @time_range_for_query()
+    def extract(
+        self, path=None, format=None,
+        suite=None, configurations=None, recent=None,
+        branch=None, begin=None, end=None,
+        begin_query_time=None, end_query_time=None,
+        limit=None, **kwargs
+    ):
+        AssertRequest.is_type(['GET'])
+        AssertRequest.query_kwargs_empty(**kwargs)
+        recent = boolean_query(*recent)[0] if recent else True
+
+        if not suite:
+            suites = set()
+            for config_suites in self.upload_context.find_suites(configurations=configurations, recent=recent).values():
+                [suites.add(suite) for suite in config_suites]
+        else:
+            suites = set(suite)
+
+        result = None
+        with self.archive_context, self.upload_context:
+            for suite in suites:
+                for files in self.archive_context.file(
+                    path=path,
+                    configurations=configurations, suite=suite, branch=branch[0],
+                    begin=begin, end=end, recent=recent, limit=2,
+                    begin_query_time=begin_query_time, end_query_time=end_query_time,
+                ).values():
+                    for file in files:
+                        candidate = file.get('file')
+                        if not candidate:
+                            continue
+                        if not result:
+                            if isinstance(candidate, list):
+                                result = set(candidate)
+                            else:
+                                result = candidate
+                            continue
+                        if isinstance(candidate, list) and isinstance(result, set):
+                            result |= set(candidate)
+                            continue
+                        if result == candidate:
+                            continue
+                        abort(403, 'Multiple archives match with different content')
+
+        if not result:
+            abort(404, f"No archive content{' at ' + path if path else ''}")
+
+        if isinstance(result, set):
+            return self.list(path=path, values=sorted(result))
+
+        mimetype = self.FORMAT.get(format)
+        if not mimetype and '.' in path:
+            mimetype = self.FORMAT.get(path.split('.')[-1])
+        mimetype = mimetype or 'text/plain'
+
+        # A bit of a hack to add the right query arguments into results.html
+        # Ideally, this should be done with changes to results.html, but we
+        # have legacy results to handle.
+        if mimetype == 'text/html':
+            query = query_as_string()
+            result = result.replace(
+                "href="" + testPrefix + suffix + '\"".encode('utf-8'),
+                f"href="" + testPrefix + suffix + '{query}' + '\"".encode('utf-8'),
+            )
+
+            for include_to_strip in ['js/status-bubble.js', 'code-review.js?version=48']:
+                result = result.replace(f'<script src="" ''.encode('utf-8'))
+
+            if (query):
+                result = result.replace("src += '?format=txt'".encode('utf-8'), "src += '&format=txt'".encode('utf-8'))
+
+        return Response(result, mimetype=mimetype or 'text/plain')

Added: trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view_unittest.py (0 => 253721)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view_unittest.py	                        (rev 0)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view_unittest.py	2019-12-18 22:22:24 UTC (rev 253721)
@@ -0,0 +1,75 @@
+# Copyright (C) 2019 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import base64
+import json
+import time
+
+from fakeredis import FakeStrictRedis
+from resultsdbpy.controller.commit import Commit
+from resultsdbpy.controller.configuration import Configuration
+from resultsdbpy.model.configuration_context_unittest import ConfigurationContextTest
+from resultsdbpy.model.mock_cassandra_context import MockCassandraContext
+from resultsdbpy.model.mock_model_factory import MockModelFactory
+from resultsdbpy.model.mock_repository import MockStashRepository, MockSVNRepository
+from resultsdbpy.model.wait_for_docker_test_case import WaitForDockerTestCase
+from resultsdbpy.view.view_routes_unittest import WebSiteTestCase
+from selenium.webdriver.support.select import Select
+
+
+class ArchiveViewUnittest(WebSiteTestCase):
+    def register_archive(self, client):
+        response = client.post(
+            self.URL + '/api/upload/archive',
+            data=""
+                configuration=json.dumps(ConfigurationContextTest.CONFIGURATIONS[0], cls=Configuration.Encoder),
+                suite='layout-tests',
+                commits=json.dumps([MockStashRepository.safari().commit_for_id('bb6bda5f'), MockSVNRepository.webkit().commit_for_id(236542)], cls=Commit.Encoder),
+            ),
+            files=dict(file=base64.b64decode(MockModelFactory.ARCHIVE_ZIP)),
+        )
+        self.assertEqual(response.status_code, 200)
+
+    @WaitForDockerTestCase.mock_if_no_docker(mock_redis=FakeStrictRedis, mock_cassandra=MockCassandraContext)
+    @WebSiteTestCase.decorator()
+    def test_directory(self, driver, client, **kwargs):
+        self.register_archive(client)
+        driver.get(self.URL + '/archive')
+
+        titles = driver.find_elements_by_class_name('title')
+        self.assertEqual(len(titles), 2)
+        self.assertEqual(titles[1].text.strip(), '/')
+
+        path_list = driver.find_element_by_id('paths')
+        self.assertIsNotNone(path_list)
+        files = path_list.find_elements_by_class_name('item')
+        self.assertEqual(len(files), 2)
+        self.assertEqual(files[0].text.strip(), 'file.txt')
+        self.assertEqual(files[1].text.strip(), 'index.html')
+
+    @WaitForDockerTestCase.mock_if_no_docker(mock_redis=FakeStrictRedis, mock_cassandra=MockCassandraContext)
+    @WebSiteTestCase.decorator()
+    def test_file(self, driver, client, **kwargs):
+        self.register_archive(client)
+        response = client.get(self.URL + '/archive/file.txt')
+        self.assertEqual(response.status_code, 200)
+        self.assertEqual(response.text, 'data')

Added: trunk/Tools/resultsdbpy/resultsdbpy/view/templates/archive_list.html (0 => 253721)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/templates/archive_list.html	                        (rev 0)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/templates/archive_list.html	2019-12-18 22:22:24 UTC (rev 253721)
@@ -0,0 +1,115 @@
+<!--
+ Copyright (C) 2019 Apple Inc. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY APPLE INC. "AS IS" AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+-->
+
+{% extends "base.html" %}
+{% block head %}
+<link rel="stylesheet" type="text/css" href=""
+
+<script type="module">
+import {REF, DOM} from '/library/js/Ref.js';
+
+function collapsableListForPaths(root, directory, paths)
+{
+    let isExpanded = false;
+    let list = null;
+    const expander = REF.createRef({
+        onElementMount: (element) => {
+            element._onclick_ = () => {
+                isExpanded = !isExpanded;
+                element.innerHTML = isExpanded ? '-' : '+';
+                if (list)
+                    list.style.display = isExpanded ? 'block' : 'none';
+            }
+        }
+    });
+    const listRef = REF.createRef({
+        onElementMount: (element) => {
+            list = element;
+        },
+    });
+
+    const params = document.URL.split('?')[1];
+    return `<div class="item">
+            <a style="cursor: pointer;" class="text medium" ref="${expander}">+</a> | 
+            <a href="" path }}${directory}${params ? '?' + params : ''}">${directory.slice(root.length)}</a>
+            <div class="list" ref="${listRef}" style="display: none;">
+                ${listContentForPaths(directory, paths)}
+            </div>
+        </div>`;
+}
+
+function listContentForPaths(root, paths) {
+    let directory = null;
+    let filesInDirectory = [];
+    let result = paths.map((path) => {
+        if (directory && path.startsWith(directory)) {
+            filesInDirectory.push(path);
+            return;
+        }
+        let previous = '';
+        if (directory)
+            previous = collapsableListForPaths(root, directory, filesInDirectory);
+
+        directory = null;
+        filesInDirectory = [];
+        if (path[path.length - 1] == '/') {
+            directory = path;
+            return previous;
+        }
+        const params = document.URL.split('?')[1];
+        return `${previous}
+            <div class="item">
+                <a href="" path }}${path}${params ? '?' + params : ''}">${path.slice(root.length)}</a>
+            </div>`;
+    }).join('');
+
+    if (directory)
+        return result + collapsableListForPaths(root, directory, filesInDirectory);
+    return result;
+}
+
+const paths = [{% for val in values %}'{{ val }}', {% endfor %}];
+paths.forEach(pth => {
+    console.log(pth);
+})
+DOM.inject(document.getElementById('paths'), listContentForPaths('', paths));
+
+</script>
+
+{% endblock %}
+{% block content %}
+<div class="content">
+    <div class="title">
+        {% if path != '' and path.split('/')[:-2]%}
+             <a href="" '/'.join(path.split('/')[:-2]) }}/{{ query }}">&lt</a> 
+        {% elif path != '' %}
+            <a href="" query }}">&lt</a>
+        {% endif %}
+        /{{ path }}
+    </div>
+    <div class="list" id="paths">
+    </div>
+</div>
+{% endblock %}

Modified: trunk/Tools/resultsdbpy/resultsdbpy/view/view_routes.py (253720 => 253721)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/view_routes.py	2019-12-18 22:20:55 UTC (rev 253720)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/view_routes.py	2019-12-18 22:22:24 UTC (rev 253721)
@@ -28,6 +28,7 @@
 from jinja2 import Environment, PackageLoader, select_autoescape
 from resultsdbpy.flask_support.util import AssertRequest
 from resultsdbpy.flask_support.authed_blueprint import AuthedBlueprint
+from resultsdbpy.view.archive_view import ArchiveView
 from resultsdbpy.view.ci_view import CIView
 from resultsdbpy.view.commit_view import CommitView
 from resultsdbpy.view.site_menu import SiteMenu
@@ -68,6 +69,11 @@
             ci_controller=controller.ci_controller,
             site_menu=self.site_menu,
         )
+        self.archive = ArchiveView(
+            environment=self.environment,
+            archive_controller=controller.archive_controller,
+            site_menu=self.site_menu,
+        )
 
         self.add_url_rule('/', 'main', self.suites.search, methods=('GET',))
         self.add_url_rule('/search', 'search', self.suites.search, methods=('GET',))
@@ -85,6 +91,9 @@
         self.add_url_rule('/urls/worker', 'urls-worker', self.ci.worker, methods=('GET',))
         self.add_url_rule('/urls/build', 'urls-build', self.ci.build, methods=('GET',))
 
+        self.add_url_rule('/archive', 'archive-list', self.archive.extract, methods=('GET',))
+        self.add_url_rule('/archive/<path:path>', 'archive', self.archive.extract, methods=('GET',))
+
         self.site_menu.add_endpoint('Main', self.name + '.main', parameters=['branch'])
         self.site_menu.add_endpoint('Suites', self.name + '.suites', parameters=['branch'])
         self.site_menu.add_endpoint('Documentation', self.name + '.documentation')
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to