Fixes some textile issues with JRuby (#5404).
Backported r3683 from trunk.
Refactor: Pull up #find_optional_project to ApplicationController.
Merged r3705 from trunk.
Merged r3702 from trunk.
Backported r3692 from trunk.
Merged r3678 from trunk.
Merged r3682 from trunk.
Fixes theme discovery under JRuby on Rails war structure (#632, #5404).
Fixes workflow edit with JRuby (#5404).