Git Product home page Git Product logo

bcjs's Introduction

BetterContext Library

Example script tag:

<script 
  src="BetterContext.js" 
  data-bc-user="[email protected]"
  data-bc-api="1c4f5fd4-e7a9-4d2b-a4db-b6191e5fbe75">
</script>
  • data-bc-user - the current better context user id
  • data-bc-api - your better context api key

Auto mode example script:

<script 
  src="BetterContext.js" 
  data-bc-user="[email protected]"
  data-bc-auto
  data-bc-api="1c4f5fd4-e7a9-4d2b-a4db-b6191e5fbe75">
</script>

  • data-bc-auto - enabled auto bootstrap of charts

BetterContext auto chart elements

<div 
  data-bc-chart="pentagon" 
  data-bc-id="SOME_ID">
</div>

Development

There are three scripts which can be used while working on the BetterContext JavaScript code.

  • script/setup - installs all dependencies and builds the project
  • script/build - builds the project
  • script/serve - starts the development server

Scripts can be run from the root of the repo. For example to setup the project you could run:

./scripts/setup

bcjs's People

Contributors

nnnick avatar getnashty avatar treasonx avatar andyburke avatar miosss avatar chandruxp avatar robocoder avatar brettbukowski avatar esamattis avatar fizerkhan avatar ooflorent avatar ilyakatz avatar jbrooksuk avatar mardaneus86 avatar fulldecent avatar

Watchers

 avatar James Cloos avatar

bcjs's Issues

"Spark" Shape - images

We need for publishers to be able to show an item's shape without hitting BC on every load to receive a score and render the shape.

They might want to show a tiny photo of this shape in search results, grid listings etc. Everywhere they would want the info - without being interactive.

I see this - http://davidwalsh.name/convert-canvas-image... so what we could do, is create the image every time (or once every X loads) the avg rating is displayed on a client - and send the new image back to BC through our JS.

so then we store the image in our CDN, and give them an ability like, <img src="bettercontext.com/pub/1/item/10/shape.png"> renders <img src=" bettercontext.com/sparkshapes/329847328497.png"> or something...

What do you think?

Handling existing user ratings

nash [9:51 AM]
so I just took a look at the demo

nash [9:51 AM]
and item_ratings.json

nash [9:51 AM]
doesn't have any "u1" type metrics

nash [9:51 AM]
just "m1"

nash [9:51 AM]
stuff

james [9:52 AM]
what is u used for?

nash [9:52 AM]
the user's rating if it exists

james [9:52 AM]
and we show that where?

nash [9:52 AM]
on the same chart

james [9:52 AM]
when?

james [9:52 AM]
cause I dont think I did anything at all with that

nash [9:52 AM]
well its two different cases

nash [9:52 AM]
if the "u1"-"u5" exists

nash [9:52 AM]
then we show both ratings

nash [9:53 AM]
because it means the user already rated that item

nash [9:53 AM]
but if no "u" values exist

nash [9:53 AM]
then we just hide the avg

nash [9:53 AM]
and let them rate it

james [9:54 AM]
so if there is a u we show it as the current rating and they can adjust it?

nash [9:54 AM]
yup

james [9:54 AM]
ah okay thats easy

nash [9:55 AM]
also, thats 100% the prob, I just found a movie I didn't rate

james [9:55 AM]
those are just the initial value for the chart. if they are there

nash [9:55 AM]
yup exactly

james [9:55 AM]
okay this is an easy thing

james [9:55 AM]
no big deal

james [9:55 AM]
I'll fix it and update the demo with an example

nash [9:55 AM]
can we turn the "hide" avg if the "u" values exist too?

nash [9:55 AM]
off*

james [9:56 AM]
so we want to show average if the u stuff is there?

nash [9:56 AM]
yea

james [9:56 AM]
yup np

nash [9:56 AM]
ok cool!

Replace HTML instead of appending Canvas element

I'm trying to let the publisher show a loading icon before the chart appears...

So I figure, for this element

<div class="bc_chart" data-bc-chart...

we can just replace whatever HTML might be inside - with the Canvas element, instead of appending the element.

BC Endpoint spec

BC script needs to talk to croovies.

Currently using two endpoints, one for getting ratings, and one for posting ratings.

Posting:
https://github.com/fliptables/bcjs/blob/master/bc/bctxtFull.js#L2448

Ex:
http://www.bettercontext.com/api/user_ratings?site_id=&item_id=&user_id=&rating[]=

This one is pretty clear, the rating dimensions are sent in as an array - so the order matters. I assume its handled 1-5 on the backend but hopefully @mmichael0413 can verify that for me.

Getting:
https://github.com/fliptables/bcjs/blob/master/bc/bctxtFull.js#L2730

Ex:
http://www.bettercontext.com/api/item_ratings?site_id=1&user_id=1&items[]=1&items[]=2&items[]=3
https://gist.github.com/getnashty/6d332dcc011a62ddec26

The response sends back objects with the id being equal to the id sent in, filled w/ up to 10 properties (as seen in the gist, or if you try the link). the m1-m5 are average metrics (m stands for metrics), and if u1-u5 exist, those are the user ratings. If there are no "u" properties, then the item hasn't been rated by the user.

We called this item_ratings, rather than user_ratings, as we were using the same endpoint even if there was no user (i.e. if the person wasn't logged in and wanted to see the avg ratings). Items was obviously an array of item IDs we wanted scores for (average scores, and user scores).

Query by shape

For this page, its going to be an early need-

http://staging.croovies.com/movies

What I would expect (as a publisher):

Add "queryByShape" or something like that as a flag to the element HTML declaration.

I would expect to receive an array of objects (This is on the BC backend side - we don't need to handle this for reals yet), the data of those objects has yet to be determined.

I would then expect BCJS to provide a way (i imaging something the publisher can subscribe to), for me to receive this array.

Average Shape Objects

For pages like this:
http://staging.croovies.com/people/27

We'll need an "avg" shape item... IE, a list of ID's returns an average shape of the ratings of those IDs.

This element cannot be manipulated by the user.

I'm thinking about two different ways of managing this - either the publisher has hooks into BC (so on croovies backend, we can created new "avg" objects by supply a bunch of ID, and BC returns an "avgItemID"... Then we use that id in the BCJS element...

Or, the element itself accepts an array of ID, and returns the avg on the fly... While this seems easier for the publishers, it seems more calculation intensive/expensive for BC...

Thoughts?

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.