501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "node": true,
3 | "esnext": true,
4 | "bitwise": true,
5 | "camelcase": true,
6 | "curly": true,
7 | "eqeqeq": true,
8 | "immed": true,
9 | "indent": 2,
10 | "latedef": true,
11 | "newcap": true,
12 | "noarg": true,
13 | "quotmark": "single",
14 | "undef": true,
15 | "unused": true,
16 | "strict": true
17 | }
18 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - 'iojs'
5 | - '0.12'
6 | - '0.10'
7 |
--------------------------------------------------------------------------------
/.yo-rc.json:
--------------------------------------------------------------------------------
1 | {
2 | "generator-generator": {}
3 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # generator-meteor-react
3 |
4 | > [Yeoman](http://yeoman.io) generator
5 |
6 |
7 | ## Getting Started
8 |
9 | ### What is Yeoman?
10 |
11 | Trick question. It's not a thing. It's this guy:
12 |
13 | 
14 |
15 | Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create.
16 |
17 | Not every new computer comes with a Yeoman pre-installed. He lives in the [npm](https://npmjs.org) package repository. You only have to ask for him once, then he packs up and moves into your hard drive. *Make sure you clean up, he likes new and shiny things.*
18 |
19 | ```bash
20 | npm install -g yo
21 | ```
22 |
23 | ### Yeoman Generators
24 |
25 | Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension.
26 |
27 | To install generator-meteor-react from npm, run:
28 |
29 | ```bash
30 | npm install -g generator-meteor-react
31 | ```
32 |
33 | Finally, initiate the generator:
34 |
35 | ```bash
36 | meteor create myAmazingApp
37 | cd myAmazingApp
38 |
39 | you can delete the default .html, js & css files
40 |
41 | yo meteor-react
42 | sh startup.sh
43 | ```
44 |
45 |
46 |
47 | To add a View:
48 |
49 | ```bash
50 | yo meteor-react:view [yourViewName]
51 | ```
52 |
53 | To add a Collection:
54 |
55 | ```bash
56 | yo meteor-react:collection [yourCollectionName]
57 | ```
58 |
59 | To add a React component:
60 |
61 | ```bash
62 | yo meteor-react:component [yourComponentName]
63 | ```
64 |
65 |
66 | ### Why React components with Meteor?
67 |
68 | Because React.js is cool and worth learning
69 |
70 |
71 | Because it's easier to port a Meteor prototype to an enterprise CMS such as Sitecore, AEM or Backbase using React components.. React.js provides a common separation of the View that can be almost dropped onto another implementation
72 |
73 |
74 | ### Some example React magic comes with the default setup
75 |
76 | You will find a sample component "Topnav" comes with the default setup. This is just to demonstrate how a basic react component is set up and implemented. It's directly wired up to pull from the 'navigation' collection. And is added via the master layout.
77 |
78 |
79 |
80 | ### Getting To Know Yeoman
81 |
82 | Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.
83 |
84 | If you'd like to get to know Yeoman better and meet some of his friends, [Grunt](http://gruntjs.com) and [Bower](http://bower.io), check out the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started).
85 |
86 |
87 | ## License
88 |
89 | MIT
90 | =======
91 | # meteor-react
92 | Yeoman generator for Meteor and React.js views
93 |
--------------------------------------------------------------------------------
/app/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var yeoman = require('yeoman-generator');
3 | var chalk = require('chalk');
4 | var yosay = require('yosay');
5 |
6 | module.exports = yeoman.generators.Base.extend({
7 |
8 | prompting: function () {
9 | var done = this.async();
10 |
11 | // Have Yeoman greet the user.
12 | this.log(yosay(
13 | 'Welcome to the good ' + chalk.red('MeteorReact') + ' generator!'
14 | ));
15 |
16 | var prompts = [{
17 | type: 'confirm',
18 | name: 'someOption',
19 | message: 'Would you like to enable this option?',
20 | default: true
21 | }];
22 |
23 | this.prompt(prompts, function (props) {
24 | this.someOption = props.someOption;
25 |
26 | done();
27 | }.bind(this));
28 | },
29 |
30 | writing: {
31 | app: function () {
32 | this.mkdir("config");
33 | this.mkdir("client");
34 | this.mkdir("client/lib");
35 | this.mkdir("client/lib/layout");
36 | this.mkdir("client/lib/meteor");
37 | this.mkdir("client/lib/compatibility");
38 | this.mkdir("client/lib/meteor");
39 | this.mkdir("client/views");
40 | this.mkdir("client/views/404");
41 | this.mkdir("client/views/loading");
42 | this.mkdir("client/views/home");
43 | this.mkdir("client/views/about");
44 | this.mkdir("client/components");
45 | this.mkdir("client/components/topnav");
46 | this.mkdir("collections");
47 | this.mkdir("collections/modals");
48 | this.mkdir("server");
49 | this.mkdir("server/lib");
50 | this.mkdir("server/modules");
51 | this.mkdir("server/publish");
52 | },
53 |
54 | projectfiles: function () {
55 | this.copy('startup.sh', 'startup.sh');
56 | this.copy('config/settings.json', 'config/settings.json');
57 | this.copy('client/lib/layout/layoutFull.html', 'client/lib/layout/layoutFull.html');
58 | this.copy('client/lib/meteor/router.coffee', 'client/lib/meteor/router.coffee');
59 | this.copy('client/lib/meteor/security.coffee', 'client/lib/meteor/security.coffee');
60 | this.copy('client/lib/meteor/startup.coffee', 'client/lib/meteor/startup.coffee');
61 | this.copy('client/views/404/404.html', 'client/views/404/404.html');
62 | this.copy('client/views/loading/loading.html', 'client/views/loading/loading.html');
63 | this.copy('client/views/loading/loading.styl', 'client/views/loading/loading.styl');
64 | this.copy('client/views/home/home.coffee', 'client/views/home/home.coffee');
65 | this.copy('client/views/home/home.html', 'client/views/home/home.html');
66 | this.copy('client/views/home/home.styl', 'client/views/home/home.styl');
67 | this.copy('client/views/about/about.coffee', 'client/views/about/about.coffee');
68 | this.copy('client/views/about/about.html', 'client/views/about/about.html');
69 | this.copy('client/views/about/about.styl', 'client/views/about/about.styl');
70 | this.copy('collections/modals/navigation.js', 'collections/modals/navigation.js');
71 | this.copy('server/lib/startup.coffee', 'server/lib/startup.coffee');
72 | this.copy('server/publish/navigation.js', 'server/publish/navigation.js');
73 | this.copy('components/topnav/topnav.jsx', 'components/topnav/topnav.jsx');
74 | },
75 |
76 | mainFile: function(){
77 | var context = {
78 | title: "some test",
79 | id: this._.classify("Demo Section")
80 | }
81 |
82 |
83 | this.fs.copyTpl(
84 | this.templatePath('_main.html'),
85 | this.destinationPath('main.html'),
86 | {title: 'Some Great Application'}
87 | );
88 |
89 | },
90 |
91 | standardPackages: function(){
92 | var packages = [
93 | 'meteor-platform',
94 | 'coffeescript',
95 | 'underscore',
96 | 'iron:router',
97 | 'http',
98 | 'sacha:spin',
99 | 'stylus',
100 | 'raix:handlebar-helpers',
101 | 'alanning:roles',
102 | 'momentjs:moment',
103 | 'random',
104 | 'zimme:iron-router-active',
105 | 'aslagle:reactive-table',
106 | 'semantic:ui-css',
107 | 'reactjs:react'
108 | ];
109 |
110 | this.write('.meteor/packages', packages.join('\n'));
111 | }
112 | },
113 |
114 | end: function() {
115 | this.log('\nYeehaw! All went well!\n\nStart your Meteor app on the command line with:\n'+
116 | chalk.green('meteor')+'\n\n');
117 | }
118 | });
119 |
--------------------------------------------------------------------------------
/app/templates/_main.html:
--------------------------------------------------------------------------------
1 |
2 | <%= title %>
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/templates/client/lib/layout/layoutFull.html:
--------------------------------------------------------------------------------
1 |
2 | {{> Topnav}}
3 |
4 | {{> yield}}
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/templates/client/lib/meteor/router.coffee:
--------------------------------------------------------------------------------
1 | if Meteor.isClient
2 |
3 | Router.configure
4 | notFoundTemplate: '404'
5 | layoutTemplate: 'layoutFull'
6 | loadingTemplate: 'loading'
7 |
8 |
9 | Router.onBeforeAction ->
10 | $('body').scrollTop 0 #scroll to the top of the page on route
11 | this.next()
12 | return
13 |
14 |
--------------------------------------------------------------------------------
/app/templates/client/lib/meteor/security.coffee:
--------------------------------------------------------------------------------
1 | ###
2 | Filters are used in every controller to manage which roles have access to the route.
3 | Security can and should also be controlled in server publish
4 | ###
5 |
6 | filters =
7 | security_isUser: ->
8 | #check for a user
9 | if !Meteor.loggingIn() && !Meteor.user() #make sure we have a valid user
10 | Router.go('home') #go back home if we have a problem
11 | else
12 | this.next()
13 | return
14 |
15 | security_isAdmin: ->
16 | #check for an admin role
17 | if Meteor.user()
18 | if !Roles.userIsInRole Meteor.user()._id, ['admin']
19 | console.log "Security: No access..."
20 | Router.go('home') #go back home if we have a problem
21 | else
22 | this.next()
23 | return
24 |
25 |
26 | security_isContent: ->
27 | #chck for a content role... maybe you require a content administrator? :)
28 | if Meteor.user()
29 | if !Roles.userIsInRole Meteor.user()._id, ['content']
30 | console.log "Security: No access..."
31 | Router.go('home') #go back home if we have a problem
32 | else
33 | this.next()
34 | return
35 |
36 | @filters = filters #make global var
37 |
--------------------------------------------------------------------------------
/app/templates/client/lib/meteor/startup.coffee:
--------------------------------------------------------------------------------
1 | if Meteor.isClient
2 |
3 | Meteor.startup ->
4 | console.log "Start up client.."
5 |
6 | return
--------------------------------------------------------------------------------
/app/templates/client/views/404/404.html:
--------------------------------------------------------------------------------
1 |
2 |