Skip to content

Commit 8c0905a

Browse files
Implement baseline phase 1: Change URLs, adjusting styles, pre for new criteria set (#2518)
This PR implements baseline plan phase 1. It transitions the application from using numeric criteria levels (0, 1, 2) to human-readable named levels (passing, silver, gold) in URLs, preparing the codebase for future baseline levels. The changes maintain backward compatibility through redirects while establishing a cleaner, more maintainable URL structure. It adds a new "section" tab to projects and fixes the stylesheets to prep for baseline. Key Changes: * URL Structure: Routes now use /projects/:id/:level with named levels (passing/silver/gold) instead of numeric IDs * Routing Layer: Adds redirect rules for deprecated numeric/synonym forms with appropriate 301/302 status codes * Level Conversion: Introduces LevelConversion concern and helper methods to translate between URL-friendly names and internal numeric representations * Test Updates: Comprehensive test coverage for new routing patterns, redirects, and level normalization * Adds new "permissions" section so baseline users won't need to walk through "passing" questions to change permissions. * Project page shows new "Section" tab to make it easier to see and switch sections * Stylesheets reorganized and changed to support new information in navbar Specifics: * Change external URLs to prep for baseline * Small improvements for new routing * 100% test coverage for routing changes * IDA wasn't involved in this file * AGENTS.md: Minimize new code * First try at DRY in routes * DRY out code for redirecting from router * Remove unused parameter * Implement new _form_permissions form * Redirect missing criteria_level for projects * Simplify routing code * Cleanup: Consistently append criteria level in URL * Improve permissions page handling * Fix broken test * Add tests * Simplify level normalization and its tests * Add test to reach 100% statement coverage * Rename is_disabled to view_only Many UI components look different when they allow editing vs. when they *disable* editing. So we've been using "is_disabled" to indicate the mode that only permits viewing (not editing). However, in higher-level constructs this is confusing (what is being disabled?). This changes the name of the boolean to "view_only". It still has the same sense ("true" means "only viewing no editing), but giving its name a higher-level meaning makes it easier to follow. * Add section selector at top Add selector - this makes the various sections MUCH more discoverable and easy to use. It does use up precious space on mobile, but I think it's worth it. The term "section" is vague, but I couldn't find a better term. * Simplify end of "show project" form Historically we had some links at the bottom that didn't look pretty, but they're no longer needed. Clean this up so that the end of the project form is nicer-looking and simpler. * Organize stylesheet files These stylesheet files have become a mess over time and it's now hard to fix style problems. Solution: Reorganize style files so they "make sense" and follow more recent conventions. Then we can fix the bug involving the navigation bar (now that we've added "Section" we can have way-too-long navigation bars, and we need to deal with it). * Improve navbar hamburger processing * Fix header so it works "enough" * Fix navbar by removing extraneous boxes Signed-off-by: David A. Wheeler <[email protected]> * Regenerate db/schema.rb ActiveRecord wants to regenerate this file, so let's allow it. * Eliminate double-line navbar in wide widths * Add edge margins for navbar logo and hamburger * Force progress bar to be vertically aligned * Cleanup progress bar stylesheet settings * Reduce navbar padding to keep on 1 line * Add RHS margin in navbar * Improve navbar stacking in medium width screens * Put progressbar in top line only and always * Fix subtle problems from incorrect CSS load order The GitHub button was mysteriously not working well (when hovering the text and image disappeared). Eventually I found that the problem was a bad CSS load order. Loading the CSS in the correct order solved it cleanly. * Fix preload stylesheet type so it loads * Fix regex for SPDX License Expression Parentheses must be escaped in these regexes, even inside brackets. * Fix JavaScript: line width, omit some in dev mode * Fix test, preload stylesheet should be "sheet" * Fix CSV test (make it more flexible) The order of the CSV headers has changed (now it's alphabetical). Let's modify the test so that it's not so sensitive, we just want to ensure that many expected values are in it. * Fix progress bar and a test * Clarify comment in SCSS * Improve rakefile Add an asset precompilation task, and modify the whitespace checker to ignore generated assets (we don't control much of those). * Remove unnecessary navbar !important markings The !important marking is sometimes necessary, but best avoided if possible. These weren't necessary; remove them. * Remove unnecessary !important in navbar * Clean up navbar (remove more !important) * Remove more unnecessary !important * Document navbar layout strategy in comments The navbar layout approach is unusual. Clearly document it in the comments (including why we do it this way). * Highlight current section in list of sections The server-side code already indicated the "active" section, but previously there was no style that made it visible. This adds styling so the current (active) section is highlighted, in this case by a colored checkmark. Exactly the same text is transparently before the other sections to ensure that the text alignment is perfect. * Minor cleanup in CSS load order * Reorg: application.scss should only import Move the specific CSS commands into _base.scss. * Rename SCSS partial filenames per convention SCSS partials are supposed to have filenames beginning with "_", but we didn't do that consistently. Rename to make them consistent. The "application.scss" becomes "application.css" which imports everything else. This single CSS is cached on the user's browser, so once a user loads it, they won't need to load it again. We don't use the other files as anything other than partials, so rendering them so they can be used independently is a waste of time. * Move key shared CSS variables in separate file We have a few width values that are shared across files. Put them in a single "_variables.scss" file, so their values are shared and in exactly one place. * Identify criteria CSS as a partial Follow the filename convention for SCSS partials. * Minor cleanup of .scss files --------- Signed-off-by: David A. Wheeler <[email protected]>
1 parent 53aafc0 commit 8c0905a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2380
-1377
lines changed

AGENTS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,15 @@ moves like the direct use of `rails app:update` or adding `load_defaults
313313
8.0` is likely to cause a cascade of many changes, leading to
314314
many hard-to-fix failures with little obvious external benefit.
315315

316+
## Simple DRY code
317+
318+
It's critically important to make the code small and
319+
DRY (don't repeat yourself). If the same function or method is written
320+
more than once, it's wrong. If many lines are duplicated between
321+
functions/methods, it's usually wrong.
322+
323+
Prefer having many small pure methods called by others.
324+
316325
## Miscellaneous
317326

318327
IMPORTANT: Never have trailing whitespace in text-like files including

app/assets/javascripts/project-form.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ function getLocale() {
5858

5959
// Return current level based upon parameters in location.search
6060
function getLevel() {
61-
var levelFromUrl = location.pathname.match('projects/[0-9]*/([0-2])');
61+
// Match named levels (passing, silver, gold) or numeric (0, 1, 2)
62+
var levelPattern = 'projects/[0-9]*/(passing|silver|gold|[0-2])';
63+
var levelFromUrl = location.pathname.match(levelPattern);
6264
if (levelFromUrl) {
6365
return levelFromUrl[1];
6466
}
@@ -665,9 +667,17 @@ function TogglePanel(e) {
665667
function setupProjectForm() {
666668
// We're told progress, so don't recalculate - just display it.
667669
T_HASH = TRANSLATION_HASH_FULL[getLocale()];
668-
var percentageScaled = $('#badge-progress').attr('aria-valuenow');
669-
var percentAsString = percentageScaled.toString() + '%';
670-
$('#badge-progress').css('width', percentAsString);
670+
// Use class selector to handle multiple progress bars
671+
// (collapsed and expanded)
672+
$('.badge-progress').each(function() {
673+
var badgeProgress = $(this);
674+
var percentageScaled = badgeProgress.attr('aria-valuenow');
675+
if (percentageScaled !== undefined && percentageScaled !== null &&
676+
percentageScaled !== '') {
677+
var percentAsString = percentageScaled.toString() + '%';
678+
badgeProgress.css('width', percentAsString);
679+
}
680+
});
671681

672682

673683
// By default, hide details. We do the hiding in JavaScript, so
@@ -705,7 +715,18 @@ function setupProjectForm() {
705715
});
706716

707717
if (globalisEditing) {
708-
CRITERIA_HASH = CRITERIA_HASH_FULL[getLevel()];
718+
var level = getLevel();
719+
// Normalize named levels to numeric for CRITERIA_HASH_FULL access
720+
if (level === 'passing' || level === 'bronze') {
721+
level = '0';
722+
}
723+
if (level === 'silver') {
724+
level = '1';
725+
}
726+
if (level === 'gold') {
727+
level = '2';
728+
}
729+
CRITERIA_HASH = CRITERIA_HASH_FULL[level];
709730
$('#project_entry_form').on('criteriaResultHashComplete', function(e) {
710731
setupProjectFields();
711732
resetProgressBar();

app/assets/stylesheets/_base.scss

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Base element styles (global HTML elements)
2+
3+
@import "variables";
4+
5+
/* Work around a bug in Bootstrap's navigation bar. When the display is narrow,
6+
the navigation bar gets longer, but the body padding doesn't adjust.
7+
The result is that the navigation bar overlaps the beginning of the
8+
body content below it. This particular workaround is based on:
9+
http://stackoverflow.com/questions/10336194/
10+
twitter-bootstrap-top-nav-bar-blocking-top-content-of-the-page */
11+
12+
body {
13+
padding-top: 80px;
14+
}
15+
16+
@media (max-width: $screen-xs-max) {
17+
body {
18+
padding-top: 100px;
19+
}
20+
}
21+
22+
html, body {
23+
height: 100%;
24+
}
25+
26+
body,
27+
h1,
28+
h2,
29+
h3,
30+
h4,
31+
h5,
32+
h6 {
33+
font-family: "Lato","Helvetica Neue",Helvetica,Arial,sans-serif;
34+
font-weight: 450;
35+
}
36+
37+
section {
38+
overflow: auto;
39+
}
40+
41+
textarea {
42+
resize: vertical;
43+
min-height: 12ex;
44+
}
45+
46+
h1, h2, h3, h4, h5, h6 {
47+
line-height: 1;
48+
}
49+
50+
p {
51+
font-size: 1.1em;
52+
line-height: 1.7em;
53+
}
54+
55+
// Project Display tables
56+
.table thead tr th, .table tbody tr td {
57+
text-align: center;
58+
}
59+
60+
.tab-title {
61+
margin-left: 5px;
62+
margin-right: 5px;
63+
}
64+
65+
td p {
66+
text-align: left;
67+
font-size: 14px;
68+
line-height: 1.42857143;
69+
padding-left: 5px;
70+
padding-right: 5px;
71+
}
72+
73+
nav {
74+
min-width: 15em;
75+
}
76+
77+
// Container utilities
78+
.container_padding {
79+
padding: 1em 0;
80+
}
81+
82+
.container_margins {
83+
min-height: 100%;
84+
height: auto;
85+
margin: 1.5em auto -9.6em;
86+
padding-bottom: 100px;
87+
}
88+
89+
// Bootstrap button override
90+
.btn {
91+
padding-left: 3px;
92+
padding-right: 3px;
93+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// footer styles
22

3+
@import "variables";
4+
35
footer {
46
margin-top: 60px;
57
padding-top: 5px;
@@ -33,7 +35,7 @@ footer ul li {
3335
margin-left: 25px;
3436
}
3537

36-
@media (max-width: 768px) {
38+
@media (max-width: $screen-sm-min) {
3739
footer {
3840
nav {
3941
float: left;

app/assets/stylesheets/_forms.scss

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// frozen_string_literal: true
2+
3+
// Global form styles
4+
// Moved from static_pages.scss during CSS reorganization
5+
// NOTE: Mixins and Bootstrap variables available via application.scss import context
6+
7+
input, textarea, select, .discussion-markdown, .uneditable-input {
8+
border: 1px solid #bbb;
9+
width: 100%;
10+
margin-bottom: 15px;
11+
box-sizing: border-box;
12+
}
13+
14+
form.project_search input {
15+
width: auto;
16+
}
17+
18+
form.project_search select {
19+
width: auto;
20+
}
21+
22+
input {
23+
height: auto !important;
24+
}
25+
26+
input[type=checkbox] {
27+
width: initial;
28+
}
29+
30+
#error_explanation {
31+
color: red;
32+
ul {
33+
color: red;
34+
margin: 0 0 30px 0;
35+
}
36+
}
37+
38+
.field_with_errors {
39+
@extend .has-error !optional;
40+
.form-control {
41+
color: #a94442;
42+
}
43+
}
44+
45+
label.required:after {
46+
content:" *";
47+
}
48+
49+
.radio {
50+
width: 15px;
51+
}
52+
53+
.checkbox {
54+
margin-top: -10px;
55+
margin-bottom: 10px;
56+
span {
57+
margin-left: 20px;
58+
font-weight: normal;
59+
}
60+
}
61+
62+
// Status chooser table
63+
.borderless tbody tr td, .borderless tbody tr td label, .borderless tbody tr th, .borderless thead tr th, .borderless {
64+
border: none;
65+
padding: 0px 5px 0px 5px;
66+
}
67+
68+
.required-data {
69+
background-color: yellow;
70+
}

0 commit comments

Comments
 (0)