Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Related links #1054

Open
wants to merge 28 commits into
base: dev/new_features
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
31c2f5d
related links
Aug 21, 2024
7debca3
related links
Aug 22, 2024
5e61bb1
related links
Aug 22, 2024
09a1a0d
php fixer
Aug 22, 2024
eb2daa7
Merge branch 'main' into related-links
Aug 22, 2024
8a3275b
cleaning
Aug 22, 2024
6c2ca55
Required changes.
Sep 2, 2024
8174113
docs(contributor): contrib-readme-action has updated readme
github-actions[bot] Sep 2, 2024
b750fa1
Merge remote-tracking branch 'origin/main' into related-links
Sep 2, 2024
3055403
Merge branch 'main' into related-links
JaviviJR Sep 3, 2024
3f043fd
Related links
JaviviJR Sep 4, 2024
68d6d11
Changes requested
JaviviJR Sep 16, 2024
a5b7f85
Changes requested
JaviviJR Sep 16, 2024
1d0f707
Changes requested
JaviviJR Sep 16, 2024
09a90b4
Introducing bookmarks (#1095)
BentiGorlich Oct 6, 2024
85bd770
Make related panels respect blocks (#1183)
BentiGorlich Oct 13, 2024
55cc85a
Improve search (#1167)
BentiGorlich Oct 16, 2024
f282a29
Merge branch 'dev/new_features' into related-links
melroy89 Nov 8, 2024
77b9631
Merge branch 'main' into dev/new_features
melroy89 Nov 8, 2024
552e4bf
Merge branch 'dev/new_features' into related-links
melroy89 Nov 8, 2024
498b961
Fix php cs fixer
melroy89 Nov 8, 2024
cf72318
Merge branch 'main' into dev/new_features
melroy89 Nov 8, 2024
f34d504
Merge branch 'dev/new_features' into related-links
melroy89 Nov 8, 2024
a8ea966
Introducing bookmarks (#1095)
BentiGorlich Oct 6, 2024
6992f10
Make related panels respect blocks (#1183)
BentiGorlich Oct 13, 2024
5fec24b
Improve search (#1167)
BentiGorlich Oct 16, 2024
9b44612
Fix checkmarks not being rendered correctly anymore (#1233)
BentiGorlich Nov 20, 2024
679d683
Merge branch 'dev/new_features' into related-links
BentiGorlich Nov 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# IDEA/PhpStorm
*.iml
.idea/
.run/
.DS_Store
supervisord.log
supervisord.pid
Expand Down
66 changes: 66 additions & 0 deletions assets/controllers/form-related-links_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Controller } from '@hotwired/stimulus';

export default class extends Controller {
static targets = ['relatedContainer'];

static values = {
index: Number,
label: String,
value: String,
deleteIcon: String,
};

connect() {
const container = this.element;
container
.querySelectorAll('.related-link-row')
.forEach((item) => {
this.#addButtonDeleteLink(item);
});
}

addRelatedElement() {
console.log('entra');
console.log(this.labelValue, 'label');
console.log(this.valueValue, 'value');

const rowNode = document.createElement('div');
rowNode.className = 'related-link-row';

const nodeLabel = this.#htmlToNode(this.labelValue.replace(
/__name__/g,
this.indexValue,
));
rowNode.appendChild(nodeLabel);

const nodeValue = this.#htmlToNode(this.valueValue.replace(
/__name__/g,
this.indexValue,
));
rowNode.appendChild(nodeValue);

this.#addButtonDeleteLink(rowNode);

this.relatedContainerTarget.appendChild(rowNode);
this.indexValue++;
}

#addButtonDeleteLink(item) {
melroy89 marked this conversation as resolved.
Show resolved Hide resolved
const removeFormButton = document.createElement('button');
removeFormButton.innerHTML = this.deleteIconValue;
removeFormButton.className = 'btn btn__secondary delete-button';

item.append(removeFormButton);

removeFormButton.addEventListener('click', (e) => {
e.preventDefault();
item.remove();
});
}

#htmlToNode(html) {
const template = document.createElement('div');
template.innerHTML = html;
return template.firstChild;
}
}
40 changes: 40 additions & 0 deletions assets/controllers/subject_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,46 @@ export default class extends Controller {
}
}

/**
* Calls the address attached to the nearest link node. Replaces the outer html of the nearest `cssclass` parameter
* with the response from the link
*/
async linkCallback(event) {
const { cssclass: cssClass, refreshlink: refreshLink, refreshselector: refreshSelector } = event.params
event.preventDefault();

const a = event.target.closest('a');

try {
this.loadingValue = true;

let response = await fetch(a.href, {
method: 'GET',
});

response = await ok(response);
response = await response.json();

event.target.closest(`.${cssClass}`).outerHTML = response.html;

const refreshElement = this.element.querySelector(refreshSelector)
console.log("linkCallback refresh stuff", refreshLink, refreshSelector, refreshElement)

if (!!refreshLink && refreshLink !== "" && !!refreshElement) {
let response = await fetch(refreshLink, {
method: 'GET',
});

response = await ok(response);
response = await response.json();
refreshElement.outerHTML = response.html;
}
} catch (e) {
} finally {
this.loadingValue = false;
}
}

loadingValueChanged(val) {
const submitButton = this.containerTarget.querySelector('form button[type="submit"]');

Expand Down
4 changes: 4 additions & 0 deletions assets/styles/app.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import '@fortawesome/fontawesome-free/scss/fontawesome';
@import '@fortawesome/fontawesome-free/scss/solid';
@import '@fortawesome/fontawesome-free/scss/regular';
@import '@fortawesome/fontawesome-free/scss/brands';
@import 'simple-icons-font/font/simple-icons';
@import 'glightbox/dist/css/glightbox.min.css';
Expand All @@ -21,6 +22,7 @@
@import 'layout/alerts';
@import 'layout/forms';
@import 'layout/images';
@import 'layout/icons';
@import 'components/announcement';
@import 'components/topbar';
@import 'components/header';
Expand All @@ -35,6 +37,7 @@
@import 'components/figure_image';
@import 'components/figure_lightbox';
@import 'components/post';
@import 'components/search';
@import 'components/subject';
@import 'components/login';
@import 'components/modlog';
Expand All @@ -51,6 +54,7 @@
@import 'components/settings_row';
@import 'pages/post_single';
@import 'pages/post_front';
@import 'pages/page_bookmarks';
@import 'themes/kbin';
@import 'themes/default';
@import 'themes/solarized';
Expand Down
24 changes: 24 additions & 0 deletions assets/styles/components/_search.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.search-container {
background: var(--kbin-input-bg);
border: var(--kbin-input-border);
border-radius: var(--kbin-rounded-edges-radius) !important;

input.form-control {
border-radius: 0 !important;
border: none;
background: transparent;
margin: 0 .5em;
padding: .5rem .25rem;
}

button {
border-radius: 0 var(--kbin-rounded-edges-radius) var(--kbin-rounded-edges-radius) 0 !important;
border: 0;
padding: 1rem 0.5rem;

&:not(:hover) {
background: var(--kbin-input-bg);
color: var(--kbin-input-text-color) !important;
}
}
}
49 changes: 48 additions & 1 deletion assets/styles/layout/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ input[type=radio] {
align-content: center;
cursor: pointer;

@extend %fa-icon;
@extend .fa-solid;

&::before {
font-family: var(--kbin-font-awesome-font-family);
content: "\f00c";
content: fa-content($fa-var-check);
transform: scale(0);
transition: 100ms transform ease-in;
}
Expand Down Expand Up @@ -525,3 +528,47 @@ div.input-box {
border-radius: var(--kbin-rounded-edges-radius) !important;
}
}

.form-control {
display: block;
width: 100
}

.related-link-fieldset {
border: 0;
margin: 0;
padding: 0;
}

.related-link-fieldset legend {
margin-bottom: 0.5rem;
}

.related-links-group {
margin-bottom: 0.25rem;
}

.related-link-row {
display: flex;
flex-wrap: nowrap;
row-gap: 0.5rem;
column-gap: 0.2rem;
align-items: center;
margin-bottom: 0.25rem;
}

.related-link-row div {
margin-bottom: 0;
flex-grow: 1
}

.delete-button {
padding: 0;
border: 0;
}

.add-button-container {
display: flex;
margin-right: 13.9px;
justify-content: center;
}
3 changes: 3 additions & 0 deletions assets/styles/layout/_icons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
i.active {
color: var(--kbin-color-icon-active, orange);
}
14 changes: 13 additions & 1 deletion assets/styles/layout/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ figure {
code,
.ts-control > [data-value].item,
.image-preview-container {
border-radius: var(--kbin-rounded-edges-radius) !important;
&:not(.ignore-edges) {
border-radius: var(--kbin-rounded-edges-radius) !important;
}
}

.ts-wrapper {
Expand Down Expand Up @@ -361,10 +363,20 @@ figure {
gap: .25rem;
}

@include media-breakpoint-down(lg) {
.flex.mobile {
display: block;
}
}

.flex-wrap {
flex-wrap: wrap;
}

.flex-grow-1 {
flex-grow: 1;
}

pre, code {
white-space: pre-wrap;
word-wrap: break-word;
Expand Down
8 changes: 0 additions & 8 deletions assets/styles/layout/_section.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,3 @@
color: var(--kbin-alert-danger-text-color);
}
}

.page-search {
.section--top {
button {
padding: 1rem 1.5rem;
}
}
}
6 changes: 6 additions & 0 deletions assets/styles/pages/page_bookmarks.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.page-bookmarks {
.entry, .entry-comment, .post, .post-comment, .comment {
margin-top: 0!important;
margin-bottom: .5em!important;
}
}
71 changes: 71 additions & 0 deletions config/kbin_routes/bookmark.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
bookmark_front:
controller: App\Controller\BookmarkListController::front
defaults: { sortBy: hot, time: '∞', federation: all }
path: /bookmark-lists/show/{list}/{sortBy}/{time}/{federation}
methods: [GET]
requirements: &front_requirement
sortBy: "%default_sort_options%"
time: "%default_time_options%"
federation: "%default_federation_options%"

bookmark_lists:
controller: App\Controller\BookmarkListController::list
path: /bookmark-lists
methods: [GET, POST]

bookmark_lists_menu_refresh_status:
controller: App\Controller\BookmarkListController::subjectBookmarkMenuListRefresh
path: /blr/{subject_id}/{subject_type}
requirements:
subject_type: "%default_subject_type_options%"
methods: [ GET ]

bookmark_lists_make_default:
controller: App\Controller\BookmarkListController::makeDefault
path: /bookmark-lists/makeDefault
methods: [GET]

bookmark_lists_edit_list:
controller: App\Controller\BookmarkListController::editList
path: /bookmark-lists/editList/{list}
methods: [GET, POST]

bookmark_lists_delete_list:
controller: App\Controller\BookmarkListController::deleteList
path: /bookmark-lists/deleteList/{list}
methods: [GET]

subject_bookmark_standard:
controller: App\Controller\BookmarkController::subjectBookmarkStandard
path: /bos/{subject_id}/{subject_type}
requirements:
subject_type: "%default_subject_type_options%"
methods: [ GET ]

subject_bookmark_refresh_status:
controller: App\Controller\BookmarkController::subjectBookmarkRefresh
path: /bor/{subject_id}/{subject_type}
requirements:
subject_type: "%default_subject_type_options%"
methods: [ GET ]

subject_bookmark_to_list:
controller: App\Controller\BookmarkController::subjectBookmarkToList
path: /bol/{subject_id}/{subject_type}/{list}
requirements:
subject_type: "%default_subject_type_options%"
methods: [ GET ]

subject_remove_bookmarks:
controller: App\Controller\BookmarkController::subjectRemoveBookmarks
path: /rbo/{subject_id}/{subject_type}
requirements:
subject_type: "%default_subject_type_options%"
methods: [ GET ]

subject_remove_bookmark_from_list:
controller: App\Controller\BookmarkController::subjectRemoveBookmarkFromList
path: /rbol/{subject_id}/{subject_type}/{list}
requirements:
subject_type: "%default_subject_type_options%"
methods: [ GET ]
Loading