Skip to main content
Topic: Separate "Sources" and "Themes" in js too? (Read 12317 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Separate "Sources" and "Themes" in js too?

Reply #15

Quote from: The Craw – I could see that happening if things got super polymorphic or something with a zillion different interlocked objects, but if anything I'd say splitting this up makes it easier. Especially if the files and methods are named well, being descriptive of their purpose. Plus then your theme authors know exactly where to go to find some display code, rather than digging around in a few really huge files.
That sounds good in theory, but we tried something similar during 2.0.x development. The early betas and RC's had the CSS split into a bunch of files. It was found that in practice this was a right PITA, and it was a lot easier on people if the whole lot was just rolled into index.css.

Sure it was a bigger file, but as long as you has a search term you could find what you wanted very easily, with no need to scroll through the whole thing, and you didn't have to remember whch frigging file the bit you wanted was hiding in.

The idea that "Oh hey if we have smaller files things will be easier to find" is not necessarily true. It might be true, if you can memorise the content of every file. :P
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Separate "Sources" and "Themes" in js too?

Reply #16

Btw, search in files instead of search in one file, when you have a problem. Every editor allows that, and every file manager.

Quote from: Antechinus – The idea that "Oh hey if we have smaller files things will be easier to find" is not necessarily true. It might be true, if you can memorise the content of every file. :P

Nope. If the separation is meaningful, and correctly represented by names/structure.
The best moment for testing your PR is right after you merge it. Can't miss with that one.

Re: Separate "Sources" and "Themes" in js too?

Reply #17

QuoteNope. If the separation is meaningful, and correctly represented by names/structure.

Antechinus' experience is matched by mine. The reality doesn't conform to what we think it should.

Re: Separate "Sources" and "Themes" in js too?

Reply #18

Quote from: TestMonkey – Btw, search in files instead of search in one file, when you have a problem. Every editor allows that, and every file manager.
Yeah sure. I know how that works. Open every damned file in the directory. Run your search term on every file. Ok, so you get a hit if you're lucky. So now, close all the files you don't want, so you can actually get at the one you do want. Repeat this process every time you need to edit something.

What Ranty said. :)
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Separate "Sources" and "Themes" in js too?

Reply #19

Notepad++ does it rather elegantly, but even so it's still not that clever for this.

Re: Separate "Sources" and "Themes" in js too?

Reply #20

Notepad++ is what I was referring to. It's what I usually use.

ETA: "Nope. If the separation is meaningful, and correctly represented by names/structure." Umm, meaningful to everyone, or meaningful to whoever happened to write it? :D
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Separate "Sources" and "Themes" in js too?

Reply #21

Quote from: Antechinus –
Quote from: TestMonkey – Btw, search in files instead of search in one file, when you have a problem. Every editor allows that, and every file manager.
Yeah sure. I know how that works. Open every damned file in the directory. Run your search term on every file. Ok, so you get a hit if you're lucky. So now, close all the files you don't want, so you can actually get at the one you do want. Repeat this process every time you need to edit something.
Find in files. All files in directory/directories.

Re: separation in files criteria:
Layout vs actions, is a conceptual separation which makes sense for many reasons.

It is also fine if people don't want to do it, and I can see where the risks of becoming confusing are. But if you do want to do it, go ahead and do it. I think discussion of a real proposal is preferable. Ant, feel free to keep an eye on PRs and see if they make sense to you.
The best moment for testing your PR is right after you merge it. Can't miss with that one.

Re: Separate "Sources" and "Themes" in js too?

Reply #22

I agree that proper and meaningful separation is difficult to achieve.

What I think, though, is that have all the template elements as close as possible is better than have them spread all over the places.
I think started this topic because I realised there are (or there were) theme elements in script.js (I think) left from before the rework of the theme for 2.1 and not changed. Why? It's not important.
So, from that the "idea" to have all (or at least most) of the "presentation" in one single place instead of spread all over the places (because at the moment it is spread over at least 3 to 5 files).
Nothing too complex, nothing too fancy.

css is for sure a quite different beast.
Bugs creator.
Features destroyer.
Template killer.

Re: Separate "Sources" and "Themes" in js too?

Reply #23

Quote from: Antechinus –
Quote from: TestMonkey – Btw, search in files instead of search in one file, when you have a problem. Every editor allows that, and every file manager.
Yeah sure. I know how that works. Open every damned file in the directory. Run your search term on every file. Ok, so you get a hit if you're lucky. So now, close all the files you don't want, so you can actually get at the one you do want. Repeat this process every time you need to edit something.

What Ranty said. :)

Just a quick note.

You're doing it wrong. You can search through a whole directory (and the sub-dirs) without opening a single file in Notepad++.
Success is not the result of spontaneous combustion, you must set yourself on fire!

Re: Separate "Sources" and "Themes" in js too?

Reply #24

Yeah I just found that out after PestFunky said that stuff about files. ;D
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Separate "Sources" and "Themes" in js too?

Reply #25

Bump for great justice.

Back to the original topic, without all the wandering about files, my original intent was:
script.js => does stuff
theme.js => shows stuff
scripts.js calls theme.js to finds out *how show certain stuff.
That's all I am thinking to achieve.

And since we are adding some stuff "js-only", I think it's a good moment to start thinking at least of a general structure...
Bugs creator.
Features destroyer.
Template killer.

Re: Separate "Sources" and "Themes" in js too?

Reply #26

Usual disclaimer: I was just having some fun reading stuff.

I was curious and I searched a bit the web to see how other people handle this kind of things and I found a list of template engines for javascript:
http://upcomingweb.org/2012/06/javascript-template-engine.html

Most of them seem rather complex stuff, between the first three, dustjs seems the easiest:
https://github.com/linkedin/dustjs
it's used by linkedin (and maybe paypal, I'm not sure about that, though), so it should have something positive. lol
Bugs creator.
Features destroyer.
Template killer.

Re: Separate "Sources" and "Themes" in js too?

Reply #27

angularjs is cool too.
Success is not the result of spontaneous combustion, you must set yourself on fire!

Re: Separate "Sources" and "Themes" in js too?

Reply #28

I have used JS template engines before but for Elkarte, I can't imagine there are many times when you'll want to use a template from the backend instead of just adding another div or row to a table. In that case, just get the last one, duplicate it, and then change the content. Less things to keep track of.

Re: Separate "Sources" and "Themes" in js too?

Reply #29

Yeah, I used that approach in some places, but honestly it's a mess.
It works if you have to add just a couple of things, but for mid-complex stuff it's basically impossible. For example I was thinking to use that approach for my infinite-scrolling trick, but clone the post/poster area and replace the stuff is a nightmare...
Bugs creator.
Features destroyer.
Template killer.