Code Monkey home page Code Monkey logo

nm-drupal-app's Introduction

New/Mode Code Test

When writing the code test, please keep in mind best programming practices as well as proper coding style and the Drupal community’s PHP and JavaScript coding standards. Specifications

Write a small web application that allows end users to enter a Canadian postal code and view a list of political representatives associated with that postal code. Data should be pulled from the Open North Represent API (http://represent.opennorth.ca/api/). Representatives should be presented in a table or list ordered by ‘representative set’ (as found via the Represent API using this end point http://represent.opennorth.ca/postcodes).

Specs

[x] The implementation should be a small Drupal 9 module that implements Drupal’s form API. [] Include caching wherever applicable to improve the application’s performance. [] The code does not need to be perfect, but it should be considered production ready. We estimate this to take approximately 5 hours.

[x] All PHP, JavaScript, etc. needed to install, configure, and use the module or application. [x] Attach screenshots of the form. [x] Compress everything in a tarball or commit it to a github repo.

Notes

Overall, this coding challenge was a struggle for me. Having never used Drupal before, finding the resources and adapting them to the work that needed to be completed took a lot of work. As it currently exists, the app, when used within MAMP, can get and aggregate the representative data by postal code. The data is manipulated to group by representative sets, creating an object in which the representative sets are keys who's values are arrays of representatives that belong to those sets.

The Process

Day 1: The day started by trying to learn the basic concepts behind the Drupal framework and the reasons for its design. After a half day of consuming informational videos, docs, and tutorials, I began by setting my sites on getting a site using Drupal up and running. I originally set out to use Docker for hosting my server locally. Having other projects run on Docker, I am fairly comfortable using it to host severs locally. The docs recommended a tool called DDEV, which seemed like the right direction to be heading in, the tool's docs had a quick start guide for Drupal 9 -- documentation including caveats to this new version seem to be few and far between. After learning that Drupal gets installed after the server (duh) I had a server that was set up and ready to go. After going through the installer, I began learning about custom modules and started to create a skeleton of files I would want to use to fulfill the requirements. It looked like I would want a form that would extend the FormBase class. Cool.

Day 2: The next day, I followed the Hello World tutorial for creating custom modules. My plan was to iterate upon this simple custom module example: switching from a controller to a form, hooking up the form's submit to the opennorth API, collecting and grouping the data correctly, implementing a table to display the data, creating the cache and defining its conditions, and then if I had time, I would work on cosmetics. However, I discovered that after installing the custom module through the GUI, any attempt to access the new form endpoint would give a server error of 'Transport endpoint is not connected.' A couple hours were sunk into trying to debunk this before investigating another solution for local hosting. At this point, I switched to MAMP (and accidentally MAMP Pro for 30 minutes as the download page directed me there first 🤦‍♂️) and after a while, was successfully back up and running, with the ability to hit the form endpoint without error. The form was easily wired up to send out a request to the opennorth API using PHP's cURL and retrieving and regrouping the data by representative set was complete. The next challenge is where I still am currently. The form does not offer a way to render extra HTML, so I began to explore using blocks. This however did not use the form API as was instructed, so I had to return to using the form. An attempt to utilize themes ultimately proved nothing.


CONTENTS OF THIS FILE

  • About Drupal
  • Configuration and features
  • Installation profiles
  • Appearance
  • Developing for Drupal
  • More information

ABOUT DRUPAL

Drupal is an open source content management platform supporting a variety of websites ranging from personal weblogs to large community-driven websites. For more information, see the Drupal website at https://www.drupal.org, and join the Drupal community at https://www.drupal.org/community.

Legal information about Drupal:

  • Know your rights when using Drupal: See LICENSE.txt in the "core" directory.
  • Learn about the Drupal trademark and logo policy: https://www.drupal.com/trademark

CONFIGURATION AND FEATURES

Drupal core (what you get when you download and extract a drupal-x.y.tar.gz or drupal-x.y.zip file from https://www.drupal.org/project/drupal) has what you need to get started with your website. It includes several modules (extensions that add functionality) for common website features, such as managing content, user accounts, image uploading, and search. Core comes with many options that allow site-specific configuration. In addition to the core modules, there are thousands of contributed modules (for functionality not included with Drupal core) available for download.

More about configuration:

INSTALLATION PROFILES

Installation profiles define additional steps (such as enabling modules, defining content types, etc.) that run after the base installation provided by core when Drupal is first installed. There are two basic installation profiles provided with Drupal core.

Installation profiles from the Drupal community modify the installation process to provide a website for a specific use case, such as a CMS for media publishers, a web-based project tracking tool, or a full-fledged CRM for non-profit organizations raising money and accepting donations. They can be distributed as bare installation profiles or as "distributions". Distributions include Drupal core, the installation profile, and all other required extensions, such as contributed and custom modules, themes, and third-party libraries. Bare installation profiles require you to download Drupal Core and the required extensions separately; place the downloaded profile in the /profiles directory before you start the installation process.

More about installation profiles and distributions:

APPEARANCE

In Drupal, the appearance of your site is set by the theme (themes are extensions that set fonts, colors, and layout). Drupal core comes with several themes. More themes are available for download, and you can also create your own custom theme.

More about themes:

DEVELOPING FOR DRUPAL

Drupal contains an extensive API that allows you to add to and modify the functionality of your site. The API consists of "hooks", which allow modules to react to system events and customize Drupal's behavior, and functions that standardize common operations such as database queries and form generation. The flexible hook architecture means that you should never need to directly modify the files that come with Drupal core to achieve the functionality you want; instead, functionality modifications take the form of modules.

When you need new functionality for your Drupal site, search for existing contributed modules. If you find a module that matches except for a bug or an additional needed feature, change the module and contribute your improvements back to the project in the form of a "patch". Create new custom modules only when nothing existing comes close to what you need.

More about developing:

MORE INFORMATION

  • See the Drupal.org online documentation: https://www.drupal.org/documentation

  • For a list of security announcements, see the "Security advisories" page at https://www.drupal.org/security (available as an RSS feed). This page also describes how to subscribe to these announcements via email.

  • For information about the Drupal security process, or to find out how to report a potential security issue to the Drupal security team, see the "Security team" page at https://www.drupal.org/drupal-security-team

  • For information about the wide range of available support options, visit https://www.drupal.org and click on Community and Support in the top or bottom navigation.

nm-drupal-app's People

Contributors

kshiga avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.