CTFd / CTFd/CTFd

Question on replacing a single JS function

Open
#1,648 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6.8k
Forks
2.8k
Avg merge
1d 6h
Merged PRs (30d)
5

Description

Hello,

I am interested in customizing how the challenges are laid out. I am pretty confident that in order to do so, I want to modify: https://github.com/CTFd/CTFd/blob/dfe4f004f28ff50cb1f9448db89202a840cc9f41/CTFd/themes/core/assets/js/pages/challenges.js#L275

In my mind it would seem reasonable to override that file (rather than just the function), in much the same way that I would override an entire jinja template to make a modification to it. This is what I already do in my plugin. This, however, doesn't seem so trivial to do for the JS side of things.

It seems like in order to make this modification, I would need to copy the entire theme directory, make a modification to that file, and perform a yarn build. Now, in order to stay consistent with any changes made to the core theme on master, I will have to manually keep my theme up to date. This seems like a nightmare situation. At this point it would just be easier to maintain a fork of CTFd all together.

Am I missing something, or is there really not a better solution? I'm not super familiar with JavaScript, but I'd even be fine with a hacky solution where I insert additional JavaScript into the jinja template that replaces `loadChals` at run time (ideally before it gets called the first time). I would have no issue doing this sort of thing if my plugin needed to modify core python code within CTFd, I'm just not familiar on how I'd do it in the case of JavaScript.

Thanks.

Contributor guide

Open the contributing guide

Research direction

Start with CTFd/themes/core/assets/js/pages/challenges.js at line 275 and trace how loadChals is called. Review the plugin and Jinja-template customization described in the issue, along with the yarn build workflow. Done means identifying and documenting or implementing a maintainable way to customize this function without copying the entire theme.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
developer-experience, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.