Skip to content

Development subsites

Cameron Hyde edited this page Jan 8, 2024 · 7 revisions

Creating a new subsite (a.k.a Lab)

Subsite (lab) landing pages are built and served from the Galaxy Media Site under /landing/<lab-name>. GMS has a framework for building new labs pages in a consistent and reproducible manner, with a schema written in Python. It goes something like this:

# As defined in sections.py:
sections = [
    {
        "id": str,
        "title": str,  # e.g. "Data import and preparation"
        "tabs": [
            {
                "id": str,            # e.g. "tools"
                "title": str,         # e.g. "Tools"
                "heading_html": str,  # accepts inline HTML e.g. <code> <b> <i> <a>
                "content": content,
            },
            # ...
        ],
    },
    # ...
]

# As defined in content/*.py:
content = [
    {   # Each of these will make an accordion item
        "title_html": str,        # inline HTML
        "description_html": str,  # inline HTML; should be a <p>; can have internal line breaks etc.
        "inputs": [
            {
                'datatypes': [str, ],  # List of accepted Galaxy datatypes for this input
                'label': str,  # Name of this input
            },
            {   # An example input:
                'datatypes': ['fastq', 'bam', 'sam'],  # List of accepted datatypes for this input
                'label': 'Raw sequencing reads',  # Descriptive name for this input
            },
            # ...
        ],
        # These are all optional:
        "button_link": str,  # URL for run button e.g. Galaxy tool link
        "button_html": str,  # defaults to "play" icon
        "button_tip": str,   # tooltip text; defaults to "Run tool"
        "view_link": str,    # URL for view button e.g. workflowhub link
        "view_html": str,    # defaults to "eye" icon
        "view_tip": str,     # tooltip text; defaults to None
    },
    # ...
]

The button_link or view_link can be omitted to hide that button. The above schema will render a webpage that looks something like this:

Example lab webpage rendered from Python content

For examples of the above, please see genome/content/assembly.py.

Step-by-step

  1. Create a git branch for the new lab
  2. Decide on a consisteny lab name to use. This will be referred to as $LAB here.
  3. Create a new subsite dir by cloning webapp/home/subdomains/genome/ to webapp/home/subdomains/${LAB}.
  4. Create webpage content for the new lab by modifying the ${LAB}/sections.py ${LAB}/content/*.py files, observing the Python schema.
  5. Clone the HTML template webapp/home/templates/home/subdomains/genome.html to ${LAB}.html
  6. Edit the HTML template to make the landing page for your lab. It will render the content created in the step above as sections/accordion elements.
  7. You may wish to reuse/create snippets for this template in webapp/home/templates/home/subdomains/components
  8. Run the branch with local development server
  9. In the web admin, add a Subsite record with the lab name "$LAB"
  10. You should find the lab landing page at /landing/$LAB.
Clone this wiki locally