Code boxes

Just a small convenience issue. It would be nice to have a “select all” button in the code boxes. Or am I missing something? Does anyone know if this can be done with css? I don’t think so but I’m not a coder.

Thanks.

It’s not CSS. It would need custom javascript. But yes, I agree that is an oversight and it would be nice to have it fixed. It’s common on other forum apps, so there’s no obvious reason for Discourse to not have it if they are claiming it be more advanced than others.

Incidentally, I find that cutting default code box height and adding resize: vertical; gives good results. Less space wasted up front, but easily expandable if you want to.

OK thanks, I’ll try that.

Great suggestion! Turns our there was a ‘theme component’ available to help with this. I have activated it:

/* Hide featured pics banner on posts */
.topic-above-post-stream-outlet {
    display: none;
}

/* Hide featured link button under featured pics */
.featured-link {
	display: none;
}

Cool. Funny that they didn’t have it on by default. It seems like an obvious feature that coders will want.

Most Discourse communities have no interest in code. And as this adds a (small) overhead for each page, it makes sense they don’t enable such a feature by default.

I can see the argument. On the other hand communities that have no interest in code simply won’t use code boxes, so there will be no overhead anyway. Even on communities that do have (some, intermittent) interest in code, the overhead will only apply for posts which actually use the code boxes, which is where coders will want the feature.

My 2c: I still think they were being a bit silly. Anyway we haz it now so it’s all good.

Not true, the CSS and Javascript codes are still on the page and are being loaded. So perhaps small, but if you add enough of features that a specific user group has no use for, you create bloat.

Ah. So they’re actually removing the additional code before compiling and minifying the CSS and JS* for sending to the browser? In that case I can see the sense of it.

*From the main site files, I mean. Obviously it wouldn’t show in the markup if no code boxes are being used on that page.

Excellent. Thanks again!

Not just before sending to the browser, but they ‘recompile’ all the assets during a rebuild - which is where you pull in the latest code from github, add new plugins etc. This is also the reason that the site is sometimes offline for a few minutes - during the rebuild the app closes.

Ah! I was wondering about that. This info should be stickied somewhere. Site often down looks like a technical problem (shabby site) and also some won’t come back till next day when they see it. I suppose. I’ve done that here before I realized it always comes back in a minute or so.

I’m actually looking into a better way to do rebuilds without downtime. It’s a bit more complex, but I’ll figure it out :slight_smile:

On second thought, I just remembered I gave up on that idea and just went with a 20em max-height. Anyway if you want to play with it you need max-height set to auto, or to some large value of em, and then height set to whatever you want for the standard height.

This is why I gave up on it: because it involves setting a standard height that will apply initially regardless of whether you are posting one line of code or 100 lines of code. IOW, it will waste some screen height for short snippets of code, and only comes into its own once you have about 12 or 14 lines of code. :slight_smile: