Skip to content

Commit

Permalink
first commit from cookiecutter
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed May 27, 2024
0 parents commit fdf4f01
Show file tree
Hide file tree
Showing 20 changed files with 1,110 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/omero_plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Install and test and OMERO plugin e.g. a Web app, a CLI plugin or a library
#
# This workflow will install omero-test-infra, start an OMERO environment
# including database, server and web deployment, configure the OMERO plugin
# and run integration tests.
#
# 1. Set up the stage variable depending on the plugin. Supported stages
# are: app, cli, scripts, lib, srv
#
# 2. Adjust the cron schedule as necessary

name: OMERO
on:
push:
pull_request:
schedule:
- cron: '0 0 * * 0'

jobs:
test:
name: Run integration tests against OMERO
runs-on: ubuntu-22.04
env:
STAGE: app
steps:
- uses: actions/checkout@v4
- name: Checkout omero-test-infra
uses: actions/checkout@master
with:
repository: ome/omero-test-infra
path: .omero
ref: master
- name: Build and run OMERO tests
run: .omero/docker $STAGE
25 changes: 25 additions & 0 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: PyPI
on:
push:
tags:
- '*'

jobs:
build-n-publish:
name: Build and publish Python distribution to PyPI
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Build a binary wheel and a source tarball
run: |
python -mpip install build
python -m build
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.8.14
with:
password: ${{ secrets.PYPI_PASSWORD }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build
node_modules
*.pyc
*.DS_Store
Empty file added CHANGELOG.md
Empty file.
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include *.md
include LICENSE
prune dist
prune build
recursive-include omero_script_ui *
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

[![Actions Status](https://github.com/will-moore/omero-script-ui/workflows/OMERO/badge.svg)](https://github.com/will-moore/omero-script-ui/actions)


OMERO.omero_script_ui
==================================

Experimental app to add custom UIs for OMERO scripts.

Installation
============

This section assumes that an OMERO.web is already installed.

Installing from Pypi
--------------------

Install the app using [pip](<https://pip.pypa.io/en/stable/>) .

Ensure that you are running ``pip`` from the Python environment
where ``omero-web`` is installed. Depending on your install, you may need to
call ``pip`` with, for example: ``/path/to_web_venv/venv/bin/pip install ...``

::

$ pip install -U omero-script-ui


Development mode
----------------

Install `omero-script-ui` in development mode as follows:

# within your python venv:
$ cd omero-script-ui
$ pip install -e .

After installation either from [Pypi](https://pypi.org/) or in development mode, you need to configure the application.
To add the application to the `omero.web.apps` settings, run the following command:

Note the usage of single quotes around double quotes:

$ omero config append omero.web.apps '"omero_script_ui"'

Optionally, add a link "Script UI" at the top of the webclient to
open the index page of this app:

$ omero config append omero.web.ui.top_links '["Script UI", "omero_script_ui_index", {"title": "Open Script UI in new tab", "target": "_blank"}]'


Now restart your `omero-web` server and go to
<http://localhost:4080/omero_script_ui/> in your browser.


Further Info
============

1. This app was derived from [cookiecutter-omero-webapp](https://github.com/ome/cookiecutter-omero-webapp).
2. For further info on deployment, see [Deployment](https://docs.openmicroscopy.org/latest/omero/developers/Web/Deployment.html)


License
=======

This project, similar to many Open Microscopy Environment (OME) projects, is
licensed under the terms of the AGPL v3.


Copyright
=========

2024 University of Dundee

20 changes: 20 additions & 0 deletions omero_script_ui.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Metadata-Version: 2.1
Name: omero-script-ui
Version: 0.1.0.dev0
Summary: Experimental app to add custom UIs for OMERO scripts
Home-page: https://github.com/will-moore/omero-script-ui
Download-URL: https://github.com/will-moore/omero-script-ui/v0.1.0.dev0.tar.gz
Author: Will Moore
Author-email: w.moore@dundee.ac.uk
License: AGPLv3
Keywords: omero
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Plugins
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
License-File: LICENSE
16 changes: 16 additions & 0 deletions omero_script_ui.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CHANGELOG.md
LICENSE
MANIFEST.in
README.md
setup.py
omero_script_ui/__init__.py
omero_script_ui/urls.py
omero_script_ui/views.py
omero_script_ui.egg-info/PKG-INFO
omero_script_ui.egg-info/SOURCES.txt
omero_script_ui.egg-info/dependency_links.txt
omero_script_ui.egg-info/not-zip-safe
omero_script_ui.egg-info/top_level.txt
omero_script_ui/static/omero_script_ui/app.css
omero_script_ui/static/omero_script_ui/app.js
omero_script_ui/templates/omero_script_ui/index.html
1 change: 1 addition & 0 deletions omero_script_ui.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions omero_script_ui.egg-info/not-zip-safe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions omero_script_ui.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
omero_script_ui
17 changes: 17 additions & 0 deletions omero_script_ui/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python
#
# Copyright (c) 2024 University of Dundee.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
5 changes: 5 additions & 0 deletions omero_script_ui/static/omero_script_ui/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

body {
font-family: Arial, Helvetica, sans-serif;
margin: 20px;
}
22 changes: 22 additions & 0 deletions omero_script_ui/static/omero_script_ui/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@


// Construct the API projects URL
var projectsUrl = PARAMS.API_BASE_URL + 'm/projects/';

// Filter projects by Owner to only show 'your' projects
projectsUrl += '?owner=' + PARAMS.EXP_ID;

fetch(projectsUrl).then(rsp => rsp.json())
.then(data => {
let projectCount = data.meta.totalCount;
let projects = data.data;

// Render html...
let html = `
<div>Total: ${projectCount} projects...</div>
<ul>
${projects.map(p => `<li>${p.Name} (ID: ${p['@id']})</li>`).join("")}
</ul>`;

document.getElementById('projects').innerHTML = html;
});
50 changes: 50 additions & 0 deletions omero_script_ui/templates/omero_script_ui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<!DOCTYPE html>
<html>
<head>
<title>OMERO Script UI</title>

<!-- Include static css -->
<link rel="stylesheet" type="text/css" href="{% static 'omero_script_ui/app.css' %}" />

<script type="text/javascript">
// Global variables, used by JavaScript code.
window.PARAMS = {};
window.PARAMS.EXP_ID = {{ experimenterId }};

// Render a URL to the /api/v0/ URL for loading JSON data
window.PARAMS.API_BASE_URL = "{% url 'api_base' 0 %}";
</script>
</head>

<body>
<h1>Welcome to Script UI</h1>

<p>
Logged in as:
<!-- Django template renders values from context -->
<strong>{{ firstName }} {{ lastName }}</strong>
</p>

<p id="projects">
Loading Projects...
</p>

<!-- Include the static JavaScript -->
<script src="{% static 'omero_script_ui/app.js' %}"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions omero_script_ui/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
#
# Copyright (c) 2024 University of Dundee.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

from django.urls import re_path

from . import views

urlpatterns = [
# index 'home page' of the app
re_path(r"^$", views.index, name="omero_script_ui_index"),
]
43 changes: 43 additions & 0 deletions omero_script_ui/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python
#
# Copyright (c) 2024 University of Dundee.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

from django.shortcuts import render

from omeroweb.decorators import login_required


# login_required: if not logged-in, will redirect to webclient
# login page. Then back to here, passing in the 'conn' connection
# and other arguments **kwargs.
@login_required()
def index(request, conn=None, **kwargs):
# We can load data from OMERO via Blitz Gateway connection.
# See https://docs.openmicroscopy.org/latest/omero/developers/Python.html
experimenter = conn.getUser()

# A dictionary of data to pass to the html template
context = {
"firstName": experimenter.firstName,
"lastName": experimenter.lastName,
"experimenterId": experimenter.id,
}
# print can be useful for debugging, but remove in production
# print('context', context)

# Render the html template and return the http response
return render(request, "omero_script_ui/index.html", context)
Loading

0 comments on commit fdf4f01

Please sign in to comment.