Skip to content

Global properties #174

Open
Open

Description

@rodrigodalcindev

Global properties support should be improved through an augmented Status or route-based service. Some of these are essential to any web app and make front-end development work much easier, for example:

  • Body tag identifiers (page or route-based classes and IDs)
  • Meta tags (for SEO purposes, also page or route-based)
  • Page titles (also page or route-based)

Activity

  1. rodrigodalcindev commented on Jun 15, 2015

    @rodrigodalcindev
    Author

    As a reminder, @simonwalsh suggests using Bower to achieve this.

  2. joshnuss commented on Jun 15, 2015

    @joshnuss
    Contributor

    We can add custom options for these to our routes (like how we added requires: {user: true})

    Example:

    $routeProvider
       .when '/foos',
           meta:
              keywords: 'fooseball, foose, foosing'
           title: 'Fooseball'
           layout:
              body:
                 id: "foose-page"
                 class: 'full'
           controller: 'FoosCtrl'
    
    
  3. rodrigodalcindev commented on Jun 16, 2015

    @rodrigodalcindev
    Author

    @joshnuss That would involve overriding routes.coffee in the host app, correct? How would we later reference these custom options on the app's views (eg.: injecting the keywords property to a meta tag)?

  4. simonwalsh commented on Jun 16, 2015

    @simonwalsh
    Contributor

    @rodrigodalcindev

    You can get them from the $route object when you transition from start to success.

    I would still advise for us to build a proper Status module that would take care of this sort of things.

    I started a proof of concept in reformation and it looks like so:

    .when '/products',
          requires: {setup: true}
          controller: 'ProductListCtrl'
          templateUrl: 'products/index.html'
          status:
            page: "products"
            bodyClass: "s-products is-nav--dark"
    

    ... and in the Status service:

    status =
        initialized: false
        pageTitle: ""
        requestedPath: null
        httpLoading: false
        routeChanging: false
        manuallyLoading: false
        cachedProducts: []
        meta: {}
        $body: angular.element('body')
        page: null
        previous: null
    

    I would love for us to set those in the routes and override them in the controllers if needed. This way you don't need to create a controller just to set the meta of a page...

  5. simonwalsh commented on Jun 16, 2015

    @simonwalsh
    Contributor

    I have many ideas for this module so I can assign that to me!

  6. self-assigned this
    on Jun 16, 2015
  7. joshnuss commented on Jun 16, 2015

    @joshnuss
    Contributor

    @rodrigodalcindev @simonwalsh Good points

    What do you think about defining "status" settings in a different file? Like have a status.coffee (we should find a better name then "status")

    e.g.

    YourApp.config ($statusProvider) ->
       $statusProvider
          .when '/products',
               title: "Shirts"
               keywords: "Awesome"
          .when ... 

    That way sites dont have to override routes or controllers to adjust meta stuffs

  8. simonwalsh commented on Jun 16, 2015

    @simonwalsh
    Contributor

    @joshnuss Exactly what I had in mind!

    The way I see it is :

      1. default (from the app)
      1. status json/coffee mapping file
      1. routes attributes
      1. controller

    0 being the lowest priority. This way we would have a convenient and flexible meta service.

  9. joshnuss commented on Jun 16, 2015

    @joshnuss
    Contributor

    @simonwalsh big 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions