Added some web UI so that sidebar and index etc. are at least functional.
authorSybren A. Stüvel <sybren@stuvel.eu>
Wed, 8 Nov 2017 15:14:15 +0000 (16:14 +0100)
committerSybren A. Stüvel <sybren@stuvel.eu>
Wed, 8 Nov 2017 15:14:15 +0000 (16:14 +0100)
src/styles/main.sass [new file with mode: 0644]
src/templates/svnman/errors/service_not_available.pug
src/templates/svnman/index.pug [new file with mode: 0644]
src/templates/svnman/layout.pug [new file with mode: 0644]
src/templates/svnman/sidebar.pug
svnman/__init__.py
svnman/routes.py

diff --git a/src/styles/main.sass b/src/styles/main.sass
new file mode 100644 (file)
index 0000000..27ec247
--- /dev/null
@@ -0,0 +1,5 @@
+/* Import basic styling and config from Pillar */
+@import ../../../pillar/src/styles/_config
+@import ../../../pillar/src/styles/_utils
+@import ../../../pillar/src/styles/base
+@import ../../../pillar/src/styles/_project-sharing
index 016ad23..3fa4222 100644 (file)
@@ -6,5 +6,5 @@
                        .error-title Service not available.
                .error-lead
                        p
-                               | The Subversion service requires a special subscription.
+                               | The Subversion service is still under development, and not available at the moment.
 | {% endblock %}
diff --git a/src/templates/svnman/index.pug b/src/templates/svnman/index.pug
new file mode 100644 (file)
index 0000000..3561b70
--- /dev/null
@@ -0,0 +1,55 @@
+| {% extends 'svnman/layout.html' %}
+| {% block bodyattrs %}{{ super() }} data-context='dashboard'{% endblock %}
+| {% block page_title %}Subversion Dashboard{% endblock %}
+
+| {% block style %}
+style.
+       #col_right section {
+               margin: 2ex;
+       }
+
+       #col_right section p {
+               line-height: 180%;
+               hyphens: auto;
+               text-align: center;
+       }
+| {% endblock %}
+
+| {% block body %}
+#col_main
+       .dashboard
+               h4
+                       i.pi-svnman
+                       |  Subversion
+
+               | {% for proj in projects._items %}
+               h4
+                       a(href="{{ url_for('pillar.web.projects.edit_extension', project_url=proj.url, extension='svnman') }}") {{ proj.name }}
+               | {% else %}
+               h4 No Subversion repositories
+
+               p
+                       | You have no Subversion repositories yet. To create one, visit the project you
+                       | want to create the repository for and click on "Edit Project".
+               p
+                       a.btn.button-success(href="{{ url_for('projects.index') }}") my projects
+
+               | {% endfor %}
+
+#col_right
+       .d-welcome
+               .welcome-logo
+                       i.pi-svnman
+               .welcome-title Welcome to SVNman
+
+               .welcome-text
+                       p Your Subversion Server in the Cloud
+
+       section
+               p
+                       | For documentation, downloads, and everything you need for running your own
+                       | Ren&shy;der Ma&shy;na&shy;ge&shy;ment Soft&shy;ware, visit the
+                       =' '
+                       a(href='https://www.svnman.io/', target='_blank') SVNman Website.
+
+| {% endblock %}
diff --git a/src/templates/svnman/layout.pug b/src/templates/svnman/layout.pug
new file mode 100644 (file)
index 0000000..b7e8b0b
--- /dev/null
@@ -0,0 +1,81 @@
+doctype html
+html(lang="en")
+       head
+               meta(charset="utf-8")
+               title {% if self.page_title() %}{% block page_title %}{% endblock %} — {% endif %}SVNman
+               meta(name="viewport", content="width=device-width, initial-scale=1.0")
+
+               | {% block head %}{% endblock %}
+
+               link(href='//fonts.googleapis.com/css?family=Roboto:300,400', rel='stylesheet', type='text/css')
+
+               link(href="{{ url_for('static_pillar', filename='assets/css/vendor/bootstrap.min.css') }}", rel="stylesheet")
+               link(href="{{ url_for('static_pillar', filename='assets/css/font-pillar.css', v=141020161) }}", rel="stylesheet")
+               link(href="{{ url_for('static_svnman', filename='assets/css/main.css') }}", rel="stylesheet")
+               script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery-3.1.0.min.js')}}")
+               script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery.bootstrap-3.3.7.min.js') }}")
+               script(src="{{ url_for('static_pillar', filename='assets/js/tutti.min.js') }}")
+               script(src="{{ url_for('static_svnman', filename='assets/js/generated/tutti.min.js') }}")
+               script(src="{{ url_for('static_pillar', filename='assets/js/vendor/clipboard.min.js')}}")
+
+               link(href="{{ url_for('static_svnman', filename='assets/img/favicon.png') }}", rel="shortcut icon")
+
+               | {% block style %}{% endblock %}
+
+       body("{% block bodyattrs %}{% endblock %}")
+               #app-main
+                       #col_sidebar
+                               nav.sidebar(role='navigation')
+                                       ul
+                                               li
+                                                       a.navbar-item.cloud(href="{% if project %}{{url_for('projects.view', project_url=project.url)}}{% else %}{{ url_for('main.homepage') }}{% endif %}",
+                                                               title='Blender Cloud')
+                                                               i.pi-blender-cloud
+                                               li
+                                                       a.navbar-item.svnman(href="{{ url_for('svnman.index') }}",
+                                                               title='SVNman')
+                                                               i.pi-svnman
+                                       ul.bottom
+
+                                               | {% from '_macros/_menu.html' import navigation_menu_notifications, navigation_menu_user %}
+                                               | {{ navigation_menu_notifications(current_user) }}
+                                               | {{ navigation_menu_user(current_user) }}
+
+                       | {% block body %}
+                       #col_left
+                       #col_main
+                               h1 Main
+                       #col_right
+                               h1 Right
+                       | {% endblock %}
+
+               .modal.fade#modal(role="dialog")
+                       .modal-dialog
+                               .modal-content
+                                       .modal-header
+                                               button.close(type="button", data-dismiss="modal", aria-label="Close")
+                                                       i.pi-cancel
+                                               span.title
+                                       .modal-body
+
+               script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery.select2.min.js') }}", async=true)
+               script.
+                       {% if project %}
+                       $('.js-help').openModalUrl('Help', "{{ url_for('svnman.help', project_url=project.url) }}");
+                       {% endif %}
+
+                       $(document).ready(function() {
+                               {% if current_user.is_authenticated %}
+                                       getNotificationsLoop(); // Check for new notifications in the background
+
+                                       // Resize #notifications and change overflow for scrollbars
+                                       $(window).on("resize", function() { notificationsResize(); });
+                               {% endif %}
+                       });
+
+                       $(window).on('load resize', function(){
+                               var window_height = $(window).height() - 55; // header is 55px
+                               $('.col-scrollable').css({'height': window_height});
+                       });
+
+               | {% block footer_scripts %}{% endblock %}
index 6f80dca..0189d30 100644 (file)
@@ -1,8 +1,8 @@
+| {% if current_user.has_cap('svn-use') %}
 li.tabs-svnman(
-       title="SVNman",
+       title="Subversion",
        data-toggle="tooltip",
        data-placement="right")
-       | {% if current_user.has_cap('svn-use') %}
-       a(href="alert('hmmm nothing here yet')")
-               i.pi-svnman
-       | {% endif %}
+       a(href="{{ url_for('projects.edit_extension', project_url=project.url, extension_name='svnman')}}")
+               i.pi-svnman SVN
+| {% endif %}
index 400aa9a..88f29de 100644 (file)
@@ -1,6 +1,7 @@
 import logging
 import os.path
 import string
+import typing
 from urllib.parse import urljoin
 
 import flask
@@ -100,6 +101,8 @@ class SVNManExtension(PillarExtension):
     def sidebar_links(self, project):
         if not current_user.has_cap('svn-use'):
             return ''
+        if not self.is_svnman_project(project):
+            return ''
         return flask.render_template('svnman/sidebar.html', project=project)
 
     @property
@@ -229,6 +232,26 @@ class SVNManExtension(PillarExtension):
         eprops.pop('access', None)
         proj_utils.put_project(proj)
 
+    def svnman_projects(self, *, projection: dict = None):
+        """Returns projects with a Subversion repository.
+
+        :returns: {'_items': [proj, proj, ...], '_meta': Eve metadata}
+        """
+
+        import pillarsdk
+        from pillar.web.system_util import pillar_api
+
+        api = pillar_api()
+
+        # Find projects that have a repository.
+        params = {'where': {f'extension_props.{EXTENSION_NAME}.repo_id': {'$exists': 1}}}
+        if projection:
+            params['projection'] = projection
+
+        projects = pillarsdk.Project.all(params, api=api)
+        return projects
+
+
 
 def _get_current_svnman() -> SVNManExtension:
     """Returns the SVNMan extension of the current application."""
index 6b390b3..1bc98f5 100644 (file)
@@ -27,13 +27,8 @@ def index():
     for project in projects['_items']:
         attach_project_pictures(project, api)
 
-    projs_with_summaries = [
-        (proj, current_svnman.job_manager.job_status_summary(proj['_id']))
-        for proj in projects['_items']
-    ]
-
     return render_template('svnman/index.html',
-                           projs_with_summaries=projs_with_summaries)
+                           projects=projects)
 
 
 def error_project_not_available():