Skip to content

Commit

Permalink
Merge branch 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
charmander committed Dec 5, 2024
2 parents 18d1784 + 047be16 commit ca94f77
Show file tree
Hide file tree
Showing 15 changed files with 178 additions and 132 deletions.
102 changes: 102 additions & 0 deletions assets/scss/components/_edit-profile.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
.social .group input {
margin-bottom: 6px;
}

.social .group {
margin-bottom: 12px;
}

#edit-profile {
.buttons {
padding-top: 1em;
}

@media (min-width: 30em) {
.social .group {
width: 48%;
float: left;
padding-right: 2%;
}
}

@media (min-width: 45em) {
.column {
width: 48%;
}

.info {
float: left;
clear: left;
}

.settings {
float: left;
padding-left: 4%;
}

.profile {
padding-bottom: 4px;
}

.social, .profile {
clear: both;
width: 100%;
}

.social .group {
width: 23%;
}
}

@media (min-width: 63em) {
.column {
width: 31%;
}

.settings {
clear: none;
padding-left: 3.5%;
margin-left: 0;
}

.profile {
margin-left: 65.5%;
padding-left: 3.5%;
clear: none;
overflow: hidden;
}

.social {
width: 100%;
}

.social .group {
width: 18%;
}
}

@media (min-width: 80em) {
.column {
width: 23%;
}

.settings {
padding-left: 2%;
}

.profile {
width: 50%;
margin-left: 48%;
padding-left: 2%;
overflow: hidden;
}

.social {
width: 100%;
}

.social .group {
width: 14.6%;
}
}
}
70 changes: 10 additions & 60 deletions assets/scss/site.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import 'theme';
@import 'reset';
@import 'components/date-picker';
@import 'components/edit-profile';
@import 'components/option';
@import 'components/page-navigation';
@import 'components/private-messages';
Expand Down Expand Up @@ -66,14 +67,6 @@ dl.leaders dd {
text-align: right;
}

.social .group input {
margin-bottom: 6px;
}

.social .group {
margin-bottom: 12px;
}

/* Typefaces
--------------------------------*/
#page-container, textarea, .typeface-default, button {
Expand Down Expand Up @@ -3675,37 +3668,20 @@ img + #detail-art-text {
padding-top: 2em;
}

#edit-profile .buttons {
padding-top: 1em;
}

.tags-help {
padding-top: 0.5em;
}

@media (min-width: 30em) {
#edit-profile .social .group {
width: 48%;
float: left;
padding-right: 2%;
}
}

@media (min-width: 45em) {
#submit-form .column, #edit-profile .column, #commishprices-content .column {
#submit-form .column, #commishprices-content .column {
width: 48%;
}

#submit-form .files, #submit-form .info, #edit-profile .info, #commishprices-content .classes {
#submit-form .files, #submit-form .info, #commishprices-content .classes {
float: left;
clear: left;
}

#edit-profile .settings {
float: left;
padding-left: 4%;
}

#submit-form .description, #submit-form .tagging, #submit-form .options {
margin-left: 52%;
overflow: hidden;
Expand All @@ -3724,23 +3700,14 @@ img + #detail-art-text {
padding-top: 1em;
}

#submit-form .description, #submit-form .tagging, #edit-profile .profile {
#submit-form .description, #submit-form .tagging {
padding-bottom: 4px;
}

#submit-form .buttons {
clear: both;
padding-top: 2em;
}

#edit-profile .social, #edit-profile .profile {
clear: both;
width: 100%;
}

#edit-profile .social .group {
width: 23%;
}
}

@media (min-width: 53em) {
Expand Down Expand Up @@ -3769,11 +3736,11 @@ img + #detail-art-text {
margin: 0 auto;
}

#submit-form .column, #submit-form.journal .column, #edit-profile .column, #commishprices-content .column {
#submit-form .column, #submit-form.journal .column, #commishprices-content .column {
width: 31%;
}

#submit-form .info, #edit-profile .settings {
#submit-form .info {
clear: none;
padding-left: 3.5%;
margin-left: 0;
Expand All @@ -3783,7 +3750,7 @@ img + #detail-art-text {
padding-left: 0;
}

#submit-form .description, #submit-form .tagging, #submit-form .options, #edit-profile .profile {
#submit-form .description, #submit-form .tagging, #submit-form .options {
margin-left: 65.5%;
padding-left: 3.5%;
clear: none;
Expand All @@ -3795,42 +3762,25 @@ img + #detail-art-text {
margin-left: 34.5%;
padding-left: 0;
}

#edit-profile .social {
width: 100%;
}

#edit-profile .social .group {
width: 18%;
}
}

@media (min-width: 80em) {
#submit-form .column, #edit-profile .column {
#submit-form .column {
width: 23%;
}

#submit-form .info, #edit-profile .settings {
#submit-form .info {
padding-left: 2%;
}

#submit-form .description, #submit-form .tagging, #submit-form .options, #edit-profile .profile {
#submit-form .description, #submit-form .tagging, #submit-form .options {
width: 50%;
margin-left: 48%;
padding-left: 2%;
overflow: hidden;
}

#edit-profile .social {
width: 100%;
}

#edit-profile .social .group {
width: 14.6%;
}
}


/* ------------------------------------ =notifications -- */

.notifs-actions {
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ services:

web:
image: weasyl
pull_policy: never
build: &weasyl-build
context: .
args:
Expand Down Expand Up @@ -147,6 +148,7 @@ services:
migrate:
profiles: [ migrate ]
image: weasyl
pull_policy: never
build: *weasyl-build
command:
- ash
Expand Down Expand Up @@ -181,6 +183,7 @@ services:
revision:
profiles: [ revision ]
image: weasyl
pull_policy: never
build: *weasyl-build
entrypoint:
- ash
Expand Down
25 changes: 0 additions & 25 deletions libweasyl/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,13 @@
File manipulation and detection.
"""

import errno
import os

from sanpera.exception import SanperaError

from libweasyl.constants import Category
from libweasyl.exceptions import InvalidFileFormat, UnknownFileFormat
from libweasyl import images


def makedirs_exist_ok(path):
"""
Ensure a directory and all of its parent directories exist.
This is different from :py:func:`os.makedirs` in that it will not raise an
exception if the directory already exists. Any other exceptions (e.g.
permissions failure; filesystem out of inodes) will still propagate.
This is functionally equivalent to specifying ``os.makedirs(path,
exist_ok=True)`` in python 3.2+, but exists in libweasyl for compatibility
with python 2.7.
Parameters:
path: The directory whose existence must be ensured.
"""
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
raise


def fanout(name, fanout):
"""
Generate fanout for a particular name.
Expand Down
4 changes: 2 additions & 2 deletions libweasyl/models/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sqlalchemy.orm import relationship, foreign, remote, joinedload, lazyload, load_only
from sqlalchemy.sql.expression import any_

from libweasyl.files import fanout, makedirs_exist_ok
from libweasyl.files import fanout
from libweasyl.models.meta import Base
from libweasyl.models.users import Profile
from libweasyl.models import tables
Expand Down Expand Up @@ -35,7 +35,7 @@ def fetch_or_create(cls, data, file_type=None, im=None, attributes=()):

# Write our file to disk
real_path = obj.full_file_path
makedirs_exist_ok(os.path.dirname(real_path))
os.makedirs(os.path.dirname(real_path), exist_ok=True)
with open(real_path, 'wb') as outfile:
outfile.write(data)

Expand Down
33 changes: 0 additions & 33 deletions libweasyl/test/test_files.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
import errno

import pytest

from libweasyl.constants import Category
from libweasyl.test.common import datadir
from libweasyl import exceptions, files


def test_makedirs_default_behavior(tmpdir):
"""
``makedirs_exist_ok`` creates multiple levels of directories.
"""
d = tmpdir.join('a', 'b', 'c')
assert not d.exists()
files.makedirs_exist_ok(d.strpath)
assert d.exists()


def test_makedirs_with_extant_directories(tmpdir):
"""
``makedirs_exist_ok`` doesn't care if the directories already exist.
"""
d = tmpdir.join('a', 'b', 'c')
d.ensure(dir=True)
files.makedirs_exist_ok(d.strpath)
assert d.exists()


def test_makedirs_reraises_other_errors(tmpdir):
"""
``makedirs_exist_ok`` reraises errors it can't handle, such as EACCES.
"""
tmpdir.chmod(0)
d = tmpdir.join('a', 'b', 'c')
with pytest.raises(OSError) as e:
files.makedirs_exist_ok(d.strpath)
assert e.value.errno == errno.EACCES


def test_file_type_for_category_invalid_category():
"""
``file_type_for_category`` raises an exception on unknown categories.
Expand Down
4 changes: 3 additions & 1 deletion libweasyl/test/test_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def test_fetch_or_create_requires_file_type():
"""
A file type is required if an image isn't being passed in.
"""
pytest.raises(ValueError, media.MediaItem.fetch_or_create, b'spam')
with pytest.raises(ValueError) as err:
media.MediaItem.fetch_or_create(b'spam')
assert str(err.value) == "a file type is required"


def test_disk_media_item_display_url(db):
Expand Down
Loading

0 comments on commit ca94f77

Please sign in to comment.