Bye-Bye Facebook

There’s a saying: “If there’s a Nazi at the table and 10 other people sitting there talking to him, you got a table with 11 Nazis.”

It’s been reported that Mark Zuckerberg recently had dinner with Donald Trump at Mar-a-Lago. For me, this was the last straw. For a while now, I had been wanting to leave Facebook. But that’s it for me. I’m quitting Facebook.

I’ve made my last posting on Facebook, telling my Facebook friends how to find me on Mastodon and Bluesky. But in a few weeks, I’ll cut the cord completely.

It’s now been about 16 years since I signed up with Facebook. Facebook suggested a number of people I should connect with, and I was impressed with how accurate the suggestions were. But then I realized how they did it, and I was less than impressed. Even before I had signed up, they had developed a profile of me and my on-line contacts.

But for a while at least, Facebook seemed like a cool place to be, with a lot of my friends, relatives, and acquaintances. At one point, I had more than 200 Facebook friends. And I found a couple of useful groups, in the realms of music and genealogy. I even was able to reconnect with some old classmates from high school.

At first, Facebook had options to let me prioritize what I wanted to view. But after a while, these options disappeared. It was now Facebook that made the decisions about what I should see. I wasn’t happy about that, but I grudgingly stayed. However, I was still never happy with the fact that we, the users, are not the primary concern of Facebook. Their customers are the advertisers, and we are their product.

When Google Plus came along, I readily joined it. It seemed like a good mix of Facebook and Twitter features. I saw a lot of potential with G+, but Google lost interest, and it faded away. I did try out Twitter, but I didn’t see much point in it, and generally ignored it. When Elon Musk bought it, I deleted my Twitter account immediately.

Which now brings us up to the present time. I signed up with Mastodon, and I’ve been pretty satisfied with it. And now we have Bluesky, and everyone seems to be jumping on board, primarily after leaving X (AKA Twitter). The two seem very similar is design and concept. Mastodon has the advantage of being totally distributed, which means it can never be under the control of a faceless corporation or selfish billionaire. On the other hand, Bluesky has the momentum. It’s now the attractive place for the disaffected masses.

For the next little while, it will be difficult finding alternatives to Facebook. There are still a couple of groups that I will miss. But it is important to take a stand and send a message. Zuckerberg has made his choice, and has sided with the Trumpists. We must now make a choice too, to side with Zuckerberg and his ilk, or stand with what’s right.

During the Nazi era, my grand-father spent time in prison for his political beliefs. We must not forget the lessons of history as we face a couple of difficult years.


My Core Repertoire

I started playing bass about five years ago now. At the time, I had been playing ukulele for about eleven years, and had amassed a collection of several hundred songs. Now it was time to relearn those songs for the bass.

As in the photo above, my first bass was a Gold Tone microbass, which is basically a large bass ukulele. It’s easy to play and has an amazing sound. After just six days of practice, I was playing this thing at my usual weekly jam, and did okay. I learned quickly how important the bass is in any jam environment. As bass player, although you must follow the lead singer, everyone else in the group depends on you. You really don’t have to be too fancy. In many respects, the bass player is the metronome for the group.

The first song I tried was one of my favorite jam songs, “Coming Into Los Angeles” by Arlo Guthrie. Although I did eventually master this song, I quickly realized that I needed to start with some easier songs first. One big problem was learning how to sing while playing bass. At first, I just couldn’t find the right vocal line.

I then went with a fun song, “I’m The Urban Spaceman” by Neil Innes and the Bonzo Dog Doo-Dah Band. I did this in the key of G major using just the A and D strings. I used easy 1-5 and 1-3 patterns with walks up or down at the chord changes. I still often do this song in my regular jams since it offers other musicians solo opportunities during the instrumental breaks.

I continued my initial learning explorations with some more three or four chord songs. I always liked “Down By The Henry Moore” by Murray McLauchlan since it’s one of the few songs about Toronto, a city I lived in for 29 years. “Dead Skunk” by Loudon Wainwright III is a fun and easy three chord song.

“Walkin’ Down The Line” and “You Ain’t Goin’ Nowhere” are a couple of easy songs written by Bob Dylan in the 1960’s. In his early days, Dylan had a talent of writing songs that seemed timeless. In particular, “Walkin’ Down The Line” could have been written by Woody Guthrie decades earlier.

I’ll continue exploring my core repertoire in subsequent posts, but I’ll end this initial list with a really fun three chord song, “Stop Stop Stop” by the Hollies. This one is always a favorite with my Wednesday morning ukulele jam in Gananoque, partly because the verse uses just one chord. The trick is that a 7th chord is used in the verse instead of the usual major chord, giving the song an exotic flavor.

Napanee Train Show 2023

It’s been a while since the last time I attended a train show, perhaps 10 years ago. But a few weeks ago, we were in Napanee and saw a sign advertising an upcoming train show. So we added it to our calendar. I haven’t done anything in the realm of model railroading since moving to Kingston 13 years ago. However, now and then I toy with the idea of building a small N-Scale layout.

The Napanee show was held at the Lennox Agricultural Memorial Community Centre, with a typical train show arrangement with vendors positioned around the arena and club layouts in the middle. There was the usual assortment of scales and gauges, N, H0, O, O scale on H0 track, etc.

In this post, I’ve included some photos from the show. There were some quite fine examples of railroad modeling. The next local show is Saturday, October 21, in Kingston, at the Royal Canadian Legion on Montreal Street.

The Congregation of the Lord

Which takes precedence: God’s law, or man’s law? If you ask a conservative Christian that question, most will answer that God’s law takes precedence over any civil law. But what does that mean? The Bible contains a large number of rules, laws, and commandments. In this blog post, I look at a couple of laws laid down in the book of Deuteronomy, which have relevance to the field of genealogy.

The first is Deuteronomy 23:2: “A bastard shall not enter into the congregation of the Lord; even to his tenth generation shall he not enter into the congregation of the Lord.” (KJV)

A rather strict rule, that, applying even to the descendants of the illegitimate child. Even if your parents were legitimately married when you were born, you would not be allowed to enter into the congregation of the Lord if any of your ancestors going back ten generations was born out of wedlock.

As an amateur genealogist, I can attest that it would be quite the challenge to prove that all of your ancestors going back that far were born legitimately.

In my own data, there are roughly three generations per century. Ten generations brings you back to the late 1700’s. On the Dutch side of my pedigree, I know the names of all of my 4th great grandparents, as well as all but two of my 5th great grandparents. To complete my pedigree going back ten generations, I would need to get information on everyone back to my 8th great grandparents. That can be as many as 2046 ancestors!

Clearly, few people can accurately provide proof that they are allowed to enter into the congregation of the Lord based on Deuteronomy 23:2. If you believe in an omnipresent supreme being, then that being would know for certain, but you can never be sure.

You could take the approach that one is innocent before proven guilty. In that case if you can identify one bastard ancestor, the rule would apply to you and you would not be allowed to enter the congregation of the Lord. Since I do have a couple of illegitimate ancestors, the rule applies to me, as well as seven generations of my descendants.

In my case, the illegitimate ancestors are on the German side of my pedigree. Since it was not always easy for a couple to get permission to marry in the Grand-duchy of Mecklenburg-Schwerin, even up to the end of the 19th Century, it was not uncommon for a couple to have a child (or two) before getting married. On the other hand, since the Netherlands was generally more affluent, illegitimate births were much less common there. So as far as I can tell, of my Dutch ancestors I know about, all were born after their parents were married.

But now let’s take a look at another rule, one chapter earlier, Deuteronomy 22:20-21: “But if this thing be true, and the tokens of virginity be not found for the damsel: Then they shall bring out the damsel to the door of her father’s house, and the men of her city shall stone her with stones that she die: …

In a nutshell, according to Deuteronomy 22, for a marriage to be considered valid, the bride must be a virgin on her wedding night. And if a marriage is not valid, all children from the marriage must be considered bastard children. And then Deuteronomy 23:2 applies.

This means that for someone to be allowed to enter into the congregation of the Lord, one must not only prove that all ancestors going back roughly three centuries were born legitimately, but that as many as 1023 female ancestors were virgins when they married. Based on surviving records, of course this would be an impossible challenge. But as before, all it takes is one case to prove that one is not allowed to enter into the congregation of the Lord.

On the Dutch side of my pedigree, you don’t have to go very far. It’s not a secret in my family that my Dutch grandparents had to get married. Their first child was born in 1927 about four months after their marriage. Unless some sort of miracle occurred, my Dutch grandmother was obviously not a virgin when she married. (Coincidentally, that’s also true for my German grandparents, in 1926.) And as a consequence, all of my aunts and uncles, all 28 of my first cousins, and all of their many descendants are not allowed to enter into the congregation of the Lord.

If you believe that God’s law takes precedence over any civil law, then you have a problem. Specifically, I know of two ministers of one particular conservative Christian denomination who are technically not allowed to enter the into congregation of the Lord by these particular rules.

One might argue that one cannot be punished because of the sins of their ancestors. But then you would put into doubt one of the most fundamental principles of conservative Christianity, the doctrine of original sin.

I don’t envy the conservatives. Almost certainly they can find a way interpret the Biblical laws in their own favor. But it would take some interesting theological gymnastics. One would have to argue that these verses do not really mean what they say. Or perhaps they can find some other verses that contradict these particular verses, in which case they would have to admit that the Bible is flawed and subject to interpretation.

You really have to wonder, by these rules laid down in the Holy Bible, is there anyone who is able to enter into the congregation of the Lord?

Minna Boldt and Frederick D’Aperng

Up until recently, I didn’t know much about my grand-aunt Minna Anna-Marie Sophie Boldt (1902-1993) and her husband Frederick d’Aperng (1880-1954). During the early 1950’s, my grandfather had a falling-out with his sister and had very little contact since then. I was told that Minna emigrated to Canada in the 1920’s, and that her husband Frederick was married before and had five children. And I knew that the two were buried in the Cataraqui Cemetery in Kingston:

A week ago, though, I came across an interesting fact. Prior to her marriage with Frederick, Minna Boldt was married in 1927, surprisingly in Amsterdam! The marriage lasted less than six years, though.

1927 Jacobus Johannes Penning & Minna Anna Marie Sophie Boldt marriage

I posted this on the Dutch Genealogy group on Facebook. Some of the members of the group were very helpful, and some provided links to population registers showing where Minna lived in Amsterdam. One of these had another surprise:

Prinsengracht 850, Amsterdam

In the middle of the back side of the card, look who’s name appears, twice: Frederick d’Aperng! Further research showed that Frederick resided in Amsterdam, at various addresses, between 1929 and 1938. And wherever he resided, it was either at the same address as Minna, or very close to her.

I then resumed my Ancestry membership to see what more I could find. So Frederick d’Aperng was born March 3, 1880, in the city of Thorn in the German Empire. (Thorn is now the city of Toruń in Poland.) He emigrated to Canada in 1902, and lived in a number of different places, such as Kingston, Montréal, Picton, and Odessa. With his first wife Frieda, he had a number of children born between 1912 and 1921: Erica, Adele, Eric, Frederick, and Hans. (Some of the children have interesting stories too, but I may save them for another time.)

From about 1920 to 1938, Frederick traveled frequently between Canada and Europe, because of his occupation as agent, merchant, or chemist, presumably engaging in import and export of pharmaceutical products. While he resided in Amsterdam, he also had a residence in Picton, Ontario. In 1940, his occupation was medical supply jobber in Montréal.

The big question is this: What was Frederick’s relationship with Minna during their time in Amsterdam? Clearly, the two knew each other. But although she was married, it’s not clear if Minna ever lived with her first husband.

One more thing about Minna. It turns out that she did emigrate to Canada in 1924. At the time, though, she didn’t stay long and by 1926 ended up in Amsterdam. In her entry to Canada, she claimed to be a nurse. I find that dubious, since in Amsterdam she worked as a boarding-house housekeeper.

In 1938, both Minna and Frederick left Amsterdam, separately, I assume to Canada, first Frederick in May and then Minna two months later. Frederick’s first wife Frieda died in 1939, and I assume Frederick and Minna married shortly afterwards.

There are still a lot of missing pieces to this puzzle, and many of them are probably lost forever now. But what is known so far offers up an intriguing story.

Hans

The Putten Raid

Jan Kamphorst

Recently I was adding distant cousins to my genealogy database when I came across the death information for one of them. Third cousin, twice removed, Jan Kamphorst died 1944 in Ladelund-Neuengamme, Germany. No doubt he was captured as a prisoner. My suspicions were confirmed when I discovered that Ladelund was a concentration camp. Further research revealed the gruesome details of the “Putten Raid“.

Aalt van Koot

On the night of September 30, 1944, a group of Dutch resistance fighters ambushed a German army car carrying two officers and two corporals on the road between Putten and Nijkerk. The subsequent reprisals against Dutch citizens were considered some of the worst of the German occupation of the Netherlands. 661 adult men of Putten were rounded up. 602 of them were taken to the Neuengamme concentration camp near Hamburg. Only 48 of them returned home after the war, many in emaciated condition.

Hendrik Haverkamp

One of the most important web sites documenting the events of October 1944 is Stichting Oktober 44. At that site, you can find a list of the victims of the Putten Raid reprisals, as well as documents relating to their captivity and death, some from the Arolsen Archives. Going through that list, I found a number of distant cousins who died in concentration camps:

  • Dirk Buitenhuis, born June 2, 1920, Nijkerk, died November 16, 1944 in Ladelund. (3rd cousin, twice removed)
  • Gerrit Buitenhuis, born March 31, 1923, Nijkerk, died December 14, 1944 in Versen. (3rd cousin, twice removed)
  • Willem Buitenhuis, born June 1, 1908, Nijkerk, died January 18, 1945 in Neuengamme. (3rd cousin, twice removed)
  • Hendrik Haverkamp, born August 13, 1905, Nijkerk, died November 29 in Ladelund. (4th cousin, once removed)
  • Jan Kamphorst, born April 2, 1910, Nijkerk, died November 25, 1944 in Ladeund. (3rd cousin, twice removed)
  • Reijer Klarenbook, born January 21, Putten, died March 1, 1945 in Neuengamme. (5th cousin, once removed)
  • Aalt van Koot, born September 20, 1925, Nijkerk, died December 9, 1944 in Neuengamme. (5th cousin)
  • Gijsbert Kuiper, born December 29, 1913, Putten, died December 30, 1944 in Neuengamme. (5th cousin, once removed)
  • Jacobus van Losenoord, born November 11, 1901, Putten, died December 25, in Bevern. (5th cousin once removed)
  • Hendrikus Schipper, born January 16, 1923, Putten, died November 11, 1944 in Ladelund. (4th cousin, once removed)
  • Albertus Stoffelsen, born December 25, 1914, Nijkerk, died December 7, 1944 in Ladelund. (4th cousin, once removed)
  • Evert Stoffelsen, born April 13, 1912, Nijkerk, died November 28, 1944 in Ladelund. (4th cousin, once removed)
  • Ruth Stoffelsen, born November 2, 1919, Nijkerk, died November 24, 1944, in Ladelund. (4th cousin, once removed)
  • Johan Gerard Zech, born August 24, 1908, Utrecht, died May 31, 1945 at Ravensbrück. (5th cousin, once removed.)
Dirk Buitenhuis

The first three in this list were brothers, as well as the last three. Also, Jan Kamphorst and Aalt van Koot were half 3rd cousins, twice removed. In addition, there are other victims who are not directly related to me, but can be connected to people in my database.

Gerrit Buitenhuis

Genealogy is not an easy pursuit. Recording information can be boring, and sometimes you can get blase about things like infant deaths. But connecting your blood relatives to an atrocity like this can be quite jarring. I’ve heard stories of the war from both my parents, but nothing they’ve told me was quite as shocking as this. Surely, my mother’s family must have known about this. Even more personal is the fact that one of the victims listed above shares my birthday.

Willem Buitenhuis

When I first posted this back in February, I knew of six distant cousins taken up in the raid. Today, a month later, I found another three. As I continue my research, I may well find a few more. I will update this post when more cousins are found in this group.

WordPress – Some Lessons Learned

As you’ve read before in this blog, I’m working on some plugins to display genealogy data on a WordPress site. I have a plugin for Gramps (written in Python) that creates data files, and a plugin for WordPress (written in PHP) to present that data. This currently requires the webmaster to manually copy the resulting files to the server. The next step in the development process is to make the Gramps plugin communicate directly with the WordPress plugin to update the data.

This is one of the most ambitious projects I’ve embarked on as a hobby programmer. I spent the past few days getting up to speed on programming the WordPress REST API. The last hurdle to get past was interesting. The REST API requires creating a nonce, and passing it on all API calls to the server. Since my code needs to update data on the server, these API calls must be in the context of a logged-in session. The first step in the process must, however, be allowed for a not logged-in user since it logs the user into the server.

The problem is that the value of the nonce is determined based on the session cookie, and that cookie is different for a logged-in session and a not logged-in session. I struggled for a while to try to figure out how I could create a nonce for the logged-in session while performing a function in a not logged-in session.

After a few days of trying different things, searching on-line, and at times spinning my wheels, I finally found that one source on-line that explained the solution. Here’s my working signon function code with the necessary code in bold:

function my_update_cookie($logged_in_cookie) {
    $_COOKIE[LOGGED_IN_COOKIE] = $logged_in_cookie;
}

function tangled_web_start(WP_REST_Request $request) {
    add_action('set_logged_in_cookie', 
               [$this, 'my_update_cookie']);

    $creds = ['user_login' => 
                   $request->get_param('id'),
              'user_password' => 
                   $request->get_param('pw'),
              'remember' => true];

    $user = wp_signon($creds, false);
    if (is_wp_error($user)) {
        return $user;
    }

    wp_set_current_user($user->ID);
    wp_set_auth_cookie($user->ID);
    return wp_create_nonce('wp_rest');
} 

The key is to add the 'set_logged_in_cookie' action. Once the signon takes place, that action is called and the LOGGED_IN_COOKIE is updated. Once that is done, the correct nonce is then created.

On the python side, the session issues are managed by an instance of the requests.Session() class. Here’s how the call to the above API is done:

# Logon to WordPress site
session = requests.Session()
parms = {'id': logon_creds['userid'],
         'pw': logon_creds['password']}
res = session.post(url=tgturl + 
                   wp-json/tangled_web/start',
                   data=parms);
if res.status_code != 200:
    return 'Login failed'
nonce = res.text
session.headers.update({'X-WP-Nonce': nonce})

Once the nonce is returned, it gets added to the headers for all subsequent API calls.

Now that I’ve got this working, the rest of the development process should be relatively straight-forward. I’ll have to program API’s for the following tasks:

  • Get a list of checksums for the JSON data files on the servers for a given Tangled Web instance
  • Upload a JSON file or image file to the server
  • Update the names index on the server
  • Update the global settings for the instance

Once this is done, my usual Gramps workflow will have one more step. At the end of a session adding and updating people in my Gramps database, I’ll be able to invoke the “Export to Tangled Web” function in Gramps to update the server immediately, instead of having to manually copy and unpack the files on the server and reload the data.

The Tangled Web Project

Genealogy research doesn’t (or shouldn’t) happen in a vacuum. We all want to share the results of our research with others. These days, that usually is done on the internet. I’ve regularly posted the results on my own web site. Ever since using Gramps, I’ve posted my data using the Gramps Narrated Web Site, but I was never been fully satisfied with it. The information wasn’t always the easiest to navigate, some pages were very large, and it wasn’t very mobile friendly.

Web technology steadily changes. For the past four years, I’ve been using WordPress. The genealogy data was the only section of my web site still using static html pages. I knew programming a new web publishing system would be a big project, but a few months ago I dove in. And so now, I’m able to publish my data using that new system. You can see my genealogy data at Boldts & Molls.

I call this project “Tangled Web”. The most common metaphor used in genealogy is the tree. However, that’s a flawed metaphor, useful only in narrow scopes. Relationships are complex, and form a vast web of interrelationships, often quite complicated.

Clicking on Boldts & Molls, you first see an introductory page. That “home” page includes a list of people born on today’s date in history. It also shows a list of the most common names in the genealogy, in the form of a name cloud, with the bigger names indicating the more common names. There’s also a “search” button, where you can search on last name, given name, location, or a range of years.

For individuals, the new system uses a tabbed layout. The “Family” tab shows parents, grand-parents, siblings, spouses, and children. The “Timeline” shows a history of the person, starting with the marriage of the parents. All events recorded in the Gramps database are listed, and birth, marriage, and death events include witnesses and informants. The “Pedigree” shows the pedigree for the person, with instances of pedigree collapse shown. And the “Sources” tab shows the sources and citations, including scans of the primary source records.

One aspect I wanted to emphasize was relationships between people. And so wherever a person is listed on someone’s page, their relationship is shown.

How was this implemented? First, there’s a Gramps plugin, which creates a set of data files. Like all Gramps plugins, this code is written in Python. Next, there’s a WordPress plugin, written in PHP, which processes that data, and maintains the search index. Finally, there’s a good chunk of code written in JavaScript that formats the data in a browser. The latter uses a technique called Ajax, which is becoming more and more popular. The idea is that the content of the web page is written dynamically, under the control of the JavaScript program. The browser doesn’t have to refresh the whole page whenever you click on a link, but just has to request the changed data from the server. This is how pages like Google Maps work. Altogether, it’s about 5000 lines of Python, PHP, JavaScript, and CSS code.

What’s next? My first priority is to write up some documentation, and upload the code to my GitHub page. The code will be available to anyone under a GPL license. For the next version of the code, my goal is to make it easier to update a Tangled Web instance on the server. That is, I want the Gramps plugin to have the capability to communicate directly with the WordPress plugin to update the data changed since the last update.

Finally, I invite other people to contribute to this project. WordPress isn’t the only content management system out there. Although it’s the most commonly used CMS, there are others like Drupal or Joomla!. If you’d like to have a Tangled Web instance running on your self-hosted web site running on a different CMS, feel free to rewrite the PHP code to suit your CMS.

Cheers! Hans

Some Reasons Why I Use Open Source Software

I’ve been using Linux now for some 23 years. My first reaction after loading RedHat 5.1 was “What the heck am I getting myself into?”. But the open source world gradually matured, and now there are very few reasons not to use free or open-source software (FOSS).

I won’t go into all of my reasons for using FOSS. I worked for several decades as a software developer. So I know full well what goes into developing, selling, maintaining, and supporting software. For companies that sell software, the unfortunate reality is that their number one priority is profit. Once a software product is developed, in the worst case, they will fix defects and enhance the product only if there is a business case for it. And of course, to maximize profit, they will hire the lowest cost developers they can.

I think most of us know of software defects that have gone unfixed for years. I myself have been burned buying shoddy software. That’s one reason I really appreciate the good quality, open-source software that I rely on daily.

To illustrate, let’s look at some of the programs in the “Favorites” category of the application menu on my Linux system:

First, there’s Google Chrome. This is clearly one of the biggest success stories in the FOSS world. And it’s very likely that you too already use Chrome. At one time, Microsoft Internet Explorer had a massive dominant position among web browsers. But now, even Microsoft has abandoned IE, and now uses the open-source Chromium engine to power its Edge browser.

Next, there’s LibreOffice Writer. While Microsoft has ceded the battle for browser supremacy, they still vigorously defend their office suite cash cow. However, here’s a case where the FOSS alternative to Microsoft Word is clearly superior. LibreOffice Writer isn’t just as good as Word, it has more functionality than Word. Writer is considered as desktop publishing application, while Word is not.

Then there’s the GIMP, the Gnu Image Manipulation Program. This is a program I use almost daily. It provides almost the same functionality as PhotoShop, but at a price hundreds of dollars cheaper. While a professional photographer or graphic designer can write off the cost of an application like PhotoShop, an amateur like me cannot. I simply can’t justify the high price of PhotoShop given the availability of a powerful program like GIMP that more than satisfies my image processing needs.

MuseScore is an amazing application that every musician or songwriter should know about. This isn’t just a music score editor. While you’re composing your musical creation, you can hear what the piece sounds like. You can have as many instruments as you want, you can change instruments, transpose keys, and once you’re done, you can record the composition. The user interface isn’t the easiest, but I think that probably goes with the territory. Music composition isn’t easy to begin with, and there is definitely a learning curve to get past.

In the realm of genealogy, it’s (unfortunately) especially important to consider the reputation and integrity of any vendor. That’s why open-source is very important in this realm. Gramps is a full-function genealogy application that supports pretty much the whole GEDCOM data model. In addition, it includes a framework for supporting user-written extensions. You can find some of my own Gramps extensions at my GitHub page.

The latter application illustrates an important point about FOSS. It’s not just one company supporting a piece of software. In the open-source realm, it’s a whole community. Frankly, as a programmer, I have no inclination whatsoever to improve the quality of a program if it just adds to the profits of some company. On the other hand, the open-source community is full of people willing to contribute to the benefit of other users. Everyone is free to use the software without obligation, but also, everyone is invited to contribute in any way that they are able to.

I could go on describing other FOSS applications I use either regularly or occasionally. Such as Audacity for audio editing, Kdenlive for video editing, or Komodo edit for developing software. But I think this list should provide enough justification for considering open-source software instead of buying commercial software.

JavaScript – Some Lessons Learned

If you’re not a programmer, move along, there’s nothing to see here. Only programmers will understand what I’m writing about here.

As you might already be aware, I post the results of my genealogy research on this website. So far, I’ve been using the “Narrated Web Site” feature of Gramps. But since I’ve never been totally satisfied with it, I’ve always toyed with the idea of coming up with a better way to present my data. So finally, about a month ago, I started work on a new project, a different way to present my genealogy data.

This is turning out to be a rather ambitious project, with elements coded in Python, PHP, and JavaScript, as well as CSS and HTML. Sometimes it’s hard keeping all the different languages straight. Since I’m using dynamically-generated HTML, most of the challenges are in the JavaScript code, an area that I’m certainly not expert in. In this missive, I discuss some of the lessons I’ve learned while coding, some after much flailing about. I won’t dive too deeply into specific details. You can learn more with the right Google search.

When to register click handlers

First, since I make heavy use of dynamic HTML, I make good use of click handlers. But while coding, I noticed that in some situations, the click handlers weren’t working as expected. It took a bit of digging, and I found a solution I wasn’t totally happy with. Digging further, I then realized something important about registering click handlers when using dynamic HTML: You need to register the click handler after adding the HTML to the DOM. In the cases where they weren’t firing as expected, the handlers were registered first.

Handling history

When using static HTML page, you don’t have to worry about history. The browser does it all automatically. However, with dynamic HTML, you need to manually keep track of the history if you want meaningful navigation through your content. This is achieved by coding an “onpopstate” event handler, as well as calls to functions “pushState()” and “replaceState()”.

After some flailing about, I stepped back and studied the issue in a bit more detail. And I realized it really wasn’t so bad. I just needed to keep track of three specific situations when displaying page content.

First, when moving to a new page, you need to call “pushState” while outputting the new content. That registers the new page in the history stack.

Second, when navigating to a page previously displayed using an “onpopstate” handler (invoked when the user presses the “back” or “forward” button), you just have to output the page content. No further action is needed.

Finally, there’s “replaceState()”. That’s used in situations where you want to update the content currently on the screen, but you don’t want to advance further in the history. For example, you may just want to switch to a different tab in your content. Or perhaps you want to present a table of search results ordered by name instead of date. These are cases where, when pressing the “back” button, you don’t want to go back through these different views. In this type of situations, you call “replaceState()”.

Querying attributes of HTML elements

The final lesson regards querying certain attributes of HTML elements. I’m now getting into an interesting piece of JavaScript programming where I need to know the real sizes of some HTML elements. There are some functions in jQuery to get the size of an element: “outerHeight()” and “outerWidth()”. I tried calling them, and was surprised to get zeroes as the result.

Again, a bit of digging on-line, and I found the answer. Immediately after adding dynamic elements to the DOM, the attributes might not be set yet. Processing the elements must wait until they are ready. So you’ll need to code something like:

jQuery('#mysection').ready( function() {
process_section();
});

I tried this, and I did get non-zero values for the height and width. However, the values returned did not take into account the size of an embedded image. Taking this approach further requires waiting until all embedded images are loaded. Grrr!

I ended up deciding that this avenue was just too strewn with potential problems. I stepped back and decided to take a different approach to what I wanted to do, an approach with a lot fewer complications.

In addition, further research turn up another issue: This usage of the “ready()” function is deprecated by jQuery.

Conclusion

There’s a lot to JavaScript coding. It’s an incredibly complicated and potentially intimidating environment. I’m constantly looking things up on-line: in manuals, on-line courses, or other blogs. However, on-line information, while usually correct, is sometimes missing some important detail that a novice JavaScript programmer might not be aware of that’s needed to make full sense of the information.

Cheers! Hans