Giter VIP home page Giter VIP logo

tedxkaset's Introduction

tedxkaset

Installation

  • using node v.6
  • run command npm install or yarn to install packages
  • add config to your .env file
COOKIE_SECRET=
CLOUDINARY_URL=
MANDRILL_API_KEY=
MONGO_URI=

Development

  • run command node keystone or yarn start to start project. TEDxKasetsartU website should open in http://localhost:3000.

App wide constants

Write your app wide constants in /constants.js for easy use across the app.

var consts = require('../constants.js');
console.log(consts.locales);

Internationalization (i18n)

There's couple of gotchas with the internationalization of TEDxKasetsartU website.

Configuration

Used locales and e.g. name of the cookie containing locale are stored in constants.js.

Static translations

Locale files are located in locales/. They're somewhat autogenerated so don't touch anything else than the translated string values.

.jade templates

Use __('view_id_here.string_id_here') for all hard coded strings. See templates/views/index.jade for further reference.

Example:

p
  | !{__('index.new_website', {keystoneLink: '<a href="http://keystonejs.com" target="_blank">KeystoneJS</a>'})}

Dynamic content translations

Creating and using translatable fields for dynamic content is possible with createField, combineFields and getField.

Models
var keystone = require('keystone');
const { createField, combineFields } = require('keystone-translated-fields');

const locales = require('../constants').locales;
const Types = keystone.Field.Types;

const Speaker = new keystone.List('Speaker', {
	map: {
		name: 'title',
	},
	singular: 'Speaker',
	plural: 'Speakers',
	autokey: {
		path: 'slug',
		from: 'title',
		unique: true,
	},
});

Speaker.add(combineFields([
	{ title: { type: String, required: true } },
	{ name: { type: String } },
	{ desc: { type: Types.Html, wysiwyg: true, height: 300 } },
	{ image: { type: Types.CloudinaryImage } },
	createField('about', { type: String }, locales),
]));

Speaker.register();
Templates
h3 #{getField(speaker, 'title', locale)}
if speaker.desc
	!= speaker.desc
p #{getField(speaker, 'about', locale)}

Contribution

Follow git flow.

tedxkaset's People

Contributors

baivarn-tjr avatar eveem avatar komkanit avatar mameaw14 avatar stapy127 avatar vaaralav avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tedxkaset's Issues

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.