Giter VIP home page Giter VIP logo

oec-website's Introduction

OEC Canon Website


Contributor FAQs (CMS Best Practices)

Data URLs

All generator and visualization URLs should never contain the hostname of the server, unless it is going to an external non-OEC source (like Macro Market). For example:

Incorrect URL ❌

https://api.oec.world/tesseract/data.jsonrecords?cube=trade_i_baci_a_92&drilldowns=Exporter+Country&measures=Trade+Value

Correct URL ✅

/olap-proxy/data.jsonrecords?cube=trade_i_baci_a_92&drilldowns=Exporter+Country&measures=Trade+Value

All data calls need to be routed through the /olap-proxy endpoint, which handles redirecting to the correct Tesseract endpoint. It also authenticates the request, so that PRO users receive data from cubes that are not open publically.

This also applies to all URLs that hit a /stats endpoint. For example:

Incorrect URL ❌

https://dev.oec.world/api/stats/relatedness?cube=trade_i_baci_a_92&filter_hs92=010101&time=year.latest&measures=Trade+Value&rca=Exporter+Country,Trade+Value

Correct URL ✅

/api/stats/relatedness?cube=trade_i_baci_a_92&filter_hs92=010101&time=year.latest&measures=Trade+Value&rca=Exporter+Country,Trade+Value

By starting URLs with a forward slash /, all CMS and client (d3plus) requests will be routed to localhost. This also applies to all manually constructed anchor links. For example:

Incorrect URL ❌

<a href="https://dev.oec.world/en/profile/country/usa">United States</a>

Correct URL ✅

<a href="/en/profile/country/usa">United States</a>

Showing a Paywall

Certain database tables have their access restricted to only certain classes of users, known as "roles". Based on the user's current "role", the tesseract API endpoints will selectively choose whether or not to return data for certain queries. The current user roles are as follows:

  • undefined - No Account Made (needs to sign up)
  • 0 - Free User Account (signed up, but no purchases made)
  • 1 - Pro Account (purchased a subscription)
  • 10 - Contributor (internal CMS contributor)

Currently, we are only limiting cubes for users with role < 1, so that only paying customers and internal team members get access to the premium content.

Step 1 - Set Up Materializer

To start making a paywall, a profile editor needs to create 3 variables in a materializer for that specific profile.

Please Note: These variables only need to be set up once for each profile, so please check that they haven't already been set up for the profile you are working on. If they already have been set up, take note of their names and move onto Step 2.

const {id, role} = variables.user;

return {
  isPro: role > 0, // boolean value that is true for pro users
  notPro: !role, // boolean value that is true for non-pro users
  paywallObject: {user: id} // config for the paywall
};

Step 2 - Hide Premium Visualization

Go into the section editor for the section that contains the visualization you would like to hide. Open the editor for that visualization, and change the "Visible" dropdown to use the isPro variable created from Step 1 (shown here circled in red):

Step 3 - Create the Paywall Visualization

In the same section where you hide the visualization in Step 2, add a new visualization of type "HTML". This "visualization" is going to be our paywall, only visible to "non-Pro" users.

HTML visualizations allow any custom HTML string to be injected into the page. The visualization editor allows you to select a variable to be used as this injected HTML, and a formatter on that variable (if needed). We can use this to pass our paywallObject through a global Paywall formatter that exists in order to create the appropriate HTML string. Make sure you also set the "Visible" status to notPro. The 4 selections you need to make are highlighted here in red:

Advanced Paywall Features

There are properties in the Paywall formatter that can be overridden by the paywallObject you create in the materializer. These properties can be used to further customize the display of the paywall for the specific profile. You can even create multiple paywall objects to be used in different sections on the same page! Here are all of the current settings with their default values:

{
  button: "Click here to sign up!",
  image: undefined, // full image path (overrides "type" image)
  title: "This feature is only available for PRO accounts.",
  type: "Treemap", // d3plus viz type for background image
  url: user ? "/en/account" : "/en/signup",
  user: undefined // determines the default link behavior
}

Subnational Landing Page

How do I add a new subnational map to the /subnational page?

  • Requirement: Country data must be ingested.
  • Find the 3-letter country code from ISO 3166. Check here.
  • Identify what are the administrative levels presents in the new country's data. Could be one or more: Regions & Comunas, or just Areas.
  • Play with Tesseract UI queries to get the names of each member per level.
  • Check with Google Maps or Wikipedia if the names (members and levels) are correct.
  • Go to GADM or IGISMAP or any official place to get the shapes and find the right map for each level.
  • If file size is too big for web -probably it is- simplify it, we don't need too many details. You can use any tool. MapShaper works great, is easy to use and in-browser. Also resolve some overlapping points.
  • Export the maps in TOPOJSON format and save it (static/shapes)[static/shapes] with name subnational_<3 letter country code>_<level slug (plural)>.topojson;
  • Open for edit the topojson file using geojson.io table view (or any other tool). You can edit using also: https://geoman.io/
  • Make sure to create/update an id and name columns based on tesseract ui query to match the ids with shapes. Pay attention on that.
  • Remove any other useless property. We just need id and name.
  • Sometimes we use type column for clarify geo level that are mixed in the same file.
  • Export it with the same name than before. (Make a copy if you are not sure of the results).
  • Go to consts.js file and add a new item inside SUBNATIONAL_COUNTRIES array.
  • Replace the object values with your own data.
    {
      name: "Brazil",
      code: "bra",
      dimension: "Subnat Geography",
      geoLevels: [
        {name: "States", level: "Region", slug: "states"},
        {name: "Municipalities", level: "Subnat Geography", slug: "municipalities"}
      ]
    }
  • Test the new country in /subnational.
  • Success!

oec-website's People

Contributors

cnavarreteliz avatar davelandry avatar alexandersimoes avatar nspmx avatar palamago avatar perpetualgrimace avatar ffigueroal avatar eduardovastol avatar jhmullen avatar frabarz avatar walambrecht avatar alanorb avatar cesifoti avatar

Stargazers

 avatar Alex Pinos avatar  avatar Willia.m avatar Salvador Guzman avatar Eduardo Spanó avatar Wouter Bam avatar James Lamb avatar

Watchers

James Cloos avatar

oec-website's Issues

rankings page

  • Country Rankings
  • Product Rankings
  • Dynamic Rankings Mockup

resource pages

  • About the Site (/en/resources/about)
  • Data Sources (/en/resources/data)
  • Methodology (/en/resources/methodology)
  • Permissions (/en/resources/permissions)
  • FAQs (/en/resources/faqs)
  • Publications (previously /publications, but please make it /en/resources/publications and include a redirect)
  • API (previously /api, but please make it /en/resources/api and include a redirect)

user accounts

  • sign up flow
  • login/logout
  • account page
  • Stripe integration/testing
  • e-mail confirmation
  • terms and conditions
  • privacy policy
  • password reset
  • password change
  • CMS user paywall example
  • customer service/support links

design for subnational selection page

It would be nice to have a landing page for users to select a subnational profile page to view. I think something similar to CDC would work really well here:

Screen Shot 2019-12-27 at 2 46 10 PM

Instead of seeing a US map, users would see the world map and be allowed to solo a country to see a list of all the different subnational entities.

implement styles for dashboard demo interface

These styles/pages will be held in separate "one off" routes. As such we'll need to make the nav hide depending on whether or not these pages are being viewed. Latest design is forthcoming from.

Consistent numbers in country profiles

Take Argentina as an example.

First it says 56.9 B exports but then another number appears.

Digging a bit, as Lucre Cosentino explained, it looks that the profile is first showing SITC exports and then HS exports.

Provided some countries do an imperfect translation between coded, we should stick to one trasde classification for the full profile.

trade data prediction pipeline

Add support for a python service to send data via an api endpoint to the front-end of data predictions.

The end goal is to have predictions in the "trade balance" section of the geo profile, showing a dashed line of exports/imports into the future.

design updates for idb / oec dashboard demo

Another iteration of the idb demo pages including the following feedback:

  • keep the swirly background
  • increase font-size (for further distances)
  • make the country/product selections more of the focus for the intro page

pro user mockups

  • login/signup flow
  • payment flow
  • user account page (with favorites)

subnational profile

Add the following sections:

  • map of municipalities (for states)
  • map in header
  • port of entry (for states)-- maybe a sankey?
  • transport mode (for states)
  • trade balance viz

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.