Basics of browsing the core code

16 views
Skip to first unread message

Yakov

unread,
Aug 9, 2011, 4:53:05 PM8/9/11
to TiddlyWikiDev
Hello.

I have two basic questions which rised when I tried to understand the
core code for the second time.

1. main.js contains functions which are not defined there (for
instance, displayMessage). How JavaScript processor understands where
to find thos functions? Should I think of it as just "ok, there are
some .js scripts and in the end they are put together in one big
script and there all the definitions are present" or there's some more
structure in this? I guess this is something to do with the
"recipes"..

2. There's Eric's insideTW which allows to track dependencies and to
see what is included in the each .js piece; but what it has to do with
those recipes? Also, the code in [1] and [2] slightly differs (for
instance, main in [1] begins as

function main()

and in the [2] as

main =function main()

) -- is it some sort of automatic reprocessing and everything is
syncronized nonetheless?


Also, can anyone suggest a good intro for reading scripts with jQuery
usage (rather than writing; I mean those

$(function() {
// jquery goes here
});

and other "strange" constructions)?

[1] http://svn.tiddlywiki.org/Trunk/core/js/main.js
[2] http://www.tiddlytools.com/insideTW/#main

Martin Budden

unread,
Aug 10, 2011, 7:08:17 AM8/10/11
to tiddly...@googlegroups.com
To answer some of your questions:

1) Should I think of it as just "ok, there are some .js scripts and in


the end they are put together in one big script and there all the

definitions are present"?

Yes, that how it works. The cook tool puts together a list of .js
files according to a recipe. The .js files were originally created by
splitting TiddlyWiki. Code was grouped together logically, but there
were too many interdependencies in the original TiddlyWiki to have
self contained .js files.

I can't make a good suggestion for a jQuery intro. I can answer about
the odd looking constructions, such as:


$(function() {
// jquery goes here
});

These are because javascript is a function scoped, rather than a block
scoped language, so to constrain the scope of variables you need to
wrap them in a dummy function. In a block scoped language, you would
just wrap the variables in a block (ie {...} or BEGIN...END).

Martin

> --
> You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
> To post to this group, send email to tiddly...@googlegroups.com.
> To unsubscribe from this group, send email to tiddlywikide...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/tiddlywikidev?hl=en.
>
>

Yakov

unread,
Aug 10, 2011, 9:57:29 AM8/10/11
to TiddlyWikiDev
Thanks, Martin

> Yes, that how it works. The cook tool puts together a list of .js
> files according to a recipe.

The only thing I don't understand is what this "recipe" looks like. I
mean, how this "putting together" is different from concatenating all
the .js files? Does it change the functions' definitions so that
nothing is undefined up to the time of usage?

> I can't make a good suggestion for a jQuery intro. I can answer about
> the odd looking constructions, such as:
>
> $(function() {
> // jquery goes here
>
> });
>
> These are because javascript is a function scoped, rather than a block
> scoped language, so to constrain the scope of variables you need to
> wrap them in a dummy function. In a block scoped language, you would
> just wrap the variables in a block (ie {...} or BEGIN...END).

Aha. So, for instance in [1] the onLoad function is defined so that it
can't be used outside the abego.loadFile, right? But what does the $()
mean here? Does this mean that the code in $() "sees" jQuery
functions?

[1] http://tiddlywiki.abego-software.de/archive/IncludePlugin/Plugin-Include-src.1.0.1.js

Yakov

unread,
Aug 13, 2011, 1:26:55 PM8/13/11
to TiddlyWikiDev
Also, what does a construction in [1] means:

(function ($) {
...
}) (jQuery);

?

[1] http://helloworld.tiddlyspace.com/#HelloWorldButtonPlugin

FND

unread,
Aug 14, 2011, 5:57:39 AM8/14/11
to tiddly...@googlegroups.com
> Also, what does a construction in [1] means:
> (function ($) {
> ...
> }) (jQuery);

http://oldwiki.tiddlywiki.org/wiki/Dev:Best_Practices#Creating_Aliases


-- F.

Yakov

unread,
Aug 19, 2011, 10:09:41 AM8/19/11
to TiddlyWikiDev
Right, thanks.

Ok, two more questions about browsing the core code:

1) where can I see the code of the older versions of TW?

2) there are at least [1] and [2] as repositories of the core code.
What's the difference between them? Should the [1] be considered as a
deprecated one?

[1] https://github.com/TiddlyWiki/tiddlywiki
[2] http://svn.tiddlywiki.org/Trunk/core/

colmjude

unread,
Aug 19, 2011, 10:27:01 AM8/19/11
to TiddlyWikiDev


On Aug 19, 3:09 pm, Yakov <yakov.litvin.publi...@gmail.com> wrote:
> Right, thanks.
>
> Ok, two more questions about browsing the core code:
>
> 1) where can I see the code of the older versions of TW?

Github is the best place to see the source code, both old and new
versions.
In Github if you view any file there is a history button which lets
you see all the commits/changes people have made to that file over
time. Very useful.

>
> 2) there are at least [1] and [2] as repositories of the core code.
> What's the difference between them? Should the [1] be considered as a
> deprecated one?
>
> [1]https://github.com/TiddlyWiki/tiddlywiki

Github is the one to use now. TW used to use SVN but has been migrated
over to Github along with all the commit history.

> [2]http://svn.tiddlywiki.org/Trunk/core/

The SVN repo is older than the Github one. I think that one of the
reasons why it is still around is that there are a lot of old tickets
open on trac which still need to be
a) close,
b) solved,
c) moved to GitHub

Hope that helps,

Colm

Yakov

unread,
Aug 23, 2011, 3:52:41 PM8/23/11
to TiddlyWikiDev
> > 1) where can I see the code of the older versions of TW?
>
> Github is the best place to see the source code, both old and new
> versions.
> In Github if you view any file there is a history button which lets
> you see all the commits/changes people have made to that file over
> time. Very useful.

Yes, that's better, thanks. However, this system seems to be not
effective if one want to see code of, say, TiddlyWiki v2.1.3. I don't
mean to complain, but perhaps someone knows any tricks for this case..

> Github is the one to use now. TW used to use SVN but has been migrated
> over to Github along with all the commit history.

Ok, I see.

Yakov

unread,
Oct 22, 2011, 8:35:54 AM10/22/11
to TiddlyWikiDev
One more question. Is there any way to *search* through the code in
github? For me, the necessity of search grows (yet it's not very
high), but I can't see it in github; at the same time Eric's insideTW
gets more and more outdated (some things are even specified to belong
to the wrong .js "file"; sorry, I don't remember the examples I faced
lately). And usually a search for a definition of functions/objects is
even more in demand.

So, basically, the question(s) is (are):
* does github have a search engine that I overlooked? (I'd like to be
sure before I make a request)
* what else can be used for search through the core code?

chris...@gmail.com

unread,
Oct 22, 2011, 8:45:44 AM10/22/11
to TiddlyWikiDev
On Sat, 22 Oct 2011, Yakov wrote:

> * what else can be used for search through the core code?

git clone the code to your local system and use grep?

--
Chris Dent http://burningchrome.com/
[...]

colmjude

unread,
Oct 22, 2011, 8:49:10 AM10/22/11
to TiddlyWikiDev
I feel your pain when it comes to searching the core code. It isn't
the easiest task.

I'm not aware of a way to search through the core code on github,
someone else might know if there is a feature but it certainly isn't
well exposed if there is one.

The best way of searching through the code, imo, is to check out all
the code and perform searches using your code editor. I use TextMate
which has a "Find in Project" feature that I use to find things.

Hope that helps,

Colm
Reply all
Reply to author
Forward
0 new messages