WWW posts page 35

GiveCamp 2012

This past weekend I went to my second GiveCamp. GiveCamp is an event where a bunch of developers/designers get together with local charities to build them websites, applications, databases, etc. to meet a need of theirs. The product is started Friday evening and finished Sunday afternoon. The developers donate their time and get food, fun, and great experience in return. It’s a great way to learn new techniques, practices, even languages, as well as meet new people in the industry, often some of the well known in the area.

This year my team was to build a website for Buckeye Industries, a division of New Avenues to Independence. Buckeye Industries is a business enterprise that provides training and jobs for people with disabilities. They have info on the New Avenues site, but wanted to separate out the content into its own site. So it was basically a new site except for the content. Sarah Dutkiewicz was our able project leader. She did a great job working with our client, organizing things, and keeping us moving even through some troubles. Our client contact, named Karen, was very helpful and probably the most enthusiastic client I’ve met. The rest of our team started out as five people but then dropped to four as one went to another project.

Continue reading post "GiveCamp 2012"

I’m on GitHub

A couple months ago I finally made my first repos on GitHub. It provides a good place for me to store some of the code I use in an easily accessible location and also offers the potential for others to be able to make use of it and even contribute to it. I definitely like it so far. It has been quite easy to work with and offers a rather nice web interface. I can now not only access these repos from anywhere (with internet connectivity), but also read the source with its file browser and reader and view commit history with diffs.

I started off by adding some Symfony related repos, three that will form a basis for my personal Symfony projects (Symfony-Initial, Symfony-BaseBundle, and Symfony-Shared). I also added another Symfony one related to a project I’m working on (Symfony-BaseBundle). Then I added some more generic web related ones, a new CSS repo Web-Presentation and my JavaScript codebase TMLib (Web-ClientBehavior). I’ve been working on TMLib for a while now and have been wanting to add it.

I will work on these as need warrants and time allows. I will probably continue to add more of my collections of code that I’m fine with making public.


Symfony: PHP Templating Engine and Global Variables

At Cogneato, we are using Symfony’s PHP templating engine to render our views for compatibility with our existing system and for allowing our developers to continue using the same language they’re used to. I was looking for a way to make various services and other “variables” globally available in all view files, like can be done for Twig as mentioned in this cookbook. I asked on Stack Overflow, but didn’t get what I was looking for. We came up with our own solutions. I provided some as my own answer to that question. I will discuss the ones I can think of in this post.

Container

The one answer to my Stackoverflow question pointed out that the $view object has a container member object that has services available, and you can also access parameters set in your configuration file. Services would be accessed like (I believe):

Continue reading post "Symfony: PHP Templating Engine and Global Variables"

Using Symfony alongside an existing system

At Cogneato we’ve had a CMS that has been built up over more than a decade. We started working on a completely new system a while back to have a new and more powerful interface, add new features, and get rid of a lot of the cruft that the old system had from being developed over such a long period by many developers with different styles. We decided to use Doctrine as an ORM and Symfony as a framework for our back end.

We have maybe 200 sites running on various versions of our old system though, and we need to be able to add the new system’s features without having to completely redo them. We needed a way to be able to leave all the current stuff in place and pull in the Symfony stuff to the existing files with a simple include.

Continue reading post "Using Symfony alongside an existing system"

Symfony 2.0 and Custom Validation for Entity Based Forms

I recently started using Symfony’s form system at work instead of dealing with the forms entirely manually. I had found it confusing at first and so was reluctant to start using it, but now that I’ve started to figure it out, it’s proving rather nice. I still haven’t figured out how to create form classes or deal with subforms or any fancy stuff like that, but it’s helped reduce the amount of work effort per form and normalize the way we handle each.

Forms for entities are nice and do a lot automatically. However, I did run into a problem with them in dealing with a multi-site system: They can’t currently have custom validation applied to them. The constraints are specified in annotations in the entity or YAML or other configuration files, which I don’t think will easily accommodate being overridden for an individual site’s needs. We have many sites that have similar functionality that we want to share between them but some need things slightly different. To accommodate a site having custom validation, I created a form service with a function to handle custom validation constraints. The function looks like:

Continue reading post "Symfony 2.0 and Custom Validation for Entity Based Forms"

Workings of Late: Symfony, Less, Responsive Design, Etc

As I’ve mentioned, at Cogneato we’ve been building a new version of our CMS using Symfony on the server side. I’ve spent a LOT of time with Symfony now. I like it and will be using it for some other projects outside of work as well. We’ve been working on some eCommerce type sites that will hopefully be launched in the coming months, while building the system that all of our sites will eventually run on.

Though I like it, there have been many challenges to deal with, especially with making Symfony work with our old system. We have way too many existing sites with more than enough custom programming to convert them completely to a new system, so we’re setting it up so that both can be run side by side on old sites, while new sites will eventually only need the new system. But it has been a lot of effort to get the two working together properly. Symfony is inflexible in some ways, and not well documented in some areas. I intend to, in the coming months, write about my solutions for the various issues we’ve dealt with.

Continue reading post "Workings of Late: Symfony, Less, Responsive Design, Etc"

JQuery UI Droppable and Handling Multiple Draggable Types per Droppable

JQuery UI Draggable and Droppable make it fairly easy to implement dragondrop on a web page. There are some things that are not easy to do with it though. One example is having a droppable accept multiple types of draggables with different responses depending on type, especially when added at different times (for instance, being attached by separate objects/scripts). The way JQuery UI is set up, only one droppable behavior set can be attached to an element, so doing

element.droppable({accept: ".type1",...});
element.droppable({accept: ".type2",...});

simply replaces the “.type1” options with the “.type2” options.

In a recent project, I needed multiple draggable types per droppable, so I created an object class to handle adding a new “accept” type and associated events to an element that is already a droppable. I do this using duck punching to overwrite the original event callbacks. The wrapper callback checks the draggable element to see if it matches the new “accept” value. If so, it runs the new callback, otherwise it runs the original callback. Every time a new set of droppable options is applied, a new wrapper callback is created that calls the previous, so that no functionality is lost. Perhaps not as efficient as a single function with an if/switch tree, but that would not be feasible for this use case.

Continue reading post "JQuery UI Droppable and Handling Multiple Draggable Types per Droppable"

Synopsis 2011

Haven’t been posting much at all, but I’ve not been working on web stuff any less. I’ll give a bit of a synopsis of what I’ve been doing. This year I’ve been doing less new and interesting with HTML and CSS and more with JavaScript and PHP and database stuff, particularly the last several months. We’ve had one rather large project that requires mostly work in those areas. We are building a system that will use a JS heavy admin area based on Qooxdoo. The public side will use Symfony 2 with Doctrine for managing data. All three of those I’ve never worked with before and have had to learn as I go.

Qooxdoo is a full framework for JavaScript with a class system and a bunch of widgets that make working with it sort of like programming a desktop GUI application. It really extracts away from HTML/CSS and it can be frustrating knowing how to do something easily with those but not being able to use them. I don’t care for the abstraction, and it would be unfeasible to build a non-JS compatible app with this approach. I do like its class system quite a bit though. It has a lot of features and gives a lot of functionality for free, such as firing events on property change and easy access to parent methods. I’ve been working on my own class system and would like to incorporate some of its features.

Continue reading post "Synopsis 2011"

Givecamp 2011

Last weekend I went to GiveCamp in Cleveland. GiveCamp is a weekend of developers and designers building sites and applications for various charities. There were like 202 people there, working in the Lean Dog boat and in the hallway of Burke Lakefront Airport. There were 22 charities, each assigned a team appropriate to their needs. 21 of the projects were completed or nearly so in the one weekend allotted.

My project was Cleveland Carousel. My team also included a designer named Greg and another developer named Jon Knapp, who kind of managed the project most of the time. We had continuous help from at least one of the Cleveland Carousel people at all times. We also had a couple dedicated project managers come help us out for a little while as well.

The clients had a simple WordPress site in running with four pages, but they want something with a lot more content and pictures and a custom design. They came well prepared with a detailed plan of what they wanted, allowing us to move quickly with our small team. They worked with Greg to come up with a design, worked to put all of the content in place, and gave us continuous feedback as we built the site.

Continue reading post "Givecamp 2011"

Animation queue management for jQuery

jQuery makes it fairly easy to animate DOM elements. Animating a single-step animation on one or more elements is simple with the call of the animate method. Multi-step animations can be more complex because animations are run asynchronously, meaning that they will start running when called but the script will continue onto the next step before the animation is done. For these, jQuery has the ability to queue steps. jQuery automatically queues multiple steps on a single object and dequeues as each completes, so you don’t have to worry about managing things and setting up callbacks. But for more complex animations where multiple elements are animated at different times or other functionality must be performed after an animation step, there is no automatic queuing.

A common practice for simple queuing is to use the “complete” parameter of the animate method or of other similar asynchronous methods that is a callback to be run when the animation is finished. This works nicely when there are a few steps. It becomes more unwieldy though the more steps you add. That is where queue comes in, allowing for adding of as many steps as you want without having to nest in callback after callback.

Continue reading post "Animation queue management for jQuery"