Coder Social home page Coder Social logo

ksp-spacedock / spacedock Goto Github PK

View Code? Open in Web Editor NEW
71.0 18.0 33.0 8.6 MB

Current Codebase (Python /Flask)

Home Page: https://spacedock.info

License: Other

Python 44.23% Mako 0.07% JavaScript 0.39% CoffeeScript 8.36% CSS 1.80% HTML 37.73% Shell 0.65% Dockerfile 0.16% SCSS 4.08% Twig 2.53%

spacedock's Introduction

SpaceDock

Website engine for Kerbal Space Program mods.

https://spacedock.info

Contributing

Please see CONTRIBUTING.md

Installation

This describes a bare-metal setup. For a local development setup using Docker, see https://github.com/KSP-SpaceDock/SpaceDock/wiki/Development-Guide#running-with-docker.

Quick overview:

  1. Install and set up the dependencies
  2. Clone SpaceDock repository
  3. Activate the virtualenv
  4. Install pip requirements
  5. Build frontend
  6. Configure SpaceDock
  7. SQL
  8. Site configuration

Install the dependencies

You'll need these things: (Names taken from Ubuntu's package repository)

  • python3, python3-dev for uwsgi, python3-pip, python3-virtualenv
  • nodejs, npm
  • postgresql (or postgresql-client if the database is on another server)
  • redis-tools

Use the packages your OS provides, or build them from source. For an up to date NodeJS distribution, see https://nodejs.org/en/download/current/ and https://github.com/nodesource/distributions/blob/master/README.md

Set up services

Do a quick sanity check on all of those things.

$ python3 --version
  Python 3.8.10
$ node --version
  v16.6.1
$ npm --version
  7.20.3
$ pip --version
  pip 21.2.3
$ virtualenv --version
  virtualenv 20.0.17
$ psql --version
  psql (PostgreSQL) 12.7 (Ubuntu 12.7-0ubuntu0.20.04.1)
$ redis-cli --version
  redis-cli 5.0.7

YMMV if you use versions that differ from these.

Prepare a connection string that looks like this when you're done, prepare PostgreSQL accordingly:

postgresql://username:password@hostname:port/database

The connection string for localhost can look like this:

postgresql://postgres@localhost/spacedock

SpaceDock needs to be able to create/alter/insert/update/delete in the database you give it.

You also need to start up Redis on the default port if you want to send emails.

Clone SpaceDock

Find a place you want the code to live.

$ git clone git://github.com/KSP-SpaceDock/SpaceDock.git
$ cd SpaceDock

Activate virtualenv

$ virtualenv -p python3 .
$ source bin/activate

If you are on a system where python3 is not the name of your Python executable, add --python=/path/to/python3 to the virtualenv command to fix that.

pip requirements

If you use systemd/spacedock.target or Docker, this will be done automatically for you.

$ pip install -r requirements.txt

Frontend

$ ./build-frontend.sh

Configure SpaceDock

$ cp config.ini.example config.ini
$ cp alembic.ini.example alembic.ini
$ cp logging.ini.example logging.ini

Edit config.ini and alembic.ini to your liking.

Postgres Configuration

Depending on your environment, you may need to tell postgres to trust localhost connections. This setting is in the pg_hba.conf file, usually located in /etc/postgresql/[version]/main/. An example of what the config should look like:

local   all    all                    trust
host    all    all    127.0.0.1/32    trust
host    all    all    ::1/128         trust    #may or may not be needed for IPv6 aware installs

Site Configuration

What you do from here depends on your site-specific configuration. If you just want to run the site for development, you can source the virtualenv and run

python app.py

To run it in production, you probably want to use gunicorn behind an nginx proxy. There's a sample nginx config in the configs/ directory here, but you'll probably want to tweak it to suit your needs. Here's how you can run gunicorn, put this in your init scripts:

/path/to/SpaceDock/bin/gunicorn app:app -b 127.0.0.1:8000

The -b parameter specifies an endpoint to use. You probably want to bind this to localhost and proxy through from nginx. I'd also suggest blocking the port you choose from external access. It's not that gunicorn is bad, it's just that nginx is better.

To get an admin user you have to register a user first and then run this (replace <username> with your username):

source bin/activate
python

from KerbalStuff.objects import *
from KerbalStuff.database import db
u = User.query.filter(User.username == "<username>").first()
u.admin = True
u.confirmation = None
db.commit()

When running in a production environment, run python app.py at least once and then read the SQL stuff below before you let it go for good.

Emails

If you want to send emails (like registration confirmation, mod updates, etc), you need to have redis running and then start the KerbalStuff mailer daemon. You can run it like so:

celery -A KerbalStuff.celery:app worker --loglevel=info

Of course, this only works if you've filled out the smtp options in config.ini and you have sourced the virtualenv.

SQL Stuff

We use alembic for schema migrations between versions. The first time you run the application, the schema will be created. However, you need to tell alembic about it. Run the application at least once, then:

$ cd /path/to/SpaceDock/
$ source bin/activate
$ python
>>> from alembic.config import Config
>>> from alembic import command
>>> alembic_cfg = Config("alembic.ini")
>>> command.stamp(alembic_cfg, "head")
>>> exit()

Congrats, you've got a schema in place. Run alembic upgrade head after pulling the code to update your schema to the latest version. Do this before you restart the site.

spacedock's People

Contributors

4o66 avatar alexanderdzhoganov avatar allista avatar andyleap avatar avivey avatar dasskelett avatar ddevault avatar dependabot[bot] avatar eirexe avatar frikfry avatar godarklight avatar hebarusan avatar ihsoft avatar ilm126 avatar necrobones avatar oharaandrew314 avatar olympic1 avatar phwoelfel avatar pjf avatar plague006 avatar redstonewizard08 avatar romb avatar sharksharkco avatar space-duck avatar spaceisbig42 avatar stolld avatar thehandsomecoder avatar toadicus avatar v1ta5 avatar xinayder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spacedock's Issues

Enhancement:CKAN Opt-In Page

I recommend moving the CKAN check box off the main mod upload submission form, and instead present authors a page asking if they'd like their mod to be included on CKAN, espousing its benefits with the opt-in being a button, and continue without opting-in another button, and a text explaining that a mod author can opt-in later or opt out later (if possible).

Then the next page would be the form to upload their mod.

"Rename" buttons

Something that KerbalStuff was always missing was an option to rename things. I know Sircmpwn had his reasons for not allowing renames of mods. Do we want to revisit this?

Also, the "mod packs" lack a rename option (as well as the ability to be deleted by the owner). Perhaps the packs should be able to be renamed, whether the mods can be renamed or not?

Discussion: Popular Mods - how do we want to handle these?

Does anyone know how popular mods are currently ranked? It's not by downloads, or if it is, then the ranking must be taking place at intervals that are not instant.

How do we want to serve the list of popular mods going forward? Is it broken? Can it be better? What do you want to see?

More configuration options

Site name, source code adress and support email should be configurable without editing the template files.

We probably want to put everything into config.ini, since it is there, it is dynamic (which is good) and it is .ini, which is easy to parse and to read. That results in a faster startup.

Follow/Unfollow

spamming those buttons on the dev-site, redirected to registration page.

Spurious tags in <a href>

The verification email link won't work:

<a hrel="noreferrer">http://spacedock.info/confirm/<wbr>pcm_test1/13fab815f64ce79e34c5<wbr>449de0d62c3582437945</a>

Create user search functionality for (admin) users

Something that was brought up in IRC is that it would be useful for admin users to be able to search for users via the admin page, hopefully with support for wildcards, case-insensitive searching, etc.

Making a Dockerfile for easy setup

Yeah, currently, the setup process is a painful mess, a dockerfile (or even just a simple build script) would be a good option to make this easier. Even though simple shell scripts would work too, a Dockerfile would be prefered since Docker takes care of everything needed in the background and you can easily start / stop the software.

I will look into this in the future, if someone voluteers, even better :)

TAB to search.

Currently using the TAB to search feature found in Google Chrome still directs you to the old KerbalStuff URL.

Full (Optional) Github Integration

One feature that would be awesome for SpaceDock would be to have full GitHub integration for people who want to use it. I want to stress that this would be a totally optional feature for people to use. Below were some of the features I was thinking of:

  • OAuth login via GitHub: People could log in via GitHub like how on other sites people can log in via Google, Twitter, Facebook, etc.
  • "Import Mod from GitHub": Show a list of the users GitHub repositories and have them select which repositories to pull releases from a la #33.
  • Pull requests like the old KerbalStuff-Bot tied to the user: Have the PRs sent for the mods be sent by the user's GitHub profile instead of the replacement of KerbalStuff-Bot.

This would make it much easier for people who traditionally deploy their mods on GitHub to switch to SpaceDock.

Categories

Add categories from ModulousSmash/Modulous

You guys can suggest some

Title bar is too wide on mobile

Description (What went wrong?):

To see the title bar you have to either zoom out or scroll to the right on mobile, both instances leave a lot of white space on the right side of the screen (see the screenshot below)

Expected Behavior (What do you think should have happened instead?):

The title bar should scale with the rest of the site.

Environment (OS/Browser/Plugins/etc):

Samsung Galaxy S4, Lollipop, Chrome, with similar effects on Firefox

Extra Information (Screenshots/Error Messages/Javascript Console Output):

Screenshot

Suggestion: Updated != New

The front page has a "Newest Mods" and a "Recently Updated Mods" section.

A long-standing pet peeve of mine: Currently (and on Kerbal Stuff, since forever), it treats a new mod as being "updated", which means any time someone posts a new mod, it appears twice on the page (at the top of both the "new" and "updated" lists).

Suggestion: Alter the logic for "Recently Updated" so that it only shows mods that have more than one version.

Rationale: There's not a lot of use in a mod showing up twice on the page. It means that the existing mods who are actually updated don't get as much screen time because the new mods are elbowing them out. Seems more helpful to treat "new" and "updated" as different things, since both sections are present.

Thoughts, anyone?

Github integration

Fixing how this is put, that is all.

Adding github integration on the level of an author (who has linked the accounts) will only have to post a release to github, and the release be pulled to spacedock automatically as an update to the mod in question. Changelog and the like can be automatically filled out by pulled from changelog.md files as well. On page issue reporting (i.g. not having to go to the github page to post or review issues) can also be supported, though I don't recall how this is handled.

User suggestion: galleries for mods hosted on SD

via support@:

Hello, just a suggestion for spacedock, something that always frustrated me with kerbal stuff, would it be going too far to add a tab next to the info tab on mods for screenshots or something? Always love to download mods more when I can actually see them…

I'm of two minds here, as mod authors can embed Imgur galleries in the mod description. It's be a duplication of effort.

On the other hand, it does provide some convenience for users and modders, but probably not enough considering the time we would have to invest for a little used feature.

Word Replacement Mistake!

In the about Space Dock section it says this: "There have been a few poor modding sites for Space Dock Program in the past." Probably just a quick fix but i thought it should come to your attention!

Thumbnail aspect ratios

Something that always bugged me is that the aspect ratios differ for the thumbnails and banner images, even though you only upload a single image to be used for both. It was very difficult to make an image that looked good for both, especially since the centering for the thumbnail was automati (as in, it didn't center at all, it just truncated).

Is this something folks would be interested in revisiting? I'd suggest one of several possible solutions:

  1. Make them both use the same aspect ratio.

or

  1. Split them out into two separate image uploads.

Thumbnail Generation

Because the frontpage is way too heavy as it is, and the easiest way is to generate thumbnails for display, either when an image is uploaded, or when it is first accessed.

For a CDN, though, generating the thumb when uploaded would be best.

Add a suggest a feature button.

I think it would be a good idea to put in a suggest a feature button to the very bottom of every page next to the API and source code.

Multiple KSP Versions

This is a repost of KerbalStuff/KerbalStuff#77.

Would it be possible to add a feature for SpaceDock letting modders declare that a mod is compatible with multiple versions of KSP? For example, a mod might be compatible with KSP 1.0.2 through 1.0.5.

Possible user interfaces (in no particular order):

  • Curse-style checkboxes
  • Multi-valued select
  • Text box accepting ranges (suggested by @apemanzilla)
  • Min/max versions, as used by CKAN and AVC (suggested by @pjf)

Email, Auth, and Sanity

Thomas fixes the email auth problem for now to get SpaceDock up and running.

After this: refactor the email BS into something resembling sanity and working in a dev environment, so we don't have to fix in production.

CKAN

Well, we need to think of a way to handle CKAN Integration of SpaceDock. CKAN was an important part of KerbalStuff, and we certainly want to archive the same, but we seriously need to overthink the concept KerbalStuff used.

If a mod got added to CKAN on KerbalStuff, there was no way to remove it, unless you had it licensed as All Rights Reserved, due to CKAN's policy on mod-deindexing. Even thought I respect their decision, I do not agree with it. The modmaker should have the absolute control over where his mod is distributed. We are allowed to do it, but we shouldn't - to respect the wishes of the guys who make so great mods for KSP. πŸ‘

My idea is that we should run our own CKAN metadata repository (at least for NetKAN, CKAN needs some more infrastructure, which we would have to set up first, which is not the problem though). That would give us and our users the ability to remove mods from CKAN, and it avoids spamming the CKAN team with merge requests from SpaceDock mods. Also, the mod makers would have to blame us for bad written auto generated metafiles, not the folks over at CKAN πŸ˜›

What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.