Skip to content

Instantly share code, notes, and snippets.

@bittersweet
Last active August 29, 2015 14:01

Revisions

  1. bittersweet revised this gist Jul 17, 2014. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions guide.md
    Original file line number Diff line number Diff line change
    @@ -72,15 +72,15 @@ case. I've also added some minor styling for the powered by Springest image.

    ## Modifying training URL

    In this example I change the URL attribute of the Training object received from
    Springsense. This is just like the truncating of the description, you modify
    the training/object that is passed to the (custom) template.
    In this example I change the `url` attribute of the Training object received
    from Springsense. This is just like the truncating of `description`, you modify
    the training/object before you pass it to the (custom) template.

    So basically that is to cut up an url like this:
    So basically that is to cut up the training URL you receive from springsense like:
    `http://www.springest.nl/boertien-vergouwen-overduin/salarisadministratie?utm_term=Senior%20Salarisadministrateur`

    So you are left with `salarisadministratie` and just add the training's ID so
    it corresponds with your internal URL setup.
    it corresponds with the internal URL setup of Intermediair.

    ```javascript
    var callback = function(container, data) {
  2. bittersweet revised this gist Jul 17, 2014. 1 changed file with 24 additions and 0 deletions.
    24 changes: 24 additions & 0 deletions guide.md
    Original file line number Diff line number Diff line change
    @@ -69,3 +69,27 @@ case. I've also added some minor styling for the powered by Springest image.
    }
    </style>
    ```

    ## Modifying training URL

    In this example I change the URL attribute of the Training object received from
    Springsense. This is just like the truncating of the description, you modify
    the training/object that is passed to the (custom) template.

    So basically that is to cut up an url like this:
    `http://www.springest.nl/boertien-vergouwen-overduin/salarisadministratie?utm_term=Senior%20Salarisadministrateur`

    So you are left with `salarisadministratie` and just add the training's ID so
    it corresponds with your internal URL setup.

    ```javascript
    var callback = function(container, data) {
    $.each(data.trainings, function(_, training) {
    training.description = training.description.substr(0, 150) + "...";
    var path = training.url.split('/');
    training_slug = path[path.length - 1].split('?')[0];
    training.url = 'http://www.intermediair.nl/testen-tools/opleidingen/training/' + training_slug + '/' + training.id;
    $(container).append(Springest.template("springest_template", training));
    });
    };
    ```
  3. bittersweet revised this gist May 28, 2014. 1 changed file with 71 additions and 1 deletion.
    72 changes: 71 additions & 1 deletion guide.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,71 @@
    first version
    I've generated this example based on http://www.intermediair.nl/vacature/4236810/Senior+Salarisadministrateur/

    ![](http://img.springe.st/Vacature_voor_Senior_Salarisadministrateur__Spirit__Amsterdam__44435158_20140528_174611_20140528_174612.jpg)


    Include our widget on the page:
    ```html
    <script src="https://4d9ae17c5ae68590ce6f-1c6f7d77e67457fef78cfb90b7e69696.ssl.cf3.rackcdn.com/assets/springsense.js"></script>
    ```

    Define a custom template for the Springsense output. I've 'abused' some of the
    existing classes to get the example out there quickly.

    ```html
    <script type="text/html" id="springest_template">
    <tr>
    <td class="first bookmark">
    <strong class="title">
    <a href="<%= url %>"><%= name %></a>
    </strong>
    <br />
    <span><%= description %></span>
    <a href="<%= url %>" rel="nofollow"> bekijk meer</a>
    </td>
    </tr>
    </script>
    ```

    The only new html that's necessary is a container where we load in the
    Springsense results. In the example I added this container after the closing
    div of the 'relevant vacatures'.

    ```html
    <div class="related-vacatures clearfix" style="margin-top: 40px">
    <table class="dynamic-box">
    <caption>Relevante opleidingen</caption>
    <tbody id="related-trainings">
    </tbody>
    </table>
    </div>
    ```

    This is the actual widget implementation which uses your public key, the job
    title didn't really have a unique ID so I've hardcoded the job title in this
    case. I've also added some minor styling for the powered by Springest image.

    ```html
    <script>
    $(document).ready(function() {
    Springest.setApiKey('aah2828dn33c9d76f259aac45f9c7d2');
    var job_title = 'Senior Salarisadministrateur';
    var container_id = "#related-trainings";
    var callback = function(container, data) {
    $.each(data.trainings, function(_, training) {
    training.description = training.description.substr(0, 150) + "...";
    $(container).append(Springest.template("springest_template", training));
    });
    };
    Springest.getTrainings(job_title, container_id, callback);
    });
    </script>

    <style>
    #PoweredBySpringest img {
    width: 70px;
    position: relative;
    top: 2px
    }
    </style>
    ```
  4. bittersweet created this gist May 28, 2014.
    1 change: 1 addition & 0 deletions guide.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    first version