Code Monkey home page Code Monkey logo

twreporter-react's Introduction

TW Reporter

New Media foundation in Taiwan.

Environment

Install node(https://nodejs.org/en/) v4.x.x or v6.x.x first.

Installation

$ npm install

Pre-process

$ cp api/config.example.js api/config.js 

edit api/config.js to connect to your own api host
if you have no api server, you can follow this to build your own API layer.

Build your own API

Before starting up twreporter-react, you may need serveral API endpoints to provide the articles.
If you don't have these endpoints, you can follow next steps to build up your own API layer.

FIRST STEP: create a CMS

You can use CMS of twreporter to create your own CMS.
Since you have your own CMS, you can create, edit and delete those articles you want to show on your twreporter-react site.

SECOND STEP: start up an API server

tr-projects-rest is used to start up a RESTful webservice which is created for CMS of twreporter.

THIRD STEP: edit api config to connect to your own API

edit the api/config.js, and connect to your own API host.

After doing these setups, you can start up your twreporter-react site.

Development

$ npm run dev

Production

$ npm run build; npm run start

React & Redux

This project is built on Redux framework and rendered by React. It uses server-side(universal) rendering, and also integrate Webpack Hot Middleware in Dev environment.

Redux State

Since Redux see its state as single source of truth, we store our own data like the plain object below.

{
  articlesByUuids: {
    73177cb8c0c261000b3f6d2: {
      error: null,
      hasMore: true,
      isFetching: false,
      items: [
        "57ecfc9061fdfb0f009f87a4",
        "57eb6d3361fdfb0f009f879f"
      ],
      lastUpdated: 1475302285419,
      total: 233
    }
  },
  categories: {},
  device: "desktop",
  entities:{
    articles: {
      57ecfc9061fdfb0f009f87a4: {
        ... // fields of article
      },
      57eb6d3361fdfb0f009f879f: {
        ... //fields of article
      }
    },
    categories: {
      573177cb8c0c261000b3f6d2: {
        id: "573177cb8c0c261000b3f6d2",
        key: "573177cb8c0c261000b3f6d2",
        name: "評論",
        sortOrder: 6,
        v: 0
      }
    },
    tags: {},
    topics: {}
  },
  featureArticles: {
    error: null,
    isFetching: false,
    items: [],
    lastUpdated: 1475302285397
  },
  header: {},
  relatedArticles: {},
  routing: {},
  selectedArticle: {
    error: null,
    id: "57ecfc9061fdfb0f009f87a4",
    isFetching: false, 
    lastUpdated: 1475303011138,
    slug: "photo-taichung-flaneur"
  },
  slugToId: {
    photo-taichung-flaneur: "57ecfc9061fdfb0f009f87a4",
    chen-chin-feng-illustrator: "57eb6d3361fdfb0f009f879f"
  },
  tags: {}
}

Reference

react-redux-universal-hot-example Redux React

License

  • Copyright (C) 2015 - 2016 The Reporter 報導者. All rights reserved.
  • Distributed under the GNU AGPL v3.0

twreporter-react's People

Contributors

afutseng avatar aqutw avatar audreyt avatar bobchao avatar c9s avatar hcchien avatar hsunpei avatar jessy1092 avatar kaddopur avatar kidwm avatar nickhsine avatar roth1002 avatar rudanzona avatar teaualune avatar yanhsiah avatar yhsiang avatar yutin1987 avatar

Watchers

 avatar  avatar

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.