Glen Mazza's Weblog

Main | Next page » Sunday July 17, 2016

First release - TightBlog v1.0.0 available!

I've found a good point to make my first TightBlog release, and so here it is. I held off on uploading a Java WAR file as TightBlog is primarily for Java enthusiasts who are well acquainted with the concept of mvn clean install and would presumably rely on that instead of any WAR I provided. After the dependencies (Spring, Struts, etc.) are downloaded, TightBlog takes less than a minute to build, and running mvn jetty:run from the app folder afterwards will allow you to quickly demo the application at http://localhost:8080/tightblog.

Some editing enhancements put in over the past week:

  • I pulled out the Xinha rich text editor, last updated in 2010, with the new Quill Editor which I'm downloading to the application via CDN.
  • I added Markdown (specifically CommonMark) as an editing option, giving bloggers now three options (including standard HTML entry) for their blogging pleasure.
  • JSoup was brought in to replace a 2009 script to filter out HTML tags disallowed by the TightBlog admin. Admins are provided six HTML sanitizing options for blog entries (including one option allowing everything), and three for blog comments.

These benefits are in addition to the "Notes" field on the blog edit page (to store metadata about the blog entry) I had added a while back.

Stats: 19 fewer Java source files, dropping me to 187, 62% fewer than the original 493 in the Roller release I forked. 209 issues closed, with eight open for the next release. 85K lines removed, with the removal of Xinha accounting for 15K of that. The GitHub contributors page and the OpenHub stats are indicating that, all told, I managed to drop the code about a third in size, even if I somehow sense I managed more than that. Tuesday July 05, 2016

New user administration functionality in TightBlog

Over the past few days I've added some user administration options to upcoming TightBlog:

  1. Administrators can now require all new account registrants to be approved before they are able to log in. Upon a new registration, TightBlog administrators will be sent emails to either approve or decline the account request, with a subsequent response email sent to the registrant informing them that they can now log in or that their request has been disapproved.

    This option automatically activates email verification--after registration but before the approval routing the registrant will be sent an email to click on to verify ownership of the email account. This provides administrators higher confidence that the person requesting an account with the stated email address is indeed the email address' owner.

  2. Access rights within TightBlog are of two types: Global roles (one per user) and Weblog-specific roles (one for each blog a user has write access to). The former primarily specify whether a user is a regular blogger or a blog server administrator, the latter define the rights a user has for a given weblog: can make drafts but not publish (Contributor), can publish and handle comments and some design configuration (Publisher), or has full ownership of the blog (Owner)--can change the design templates, invite new members, etc.

    I added an additional Blog Creator global role to the Blogger and Admin roles already existing. Admin remains the same while Blog Creator has the former meaning of Blogger. The lone difference between Blogger and Blog Creator is that the latter can create new blogs while the former would need to have someone first invite them to a blog with whichever weblog role the inviter desires. This new option is helpful for administrators who have Contributors or Publishers whom they don't see a need to grant create blog rights, or for blog owners they wish to limit to one, already created, weblog.

    The system administration page allows administrators to choose Blogger or Blog Creator as the default role for new blog registrants, a setting which can be subsequently overridden by an administrator on the User Administration page.

  3. The User Administration page now shows account create date and last logged-in date to help administrators determine dormant accounts that should perhaps be disabled. Friday June 24, 2016

TightBlog: June 2016 Update

Continued work on the TightBlog front-end. While TightBlog is not a single-page app, AngularJS is nonetheless playing more and more of a role on the front end for its two-way binding. Backend, I've updated to Java 8 time as well as upgraded to Struts 2.5. About 60% of the UI is now REST-based. I'm expecting "soonish" to make an testing release that I can place my own blog on while continuing to do front-end enhancements. In particular, I'd like to get the comment management screen more streamlined.

Stats: Eight fewer Java source files, moving me down to 206, 58% less than Roller 5.1.2. 52 JSPs vs. 92 in Roller, but 10-20 more JavaScript files on my side. The simplifications altogether have resulted in about 66.8K lines of source code removed. I'm increasingly running into brick walls in trying to simplify the application further, a good sign that my refactoring work is coming to a close. Nine issues open, with 197 closed. Tuesday May 24, 2016

TightBlog: May 2016 Update

Heavily working on the front-end, moving TightBlog from a server-side rendering with Struts2 & JSPs to a REST-ful architecture. The Spring Framework is doing wonders in allowing me to easily switch to REST API calls, code is nicely melting away in the process. I've mostly finished updating the server admin screens using JQuery and JSRender/JSViews. I'm trying to find a good point right now where I can do a release, deploy my own blog on it, and then continue on with enhancements & refactoring.

Stats: Due to more code auditing and analysis, the issues have jumped up to 20 open vs 177 closed, but most do not need to be done for a first release. Seventeen more Java source files have been removed (actually 20 removed and 3 new ones), dropping me to 214 total. GitHub is reporting I've removed more than 62,000 lines from the project; the OpenHub chart, which sizes the project differently, has noted the project has fallen from about 139K lines of code to 87K since I forked Apache Roller last May. As perhaps a sign of TightBlog's increased modernization, OpenHub is noting the code is 18.9% JavaScript compared to 11% for Roller. Saturday April 23, 2016

TightBlog: April 2016 Update

A satisfyingly productive month. In particular, the blog page rendering system as well as the default blog templates supplied with TightBlog were cleaned out and nicely simplified. At this time, the application is more or less usable as-is, however, I'll be rechecking the data model as well as making an additional pass through the source files to see if I've missed anything.

Stats: Sixteen more Java source files removed, dropping TightBlog to 231 total. From my commit totals, over 55,000 lines removed from the project through 248 non-merge commits. Seven issues open and 157 closed. Wednesday March 30, 2016

TightBlog: March 2016 Update

Did not get as much done the past month due to work constraints, main gain was in upgrading from Log4j to Log4j2. Right now I'm revamping the template customization functionality, once done I have a modest amount of other UI improvements to put in for the first release. Twelve issues open, 140 closed, 5 more Java source files gone (247 for TightBlog vs. 493 for Roller), and inching towards 50,000 lines (49.2K) removed. Wednesday February 24, 2016

TightBlog: February 2016 Update

Still actively working on TightBlog, but due to time constraints could not work much on the project the first couple of weeks of this period. Mainly internal refactoring, including work on simplifying and consolidating the Pager classes that are used to scroll through lists of blog entries, users, comments, weblogs, etc. I also simplified the former to mostly just the common fields that people normally customize (file is now about two-thirds smaller, compare TightBlog's to Roller's). For the many potentially useful but seldom overridden configuration settings, those can now be modified via a Spring XML configuration file placed in the same folder as the user's file. For the rarely overridden settings, using Spring configuration over a property file nicely simplifies the internal code while not placing much of an additional burden on the relative few who will need to override those settings.

Metrics: 14 issues still open, 138 closed, 199 non-merge (i.e, "real") commits with roughly 47,000 more lines removed than added (as shown on the GitHub Contributors tab), and eight more Java source files removed, dropping TightBlog to 252 total. Sunday January 24, 2016

TightBlog: January 2016 Update

Still plugging along, with particular gains in the Spring configuration, page caching, and blog model used by the Velocity rendering. One functional improvement was to pull out the Google Analytics tracker code on blog author previews so they won't show up on GA stats pages. The GitHub Issues List notes 16 issues open and 133 closed. Of the Java source files, 16 more have been removed, dropping TightBlog to 260 classes compared to the 493 in Apache Roller I forked it from. The contributors page notes almost 46,000 lines have been removed from the codebase through 188 commits. Thursday December 24, 2015

TightBlog: December 2015 update

Since my update last month, I've been able to pull out an additional 21 Java source files, dropping TightBlog to 276 total compared to Roller's 493, a nice 44% drop. Other files, such as XMLs and JSPs have also been removed if not to the same degree, as many of those simplifications I had already gotten done while on the Roller team. The GitHub Issues List notes 121 issues closed and 18 still open. Mainly still code refactoring (I'm shifting more to optimizing the SQL queries now -- identifying and removing redundant/unnecessary calls, inefficient calls, etc.) Biggest functional improvement has been in field validation and input field whitespace trimming. I also have been following changes to the Apache Roller project, incorporating those I like into Tightblog as well. Monday December 14, 2015

Working with TightBlog source code

Updated July 2016.

This entry explains how to set up a development environment and process for working on the Java-based TightBlog blog server. The tools below are the ones I use, some are optional some (such as preferred IDE or database to use) can be modified to your preference.

Tool list for programming TightBlog:

ToolBefore proceeding, make sure you can...
JDK 1.8Activate "java" and "javac" from any folder in a command-prompt window
Intellij IDEA (I use the free community edition)Can activate the application from a command-line.
Apache MavenActivate "mvn" from any folder in a terminal window
Command-line git clientRun "git" from any folder in a terminal window
Standalone Tomcat 8Can start and view Tomcat from http://localhost:8080
Apache Derby databaseCan activate ij (for Derby) from any folder in a command-prompt window. Note: See below instructions for using MySQL or PostgreSQL instead.
Firefox Web BrowserOptional; used for running Selenium tests without needing to activate Tomcat
SQL Query tool such as SquirrelSQLOptional but recommended; used for querying the TightBlog database instance.
  1. Fork TightBlog and add any desired additional themes - Do a git clone from the command-line window. You can also make a fork within GitHub to work from your own account. If you have any of custom blog themes to add, place them in the src/main/webapp/themes folder prior to building TightBlog. Make sure TightBlog build (including JUnit tests) runs successfully before proceeding further.

  2. Prepare database and (optional) mail configuration - Follow the short Chapter 5 and Chapter 6, Sections 1-4 of the Roller Install Guide (ODT), except name your override file instead of Chapter 5 provides the few commands needed to configure an empty MySQL, PostgreSQL, or Derby database and Chapter 6 the configuration of the file, optional Mail configuration, and the required Mail and JDBC JARs that will be needed in Tomcat's lib folder. The test file that I have in my Tomcat lib folder is as follows:

    # Any properties placed below overrides TightBlog default settings defined in
    # the file embedded within the TightBlog WAR, and should be 
    # stored in the CATALINA_HOME/lib folder for Tomcat.
    # EclipseLink debugging (filepath cannot be simplified via ${catalina.base} as above)
    # Mail config (See Roller Install Guide)

    Before moving on to the next step, best to deploy the app/target/tightblog.war to your Tomcat webapps directory, start Tomcat and confirm you can run the application at http://localhost:8080/tightblog. This is an important one-time check to ensure your database, file, Tomcat, and TightBlog WAR are all properly configured, and once confirmed you should be in good shape for all subsequent coding and debugging. If any deployment problems, make sure you've reviewed Chapters 5 and 6 of the Install Guide.

  3. Create a script to start development with everything needed - For efficient start-up I've created a script that opens up all needed windows and applications at once instead of having me needing to do so manually each time I start development. A simplified version of my is as follows and explained below:

    gnome-terminal --geometry=132x24 \
       --tab-with-profile=HasTitle --title "TB Trunk" --working-directory ~/work/tightblog \
       --tab-with-profile=HasTitle --title "TB Trunk2" --working-directory ~/work/tightblog -e "bash -c \"echo -Dmaven.surefire.debug; exec bash\"" \
       --tab-with-profile=HasTitle --title "Servlet Container" \
       --tab-with-profile=HasTitle --title "IntellijIDEA" -e "bash -c \"sh idea*/bin/; exec bash\"" \
       --tab-with-profile=HasTitle --title "Derby Network" --working-directory $DERBY_HOME/bin -e "bash -c \"startNetworkServer; exec bash\"" \
       --tab-with-profile=HasTitle --title "GEdit" -e "gedit worklog.txt $CATALINA_HOME/lib/ $CATALINA_HOME/logs/catalina.out $CATALINA_HOME/logs/tightblog.log `find $CATALINA_HOME/logs/localhost*.log` $CATALINA_HOME/logs/eclipselink-tomcat.log " \
       --tab -e "dolphin --geometry=600x500+1+1 tightblog-dbs tightblog $CATALINA_HOME" \
       --tab -e "google-chrome http://localhost:8080/tightblog" \
       --tab-with-profile=HasTitle --title "SquirrelSQL" --working-directory ~/work/squirrel-sql-3.7 -e "bash -c \"sh; exec bash\""

    The above script opens a multitab Console window which in turn opens a few separate application windows. In particular:

    • I open two terminal tabs pointing to the TightBlog code. This allows me to build TightBlog from one terminal while reviewing my changes (using commands git status and git diff, etc.) in the second window. I echo the -Dmaven.surefire.debug in the second tab as a reminder of the Maven string to add during JUnit test debugging (covered below).
    • I have a separate "ServletContainer" tab open to my home folder for manual activation of servlet containers (Tomcat normally) or other applications from the command line. I don't need this as often due to the script (discussed below) I now use.
    • I use a tab for starting IntelliJ IDEA.
    • I use Derby's Network mode (startNetworkServer) instead of its Embedded mode so the database can be accessed by multiple JVM's (one by Tomcat and the other by Squirrel SQL).
    • I open the multi-tab GEdit text editor with several files that are handy for me during development:
      • worklog.txt - A scratchpad file of TODO notes, commands, etc. that I keep for personal use between coding sessions.
      • - The very script above, I keep handy in case I need to make adjustments or additions to it.
      • - The configuration file discussed above and used by all TightBlog deployments to my standalone Tomcat. Changes I made here are activated on the next Tomcat restart.
      • catalina.out, tightblog.log, localhost*.log, eclipselink-tomcat.log - These are logging files filled by Tomcat and/or TightBlog during running, usually very important for debugging as error logging usually gets written to one of these files. If you see any terse "System" or similar errors reported by TightBlog in the web browser be sure to check these files for the error in detail.
      • tightblog.log, eclipselink.log - These files are under TightBlog's target directory and are populated during JUnit test running via the Maven test phase, as discussed below.
    • Dolphin - A multitab file browser that I have opened to the TightBlog trunk code, database files, and Tomcat folders for easy access to files.
    • Firefox - Here I pre-open tabs to the TighBlog website and default webpage location for TightBlog once it's deployed to Tomcat.
    • SquirrelSQL - Commented-out by default but used when I wish to query the TightBlog database to see the values that TightBlog is reading/writing. SquirrelSQL will need your database's JDBC JAR added to it as well as have the connection information configured in

    For scripts such as the above make sure there's no whitespace after the ending "\" on each line (error messages will pop up otherwise), and use a leading # (as shown above for SquirrelSQL) for actions you wish to disable by default. The $CATALINA_HOME specified above, as usual, is the base folder for your standalone Tomcat installation.

  4. How to build and deploy to local Tomcat - After a successful mvn clean install from the TightBlog trunk folder, I run this shell script that I keep in that folder:

    fuser -k 8080/tcp 8009/tcp 8005/tcp
    rm -r $CATALINA_HOME/webapps/tightblog
    cp ./app/target/tightblog.war $CATALINA_HOME/webapps
    rm $CATALINA_HOME/logs/*.log
    rm $CATALINA_HOME/logs/catalina.out

    For rapid iteration when I don't need to run the tests each time, I simplify my build and deploy process to a single line: mvn clean install -Dmaven.test.skip ; sh

    The above file first kills the Tomcat instance (via fuser -k), deletes the previous expanded TightBlog webapp directory on the Tomcat instance and copies the latest created TightBlog WAR over, and clears all the logs before finally restarting Tomcat with the new WAR. The new TightBlog will be accessible at http://localhost:8080/tightblog again using the same $CATALINA_HOME/lib/ and database (i.e., all database-stored information including test blog data created will be immediately picked up by the new TightBlog WAR.)

  5. How to debug on local Tomcat - Learning to debug from your IDE any webapp running locally on standalone Tomcat is frequently vital when troubleshooting and thankfully simple to do. First, add to your Tomcat CATALINA_OPTS environment variable:

    export CATALINA_OPTS=$CATALINA_OPTS" -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n"

    Then from IntelliJ IDEA (or Eclipse), go to menu item Run -> Edit Configurations, add a Remote Configuration with a name of your choice and accepting the given defaults, and select OK. If TightBlog is already running on Tomcat, debugging can be activated at any time by setting breakpoints in the code that the TightBlog app would be activating, selecting menu item Run --> Debug {debug config name}, and then proceed with any needed code tracing.

  6. How to debug unit tests - To activate a specific TightBlog JUnit test, navigate to the tightblog/app folder and run mvn test -Dtest=TestClassName#OptionalTestMethodName, as explained in the Maven Surefire Plugin documentation. To debug (code trace) the JUnit test within your IDE, add the -Dmaven.surefire.debug setting, set breakpoints in your IDE within code called by the tests and have it listen to port 5005 as before.

    Files to read: When running the JUnit tests, besides the Surefire results in the target/surefire-reports folder the target/tightblog.log file provides logging of the temporary in-process TightBlog instance. Also, to determine any potential SQL/JPA problems, EclipseLink JPA logging can be activated, with the output file also in the target folder, by uncommenting the eclipselink.logging.* properties in the app/src/test/ file.

  7. How to run Selenium tests - TightBlog's Selenium tests test very basic functionality (setting up a blog and saving a blog entry) but can sometimes serve as a quick sanity check that minor, last-second source code changes did not cripple the application. Navigating to the trunk/it-selenium folder and running mvn clean install will cause a temporary instance of TightBlog to activate that is subsequently used by Selenium to run its tests in Firefox. For these tests, none of the database or Tomcat configuration created above will be used, instead TightBlog will be running an embedded Jetty and a temporary (in-memory) Derby database, and shut down once Selenium is finished.

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.