guardian/frontend — pull request #7125 by johnduffell (2014-11-14 17:42:08+00:00)
Title: More history detail to allow us to implement a personalised nav bar

This pull request is for adding history of the sections/keywords/blogs/contributors to the local storage so we can write a personalised nav pointing to content a user is likely to want to see.

although this code works, for now it doesn't quite do what we want yet as follows:
In fact, commentisfree section, commentisfree/commentisfree blog both redirect to uk/commentisfree facia page.
However when visiting a few stories in that area, I get all three in my summary with different values. However if we actually made a nav bar with all three in there, all would actually redirect to the same place.

It seems we need a way to work out whether it's going to redirect something ahead of time, and rewrite the id to be that thus only adding weight to the target id not to all of the ones that redirect there.

Comments appreciated, and @stephanfowler please could you take a look while I'm away and we can reopen when I return a week on Tuesday.

Here are examples of the gu.history in localStorage, gu.history.summary in localStorage, and the config.page.summary object in the page source.
gu.history:
```
{
"value":[
{
"id":"uk/commentisfree",
"countRepeatVisits":true,
"summary":[
{
"id":"uk/commentisfree",
"displayName":"Comment is free",
"type":"faciaPage",
"weight":50
}
],
"timestamp":1415983833824,
"count":1
},
{
"id":"uk-news/2014/nov/14/uk-jihadists-citizenship-laws-human-rights",
"countRepeatVisits":false,
"summary":[
{
"id":"uk-news",
"displayName":"UK news",
"type":"section",
"weight":10
},
{
"id":"uk/uksecurity",
"displayName":"UK security and counter-terrorism",
"type":"keyword",
"weight":10,
"parentDisplayName":"UK news"
},
{
"id":"profile/alantravis",
"displayName":"Alan Travis",
"type":"contributor",
"weight":10
},
{
"id":"profile/patrickwintour",
"displayName":"Patrick Wintour",
"type":"contributor",
"weight":10
}
],
"timestamp":1415983364390,
"count":1
}
]
}
```
gu.history.summary
```
{
"value":{
"lifeandstyle":[
"Life and style",
"section",
10
],
"lifeandstyle/food-and-drink":[
"Food & drink",
"keyword",
10,
"Life and style"
],
"profile/jayrayner":[
"Jay Rayner",
"contributor",
10
],
"uk/commentisfree":[
"Comment is free",
"faciaPage",
200
],
"commentisfree":[
"Comment is free",
"section",
10
],
"world/palestinian-territories":[
"Palestinian territories",
"keyword",
10,
"World news"
],
"commentisfree/commentisfree":[
"Comment is free",
"blog",
10
],
"profile/editorial":[
"Editorial",
"contributor",
10
]
}
}
```
config.page.summary
```
[
{
"id":"commentisfree",
"displayName":"Comment is free",
"type":"section",
"weight":10
},
{
"id":"world/palestinian-territories",
"displayName":"Palestinian territories",
"type":"keyword",
"weight":10,
"parentDisplayName":"World news"
},
{
"id":"commentisfree/commentisfree",
"displayName":"Comment is free",
"type":"blog",
"weight":10
},
{
"id":"profile/editorial",
"displayName":"Editorial",
"type":"contributor",
"weight":10
}
]
```