### Install Plugin for Development Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/pluginwriter/quickstart.md Command to install the plugin in editable mode for development using pip within a virtual environment. ```bash python -m pip install --editable . ``` -------------------------------- ### Test MediaGoblin Server Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/deploying.md Starts the MediaGoblin server for testing purposes. This command should be run from the MediaGoblin installation directory. It requires the `--server-name` argument and allows connection to port 6543. Type Ctrl-c to exit. ```shell $ ./lazyserver.sh --server-name=broadcast ``` -------------------------------- ### Plugin Packaging with setup.py Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/pluginwriter/quickstart.md A basic setup.py file for packaging and distributing a MediaGoblin plugin using setuptools. ```python from setuptools import setup, find_packages setup( name='sampleplugin', version='1.0', packages=find_packages(), include_package_data=True, install_requires=[], license='AGPLv3', ) ``` -------------------------------- ### Install and Run MediaGoblin using Guix Source: https://github.com/~mediagoblin/mediagoblin/blob/master/README-Guix.md These commands demonstrate how to install and run MediaGoblin after configuring the Guix channel. 'guix pull' updates your channels, 'guix shell mediagoblin' provides a shell with MediaGoblin installed, and 'guix install mediagoblin' installs it into your user profile. ```bash guix pull guix shell mediagoblin # For a shell with MediaGoblin installed, or guix install mediagoblin # To install into your profile ``` -------------------------------- ### Sample Plugin README Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/pluginwriter/quickstart.md A basic README file for a sample plugin, explaining its functionality. ```default README ====== This is a sample plugin. It logs a line when ``setup__plugin()`` is run. ``` -------------------------------- ### Install and Enable Plugin Source: https://context7.com/~mediagoblin/mediagoblin/llms.txt Commands to install a MediaGoblin plugin in development mode and enable it in the mediagoblin.ini configuration file. This involves navigating to the plugin directory, installing it using pip, and then configuring the plugin options. ```bash # Install the plugin in development mode cd sampleplugin python -m pip install --editable . # Enable in mediagoblin.ini # [plugins] # [[sampleplugin]] # option1 = value1 ``` -------------------------------- ### MediaGoblin Theme Configuration Example Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/theming.md This snippet shows the structure of a MediaGoblin theme's configuration file. It specifies the theme's name, description, and licensing information, guiding users on how to set these parameters. ```default [theme] name = Hedgehog-ification description = For hedgehog lovers ONLY licensing = AGPLv3 or later templates; assets (images/CSS) waived under CC0 1.0 ``` -------------------------------- ### Configure Plugin in mediagoblin.ini Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/pluginwriter/quickstart.md Configuration snippet for mediagoblin.ini to enable the sample plugin. ```ini [plugins] [[sampleplugin]] ``` -------------------------------- ### Install Production Web Server and Queue Dependencies Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/deploying.md Installs Nginx as a frontend web server and RabbitMQ for media processing queues on Debian and Fedora. These are essential for a production environment. ```bash # Debian sudo apt install nginx-light rabbitmq-server # Fedora sudo dnf install nginx rabbitmq-server ``` -------------------------------- ### Start MediaGoblin Systemd Services Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/deploying.md Commands to start the MediaGoblin paster and Celery worker services for the current session. This is useful for starting MediaGoblin immediately after enabling the services or after a manual stop. ```bash sudo systemctl start mediagoblin-paster.service sudo systemctl start mediagoblin-celeryd.service ``` -------------------------------- ### Configure MediaGoblin Basic Settings Source: https://context7.com/~mediagoblin/mediagoblin/llms.txt Example `mediagoblin.ini` configuration for core settings, including database connection (PostgreSQL example), email server details, EXIF data display, and custom data directory. Shows how to specify the SQL engine and email parameters. ```ini [mediagoblin] # Use PostgreSQL instead of SQLite sql_engine = postgresql:///mediagoblin # Email configuration email_debug_mode = false email_sender_address = "noreply@example.com" email_smtp_host = smtp.example.com email_smtp_port = 587 email_smtp_user = mailuser email_smtp_pass = mailpass email_smtp_use_ssl = false email_smtp_force_starttls = true # Display EXIF metadata for images exif_visible = true # Custom data directory [DEFAULT] data_basedir = "/var/mediagoblin/user_data" # Enable plugins [plugins] [[mediagoblin.plugins.basic_auth]] [[mediagoblin.media_types.image]] [[mediagoblin.media_types.video]] [[mediagoblin.media_types.audio]] ``` -------------------------------- ### Install PostgreSQL Dependencies Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/deploying.md Installs PostgreSQL and the Python psycopg2 adapter for database connectivity on Debian and Fedora. This is recommended for medium to large deployments. ```bash # Debian sudo apt install postgresql python3-psycopg2 # Fedora sudo dnf install postgresql postgresql-server python3-psycopg2 ``` -------------------------------- ### Plugin Directory Structure Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/pluginwriter/quickstart.md Standard Python project directory tree for a MediaGoblin plugin. Includes README, LICENSE, setup.py, and the main plugin package. ```default sampleplugin/ |- README |- LICENSE |- setup.py |- sampleplugin/ |- __init__.py ``` -------------------------------- ### Start MediaGoblin Server with Lazyserver Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/deploying.md This command starts the MediaGoblin application using the lazyserver script. It requires switching to the 'mediagoblin' user and navigating to the application directory. This is used for testing the Nginx configuration. ```shell sudo su mediagoblin --shell=/bin/bash cd /srv/mediagoblin.example.org/mediagoblin/ ./lazyserver.sh --server-name=main ``` -------------------------------- ### Install Raw Image Support Dependencies on Debian Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/media-types.md Installs the Python library 'py3exiv2' required for raw image support on Debian systems. It includes commands for both Debian 11 (installing build dependencies and then pip installing) and Debian 12 (direct package installation). ```bash # Debian 11 sudo apt install libexiv2-dev libboost-python-dev ./bin/pip install py3pyexiv2 # Debian 12 sudo apt install python3-pyexiv2 ``` -------------------------------- ### Run MediaGoblin Server and Celery Task Queue Source: https://github.com/~mediagoblin/mediagoblin/blob/master/README-Guix.md These commands show how to run the MediaGoblin web server and its associated Celery task queue. The first command starts the server using 'paste.ini' for configuration. The second command starts the Celery worker. The third command purges the default Celery queue, which can be useful for clearing pending tasks. ```bash python3 -m mediagoblin.gmg_commands.__init__ serve paste.ini python3 -m mediagoblin.gmg_commands.__init__ celery python3 -m celery --broker='redis://' amqp queue.purge default ``` -------------------------------- ### Example Activity: Posting a New Image (Activity Streams JSON) Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/api/activities.md This example demonstrates an activity representing the 'post' verb, specifically when a user uploads a new image. It includes the activity's 'id', the 'verb', and an 'object' which, in this case, is a comment referencing the newly posted image. ```json { "id": "https://gmg.server.tld/api/activity/someidhere", "verb": "post", "object": { "id": "https://gmg.server.tld/api/comment/someid", "objectType": "comment", "content": "What a wonderful picture you have there!", "inReplyTo": { "id": "https://gmg.server.tld/api/image/someidhere" } }, "author": { "id": "acct:someone@gmg.server.tld" } } ``` -------------------------------- ### Install System Dependencies for Debian and Fedora Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/deploying.md Installs core system dependencies required for MediaGoblin on Debian and Fedora systems. This includes build tools, version control, Node.js, and Python development packages. Ensure you have sudo privileges. ```bash # Debian sudo apt update sudo apt install automake git nodejs npm pkgconf python3-dev \ python3-venv python3-gst-1.0 python3-pil # Fedora sudo dnf install automake gcc git-core make nodejs npm \ libffi-devel pkgconf python3-devel python3-pillow ``` -------------------------------- ### Install ASCII Art Thumbnail Dependency Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/media-types.md Installs the 'chardet' Python library, which is necessary for creating thumbnails of ASCII art files. This command uses 'easy_install', an older package management tool. ```bash $ ./bin/easy_install chardet ``` -------------------------------- ### Initialize and Start PostgreSQL on Fedora Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/deploying.md Initializes the PostgreSQL database cluster and enables/starts the PostgreSQL service on Fedora systems. These commands are specific to Fedora and not needed on Debian-based systems. ```bash # Fedora sudo /usr/bin/postgresql-setup initdb sudo systemctl enable postgresql sudo systemctl start postgresql ``` -------------------------------- ### Install Video Transcoding Dependencies on Fedora Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/media-types.md Installs the necessary GStreamer plugins and Python libraries for video transcoding on Fedora systems. This is a prerequisite for enabling video uploads and transcoding in MediaGoblin. ```bash sudo dnf install gstreamer1-plugins-{base,bad-free,good,ugly-free,openh264} python3-gobject python3-gstreamer1 ``` -------------------------------- ### Install MediaGoblin via Load-Path with Guix Source: https://github.com/~mediagoblin/mediagoblin/blob/master/README-Guix.md Installs MediaGoblin for testing and development using Guix's load-path mechanism. Provides options for a temporary shell or a profile installation. ```shell git clone https://git.sr.ht/~mediagoblin/mediagoblin cd mediagoblin guix shell --load-path=.guix/modules mediagoblin # For a temporary shell ``` ```shell guix install --load-path=.guix/modules mediagoblin # To install in your profile ``` -------------------------------- ### Install PDF and Document Support Dependencies on Fedora Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/media-types.md Installs the required packages on Fedora for PDF and document support, including 'poppler-utils' for PDF processing and 'unoconv' with 'libreoffice-headless' for converting various document formats. ```bash sudo dnf install poppler-utils unoconv libreoffice-headless ``` -------------------------------- ### MediaGoblin Plugin Configuration Example Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/relnotes.md Configuration snippet for enabling the OpenStreetMap plugin in MediaGoblin. This section should be added to your MediaGoblin configuration file to activate the geolocation plugin. ```ini [plugins] [[mediagoblin.plugins.geolocation]] ``` -------------------------------- ### Sample Plugin Code (__init__.py) Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/pluginwriter/quickstart.md The core Python code for the sample plugin, including logging and hook registration. It defines a setup_plugin function and the hooks dictionary. ```python import logging from mediagoblin.tools.pluginapi import PluginManager, get_config # This creates a logger that you can use to log information to # the console or a log file. _log = logging.getLogger(__name__) # This is the function that gets called when the setup # hook fires. def setup_plugin(): _log.info("I've been started!") config = get_config('sampleplugin') if config: _log.info('%r' % config) else: _log.info('There is no configuration set.') # This is a dict that specifies which hooks this plugin uses. # This one only uses one hook: setup. hooks = { 'setup': setup_plugin } ``` -------------------------------- ### Install Raven Python Package Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/plugindocs/raven.md Installs the 'raven' Python package using pip. This is a prerequisite for enabling the Raven plugin in MediaGoblin. Ensure you are using the correct Python environment for your MediaGoblin installation. ```bash bin/python -m pip install raven ``` -------------------------------- ### Get Host Metadata via MediaGoblin WebFinger Source: https://context7.com/~mediagoblin/mediagoblin/llms.txt This example shows how to retrieve host metadata, including service endpoints and discovery links, using the WebFinger protocol on MediaGoblin. It's a GET request to the host-meta.json endpoint, specifying the desired JSON content type. This is crucial for service discovery. ```bash curl -X GET https://mediagoblin.example.org/.well-known/host-meta.json \ -H "Accept: application/json" ``` -------------------------------- ### Upgrade MediaGoblin to v0.8.0 Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/relnotes.md Instructions for upgrading MediaGoblin to version 0.8.0. This involves updating the git remote, installing Node.js, checking out the new version, and running build and development setup scripts. ```bash git remote set-url origin https://git.savannah.gnu.org/git/mediagoblin.git git fetch && git checkout -q v0.8.0 ./bootstrap.sh && ./configure && make ./bin/python setup.py develop --upgrade && ./bin/gmg dbupdate ``` -------------------------------- ### Install MediaGoblin from Source Source: https://context7.com/~mediagoblin/mediagoblin/llms.txt Steps to clone the MediaGoblin repository, configure the build environment, and initialize the database. Requires creating a system user and setting up directories. Dependencies include git, autoconf, automake, and build tools. ```bash # Create a dedicated user for MediaGoblin (Debian) sudo useradd --system --create-home --home-dir /var/lib/mediagoblin \ --group www-data --comment 'GNU MediaGoblin system account' mediagoblin # Create the installation directory sudo mkdir --parents /srv/mediagoblin.example.org sudo chown --no-dereference --recursive mediagoblin:www-data /srv/mediagoblin.example.org # Switch to mediagoblin user sudo su mediagoblin --shell=/bin/bash cd /srv/mediagoblin.example.org # Clone and build git clone --depth=1 https://git.sr.ht/~mediagoblin/mediagoblin \ --branch stable --recursive cd mediagoblin # Configure and build ./autogen.sh ./configure make # Create media storage directory mkdir --mode=2750 user_dev # Initialize the database ./bin/gmg dbupdate ``` -------------------------------- ### Configure and Run MediaGoblin Web Interface Source: https://github.com/~mediagoblin/mediagoblin/blob/master/README-Guix.md Sets up a directory for MediaGoblin configuration, downloads default configuration files, creates a database, adds a user, and starts the web interface with foreground media processing. ```shell mkdir mediagoblin.example.org cd mediagoblin.example.org curl https://git.savannah.gnu.org/cgit/mediagoblin.git/plain/mediagoblin.example.ini > mediagoblin.ini echo "[[mediagoblin.media_types.audio]]" >> mediagoblin.ini echo "[[mediagoblin.media_types.video]]" >> mediagoblin.ini curl https://git.savannah.gnu.org/cgit/mediagoblin.git/plain/paste.ini > paste.ini gmg dbupdate gmg adduser --username admin --password a --email admin@example.com gmg addmedia admin image.jpg gmg addmedia admin audio.wav gmg addmedia admin video.mp4 CELERY_ALWAYS_EAGER=true gmg serve paste.ini ``` -------------------------------- ### Systemd Service File for MediaGoblin Paster Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/deploying.md This is a Systemd service file configuration for running the MediaGoblin Paster process. It defines how the service should start, run, and manage logs. Ensure `WorkingDirectory` and `Environment` variables match your setup. ```systemd [Unit] Description=Mediagoblin [Service] Type=simple User=mediagoblin Group=mediagoblin Environment=CELERY_ALWAYS_EAGER=false WorkingDirectory=/srv/mediagoblin.example.org/mediagoblin ExecStart=/srv/mediagoblin.example.org/mediagoblin/bin/paster serve \ /srv/mediagoblin.example.org/mediagoblin/paste.ini \ --log-file=/var/log/mediagoblin/mediagoblin.log \ --server-name=main [Install] WantedBy=multi-user.target ``` -------------------------------- ### Python Plugin Setup Source: https://context7.com/~mediagoblin/mediagoblin/llms.txt Provides a basic setup.py file for a Python MediaGoblin plugin. It uses setuptools to define package metadata, including the name, version, and dependencies. ```python # setup.py from setuptools import setup, find_packages setup( name='sampleplugin', version='1.0', packages=find_packages(), include_package_data=True, install_requires=[], license='AGPLv3', ) ``` -------------------------------- ### Fix TypeError: object() takes no parameters in MediaGoblin (Python) Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/troubleshooting.md This error typically occurs in MediaGoblin when the 'python3-gst-1.0' package is missing on Debian systems. It relates to GStreamer's Gst.Fraction usage in Python. Ensure the necessary GStreamer Python bindings are installed. ```default 2021-04-04 06:04:55,244 WARNING [mediagoblin.processing] No idea what happened here, but it failed: TypeError('object() takes no parameters',) 2021-04-04 06:04:55,262 ERROR [waitress] Exception while serving /submit/ ... File "/opt/mediagoblin/mediagoblin/media_types/video/transcoders.py", line 338, in __setup_videoscale_capsfilter caps_struct.set_value('pixel-aspect-ratio', Gst.Fraction(1, 1)) TypeError: object() takes no parameters ``` -------------------------------- ### Retrieve Image Object via MediaGoblin API Source: https://context7.com/~mediagoblin/mediagoblin/llms.txt This example shows how to fetch details of a specific image object using its ID via the MediaGoblin API. It's a GET request that requires an authorization header. The response provides comprehensive information about the image, including its URL, dimensions, author, and comment count. ```bash curl -X GET https://mediagoblin.example.org/api/image/456 \ -H "Authorization: OAuth ..." ``` -------------------------------- ### Basic MediaGoblin Plugin Structure in Python Source: https://context7.com/~mediagoblin/mediagoblin/llms.txt This Python code outlines the basic structure for a MediaGoblin plugin. It includes essential functions like `setup_plugin` for initialization and `add_to_user_home_context` for extending the user home page. It demonstrates how to access configuration and logging within the plugin. ```python # sampleplugin/__init__.py import logging from mediagoblin.tools.pluginapi import PluginManager, get_config _log = logging.getLogger(__name__) def setup_plugin(): """Called when the plugin is loaded.""" _log.info("Sample plugin has been started!") config = get_config('sampleplugin') if config: _log.info('Plugin config: %r' % config) def add_to_user_home_context(context): """Add data to the user home page context.""" context['sample_message'] = "Hello from sample plugin!" return context ``` -------------------------------- ### Set up MediaGoblin Development Environment with Guix Source: https://github.com/~mediagoblin/mediagoblin/blob/master/README-Guix.md This command sets up a pure development environment for MediaGoblin using Guix. It clones the repository, enters the directory, and then uses 'guix shell' with specific load paths and development packages to ensure a consistent build environment. It also includes steps for version file generation and running tests. ```bash git clone https://git.sr.ht/~mediagoblin/mediagoblin cd mediagoblin guix shell --pure --load-path=.guix/modules --load-path=/home/ben/ws/sturm-guix --development mediagoblin sturm-dev sturm-python-dev cp mediagoblin/_version.py.in mediagoblin/_version.py pytest --override-ini=addopts='--numprocesses=logical' # See the "Run MediaGoblin" section below for initial configuration CELERY_ALWAYS_EAGER=true python3 -m mediagoblin.gmg_commands.__init__ serve paste.ini ``` -------------------------------- ### Set Custom Theme Install Directory Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/theming.md Specifies an alternative directory for MediaGoblin theme installations. This allows themes to be stored outside the default location. ```ini [mediagoblin] # ... other parameters go here ... theme_install_dir = /path/to/themes/ ``` -------------------------------- ### Define Flatpages Routes and Templates Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/plugindocs/flatpagesfile.md This configuration example demonstrates how to define routes and associate them with templates for custom flat pages. Each line defines a unique route name, its URL path, and the corresponding template file. ```default [[mediagoblin.plugins.flatpagesfile]] about-view = '/about', about.html terms-view = '/terms', terms.html ``` -------------------------------- ### Run Plugin Unit Tests Script Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/pluginwriter/tests.md This command demonstrates how to execute the unit tests for your MediaGoblin plugin. It requires navigating to the MediaGoblin's root directory and then running the 'runtests.sh' script, passing the path to your plugin's test directory as an argument. Ensure your plugin is installed in the virtual environment used by MediaGoblin. ```bash ./runtests.sh /path/to/myplugin/tests/ ``` -------------------------------- ### MongoDB Document Structure Example Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/devel/originaldesigndecisions.md This example demonstrates a flexible JSON document structure suitable for MongoDB, showcasing how to store metadata for different media types and plugin-specific data. It highlights the ability to embed complex objects within a document. ```json { "title": "Me talking until you are bored", "description": "blah blah blah", "media_type": "audio", "media_data": { "length": "2:30", "codec": "OGG Vorbis" }, "plugin_data": { "licensing": { "license": "http://creativecommons.org/licenses/by-sa/3.0/" } } } ``` -------------------------------- ### Test Nginx Configuration and Restart Service Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/deploying.md This snippet demonstrates how to test the Nginx configuration for syntax errors and then restart the Nginx service. It's crucial for ensuring that any changes made to the Nginx configuration are valid before they are applied. ```shell sudo nginx -t sudo systemctl restart nginx ``` -------------------------------- ### Configure LDAP Server in MediaGoblin Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/plugindocs/ldap.md This configuration example demonstrates setting up a single LDAP server for authentication within MediaGoblin. It specifies the server URI and the template for constructing user distinguished names (DNs). ```ini [[mediagoblin.plugins.ldap]] [[[server1]]] LDAP_SERVER_URI = 'ldap://ldap.testathon.net:389' LDAP_USER_DN_TEMPLATE = 'cn={username},ou=users,dc=testathon,dc=net' ``` -------------------------------- ### Packaging a MediaGoblin Theme with Tar Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/siteadmin/theming.md This command demonstrates how to package a MediaGoblin theme into a `.tar.gz` archive for distribution. It assumes you are in the installed themes directory and replaces 'yourtheme' with the actual name of the theme. ```bash tar -cvfz yourtheme.tar.gz yourtheme ``` -------------------------------- ### Accessing Plugin Configuration in Python Source: https://github.com/~mediagoblin/mediagoblin/blob/master/docs/source/pluginwriter/api.md Demonstrates how to retrieve plugin-specific configuration values using the `pluginapi` module or directly from `mg_globals`. The `%(here)s` variable in the config can be used to reference the user's MediaGoblin config directory. ```python >>> from mediagoblin.tools import pluginapi # Replace with the path to your plugin. # (If an external package, it won't be part of mediagoblin.plugins) >>> floobie_config = pluginapi.get_config('mediagoblin.plugins.floobifier') >>> floobie_dir = floobie_config['floobie_dir'] # This is the same as the above >>> from mediagoblin import mg_globals >>> config = mg_globals.global_config['plugins']['mediagoblin.plugins.floobifier'] >>> floobie_dir = floobie_config['floobie_dir'] ```