Repository: edshadi/relax Branch: master Commit: 04620b4323b7 Files: 798 Total size: 1.2 MB Directory structure: gitextract_vwl5em8h/ ├── .eslintrc ├── .gitignore ├── .npmignore ├── .relaxrc.sample ├── LICENSE ├── README.md ├── ROADMAP.md ├── app.js ├── assets/ │ └── fonts/ │ └── FontAwesome.otf ├── config.js ├── lib/ │ ├── client/ │ │ ├── admin.js │ │ ├── auth.js │ │ ├── helpers/ │ │ │ └── render-routes.js │ │ └── public.js │ ├── server/ │ │ ├── graphql/ │ │ │ ├── authorize.js │ │ │ ├── mutations/ │ │ │ │ ├── color/ │ │ │ │ │ ├── add.js │ │ │ │ │ ├── duplicate.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── remove.js │ │ │ │ │ └── update.js │ │ │ │ ├── draft/ │ │ │ │ │ ├── drop.js │ │ │ │ │ ├── index.js │ │ │ │ │ └── update.js │ │ │ │ ├── fonts/ │ │ │ │ │ ├── index.js │ │ │ │ │ ├── remove-custom.js │ │ │ │ │ ├── submit-custom.js │ │ │ │ │ └── upload.js │ │ │ │ ├── index.js │ │ │ │ ├── media/ │ │ │ │ │ ├── add.js │ │ │ │ │ ├── index.js │ │ │ │ │ └── remove.js │ │ │ │ ├── menu/ │ │ │ │ │ ├── add.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── remove.js │ │ │ │ │ └── update.js │ │ │ │ ├── page/ │ │ │ │ │ ├── add.js │ │ │ │ │ ├── duplicate.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── remove.js │ │ │ │ │ ├── restore.js │ │ │ │ │ └── update.js │ │ │ │ ├── schema-entry/ │ │ │ │ │ ├── add.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── remove.js │ │ │ │ │ ├── restore.js │ │ │ │ │ └── update.js │ │ │ │ ├── schemas/ │ │ │ │ │ ├── add.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── remove.js │ │ │ │ │ ├── restore.js │ │ │ │ │ └── update.js │ │ │ │ ├── settings/ │ │ │ │ │ ├── index.js │ │ │ │ │ └── save.js │ │ │ │ ├── style/ │ │ │ │ │ ├── add.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── parsable-fields.js │ │ │ │ │ ├── remove.js │ │ │ │ │ └── update.js │ │ │ │ ├── symbol/ │ │ │ │ │ ├── add.js │ │ │ │ │ └── index.js │ │ │ │ ├── tab/ │ │ │ │ │ ├── add.js │ │ │ │ │ ├── index.js │ │ │ │ │ └── remove.js │ │ │ │ └── user/ │ │ │ │ ├── add.js │ │ │ │ ├── index.js │ │ │ │ └── remove.js │ │ │ ├── queries/ │ │ │ │ ├── color/ │ │ │ │ │ ├── colors.js │ │ │ │ │ └── index.js │ │ │ │ ├── draft/ │ │ │ │ │ ├── draft.js │ │ │ │ │ └── index.js │ │ │ │ ├── generators/ │ │ │ │ │ ├── schema-list-count.js │ │ │ │ │ └── schema-list.js │ │ │ │ ├── index.js │ │ │ │ ├── media/ │ │ │ │ │ ├── index.js │ │ │ │ │ ├── media-count.js │ │ │ │ │ └── media.js │ │ │ │ ├── menu/ │ │ │ │ │ ├── index.js │ │ │ │ │ ├── menu.js │ │ │ │ │ ├── menus-count.js │ │ │ │ │ └── menus.js │ │ │ │ ├── page/ │ │ │ │ │ ├── index.js │ │ │ │ │ ├── page.js │ │ │ │ │ ├── pages-count.js │ │ │ │ │ └── pages.js │ │ │ │ ├── revision/ │ │ │ │ │ ├── index.js │ │ │ │ │ └── revisions.js │ │ │ │ ├── schema-entry/ │ │ │ │ │ ├── index.js │ │ │ │ │ ├── schema-entry.js │ │ │ │ │ ├── schema-list-count.js │ │ │ │ │ └── schema-list.js │ │ │ │ ├── schemas/ │ │ │ │ │ ├── index.js │ │ │ │ │ ├── schema.js │ │ │ │ │ ├── schemas-count.js │ │ │ │ │ └── schemas.js │ │ │ │ ├── settings/ │ │ │ │ │ ├── index.js │ │ │ │ │ └── settings.js │ │ │ │ ├── style/ │ │ │ │ │ ├── index.js │ │ │ │ │ └── styles.js │ │ │ │ ├── symbol/ │ │ │ │ │ ├── index.js │ │ │ │ │ ├── symbol.js │ │ │ │ │ └── symbols.js │ │ │ │ ├── tab/ │ │ │ │ │ ├── index.js │ │ │ │ │ └── tabs.js │ │ │ │ └── user/ │ │ │ │ ├── index.js │ │ │ │ ├── session.js │ │ │ │ ├── user.js │ │ │ │ ├── users-count.js │ │ │ │ └── users.js │ │ │ ├── query-pagination.js │ │ │ └── types/ │ │ │ ├── color-input.js │ │ │ ├── color.js │ │ │ ├── count.js │ │ │ ├── custom-font.js │ │ │ ├── draft-id-input.js │ │ │ ├── draft-id.js │ │ │ ├── draft-input.js │ │ │ ├── draft.js │ │ │ ├── filter.js │ │ │ ├── generators/ │ │ │ │ ├── schema-entry-input.js │ │ │ │ └── schema-entry.js │ │ │ ├── media-input.js │ │ │ ├── media.js │ │ │ ├── menu-data.js │ │ │ ├── menu-input.js │ │ │ ├── menu.js │ │ │ ├── page-input.js │ │ │ ├── page.js │ │ │ ├── revision.js │ │ │ ├── schema-entry-input.js │ │ │ ├── schema-entry.js │ │ │ ├── schema-input.js │ │ │ ├── schema.js │ │ │ ├── setting-input.js │ │ │ ├── setting.js │ │ │ ├── style-input.js │ │ │ ├── style.js │ │ │ ├── symbol-input.js │ │ │ ├── symbol.js │ │ │ ├── tab-item.js │ │ │ ├── tab.js │ │ │ ├── uploaded-input.js │ │ │ ├── uploaded.js │ │ │ ├── user-input.js │ │ │ └── user.js │ │ ├── index.js │ │ ├── logger.js │ │ ├── middleware/ │ │ │ ├── fonts.js │ │ │ ├── google-analytics.js │ │ │ └── index.js │ │ ├── migrate.js │ │ ├── models/ │ │ │ ├── color.js │ │ │ ├── draft.js │ │ │ ├── index.js │ │ │ ├── media.js │ │ │ ├── menu.js │ │ │ ├── migration.js │ │ │ ├── page.js │ │ │ ├── revision.js │ │ │ ├── schema-entry.js │ │ │ ├── schema.js │ │ │ ├── setting.js │ │ │ ├── style.js │ │ │ ├── symbol.js │ │ │ ├── tab.js │ │ │ └── user.js │ │ ├── routers/ │ │ │ ├── admin.js │ │ │ ├── auth.js │ │ │ ├── index.js │ │ │ └── public.js │ │ ├── schema.js │ │ └── shared/ │ │ ├── components/ │ │ │ └── html.jsx │ │ └── helpers/ │ │ ├── create-image-thumbnail.js │ │ ├── default-favicon.js │ │ ├── file-mimetype.js │ │ ├── get-markup.js │ │ ├── get-projection.js │ │ ├── get-unique-slug.js │ │ ├── resize-image.js │ │ ├── route-handler.js │ │ ├── safe-html-string.js │ │ └── write-file.js │ └── shared/ │ ├── actions/ │ │ ├── admin-menu.js │ │ ├── colors.js │ │ ├── display.js │ │ ├── dnd.js │ │ ├── draft.js │ │ ├── elements.js │ │ ├── fonts.js │ │ ├── graphql.js │ │ ├── index.js │ │ ├── media.js │ │ ├── menu.js │ │ ├── page-builder.js │ │ ├── page.js │ │ ├── revisions.js │ │ ├── schema-entry.js │ │ ├── schema-list.js │ │ ├── schema.js │ │ ├── schemas.js │ │ ├── session.js │ │ ├── settings.js │ │ ├── styles.js │ │ ├── symbols.js │ │ ├── tabs.js │ │ └── users.js │ ├── components/ │ │ ├── a.jsx │ │ ├── animate-props.jsx │ │ ├── animate.jsx │ │ ├── background-image.jsx │ │ ├── button/ │ │ │ ├── index.jsx │ │ │ └── index.less │ │ ├── component.jsx │ │ ├── dnd/ │ │ │ ├── draggable/ │ │ │ │ ├── draggable.jsx │ │ │ │ └── index.js │ │ │ ├── dragger/ │ │ │ │ ├── dragger.jsx │ │ │ │ ├── dragger.less │ │ │ │ └── index.js │ │ │ └── droppable/ │ │ │ ├── add-ballon.jsx │ │ │ ├── add-ballon.less │ │ │ ├── droppable.jsx │ │ │ ├── droppable.less │ │ │ ├── index.js │ │ │ ├── marker.jsx │ │ │ └── marker.less │ │ ├── image.jsx │ │ ├── medium-editor/ │ │ │ ├── index.jsx │ │ │ └── index.less │ │ └── portal.jsx │ ├── decorators/ │ │ ├── bind.js │ │ ├── debounce.js │ │ └── query-props.jsx │ ├── elements/ │ │ ├── button/ │ │ │ ├── classes.js │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ ├── settings.js │ │ │ └── style.js │ │ ├── column/ │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ └── settings.js │ │ ├── columns/ │ │ │ ├── classes.js │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ └── settings.js │ │ ├── component.jsx │ │ ├── container/ │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ ├── settings.js │ │ │ └── style.js │ │ ├── counter/ │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ └── settings.js │ │ ├── date/ │ │ │ ├── index.jsx │ │ │ ├── props-schema.jsx │ │ │ └── settings.js │ │ ├── dynamic-list/ │ │ │ ├── classes.js │ │ │ ├── container.jsx │ │ │ ├── index.jsx │ │ │ ├── list.jsx │ │ │ ├── props-schema.js │ │ │ └── settings.js │ │ ├── element/ │ │ │ ├── context-menu/ │ │ │ │ ├── context-menu.jsx │ │ │ │ ├── context-menu.less │ │ │ │ └── index.js │ │ │ ├── element.jsx │ │ │ ├── empty.jsx │ │ │ ├── empty.less │ │ │ ├── highlight.jsx │ │ │ ├── highlight.less │ │ │ └── index.js │ │ ├── form/ │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ └── settings.js │ │ ├── gap/ │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ └── settings.js │ │ ├── google-maps/ │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ └── settings.js │ │ ├── icon/ │ │ │ ├── classes.js │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ ├── settings.js │ │ │ └── style.js │ │ ├── image/ │ │ │ ├── classes.js │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ └── settings.js │ │ ├── index.js │ │ ├── line-divider/ │ │ │ ├── classes.js │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ ├── settings.js │ │ │ └── style.js │ │ ├── menu/ │ │ │ ├── classes.js │ │ │ ├── entry.jsx │ │ │ ├── index.jsx │ │ │ ├── menu.jsx │ │ │ ├── props-schema.js │ │ │ ├── settings.js │ │ │ └── style.js │ │ ├── music-player/ │ │ │ ├── classes.js │ │ │ ├── container.jsx │ │ │ ├── index.jsx │ │ │ ├── player.jsx │ │ │ ├── props-schema.js │ │ │ ├── settings.js │ │ │ └── style.js │ │ ├── section/ │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ ├── settings.js │ │ │ └── style.js │ │ ├── symbol/ │ │ │ ├── classes.js │ │ │ ├── container.jsx │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ └── settings.js │ │ ├── text-box/ │ │ │ ├── classes.js │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ ├── settings.js │ │ │ └── style.js │ │ ├── text-input/ │ │ │ ├── classes.js │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ ├── settings.js │ │ │ └── style.js │ │ ├── textarea/ │ │ │ ├── classes.js │ │ │ ├── index.jsx │ │ │ ├── props-schema.js │ │ │ └── settings.js │ │ └── video/ │ │ ├── index.jsx │ │ ├── props-schema.js │ │ └── settings.js │ ├── helpers/ │ │ ├── colors.js │ │ ├── configure-store.js │ │ ├── data-types/ │ │ │ ├── index.js │ │ │ └── native.js │ │ ├── displays.js │ │ ├── ga-send.js │ │ ├── get-element-position.js │ │ ├── get-element-props.js │ │ ├── get-element-style-values.js │ │ ├── get-gravatar-image.js │ │ ├── icons.js │ │ ├── load-fonts.js │ │ ├── mime-types.js │ │ ├── parse-fields.js │ │ ├── parse-settings.js │ │ ├── request.js │ │ ├── schema-filter-default-options.js │ │ ├── schema-link-actions.js │ │ ├── schema-static-properties.js │ │ ├── stringify-fields.js │ │ ├── styles-manager.js │ │ ├── stylesheet.js │ │ └── utils.js │ ├── reducers/ │ │ ├── admin-menu.js │ │ ├── display.js │ │ ├── dnd.js │ │ ├── fonts.js │ │ ├── index.js │ │ ├── media.js │ │ ├── menu.js │ │ ├── page-builder-actions/ │ │ │ ├── add.js │ │ │ ├── change-animation.js │ │ │ ├── change-children.js │ │ │ ├── change-content.js │ │ │ ├── change-display.js │ │ │ ├── change-label.js │ │ │ ├── change-position.js │ │ │ ├── change-prop.js │ │ │ ├── change-style.js │ │ │ ├── duplicate.js │ │ │ ├── element-add-schema-link.js │ │ │ ├── element-change-schema-link-action.js │ │ │ ├── element-remove-schema-link.js │ │ │ ├── helpers/ │ │ │ │ ├── clone-children.js │ │ │ │ ├── get-id.js │ │ │ │ └── remove-children.js │ │ │ ├── index.js │ │ │ ├── make-dynamic.js │ │ │ ├── move.js │ │ │ ├── new.js │ │ │ └── remove.js │ │ ├── page-builder.js │ │ ├── revisions.js │ │ ├── schema-entry.js │ │ ├── schema.js │ │ ├── session.js │ │ ├── settings.js │ │ ├── styles.js │ │ └── symbols.js │ ├── routers/ │ │ ├── admin.js │ │ ├── auth.js │ │ └── public.js │ ├── screens/ │ │ ├── admin/ │ │ │ ├── components/ │ │ │ │ ├── admin/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── loading/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── menu/ │ │ │ │ │ ├── content-types.jsx │ │ │ │ │ ├── content-types.less │ │ │ │ │ ├── index.js │ │ │ │ │ ├── menu.jsx │ │ │ │ │ ├── menu.less │ │ │ │ │ ├── user.jsx │ │ │ │ │ └── user.less │ │ │ │ └── top-bar/ │ │ │ │ ├── actions/ │ │ │ │ │ ├── actions.jsx │ │ │ │ │ ├── actions.less │ │ │ │ │ ├── back.jsx │ │ │ │ │ ├── back.less │ │ │ │ │ ├── display.jsx │ │ │ │ │ ├── display.less │ │ │ │ │ ├── displays.jsx │ │ │ │ │ ├── displays.less │ │ │ │ │ ├── index.js │ │ │ │ │ ├── right-menu.jsx │ │ │ │ │ ├── right-menu.less │ │ │ │ │ ├── statuses.jsx │ │ │ │ │ └── statuses.less │ │ │ │ ├── index.jsx │ │ │ │ ├── index.less │ │ │ │ └── tabs/ │ │ │ │ ├── index.js │ │ │ │ ├── tab.jsx │ │ │ │ ├── tab.less │ │ │ │ ├── tabs.jsx │ │ │ │ └── tabs.less │ │ │ ├── index.js │ │ │ ├── screens/ │ │ │ │ ├── colors/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── colors.jsx │ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ │ ├── entry.less │ │ │ │ │ │ └── list.jsx │ │ │ │ │ └── index.js │ │ │ │ ├── fonts/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ │ ├── entry.less │ │ │ │ │ │ ├── fonts.jsx │ │ │ │ │ │ ├── list.jsx │ │ │ │ │ │ ├── manage/ │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ ├── manage.jsx │ │ │ │ │ │ │ └── manage.less │ │ │ │ │ │ ├── preview-text.jsx │ │ │ │ │ │ └── preview-text.less │ │ │ │ │ └── index.js │ │ │ │ ├── media/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ │ ├── entry.less │ │ │ │ │ │ ├── list.jsx │ │ │ │ │ │ ├── media.jsx │ │ │ │ │ │ ├── media.less │ │ │ │ │ │ ├── menu.jsx │ │ │ │ │ │ ├── menu.less │ │ │ │ │ │ ├── sorting.jsx │ │ │ │ │ │ ├── sorting.less │ │ │ │ │ │ └── uploading/ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── item.jsx │ │ │ │ │ │ ├── item.less │ │ │ │ │ │ ├── uploading.jsx │ │ │ │ │ │ └── uploading.less │ │ │ │ │ ├── index.js │ │ │ │ │ └── menu.js │ │ │ │ ├── menus/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── content.jsx │ │ │ │ │ │ ├── content.less │ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ │ ├── entry.less │ │ │ │ │ │ ├── list.jsx │ │ │ │ │ │ ├── menu.jsx │ │ │ │ │ │ ├── menu.less │ │ │ │ │ │ └── new/ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ └── new.jsx │ │ │ │ │ ├── index.js │ │ │ │ │ ├── menu.js │ │ │ │ │ └── screens/ │ │ │ │ │ └── menu/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── menu-builder/ │ │ │ │ │ │ │ ├── builder.jsx │ │ │ │ │ │ │ ├── builder.less │ │ │ │ │ │ │ ├── collapsable.jsx │ │ │ │ │ │ │ ├── collapsable.less │ │ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ │ │ ├── entry.less │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ ├── link/ │ │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ │ ├── link.jsx │ │ │ │ │ │ │ │ └── link.less │ │ │ │ │ │ │ ├── menu/ │ │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ │ ├── menu.jsx │ │ │ │ │ │ │ │ └── menu.less │ │ │ │ │ │ │ └── pages/ │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ ├── pages.jsx │ │ │ │ │ │ │ └── pages.less │ │ │ │ │ │ ├── menu.jsx │ │ │ │ │ │ ├── menu.less │ │ │ │ │ │ ├── state.jsx │ │ │ │ │ │ └── state.less │ │ │ │ │ └── index.js │ │ │ │ ├── pages/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ │ ├── entry.less │ │ │ │ │ │ ├── list.jsx │ │ │ │ │ │ ├── menu.jsx │ │ │ │ │ │ ├── menu.less │ │ │ │ │ │ ├── new/ │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ └── new.jsx │ │ │ │ │ │ ├── pages.jsx │ │ │ │ │ │ └── pages.less │ │ │ │ │ ├── index.js │ │ │ │ │ ├── menu.js │ │ │ │ │ └── screens/ │ │ │ │ │ └── page/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── info/ │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ ├── info.jsx │ │ │ │ │ │ │ ├── info.less │ │ │ │ │ │ │ ├── item.jsx │ │ │ │ │ │ │ └── item.less │ │ │ │ │ │ ├── page.jsx │ │ │ │ │ │ ├── page.less │ │ │ │ │ │ └── revisions/ │ │ │ │ │ │ └── index.js │ │ │ │ │ └── index.js │ │ │ │ ├── schemas/ │ │ │ │ │ └── screens/ │ │ │ │ │ ├── new/ │ │ │ │ │ │ ├── components/ │ │ │ │ │ │ │ └── builder/ │ │ │ │ │ │ │ ├── builder.jsx │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ ├── model.jsx │ │ │ │ │ │ │ ├── model.less │ │ │ │ │ │ │ ├── name.jsx │ │ │ │ │ │ │ ├── name.less │ │ │ │ │ │ │ ├── properties/ │ │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ │ ├── properties.jsx │ │ │ │ │ │ │ │ ├── properties.less │ │ │ │ │ │ │ │ ├── property-options.jsx │ │ │ │ │ │ │ │ ├── property-options.less │ │ │ │ │ │ │ │ ├── property.jsx │ │ │ │ │ │ │ │ └── property.less │ │ │ │ │ │ │ ├── type.jsx │ │ │ │ │ │ │ ├── type.less │ │ │ │ │ │ │ ├── types.jsx │ │ │ │ │ │ │ └── types.less │ │ │ │ │ │ └── index.js │ │ │ │ │ └── schema/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ │ ├── entry.less │ │ │ │ │ │ ├── list.jsx │ │ │ │ │ │ ├── menu.jsx │ │ │ │ │ │ ├── menu.less │ │ │ │ │ │ ├── new/ │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ └── new.jsx │ │ │ │ │ │ ├── schema.jsx │ │ │ │ │ │ └── schema.less │ │ │ │ │ ├── index.js │ │ │ │ │ └── menu.js │ │ │ │ ├── settings/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── menu.jsx │ │ │ │ │ │ └── menu.less │ │ │ │ │ ├── menu.js │ │ │ │ │ ├── screens/ │ │ │ │ │ │ ├── analytics/ │ │ │ │ │ │ │ ├── components/ │ │ │ │ │ │ │ │ └── analytics.jsx │ │ │ │ │ │ │ └── index.js │ │ │ │ │ │ ├── data/ │ │ │ │ │ │ │ ├── components/ │ │ │ │ │ │ │ │ └── data.jsx │ │ │ │ │ │ │ └── index.js │ │ │ │ │ │ ├── email/ │ │ │ │ │ │ │ ├── components/ │ │ │ │ │ │ │ │ └── email.jsx │ │ │ │ │ │ │ └── index.js │ │ │ │ │ │ └── general/ │ │ │ │ │ │ ├── components/ │ │ │ │ │ │ │ └── general.jsx │ │ │ │ │ │ └── index.js │ │ │ │ │ └── shared/ │ │ │ │ │ └── components/ │ │ │ │ │ └── settings-content/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ └── users/ │ │ │ │ ├── components/ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ ├── entry.less │ │ │ │ │ ├── list.jsx │ │ │ │ │ ├── new/ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ └── new.jsx │ │ │ │ │ └── users.jsx │ │ │ │ └── index.js │ │ │ └── shared/ │ │ │ ├── components/ │ │ │ │ ├── balloon/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── content/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── content-displays/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── content-header/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── content-header-actions/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── content-loading/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── content-new/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── content-search/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── content-sidebar/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── editable-title/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── input-options/ │ │ │ │ │ ├── border/ │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ └── index.less │ │ │ │ │ ├── border-style/ │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ └── index.less │ │ │ │ │ ├── box-shadow/ │ │ │ │ │ │ ├── edit.jsx │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ ├── index.less │ │ │ │ │ │ ├── shadow.jsx │ │ │ │ │ │ └── shadow.less │ │ │ │ │ ├── button/ │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── checkbox/ │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ └── index.less │ │ │ │ │ ├── color/ │ │ │ │ │ │ ├── color-palette-picker.jsx │ │ │ │ │ │ ├── color-palette-picker.less │ │ │ │ │ │ ├── color-picker.jsx │ │ │ │ │ │ ├── color-picker.less │ │ │ │ │ │ ├── color.jsx │ │ │ │ │ │ ├── color.less │ │ │ │ │ │ ├── colors-collection.jsx │ │ │ │ │ │ ├── colors-collection.less │ │ │ │ │ │ ├── edit.jsx │ │ │ │ │ │ ├── edit.less │ │ │ │ │ │ ├── gradient-points.jsx │ │ │ │ │ │ ├── gradient-points.less │ │ │ │ │ │ ├── hue.jsx │ │ │ │ │ │ ├── hue.less │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── input.jsx │ │ │ │ │ │ ├── input.less │ │ │ │ │ │ ├── inputs.jsx │ │ │ │ │ │ ├── inputs.less │ │ │ │ │ │ ├── linear-gradient.jsx │ │ │ │ │ │ ├── linear-gradient.less │ │ │ │ │ │ ├── opacity.jsx │ │ │ │ │ │ ├── opacity.less │ │ │ │ │ │ ├── radial-gradient.jsx │ │ │ │ │ │ ├── radial-gradient.less │ │ │ │ │ │ ├── radial-radius.jsx │ │ │ │ │ │ ├── radial-radius.less │ │ │ │ │ │ ├── sat-light.jsx │ │ │ │ │ │ ├── sat-light.less │ │ │ │ │ │ ├── types.jsx │ │ │ │ │ │ └── types.less │ │ │ │ │ ├── columns/ │ │ │ │ │ │ ├── column.jsx │ │ │ │ │ │ ├── column.less │ │ │ │ │ │ ├── columns-manager.jsx │ │ │ │ │ │ ├── columns-manager.less │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── combobox/ │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ └── index.less │ │ │ │ │ ├── corners/ │ │ │ │ │ │ └── index.jsx │ │ │ │ │ ├── filters/ │ │ │ │ │ │ ├── edit.jsx │ │ │ │ │ │ ├── filter.jsx │ │ │ │ │ │ ├── filters.jsx │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── font/ │ │ │ │ │ │ ├── dropdown.jsx │ │ │ │ │ │ ├── dropdown.less │ │ │ │ │ │ ├── font-picker.jsx │ │ │ │ │ │ ├── font-picker.less │ │ │ │ │ │ ├── font.jsx │ │ │ │ │ │ ├── font.less │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── icon/ │ │ │ │ │ │ ├── icon-picker.jsx │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── image/ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── picker.jsx │ │ │ │ │ │ └── picker.less │ │ │ │ │ ├── input/ │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ └── index.less │ │ │ │ │ ├── menu/ │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── number/ │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ └── index.less │ │ │ │ │ ├── optional/ │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ └── index.less │ │ │ │ │ ├── page/ │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── rich-text/ │ │ │ │ │ │ └── index.jsx │ │ │ │ │ ├── schema/ │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── section/ │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ └── index.less │ │ │ │ │ ├── shadow-position/ │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ └── index.less │ │ │ │ │ ├── sorts/ │ │ │ │ │ │ ├── edit.jsx │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── sort.jsx │ │ │ │ │ │ └── sorts.jsx │ │ │ │ │ ├── spacing/ │ │ │ │ │ │ ├── index.jsx │ │ │ │ │ │ └── index.less │ │ │ │ │ └── text-shadow/ │ │ │ │ │ ├── edit.jsx │ │ │ │ │ ├── index.jsx │ │ │ │ │ ├── index.less │ │ │ │ │ ├── shadow.jsx │ │ │ │ │ └── shadow.less │ │ │ │ ├── list-header/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── list-search-sort/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── media-item-preview/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── media-selector/ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ ├── entry.less │ │ │ │ │ ├── filters.jsx │ │ │ │ │ ├── filters.less │ │ │ │ │ ├── index.js │ │ │ │ │ ├── list.jsx │ │ │ │ │ ├── list.less │ │ │ │ │ ├── media-selector.jsx │ │ │ │ │ ├── media-selector.less │ │ │ │ │ ├── mock-entry.jsx │ │ │ │ │ ├── mock-entry.less │ │ │ │ │ ├── selected/ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── selected.jsx │ │ │ │ │ │ └── selected.less │ │ │ │ │ ├── sidebar.jsx │ │ │ │ │ ├── sidebar.less │ │ │ │ │ ├── top-bar.jsx │ │ │ │ │ └── top-bar.less │ │ │ │ ├── menu-button/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── menu-sub-button/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── modal/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── modal-delete/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── modal-input/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── modal-new/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── options-list/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── options-menu/ │ │ │ │ │ └── index.jsx │ │ │ │ ├── page-builder/ │ │ │ │ │ ├── canvas/ │ │ │ │ │ │ ├── canvas.jsx │ │ │ │ │ │ ├── canvas.less │ │ │ │ │ │ ├── empty.jsx │ │ │ │ │ │ ├── empty.less │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── elements-menu/ │ │ │ │ │ │ ├── autocomplete.jsx │ │ │ │ │ │ ├── autocomplete.less │ │ │ │ │ │ ├── elements-menu.jsx │ │ │ │ │ │ ├── elements-menu.less │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── list.jsx │ │ │ │ │ │ ├── list.less │ │ │ │ │ │ ├── search.jsx │ │ │ │ │ │ └── search.less │ │ │ │ │ ├── index.js │ │ │ │ │ ├── page-builder.jsx │ │ │ │ │ └── page-builder.less │ │ │ │ ├── page-builder-menu/ │ │ │ │ │ ├── breadcrumbs/ │ │ │ │ │ │ ├── breadcrumbs.jsx │ │ │ │ │ │ ├── breadcrumbs.less │ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ │ ├── entry.less │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── menu.jsx │ │ │ │ │ ├── menu.less │ │ │ │ │ └── tabs/ │ │ │ │ │ ├── index.js │ │ │ │ │ ├── layers/ │ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ │ ├── entry.less │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── layers.jsx │ │ │ │ │ │ └── layers.less │ │ │ │ │ ├── settings/ │ │ │ │ │ │ ├── animation.jsx │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── position.jsx │ │ │ │ │ │ ├── props.jsx │ │ │ │ │ │ ├── props.less │ │ │ │ │ │ ├── settings.jsx │ │ │ │ │ │ └── settings.less │ │ │ │ │ ├── style/ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── style-picker/ │ │ │ │ │ │ │ ├── edit.jsx │ │ │ │ │ │ │ ├── edit.less │ │ │ │ │ │ │ ├── entry.jsx │ │ │ │ │ │ │ ├── entry.less │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ ├── style-picker.jsx │ │ │ │ │ │ │ └── style-picker.less │ │ │ │ │ │ ├── style.jsx │ │ │ │ │ │ └── style.less │ │ │ │ │ ├── tab-button.jsx │ │ │ │ │ ├── tab-button.less │ │ │ │ │ ├── tabs.jsx │ │ │ │ │ └── tabs.less │ │ │ │ ├── scrollable/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── spinner/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ ├── stick/ │ │ │ │ │ ├── index.jsx │ │ │ │ │ └── index.less │ │ │ │ └── upload/ │ │ │ │ ├── index.jsx │ │ │ │ └── index.less │ │ │ └── helpers/ │ │ │ └── input-options-map.js │ │ └── auth/ │ │ ├── components/ │ │ │ └── logo/ │ │ │ ├── index.jsx │ │ │ └── index.less │ │ ├── index.css │ │ ├── index.jsx │ │ ├── screens/ │ │ │ ├── init/ │ │ │ │ ├── components/ │ │ │ │ │ └── init.jsx │ │ │ │ └── index.js │ │ │ └── login/ │ │ │ ├── components/ │ │ │ │ └── login.jsx │ │ │ └── index.js │ │ └── shared/ │ │ └── styles/ │ │ └── auth.less │ └── styles/ │ ├── colors.less │ ├── element.less │ ├── normalize.less │ ├── nucleo/ │ │ ├── index.less │ │ ├── mini/ │ │ │ └── less/ │ │ │ ├── icons.less │ │ │ ├── mixins.less │ │ │ ├── nucleo-mini.less │ │ │ └── variables.less │ │ └── outline/ │ │ └── less/ │ │ ├── icons.less │ │ ├── mixins.less │ │ ├── nucleo-outline.less │ │ └── variables.less │ └── sizes.less ├── migrations/ │ └── .gitempty ├── package.json ├── uploads/ │ └── .gitignore └── webpack/ ├── webpack.browser.config.js └── webpack.node.config.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintrc ================================================ { "extends": "airbnb", "parser": "babel-eslint", "rules": { "object-curly-spacing": [2, "never"], "space-before-function-paren": [2, "always"], "comma-dangle": [2, "never"], 'max-len': [1, 115, 2, { 'ignoreUrls': true, 'ignoreComments': false }], "no-unused-expressions": [2, { allowShortCircuit: true }], "no-use-before-define": [2, { "functions": false, "classes": true }], "no-param-reassign": [2, {"props": false}], 'react/prefer-stateless-function': 0, "consistent-return": 0, new-cap: [2, {"capIsNewExceptions": ["ObjectId"]}], "jsx-quotes": 0, 'react/jsx-no-bind': [2, { 'ignoreRefs': true, 'allowArrowFunctions': false, 'allowBind': false, }], "react/sort-comp": [2, { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md "order": [ 'lifecycle', 'everything-else', 'renderstuff' ], "groups": { lifecycle: [ "displayName", "fragments", "panelSettings", "propTypes", "contextTypes", "childContextTypes", "mixins", "statics", "defaultProps", "defaultChildren", "propsSchema", "settings", "style", "constructor", "getDefaultProps", "getInitState", "getChildContext", "componentWillMount", "componentDidMount", "componentWillReceiveProps", "shouldComponentUpdate", "componentWillUpdate", "componentDidUpdate", "componentWillUnmount" ], renderstuff: [ "render", "/^render.+$/" ] } }] } } ================================================ FILE: .gitignore ================================================ # Config .relaxrc # Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Compiled binary addons (http://nodejs.org/api/addons.html) build build/Release # Dependency directory # Commenting this out is preferred by some people, see # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules #Webstorm Config .idea # Users Environment Variables .lock-wscript /public/ dist/ ================================================ FILE: .npmignore ================================================ .relaxrc lib/ uploads/ build/ package.json.tmp ================================================ FILE: .relaxrc.sample ================================================ { "port": 8080, "devPort": 8181, "db": { "uri": "mongodb://localhost/relax" } } ================================================ FILE: LICENSE ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: README.md ================================================ ![Relax CMS](https://raw.githubusercontent.com/relax/relax/gh-pages/assets/images/logo_small.png "Relax logo") ==================================== [![Slack Status](http://slack-relax.herokuapp.com/badge.svg)](http://slack-relax.herokuapp.com/) **IMPORTANT NOTE:** Relax isn't yet ready for production, stay tuned for releases, beta version will come soon Support our work and help us make this the best open source CMS, be our [patreon](http://patreon.com/relax)! Relax is a powerful new generation CMS on top of [React](https://facebook.github.io/react/) and [Node.js](https://nodejs.org/en/) which aims for a better way of building websites. It features a live page builder based on components and a smart and easy way of binding dynamic data to them. We're currently working on releasing the beta version which should come up early 2016. If you want to collaborate in the meantime or just say anything join us at [Relax Slack](http://slack-relax.herokuapp.com/) **You can check the demo [here](http://demo.getrelax.io/admin)** Demo credentials: - user: demo - pass: demo New design for beta release ------------ (taken from using version in master branch, demo is outdated as master isn't yet stable) ![Pages](https://raw.githubusercontent.com/relax/relax/gh-pages/assets/images/pages.png) ![Media](https://raw.githubusercontent.com/relax/relax/gh-pages/assets/images/media.png) ![Colors](https://raw.githubusercontent.com/relax/relax/gh-pages/assets/images/colors.png) ![New Schema](https://raw.githubusercontent.com/relax/relax/gh-pages/assets/images/newschema.png) Installation ------------ ### Dependencies Relax uses [sharp](https://github.com/lovell/sharp) to resize images. If you're using OS X, you'll need to install its libvips dependency via `brew install homebrew/science/vips`. Full installation instructions are available [here](http://sharp.dimens.io/en/stable/install/). You'll also need [MongoDB](https://www.mongodb.org/). ### How to Relax Since we are yet to tag our first release, git clone this repository and run `npm install` followed by `npm start`. By default the application runs at port `8080`. Go ahead and visit `http://localhost:8080/admin/init`, here you can setup the first user and you're ready to relax. Configuration ------------- To configure the application you can use a `.relaxrc` file. You can place it next to the application, on any parent folder, in your `HOME` folder, etc. You can find a sample with the default values [here](.relaxrc.sample). Contributing ------------ ### Build and start #### Development While in development it's convenient to keep your application running while watching for changes, for that you can run `npm run dev`. The application will automatically restart when needed and keep your bundles up to date. #### Production To build your assets ready to go for production run `npm run build` and `npm start` to start the application. License ------- Relax is [GPL-3 licensed](LICENSE). Troubleshooting --------------- Please create [an issue](https://github.com/relax/relax/issues/new). ================================================ FILE: ROADMAP.md ================================================ Roadmap ======= v1.0.0-Beta (Spring 2016) ------------------------- Since the start of the project we've been through some major refactors in order to achieve the desired stack and experience to finally have a first stable release. We've changed from a RESTful API into a GraphQL API, while also changing the data architecture in the front end to include Redux. Our first dashboard was also not designed at all because our focus was mainly on the page builder. We're now finally tuning up the entire admin experience so that we can make it as relaxed as possible. Below you can find the major things that are still in the road we're going through to reach the beta release, there are of course other minor issues that can be found [here](https://github.com/relax/relax/milestones/1.0.0-Beta). **What must be done:** - [ ] Dashboard (*ongoing*) (#214) - [ ] Settings - [ ] Pages - [ ] Menus - [ ] Schemas - [ ] Fonts - [ ] Users - [ ] Media - [ ] Symbols - [ ] Link Element - [ ] Allow to navigate to another page - [ ] Allow to go an absolute URL - [ ] Allow anchoring (with sections) - [ ] Forms - [ ] Compose e-mail and set where the e-mail should be sent to - [ ] Symbols Management - [x] Manage through context menu (#208) - [ ] Edit symbol content (#209) - [ ] Delete symbol through context menu - [ ] Page Templates (#133) - [ ] Save page as template - [ ] Use template as a schema *single* template - [ ] Use template as a starting point to a page - [ ] Input option types (#158) - [ ] Schema entry *singles* (#127) - [ ] Import/export database - [ ] Export theme (#56) - [ ] Export data - [ ] Export all - [ ] Users - [ ] Recover password - [ ] Change password - [ ] Edit basic info - [ ] Third party elements API (#55) - [ ] Developer API Documentation (#53) **If we have time:** - [ ] Link forms to schemas (#124) - [ ] User account activation - [ ] User roles management - [ ] Schema entry single override template (#128) - [ ] Docker image (#213) There are no optional issues, we really want to have everything as polished as possible for the first release. Feel free to create missing issues or discuss some of the features in the issues section or with us over Slack. All help and feedback is welcome. ================================================ FILE: app.js ================================================ import 'babel-polyfill'; import mongoose from 'mongoose'; import app from './lib/server'; import config from './config'; import logger from './lib/server/logger'; import migrate from './lib/server/migrate'; // Connect mongoose if (!config.db) { throw new Error('Configuration to MongoDB required'); } mongoose.connect(config.db.uri, config.db); // Run migrations migrate() .then(() => { // Start server var server = app.listen(config.port, () => { var port = server.address().port; logger.debug('Listening at port', port); }); }) .done(); ================================================ FILE: config.js ================================================ var rc = require('rc'); module.exports = rc('relax', { port: 8080, devPort: 8181, db: { uri: 'mongodb://localhost/relax' } }); ================================================ FILE: lib/client/admin.js ================================================ import 'babel-polyfill'; import routes from 'routers/admin'; import renderRoutes from './helpers/render-routes'; renderRoutes(routes); ================================================ FILE: lib/client/auth.js ================================================ import routes from 'routers/auth'; import renderRoutes from './helpers/render-routes'; renderRoutes(routes); ================================================ FILE: lib/client/helpers/render-routes.js ================================================ import configureStore from 'helpers/configure-store'; import createHistory from 'history/lib/createBrowserHistory'; import React from 'react'; import {render} from 'react-dom'; import {Provider} from 'react-redux'; import {reduxReactRouter, ReduxRouter} from 'redux-router'; export default function renderRoutes (routes) { const state = window.__initialState; state.router = undefined; const store = configureStore( reduxReactRouter({createHistory, routes}), state ); render( , document.getElementById('view') ); } ================================================ FILE: lib/client/public.js ================================================ import routes from 'routers/public'; import renderRoutes from './helpers/render-routes'; renderRoutes(routes); ================================================ FILE: lib/server/graphql/authorize.js ================================================ export default function authorize (root) { if (!root.user) { throw new Error('Unauthorized'); } } ================================================ FILE: lib/server/graphql/mutations/color/add.js ================================================ import { GraphQLNonNull } from 'graphql'; import authorize from '../../authorize'; import colorInputType from '../../types/color-input'; import colorType from '../../types/color'; import ColorModel from '../../../models/color'; export default { type: colorType, args: { data: { name: 'data', type: new GraphQLNonNull(colorInputType) } }, async resolve (root, params) { authorize(root); const colorModel = new ColorModel(params.data); const color = await colorModel.save(); if (!color) { throw new Error('Error adding new color'); } return color; } }; ================================================ FILE: lib/server/graphql/mutations/color/duplicate.js ================================================ import { GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import colorType from '../../types/color'; import ColorModel from '../../../models/color'; export default { type: colorType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLID) } }, async resolve (root, params) { authorize(root); const colorToDuplicate = await ColorModel.findById(params.id).select('-_id label value').exec(); if (!colorToDuplicate) { throw new Error('Color to duplicate could not be found!'); } const color = new ColorModel(colorToDuplicate.toJSON()); const newColor = await color.save(); if (!newColor) { throw new Error('Error adding new duplicate color'); } return newColor; } }; ================================================ FILE: lib/server/graphql/mutations/color/index.js ================================================ import addColor from './add'; import duplicateColor from './duplicate'; import removeColor from './remove'; import updateColor from './update'; export default { addColor, removeColor, updateColor, duplicateColor }; ================================================ FILE: lib/server/graphql/mutations/color/remove.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import colorType from '../../types/color'; import ColorModel from '../../../models/color'; export default { type: colorType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLID) } }, async resolve (root, params, options) { authorize(root); const removedColor = await ColorModel .findByIdAndRemove(params.id, { select: getProjection(options.fieldASTs[0]) }) .exec(); if (!removedColor) { throw new Error('Color not found'); } return removedColor; } }; ================================================ FILE: lib/server/graphql/mutations/color/update.js ================================================ import { GraphQLNonNull } from 'graphql'; import getProjection from 'helpers/get-projection'; import authorize from '../../authorize'; import colorInputType from '../../types/color-input'; import colorType from '../../types/color'; import ColorModel from '../../../models/color'; export default { type: colorType, args: { data: { name: 'data', type: new GraphQLNonNull(colorInputType) } }, async resolve (root, params, options) { authorize(root); const resultColor = await ColorModel .findByIdAndUpdate(params.data._id, params.data, { upsert: true, new: true, select: getProjection(options.fieldASTs[0]) }) .exec(); if (!resultColor) { throw new Error('Color not found'); } return resultColor; } }; ================================================ FILE: lib/server/graphql/mutations/draft/drop.js ================================================ import { GraphQLNonNull, GraphQLString } from 'graphql'; import {Types} from 'mongoose'; import getProjection from 'helpers/get-projection'; import authorize from '../../authorize'; import draftType from '../../types/draft'; import DraftModel from '../../../models/draft'; import PageModel from '../../../models/page'; export default { type: draftType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLString) } }, async resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const _id = new Types.ObjectId(params.id); const _userId = root.user._id; const page = await PageModel.findById(_id); const data = { data: page.data, actions: [], __v: page.__v }; const resultDraft = await DraftModel .findByIdAndUpdate( {_id, _userId}, data, {upsert: true, new: true} ) .select(projection) .exec(); if (!resultDraft) { throw new Error('Draft not found'); } return resultDraft; } }; ================================================ FILE: lib/server/graphql/mutations/draft/index.js ================================================ import dropDraft from './drop'; import updateDraft from './update'; export default { dropDraft, updateDraft }; ================================================ FILE: lib/server/graphql/mutations/draft/update.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLNonNull, GraphQLID } from 'graphql'; import {Types} from 'mongoose'; import authorize from '../../authorize'; import draftInputType from '../../types/draft-input'; import draftType from '../../types/draft'; import DraftModel from '../../../models/draft'; export default { type: draftType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLID) }, data: { name: 'data', type: new GraphQLNonNull(draftInputType) } }, resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const _id = new Types.ObjectId(params.id); const _userId = root.user._id; const data = Object.assign({}, params.data, { data: JSON.parse(params.data.data), actions: JSON.parse(params.data.actions) }); delete data._id; return DraftModel .findByIdAndUpdate( {_id, _userId}, data, {upsert: true, new: true} ) .select(projection) .exec() .then((resultDraft) => { if (!resultDraft) { throw new Error('Draft not found'); } return resultDraft; }); } }; ================================================ FILE: lib/server/graphql/mutations/fonts/index.js ================================================ import removeCustomFont from './remove-custom'; import submitCustomFont from './submit-custom'; import uploadFont from './upload'; export default { removeCustomFont, submitCustomFont, uploadFont }; ================================================ FILE: lib/server/graphql/mutations/fonts/remove-custom.js ================================================ import path from 'path'; import rmdir from 'rimraf'; import Q from 'q'; import { GraphQLNonNull, GraphQLString, GraphQLObjectType } from 'graphql'; import authorize from '../../authorize'; export default { type: new GraphQLObjectType({ name: 'removeCustomFont', fields: { id: {type: new GraphQLNonNull(GraphQLString)} } }), args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLString) } }, resolve (root, params) { authorize(root); const id = params.id; const fontsFolder = path.join(__dirname, '../../../../..', 'public/fonts', id); return Q .nfcall(rmdir, fontsFolder) .then(() => ({ id })) .catch(() => { throw new Error('Error removing custom fonts folder'); }); } }; ================================================ FILE: lib/server/graphql/mutations/fonts/submit-custom.js ================================================ import forEach from 'lodash.foreach'; import fs from 'fs'; import mkdirp from 'mkdirp'; import mongoose from 'mongoose'; import path from 'path'; import Q from 'q'; import { GraphQLNonNull, GraphQLString, GraphQLList } from 'graphql'; import authorize from '../../authorize'; import customFontType from '../../types/custom-font'; import uploadedInputType from '../../types/uploaded-input'; export default { type: customFontType, args: { name: { name: 'name', type: new GraphQLNonNull(GraphQLString) }, files: { name: 'files', type: new GraphQLNonNull(new GraphQLList(uploadedInputType)) }, types: { name: 'types', type: new GraphQLNonNull(new GraphQLList(GraphQLString)) } }, resolve (root, params) { authorize(root); const files = params.files; const types = params.types; const id = mongoose.Types.ObjectId().toString(); const rootFolder = path.join(__dirname, '../../../../..'); const fontsFolder = path.join(rootFolder, 'public/fonts', id); return Q .nfcall(mkdirp, fontsFolder) .then(() => { const promises = []; forEach(files, (file) => { promises.push( Q.ninvoke( fs, 'rename', path.join(rootFolder, file.path), path.join(fontsFolder, file.originalname) ) ); }); return Q.all(promises); }) .then(() => { // map types to file const map = {}; for (let a = 0; a < files.length; a++) { map[types[a]] = files[a].originalname; } return { family: params.name, id, files: map }; }) .catch(() => { throw new Error('Error submiting custom fonts'); }); } }; ================================================ FILE: lib/server/graphql/mutations/fonts/upload.js ================================================ import authorize from '../../authorize'; import uploadedType from '../../types/uploaded'; export default { type: uploadedType, resolve (root) { authorize(root); return root.file; } }; ================================================ FILE: lib/server/graphql/mutations/index.js ================================================ import color from './color'; import draft from './draft'; import fonts from './fonts'; import media from './media'; import menu from './menu'; import page from './page'; import schema from './schemas'; import schemaEntry from './schema-entry'; import settings from './settings'; import style from './style'; import symbol from './symbol'; import tab from './tab'; import user from './user'; export default { ...color, ...draft, ...fonts, ...media, ...menu, ...page, ...schemaEntry, ...schema, ...settings, ...style, ...symbol, ...tab, ...user }; ================================================ FILE: lib/server/graphql/mutations/media/add.js ================================================ import createImageThumbnail from 'helpers/create-image-thumbnail'; import fileMimetype from 'helpers/file-mimetype'; import filesize from 'file-size'; import mongoose from 'mongoose'; import path from 'path'; import writeFile from 'helpers/write-file'; import { GraphQLNonNull } from 'graphql'; import {getMediaType} from 'helpers/mime-types'; import authorize from '../../authorize'; import mediaInputType from '../../types/media-input'; import mediaType from '../../types/media'; import MediaModel from '../../../models/media'; export default { type: mediaType, args: { data: { name: 'data', type: new GraphQLNonNull(mediaInputType) } }, async resolve (root, params) { authorize(root); const mediaModel = {}; const id = mongoose.Types.ObjectId(); const idStr = id.toString(); let file = params.data.file; const mimetype = fileMimetype(file); const relativePath = path.join('media', idStr); const filePath = path.join('.', 'public', relativePath); file = await writeFile(file, filePath); // Image Upload if (getMediaType(mimetype) === 'image') { const {thumbnailPath, metadata} = await createImageThumbnail( file.destPath, filePath, { width: 100, height: 100, quality: 100 } ); Object.assign(mediaModel, { dimension: { width: metadata.width, height: metadata.height }, thumbnail: path.join(relativePath, thumbnailPath) }); } // Create and save a new `MediaModel` const media = new MediaModel(Object.assign(mediaModel, { _id: id, name: file.filename, fileName: file.filename, type: mimetype, size: filesize(file.size).human(), filesize: file.size, absoluteUrl: file.destPath, url: path.join(relativePath, file.filename) })); const newMedia = await media.save(); if (!newMedia) { throw new Error('Error adding new media'); } return newMedia; } }; ================================================ FILE: lib/server/graphql/mutations/media/index.js ================================================ import addMedia from './add'; import removeMedia, {removeMediaItem} from './remove'; export default { addMedia, removeMedia, removeMediaItem }; ================================================ FILE: lib/server/graphql/mutations/media/remove.js ================================================ import getProjection from 'helpers/get-projection'; import path from 'path'; import rmdir from 'rimraf'; import { GraphQLNonNull, GraphQLID, GraphQLList } from 'graphql'; import {all, nfcall} from 'q'; import authorize from '../../authorize'; import mediaType from '../../types/media'; import MediaModel from '../../../models/media'; const mediaPath = './public/media'; export default { type: new GraphQLList(mediaType), args: { ids: { name: 'ids', type: new GraphQLList(new GraphQLNonNull(GraphQLID)) } }, async resolve (root, params) { authorize(root); const {ids} = params; const promises = []; ids.forEach((id) => { if (id) { promises.push(nfcall(rmdir, path.join(mediaPath, id))); } }); await all(promises); const removedMedia = await MediaModel.remove({ _id: { $in: ids } }); return removedMedia.result.ok && ids.map(_id => ({_id})) || []; } }; export const removeMediaItem = { type: mediaType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLID) } }, async resolve (root, params, options) { authorize(root); const {id} = params; const projection = getProjection(options.fieldASTs[0]); await nfcall(rmdir, path.join(mediaPath, id)); const removedMedia = await MediaModel .findByIdAndRemove(id) .select(projection) .exec(); return removedMedia; } }; ================================================ FILE: lib/server/graphql/mutations/menu/add.js ================================================ import { GraphQLNonNull } from 'graphql'; import authorize from '../../authorize'; import menuInputType from '../../types/menu-input'; import menuType from '../../types/menu'; import MenuModel from '../../../models/menu'; export default { type: menuType, args: { data: { name: 'data', type: new GraphQLNonNull(menuInputType) } }, async resolve (root, params) { authorize(root); const data = Object.assign( { data: {} }, params.data ); const menuModel = new MenuModel(data); const menu = await menuModel.save(); if (!menu) { throw new Error('Error adding menu'); } return menu; } }; ================================================ FILE: lib/server/graphql/mutations/menu/index.js ================================================ import addMenu from './add'; import removeMenu from './remove'; import updateMenu from './update'; export default { addMenu, removeMenu, updateMenu }; ================================================ FILE: lib/server/graphql/mutations/menu/remove.js ================================================ import { GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import menuType from '../../types/menu'; import MenuModel from '../../../models/menu'; export default { type: menuType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLID) } }, resolve (root, params) { authorize(root); return MenuModel .findByIdAndRemove(params.id) .exec() .then((removedMenu) => { if (!removedMenu) { throw new Error('Error removing menu'); } return removedMenu; }); } }; ================================================ FILE: lib/server/graphql/mutations/menu/update.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLNonNull } from 'graphql'; import authorize from '../../authorize'; import menuInputType from '../../types/menu-input'; import menuType from '../../types/menu'; import MenuModel from '../../../models/menu'; export default { type: menuType, args: { data: { name: 'data', type: new GraphQLNonNull(menuInputType) } }, resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const menuChanges = Object.assign({}, params.data); const id = params.data._id; // data hidrate if (params.data.data && typeof params.data.data === 'string') { menuChanges.data = JSON.parse(params.data.data); } return MenuModel .findByIdAndUpdate( id, menuChanges, {upsert: true, new: true} ) .select(projection) .exec() .then((resultMenu) => { if (!resultMenu) { throw new Error('Menu not found'); } return resultMenu; }); } }; ================================================ FILE: lib/server/graphql/mutations/page/add.js ================================================ import getUniqueSlug from 'helpers/get-unique-slug'; import { GraphQLNonNull } from 'graphql'; import authorize from '../../authorize'; import pageInputType from '../../types/page-input'; import pageType from '../../types/page'; import PageModel from '../../../models/page'; export default { type: pageType, args: { data: { name: 'data', type: new GraphQLNonNull(pageInputType) } }, async resolve (root, params) { authorize(root); const pageData = Object.assign({}, params.data); // Generate slug if needed if (!pageData.slug) { pageData.slug = await getUniqueSlug(PageModel, pageData.title); } // Add user info pageData.createdBy = root.user._id; pageData.updatedBy = root.user._id; const pageModel = new PageModel(pageData); const page = await pageModel.save(); if (!page) { throw new Error('Error creating page'); } return page; } }; ================================================ FILE: lib/server/graphql/mutations/page/duplicate.js ================================================ import { GraphQLNonNull, GraphQLString } from 'graphql'; import authorize from '../../authorize'; import pageType from '../../types/page'; import PageModel from '../../../models/page'; function getUniqueSlug (slug, it) { const sufix = it > 0 ? `-${it}` : ''; const resultSlug = `${slug}${sufix}`; return PageModel .findOne({slug: resultSlug}) .exec() .then((response) => { let result; if (!response) { result = resultSlug; } else { result = getUniqueSlug(slug, it + 1); } return result; }); } export default { type: pageType, args: { data: { name: 'data', type: new GraphQLNonNull(GraphQLString) } }, async resolve (root, params) { authorize(root); let page = await PageModel.findById(params.data); if (!page) { throw new Error('Page to duplicate not found'); } page = page.toJSON(); const slug = await getUniqueSlug(`${page.slug}-copy`, 0); page.slug = slug; page.title += ' (copy)'; page.state = 'draft'; delete page._id; delete page.date; delete page.actions; const pageModel = new PageModel(page); const newPage = await pageModel.save(); if (!newPage) { throw new Error('Error duplicating page'); } return newPage; } }; ================================================ FILE: lib/server/graphql/mutations/page/index.js ================================================ import addPage from './add'; import duplicatePage from './duplicate'; import removePage from './remove'; import restorePage from './restore'; import updatePage from './update'; export default { addPage, duplicatePage, removePage, restorePage, updatePage }; ================================================ FILE: lib/server/graphql/mutations/page/remove.js ================================================ import { GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import pageType from '../../types/page'; import PageModel from '../../../models/page'; import RevisionModel from '../../../models/revision'; import TabModel from '../../../models/tab'; export default { type: pageType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLID) } }, async resolve (root, params) { authorize(root); const removedPage = await PageModel.findByIdAndRemove(params.id).exec(); if (!removedPage) { throw new Error('Page not found'); } await TabModel.find({'_id._id': params.id}).remove().exec(); await RevisionModel.find({'_id._id': params.id}).remove().exec(); return removedPage; } }; ================================================ FILE: lib/server/graphql/mutations/page/restore.js ================================================ import { GraphQLNonNull, GraphQLID, GraphQLInt } from 'graphql'; import authorize from '../../authorize'; import pageType from '../../types/page'; import updatePageMutation from './update'; import RevisionModel from '../../../models/revision'; export default { type: pageType, args: { pageId: { name: 'pageId', type: new GraphQLNonNull(GraphQLID) }, version: { name: 'version', type: new GraphQLNonNull(GraphQLInt) } }, async resolve (root, params, options) { authorize(root); const {pageId: _id, version: __v} = params; const revision = await RevisionModel.findOne({ '_id._id': _id, '_id.__v': __v }).exec(); return await updatePageMutation.resolve(root, {data: revision.doc}, options); } }; ================================================ FILE: lib/server/graphql/mutations/page/update.js ================================================ import { GraphQLNonNull } from 'graphql'; import getProjection from 'helpers/get-projection'; import authorize from '../../authorize'; import pageInputType from '../../types/page-input'; import pageType from '../../types/page'; import PageModel from '../../../models/page'; import RevisionModel from '../../../models/revision'; export default { type: pageType, args: { data: { name: 'data', type: new GraphQLNonNull(pageInputType) } }, async resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const page = await PageModel.findById(params.data._id); const revision = new RevisionModel({ _id: { _id: page._id, __v: page.__v }, date: page.updatedDate, user: page.updatedBy, doc: page }); await revision.save(); const pageChanges = Object.assign({}, params.data, { __v: page.__v + 1, updatedDate: new Date() }); if (params.data.data && typeof params.data.data === 'string') { pageChanges.data = JSON.parse(params.data.data); } const resultPage = await PageModel.findByIdAndUpdate( params.data._id, pageChanges, {upsert: true, new: true} ).select(projection).exec(); if (!resultPage) { throw new Error('Error updating page'); } return resultPage; } }; ================================================ FILE: lib/server/graphql/mutations/schema-entry/add.js ================================================ import getUniqueSlug from 'helpers/get-unique-slug'; import parseFields from 'helpers/parse-fields'; import { GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import schemaEntryInputType from '../../types/schema-entry-input'; import schemaEntryModel from '../../../models/schema-entry'; import schemaEntryType from '../../types/schema-entry'; const parsableFields = ['data', 'properties']; export default { type: schemaEntryType, args: { schemaId: { name: 'schemaId', type: GraphQLID }, data: { name: 'data', type: new GraphQLNonNull(schemaEntryInputType) } }, async resolve (root, params) { authorize(root); const Model = await schemaEntryModel(params.schemaId); const data = parseFields(Object.assign({}, params.data), parsableFields); // generate slug if (!data.slug) { data.slug = await getUniqueSlug(Model, data.title); } const schemaEntry = new Model(data); const newSchemaEntry = await schemaEntry.save(); if (!newSchemaEntry) { throw new Error('Error creating schema entry'); } return newSchemaEntry; } }; ================================================ FILE: lib/server/graphql/mutations/schema-entry/index.js ================================================ import addSchemaEntry from './add'; import removeSchemaEntry from './remove'; import restoreSchemaEntry from './restore'; import updateSchemaEntry from './update'; export default { addSchemaEntry, removeSchemaEntry, restoreSchemaEntry, updateSchemaEntry }; ================================================ FILE: lib/server/graphql/mutations/schema-entry/remove.js ================================================ import { GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import schemaEntryModel from '../../../models/schema-entry'; import schemaEntryType from '../../types/schema-entry'; export default { type: schemaEntryType, args: { schemaId: { name: 'schemaId', type: GraphQLID }, id: { name: 'id', type: new GraphQLNonNull(GraphQLID) } }, async resolve (root, params) { authorize(root); const Model = await schemaEntryModel(params.schemaId); const removedSchemaEntry = await Model.findByIdAndRemove(params.id).exec(); if (!removedSchemaEntry) { throw new Error('Schema entry not found'); } return removedSchemaEntry; } }; ================================================ FILE: lib/server/graphql/mutations/schema-entry/restore.js ================================================ import { GraphQLNonNull, GraphQLID, GraphQLInt } from 'graphql'; import authorize from '../../authorize'; import schemaEntryType from '../../types/schema-entry'; import updateSchemaEntryMutation from './update'; import RevisionModel from '../../../models/revision'; export default { type: schemaEntryType, args: { schemaId: { name: 'schemaId', type: GraphQLID }, schemaEntryId: { name: 'schemaEntryId', type: new GraphQLNonNull(GraphQLID) }, version: { name: 'version', type: new GraphQLNonNull(GraphQLInt) } }, async resolve (root, params, options) { authorize(root); const {schemaEntryId: _id, version: __v} = params; const revision = await RevisionModel.findOne({ '_id._id': _id, '_id.__v': __v }).exec(); return await updateSchemaEntryMutation.resolve( root, {schemaId: params.schemaId, data: revision.doc}, options ); } }; ================================================ FILE: lib/server/graphql/mutations/schema-entry/update.js ================================================ import getProjection from 'helpers/get-projection'; import parseFields from 'helpers/parse-fields'; import { GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import schemaEntryInputType from '../../types/schema-entry-input'; import schemaEntryModel from '../../../models/schema-entry'; import schemaEntryType from '../../types/schema-entry'; import RevisionModel from '../../../models/revision'; const parsableFields = ['data', 'properties']; export default { type: schemaEntryType, args: { schemaId: { name: 'schemaId', type: GraphQLID }, data: { name: 'data', type: new GraphQLNonNull(schemaEntryInputType) } }, async resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const Model = await schemaEntryModel(params.schemaId); const schemaEntry = await Model.findById(params.data._id); const revision = new RevisionModel({ _id: { _id: schemaEntry._id, __v: schemaEntry.__v }, date: schemaEntry.updatedDate, user: schemaEntry.updatedBy, doc: schemaEntry }); await revision.save(); const schemaEntryChanges = parseFields(Object.assign({}, params.data, { __v: schemaEntry.__v + 1, updatedDate: new Date() }), parsableFields); const resultSchemaEntry = await Model.findByIdAndUpdate( params.data._id, schemaEntryChanges, {upsert: true, new: true} ).select(projection).exec(); if (!resultSchemaEntry) { throw new Error('Error updating schemaEntry'); } return resultSchemaEntry; } }; ================================================ FILE: lib/server/graphql/mutations/schemas/add.js ================================================ import getUniqueSlug from 'helpers/get-unique-slug'; import { GraphQLNonNull } from 'graphql'; import authorize from '../../authorize'; import schemaInputType from '../../types/schema-input'; import schemaType from '../../types/schema'; import SchemaModel from '../../../models/schema'; export default { type: schemaType, args: { data: { name: 'data', type: new GraphQLNonNull(schemaInputType) } }, async resolve (root, params) { authorize(root); const data = Object.assign({}, params.data, { properties: JSON.parse(params.data.properties) }); // generate slug if (!data.slug) { data.slug = await getUniqueSlug(SchemaModel, data.title); } const schema = new SchemaModel(data); const newSchema = await schema.save(); if (!newSchema) { throw new Error('Error adding schema'); } return newSchema; } }; ================================================ FILE: lib/server/graphql/mutations/schemas/index.js ================================================ import addSchema from './add'; import removeSchema from './remove'; import restoreSchema from './restore'; import updateSchema from './update'; export default { addSchema, removeSchema, restoreSchema, updateSchema }; ================================================ FILE: lib/server/graphql/mutations/schemas/remove.js ================================================ import { GraphQLNonNull, GraphQLString } from 'graphql'; import authorize from '../../authorize'; import schemaType from '../../types/schema'; import SchemaModel from '../../../models/schema'; export default { type: schemaType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLString) } }, async resolve (root, params) { authorize(root); const removedSchema = await SchemaModel.findByIdAndRemove(params.id); if (!removedSchema) { throw new Error('Schema not found'); } return removedSchema; } }; ================================================ FILE: lib/server/graphql/mutations/schemas/restore.js ================================================ import { GraphQLNonNull, GraphQLID, GraphQLInt } from 'graphql'; import authorize from '../../authorize'; import schemaType from '../../types/schema'; import updateSchemaMutation from './update'; import RevisionModel from '../../../models/revision'; export default { type: schemaType, args: { schemaId: { name: 'schemaId', type: new GraphQLNonNull(GraphQLID) }, version: { name: 'version', type: new GraphQLNonNull(GraphQLInt) } }, async resolve (root, params, options) { authorize(root); const {schemaId: _id, version: __v} = params; const revision = await RevisionModel.findOne({ '_id._id': _id, '_id.__v': __v }).exec(); return await updateSchemaMutation.resolve(root, {data: revision.doc}, options); } }; ================================================ FILE: lib/server/graphql/mutations/schemas/update.js ================================================ import { GraphQLNonNull } from 'graphql'; import getProjection from 'helpers/get-projection'; import authorize from '../../authorize'; import schemaInputType from '../../types/schema-input'; import schemaType from '../../types/schema'; import RevisionModel from '../../../models/revision'; import SchemaModel from '../../../models/schema'; export default { type: schemaType, args: { data: { name: 'data', type: new GraphQLNonNull(schemaInputType) } }, async resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const schema = await SchemaModel.findById(params.data._id); const revision = new RevisionModel({ _id: { _id: schema._id, __v: schema.__v }, date: schema.updatedDate, user: schema.updatedBy, doc: schema }); await revision.save(); const schemaChanges = Object.assign({}, params.data, { __v: schema.__v + 1, updatedDate: new Date() }); if (params.data.data && typeof params.data.data === 'string') { schemaChanges.data = JSON.parse(params.data.data); } if (params.data.properties && typeof params.data.properties === 'string') { schemaChanges.properties = JSON.parse(params.data.properties); } const resultSchema = await SchemaModel.findByIdAndUpdate( params.data._id, schemaChanges, {upsert: true, new: true} ).select(projection).exec(); if (!resultSchema) { throw new Error('Error updating schema'); } return resultSchema; } }; ================================================ FILE: lib/server/graphql/mutations/settings/index.js ================================================ import saveSettings from './save'; export default { saveSettings }; ================================================ FILE: lib/server/graphql/mutations/settings/save.js ================================================ import forEach from 'lodash.foreach'; import getProjection from 'helpers/get-projection'; import Q from 'q'; import { GraphQLNonNull, GraphQLList } from 'graphql'; import authorize from '../../authorize'; import settingInputType from '../../types/setting-input'; import settingType from '../../types/setting'; import SettingModel from '../../../models/setting'; export default { type: new GraphQLList(settingType), args: { data: { name: 'data', type: new GraphQLNonNull( new GraphQLList(settingInputType) ) } }, resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const promises = []; forEach(params.data, (setting) => { promises.push( SettingModel.findByIdAndUpdate(setting._id, setting, {upsert: true, new: true}).select(projection) ); }); return Q .all(promises) .spread((...settings) => settings); } }; ================================================ FILE: lib/server/graphql/mutations/style/add.js ================================================ import parseFields from 'helpers/parse-fields'; import { GraphQLNonNull } from 'graphql'; import authorize from '../../authorize'; import parsableFields from './parsable-fields'; import styleInputType from '../../types/style-input'; import styleType from '../../types/style'; import StyleModel from '../../../models/style'; export default { type: styleType, args: { data: { name: 'data', type: new GraphQLNonNull(styleInputType) } }, async resolve (root, params) { authorize(root); const data = parseFields(params.data, parsableFields); const styleModel = new StyleModel(data); const style = await styleModel.save(); if (!style) { throw new Error('Style not found'); } return style; } }; ================================================ FILE: lib/server/graphql/mutations/style/index.js ================================================ import addStyle from './add'; import removeStyle from './remove'; import updateStyle from './update'; export default { addStyle, removeStyle, updateStyle }; ================================================ FILE: lib/server/graphql/mutations/style/parsable-fields.js ================================================ export default ['options', 'displayOptions']; ================================================ FILE: lib/server/graphql/mutations/style/remove.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import styleType from '../../types/style'; import StyleModel from '../../../models/style'; export default { type: styleType, args: { _id: { name: '_id', type: new GraphQLNonNull(GraphQLID) } }, async resolve (root, params, options) { authorize(root); const removedStyle = await StyleModel .findByIdAndRemove(params._id, { select: getProjection(options.fieldASTs[0]) }) .exec(); if (!removedStyle) { throw new Error('Style not found'); } return removedStyle; } }; ================================================ FILE: lib/server/graphql/mutations/style/update.js ================================================ import getProjection from 'helpers/get-projection'; import parseFields from 'helpers/parse-fields'; import { GraphQLNonNull } from 'graphql'; import authorize from '../../authorize'; import parsableFields from './parsable-fields'; import styleInputType from '../../types/style-input'; import styleType from '../../types/style'; import StyleModel from '../../../models/style'; export default { type: styleType, args: { data: { name: 'data', type: new GraphQLNonNull(styleInputType) } }, async resolve (root, params, options) { authorize(root); const data = parseFields(params.data, parsableFields); const resultStyle = await StyleModel .findByIdAndUpdate(data._id, data, { upsert: true, new: true, select: getProjection(options.fieldASTs[0]) }) .exec(); if (!resultStyle) { throw new Error('Style not found'); } return resultStyle; } }; ================================================ FILE: lib/server/graphql/mutations/symbol/add.js ================================================ import { GraphQLNonNull } from 'graphql'; import authorize from '../../authorize'; import symbolInputType from '../../types/symbol-input'; import symbolType from '../../types/symbol'; import SymbolModel from '../../../models/symbol'; export default { type: symbolType, args: { data: { name: 'data', type: new GraphQLNonNull(symbolInputType) } }, async resolve (root, params) { authorize(root); const data = Object.assign({}, params.data, { data: JSON.parse(params.data.data) }); const symbolModel = new SymbolModel(data); const newSymbol = await symbolModel.save(); if (!newSymbol) { throw new Error('Error adding symbol'); } return newSymbol; } }; ================================================ FILE: lib/server/graphql/mutations/symbol/index.js ================================================ import addSymbol from './add'; export default { addSymbol }; ================================================ FILE: lib/server/graphql/mutations/tab/add.js ================================================ import { GraphQLNonNull, GraphQLString, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import tabType from '../../types/tab'; import TabModel from '../../../models/tab'; export default { type: tabType, args: { type: { name: 'type', type: new GraphQLNonNull(GraphQLString) }, id: { name: 'id', type: new GraphQLNonNull(GraphQLID) } }, async resolve (root, params) { authorize(root); const _userId = root.user._id; const item = params.id; const type = params.type; let tab = await TabModel.findOne({_userId, item}).exec(); if (!tab) { const tabModel = new TabModel({ _userId, type, item }); tab = await tabModel.save(); if (!tab) { throw new Error('Error creating tab'); } } else { tab = null; } return tab; } }; ================================================ FILE: lib/server/graphql/mutations/tab/index.js ================================================ import addTab from './add'; import removeTab from './remove'; export default { removeTab, addTab }; ================================================ FILE: lib/server/graphql/mutations/tab/remove.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import tabType from '../../types/tab'; import TabModel from '../../../models/tab'; export default { type: tabType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLID) } }, async resolve (root, params, options) { authorize(root); const removedTab = await TabModel .findByIdAndRemove(params.id, { select: getProjection(options.fieldASTs[0]) }) .exec(); if (!removedTab) { throw new Error('Tab not found'); } return removedTab; } }; ================================================ FILE: lib/server/graphql/mutations/user/add.js ================================================ import { GraphQLNonNull } from 'graphql'; import authorize from '../../authorize'; import userInputType from '../../types/user-input'; import userType from '../../types/user'; import UserModel from '../../../models/user'; async function registerUser (user, password) { return new Promise((resolve, reject) => { UserModel.register(user, password, (err) => { if (err) { reject(err); } resolve(); }); }); } export default { type: userType, args: { data: { name: 'data', type: new GraphQLNonNull(userInputType) } }, async resolve (root, params) { const {username, name, email, password} = params.data; const user = new UserModel({ username, name, email }); const count = await UserModel.count(); if (count > 0) { authorize(root); } await registerUser(user, password); return user; } }; ================================================ FILE: lib/server/graphql/mutations/user/index.js ================================================ import addUser from './add'; import removeUser from './remove'; export default { addUser, removeUser }; ================================================ FILE: lib/server/graphql/mutations/user/remove.js ================================================ import { GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import config from '../../../../../config'; import userType from '../../types/user'; import UserModel from '../../../models/user'; export default { type: userType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLID) } }, resolve (root, params) { authorize(root); if (config.demo) { throw new Error('Remove user is disabled on the demo'); } return UserModel .findByIdAndRemove(params.id) .exec() .then((removedUser) => { if (!removedUser) { throw new Error('Error removing user'); } return removedUser; }); } }; ================================================ FILE: lib/server/graphql/queries/color/colors.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLList } from 'graphql'; import colorType from '../../types/color'; import ColorModel from '../../../models/color'; export default { type: new GraphQLList(colorType), args: {}, resolve (root, params, options) { const projection = getProjection(options.fieldASTs[0]); return ColorModel.find().select(projection).exec(); } }; ================================================ FILE: lib/server/graphql/queries/color/index.js ================================================ import colors from './colors'; export default { colors }; ================================================ FILE: lib/server/graphql/queries/draft/draft.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLID } from 'graphql'; import {Types} from 'mongoose'; import authorize from '../../authorize'; import draftType from '../../types/draft'; import DraftModel from '../../../models/draft'; import PageModel from '../../../models/page'; export default { type: draftType, args: { id: { name: 'id', type: GraphQLID } }, async resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const _id = new Types.ObjectId(params.id); const _userId = root.user._id; let result = await DraftModel.findById({_id, _userId}).select(projection).exec(); if (!result) { const page = await PageModel.findById(_id).exec(); const draft = new DraftModel({ _id: { _id, _userId }, __v: page.__v, data: page.data }); result = await draft.save(); } return result; } }; ================================================ FILE: lib/server/graphql/queries/draft/index.js ================================================ import draft from './draft'; export default { draft }; ================================================ FILE: lib/server/graphql/queries/generators/schema-list-count.js ================================================ import authorize from '../../authorize'; import countType from '../../types/count'; import schemaEntryModel from '../../../models/schema-entry'; export default (type, schema) => ({ type: countType, args: {}, async resolve (root) { authorize(root); const Model = schemaEntryModel(schema); const count = await Model.count({}).exec(); return {count}; } }); ================================================ FILE: lib/server/graphql/queries/generators/schema-list.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLList } from 'graphql'; import authorize from '../../authorize'; import schemaEntryModel from '../../../models/schema-entry'; import {paginationQueryArgs, paginateQuery, searchQuery} from '../../query-pagination'; export default (type, schema) => ({ type: new GraphQLList(type), args: { ...paginationQueryArgs }, async resolve (root, params, options) { authorize(root); const Model = schemaEntryModel(schema); const projection = getProjection(options.fieldASTs[0]); const query = Model.find(searchQuery({}, params)); paginateQuery(query, params); return await query.select(projection).exec(); } }); ================================================ FILE: lib/server/graphql/queries/index.js ================================================ import color from './color'; import draft from './draft'; import media from './media'; import menu from './menu'; import page from './page'; import revision from './revision'; import schema from './schemas'; import schemaEntry from './schema-entry'; import settings from './settings'; import style from './style'; import symbol from './symbol'; import tab from './tab'; import user from './user'; export default { ...color, ...draft, ...media, ...menu, ...page, ...revision, ...schemaEntry, ...schema, ...settings, ...style, ...symbol, ...tab, ...user }; ================================================ FILE: lib/server/graphql/queries/media/index.js ================================================ import mediaCount from './media-count'; import media, {mediaItem} from './media'; export default { media, mediaItem, mediaCount }; ================================================ FILE: lib/server/graphql/queries/media/media-count.js ================================================ import {GraphQLInt} from 'graphql'; import authorize from '../../authorize'; import MediaModel from '../../../models/media'; export default { type: GraphQLInt, args: {}, async resolve (root) { authorize(root); return await MediaModel.count(); } }; ================================================ FILE: lib/server/graphql/queries/media/media.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLList, GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import mediaType from '../../types/media'; import MediaModel from '../../../models/media'; import {paginationQueryArgs, paginateQuery, searchQuery} from '../../query-pagination'; export default { type: new GraphQLList(mediaType), args: { ...paginationQueryArgs }, async resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const query = MediaModel.find(searchQuery({}, params)); paginateQuery(query, params); return query.select(projection).exec(); } }; export const mediaItem = { type: mediaType, args: { id: { name: 'id', type: new GraphQLNonNull(GraphQLID) } }, async resolve (root, params, options) { const projection = getProjection(options.fieldASTs[0]); const query = MediaModel.findById(params.id); return query.select(projection).exec(); } }; ================================================ FILE: lib/server/graphql/queries/menu/index.js ================================================ import menus from './menus'; import menusCount from './menus-count'; import menu, {validateMenuSlug} from './menu'; export default { menus, menusCount, menu, validateMenuSlug }; ================================================ FILE: lib/server/graphql/queries/menu/menu.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLString, GraphQLID, GraphQLNonNull, GraphQLBoolean } from 'graphql'; import authorize from '../../authorize'; import menuType from '../../types/menu'; import MenuModel from '../../../models/menu'; export default { type: menuType, args: { _id: { name: '_id', type: GraphQLID } }, async resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); return await MenuModel.findById(params._id).select(projection).exec(); } }; export const validateMenuSlug = { type: GraphQLBoolean, args: { slug: { name: 'slug', type: new GraphQLNonNull(GraphQLString) }, menuId: { name: 'menuId', type: GraphQLID } }, async resolve (root, {slug, menuId}) { authorize(root); return await MenuModel.count({ slug, _id: { $ne: menuId } }) === 0; } }; ================================================ FILE: lib/server/graphql/queries/menu/menus-count.js ================================================ import {GraphQLInt} from 'graphql'; import authorize from '../../authorize'; import MenuModel from '../../../models/menu'; export default { type: GraphQLInt, args: {}, async resolve (root) { authorize(root); return await MenuModel.count(); } }; ================================================ FILE: lib/server/graphql/queries/menu/menus.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLList } from 'graphql'; import authorize from '../../authorize'; import menuType from '../../types/menu'; import MenuModel from '../../../models/menu'; import {paginationQueryArgs, paginateQuery, searchQuery} from '../../query-pagination'; export default { type: new GraphQLList(menuType), args: { ...paginationQueryArgs }, resolve: (root, params, options) => { authorize(root); const projection = getProjection(options.fieldASTs[0]); const query = MenuModel.find(searchQuery({}, params)); paginateQuery(query, params); return query.select(projection).exec(); } }; ================================================ FILE: lib/server/graphql/queries/page/index.js ================================================ import pages from './pages'; import pagesCount from './pages-count'; import page, {validatePageSlug} from './page'; export default { pages, pagesCount, page, validatePageSlug }; ================================================ FILE: lib/server/graphql/queries/page/page.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLString, GraphQLBoolean, GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import pageType from '../../types/page'; import PageModel from '../../../models/page'; import SettingModel from '../../../models/setting'; export default { type: pageType, args: { _id: { name: '_id', type: GraphQLID }, slug: { name: 'slug', type: GraphQLString } }, async resolve (root, params, options) { const projection = getProjection(options.fieldASTs[0]); let result = false; if (params.slug || params._id) { result = await PageModel.findOne(params).select(projection).exec(); } else { const frontpage = await SettingModel.findById('frontpage').exec(); if (!frontpage) { throw new Error('Frontpage not defined'); } result = await PageModel.findById(frontpage.value).select(projection).exec(); } return result; } }; export const validatePageSlug = { type: GraphQLBoolean, args: { slug: { name: 'slug', type: new GraphQLNonNull(GraphQLString) }, pageId: { name: 'pageId', type: GraphQLID } }, async resolve (root, {slug, pageId}) { authorize(root); return await PageModel.count({ slug, _id: { $ne: pageId } }) === 0; } }; ================================================ FILE: lib/server/graphql/queries/page/pages-count.js ================================================ import {GraphQLInt} from 'graphql'; import PageModel from '../../../models/page'; export default { type: GraphQLInt, args: {}, async resolve () { const count = PageModel.count(); return count; } }; ================================================ FILE: lib/server/graphql/queries/page/pages.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLList } from 'graphql'; import authorize from '../../authorize'; import pageType from '../../types/page'; import PageModel from '../../../models/page'; import {paginationQueryArgs, paginateQuery, searchQuery} from '../../query-pagination'; export default { type: new GraphQLList(pageType), args: { ...paginationQueryArgs }, resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const query = PageModel.find(searchQuery({}, params)); paginateQuery(query, params); return query.select(projection).exec(); } }; ================================================ FILE: lib/server/graphql/queries/revision/index.js ================================================ import revisions from './revisions'; export default { revisions }; ================================================ FILE: lib/server/graphql/queries/revision/revisions.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLList, GraphQLString } from 'graphql'; import {Types} from 'mongoose'; import authorize from '../../authorize'; import revisionType from '../../types/revision'; import RevisionModel from '../../../models/revision'; export default { type: new GraphQLList(revisionType), args: { id: { name: 'id', type: GraphQLString } }, async resolve (root, params, options) { authorize(root); const id = new Types.ObjectId(params.id); const projection = getProjection(options.fieldASTs[0]); return await RevisionModel .find({ '_id._id': id }) .sort({'_id.__v': -1}) .select(projection) .exec(); } }; ================================================ FILE: lib/server/graphql/queries/schema-entry/index.js ================================================ import schemaList from './schema-list'; import schemaListCount from './schema-list-count'; import schemaEntry, {validateSchemaEntrySlug} from './schema-entry'; export default { schemaEntry, validateSchemaEntrySlug, schemaList, schemaListCount }; ================================================ FILE: lib/server/graphql/queries/schema-entry/schema-entry.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLString, GraphQLBoolean, GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import schemaEntryModel from '../../../models/schema-entry'; import schemaEntryType from '../../types/schema-entry'; export default { type: schemaEntryType, args: { id: { name: 'id', type: GraphQLID }, schemaId: { name: 'schemaId', type: GraphQLID } }, async resolve (root, {schemaId, id}, options) { const Model = await schemaEntryModel(schemaId); const projection = getProjection(options.fieldASTs[0]); return await Model.findById(id).select(projection).exec(); } }; export const validateSchemaEntrySlug = { type: GraphQLBoolean, args: { slug: { name: 'slug', type: new GraphQLNonNull(GraphQLString) }, schemaId: { name: 'schemaId', type: GraphQLID }, schemaEntryId: { name: 'schemaEntryId', type: GraphQLID } }, async resolve (root, {slug, schemaId, schemaEntryId}) { authorize(root); const Model = await schemaEntryModel(schemaId); return await Model.count({ slug, _id: { $ne: schemaEntryId } }) === 0; } }; ================================================ FILE: lib/server/graphql/queries/schema-entry/schema-list-count.js ================================================ import { GraphQLID, GraphQLInt } from 'graphql'; import authorize from '../../authorize'; import schemaEntryModel from '../../../models/schema-entry'; export default { type: GraphQLInt, args: { schemaId: { name: 'schemaId', type: GraphQLID } }, async resolve (root, params) { authorize(root); const Model = await schemaEntryModel(params.schemaId); return await Model.count().exec(); } }; ================================================ FILE: lib/server/graphql/queries/schema-entry/schema-list.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLList, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import schemaEntryModel from '../../../models/schema-entry'; import schemaEntryType from '../../types/schema-entry'; import {paginationQueryArgs, paginateQuery, searchQuery} from '../../query-pagination'; export default { type: new GraphQLList(schemaEntryType), args: { schemaId: { name: 'schemaId', type: GraphQLID }, ...paginationQueryArgs }, async resolve (root, params, options) { authorize(root); const Model = await schemaEntryModel(params.schemaId); const projection = getProjection(options.fieldASTs[0]); const query = Model.find(searchQuery({}, params)); paginateQuery(query, params); return await query.select(projection).exec(); } }; ================================================ FILE: lib/server/graphql/queries/schemas/index.js ================================================ import schemas from './schemas'; import schemasCount from './schemas-count'; import schema, {validateSchemaSlug} from './schema'; export default { schemas, schemasCount, schema, validateSchemaSlug }; ================================================ FILE: lib/server/graphql/queries/schemas/schema.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLString, GraphQLBoolean, GraphQLNonNull, GraphQLID } from 'graphql'; import authorize from '../../authorize'; import schemaType from '../../types/schema'; import SchemaModel from '../../../models/schema'; export default { type: schemaType, args: { _id: { name: '_id', type: GraphQLID }, slug: { name: 'slug', type: GraphQLString } }, async resolve (root, params, options) { const projection = getProjection(options.fieldASTs[0]); return await SchemaModel.findOne(params).select(projection).exec(); } }; export const validateSchemaSlug = { type: GraphQLBoolean, args: { slug: { name: 'slug', type: new GraphQLNonNull(GraphQLString) }, schemaId: { name: 'schemaId', type: GraphQLID } }, async resolve (root, {slug, schemaId}) { authorize(root); return await SchemaModel.count({ slug, _id: { $ne: schemaId } }) === 0; } }; ================================================ FILE: lib/server/graphql/queries/schemas/schemas-count.js ================================================ import {GraphQLInt} from 'graphql'; import authorize from '../../authorize'; import SchemaModel from '../../../models/schema'; export default { type: GraphQLInt, args: {}, async resolve (root) { authorize(root); return await SchemaModel.count(); } }; ================================================ FILE: lib/server/graphql/queries/schemas/schemas.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLList } from 'graphql'; import authorize from '../../authorize'; import schemaType from '../../types/schema'; import SchemaModel from '../../../models/schema'; import {paginationQueryArgs, paginateQuery, searchQuery} from '../../query-pagination'; export default { type: new GraphQLList(schemaType), args: { ...paginationQueryArgs }, resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const query = SchemaModel.find(searchQuery({}, params)); paginateQuery(query, params); return query.select(projection).exec(); } }; ================================================ FILE: lib/server/graphql/queries/settings/index.js ================================================ import settings from './settings'; export default { settings }; ================================================ FILE: lib/server/graphql/queries/settings/settings.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLList, GraphQLString } from 'graphql'; import authorize from '../../authorize'; import settingType from '../../types/setting'; import SettingModel from '../../../models/setting'; export default { type: new GraphQLList(settingType), args: { ids: { name: 'ids', type: new GraphQLList(GraphQLString) } }, resolve: (root, params, options) => { authorize(root); const projection = getProjection(options.fieldASTs[0]); return SettingModel .find({ _id: {$in: params.ids} }) .select(projection) .exec(); } }; ================================================ FILE: lib/server/graphql/queries/style/index.js ================================================ import styles from './styles'; export default { styles }; ================================================ FILE: lib/server/graphql/queries/style/styles.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLList } from 'graphql'; import styleType from '../../types/style'; import StyleModel from '../../../models/style'; export default { type: new GraphQLList(styleType), args: {}, resolve (root, params, options) { const projection = getProjection(options.fieldASTs[0]); return StyleModel.find().select(projection).exec(); } }; ================================================ FILE: lib/server/graphql/queries/symbol/index.js ================================================ import symbol from './symbol'; import symbols from './symbols'; export default { symbol, symbols }; ================================================ FILE: lib/server/graphql/queries/symbol/symbol.js ================================================ import getProjection from 'helpers/get-projection'; import {GraphQLID} from 'graphql'; import {Types} from 'mongoose'; import symbolType from '../../types/symbol'; import SymbolModel from '../../../models/symbol'; export default { type: symbolType, args: { id: { name: 'id', type: GraphQLID } }, resolve (root, params, options) { const projection = getProjection(options.fieldASTs[0]); const _id = new Types.ObjectId(params.id); return SymbolModel.findById(_id).select(projection).exec(); } }; ================================================ FILE: lib/server/graphql/queries/symbol/symbols.js ================================================ import getProjection from 'helpers/get-projection'; import {GraphQLList} from 'graphql'; import symbolType from '../../types/symbol'; import SymbolModel from '../../../models/symbol'; export default { type: new GraphQLList(symbolType), args: {}, resolve (root, params, options) { const projection = getProjection(options.fieldASTs[0]); return SymbolModel.find().select(projection).exec(); } }; ================================================ FILE: lib/server/graphql/queries/tab/index.js ================================================ import tabs from './tabs'; export default { tabs }; ================================================ FILE: lib/server/graphql/queries/tab/tabs.js ================================================ import getProjection from 'helpers/get-projection'; import {GraphQLList} from 'graphql'; import authorize from '../../authorize'; import tabType from '../../types/tab'; import TabModel from '../../../models/tab'; export default { type: new GraphQLList(tabType), args: {}, resolve (root, params, options) { authorize(root); const _userId = root.user._id; const projection = getProjection(options.fieldASTs[0]); return TabModel .find({_userId}) .select(projection) .exec(); } }; ================================================ FILE: lib/server/graphql/queries/user/index.js ================================================ import session from './session'; import user from './user'; import users from './users'; import usersCount from './users-count'; export default { user, users, usersCount, session }; ================================================ FILE: lib/server/graphql/queries/user/session.js ================================================ import {GraphQLBoolean} from 'graphql'; export default { type: GraphQLBoolean, resolve (root) { return root.isAuthenticated; } }; ================================================ FILE: lib/server/graphql/queries/user/user.js ================================================ import getProjection from 'helpers/get-projection'; import {GraphQLID} from 'graphql'; import authorize from '../../authorize'; import userType from '../../types/user'; import UserModel from '../../../models/user'; export default { type: userType, args: { id: { name: 'username', type: GraphQLID } }, resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); let id = params.id; if (!id) { id = root.user._id; } return UserModel .findById(id) .select(projection) .exec(); } }; ================================================ FILE: lib/server/graphql/queries/user/users-count.js ================================================ import {GraphQLInt} from 'graphql'; import authorize from '../../authorize'; import UserModel from '../../../models/user'; export default { type: GraphQLInt, args: {}, async resolve (root) { authorize(root); return await UserModel.count(); } }; ================================================ FILE: lib/server/graphql/queries/user/users.js ================================================ import getProjection from 'helpers/get-projection'; import {GraphQLList} from 'graphql'; import authorize from '../../authorize'; import userType from '../../types/user'; import UserModel from '../../../models/user'; import {paginationQueryArgs, paginateQuery, searchQuery} from '../../query-pagination'; export default { type: new GraphQLList(userType), args: { ...paginationQueryArgs }, resolve (root, params, options) { authorize(root); const projection = getProjection(options.fieldASTs[0]); const query = UserModel.find(searchQuery({}, params)); paginateQuery(query, params); return query.select(projection).exec(); } }; ================================================ FILE: lib/server/graphql/query-pagination.js ================================================ import forEach from 'lodash.foreach'; import { GraphQLString, GraphQLInt, GraphQLList } from 'graphql'; import filterType from './types/filter'; export const paginationQueryArgs = { sort: { name: 'sort', type: GraphQLString }, order: { name: 'order', type: GraphQLString }, limit: { name: 'limit', type: GraphQLInt }, filters: { name: 'filters', type: new GraphQLList(filterType) }, page: { name: 'page', type: GraphQLInt }, search: { name: 'search', type: GraphQLString }, s: { name: 's', type: GraphQLString } }; function parseFilterOperation (op) { const result = {}; forEach(op, (value, key) => { result[`$${key}`] = value; }); return result; } export function searchQuery (find, params) { const and = []; // Search if (params.search && params.s) { and.push({ [params.search]: new RegExp(`.*${params.s}`, 'i') }); } // Filters if (params.filters && params.filters.constructor === Array) { forEach(params.filters, (filter) => { and.push({ [filter.property]: parseFilterOperation(filter.op) }); }); } // apply and operator with all the filters if (and.length > 0) { Object.assign(find, { $and: and }); } return find; } export function paginateQuery (query, params) { if (params.sort) { query.sort({ [params.sort]: params.order || 'asc' }); } if (params.page && params.limit) { query.skip((params.page - 1) * params.limit); } if (params.limit) { query.limit(params.limit); } } ================================================ FILE: lib/server/graphql/types/color-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLID } from 'graphql'; const colorInputType = new GraphQLInputObjectType({ name: 'ColorInput', fields: { _id: {type: GraphQLID}, label: {type: GraphQLString}, value: {type: GraphQLString} } }); export default colorInputType; ================================================ FILE: lib/server/graphql/types/color.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLID } from 'graphql'; const colorType = new GraphQLObjectType({ name: 'Color', fields: { _id: {type: new GraphQLNonNull(GraphQLID)}, label: {type: GraphQLString}, value: {type: GraphQLString} } }); export default colorType; ================================================ FILE: lib/server/graphql/types/count.js ================================================ import { GraphQLObjectType, GraphQLInt } from 'graphql'; const countType = new GraphQLObjectType({ name: 'Count', fields: { count: {type: GraphQLInt} } }); export default countType; ================================================ FILE: lib/server/graphql/types/custom-font.js ================================================ import { GraphQLObjectType, GraphQLString, GraphQLNonNull } from 'graphql'; const customFontType = new GraphQLObjectType({ name: 'CustomFont', fields: { family: { type: new GraphQLNonNull(GraphQLString) }, id: { type: new GraphQLNonNull(GraphQLString) }, files: { type: new GraphQLObjectType({ name: 'CustomFontFiles', fields: { eot: {type: new GraphQLNonNull(GraphQLString)}, woff2: {type: GraphQLString}, woff: {type: new GraphQLNonNull(GraphQLString)}, ttf: {type: new GraphQLNonNull(GraphQLString)} } }) } } }); export default customFontType; ================================================ FILE: lib/server/graphql/types/draft-id-input.js ================================================ import { GraphQLInputObjectType, GraphQLString } from 'graphql'; export default new GraphQLInputObjectType({ name: 'DraftIdInput', fields: { _id: { type: GraphQLString }, _userId: { type: GraphQLString } } }); ================================================ FILE: lib/server/graphql/types/draft-id.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString } from 'graphql'; export default new GraphQLObjectType({ name: 'DraftId', fields: { _id: { type: new GraphQLNonNull(GraphQLString) }, _userId: { type: new GraphQLNonNull(GraphQLString) } } }); ================================================ FILE: lib/server/graphql/types/draft-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLInt } from 'graphql'; import draftIdInputType from './draft-id-input'; const draftInputType = new GraphQLInputObjectType({ name: 'DraftInput', fields: { _id: { type: draftIdInputType }, __v: { type: GraphQLInt }, data: { type: GraphQLString }, actions: { type: GraphQLString }, schemaLinks: { type: GraphQLString } } }); export default draftInputType; ================================================ FILE: lib/server/graphql/types/draft.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLInt } from 'graphql'; import draftIdType from './draft-id'; export default new GraphQLObjectType({ name: 'Draft', fields: { _id: { type: new GraphQLNonNull(draftIdType) }, __v: { type: GraphQLInt }, data: { type: GraphQLString, resolve: (draft) => JSON.stringify(draft.data) }, actions: { type: GraphQLString, resolve: (draft) => JSON.stringify(draft.actions) }, schemaLinks: { type: GraphQLString, resolve: (draft) => JSON.stringify(draft.schemaLinks) } } }); ================================================ FILE: lib/server/graphql/types/filter.js ================================================ import { GraphQLInputObjectType, GraphQLNonNull, GraphQLString, GraphQLList } from 'graphql'; const filterType = new GraphQLInputObjectType({ name: 'Filter', fields: { property: { type: new GraphQLNonNull(GraphQLString) }, op: { type: new GraphQLInputObjectType({ name: 'FilterOp', fields: { eq: {type: GraphQLString}, in: {type: new GraphQLList(GraphQLString)} } }) } } }); export default filterType; ================================================ FILE: lib/server/graphql/types/generators/schema-entry-input.js ================================================ import forEach from 'lodash.foreach'; import { GraphQLInputObjectType, GraphQLNonNull, GraphQLString, GraphQLInt, GraphQLID } from 'graphql'; import {TypesNativeGraphQL} from 'helpers/data-types/native'; export default (schema) => { const propertiesFields = {}; forEach(schema.properties, (property) => { if (TypesNativeGraphQL[property.type]) { const native = TypesNativeGraphQL[property.type]; propertiesFields[property.id] = Object.assign({}, native); } }); return new GraphQLInputObjectType({ name: `rlx_${schema.slug}_input`, fields: { _id: {type: new GraphQLNonNull(GraphQLID)}, title: {type: GraphQLString}, slug: {type: GraphQLString}, __v: {type: GraphQLInt}, state: {type: GraphQLString}, date: { type: GraphQLInt, resolve: () => Date.now() }, updatedDate: { type: GraphQLInt, resolve: () => Date.now() }, updatedBy: {type: GraphQLID}, createdBy: {type: GraphQLID}, data: {type: GraphQLString}, ...propertiesFields } }); }; ================================================ FILE: lib/server/graphql/types/generators/schema-entry.js ================================================ import forEach from 'lodash.foreach'; import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLInt, GraphQLID } from 'graphql'; import {TypesNativeGraphQL} from 'helpers/data-types/native'; import userType from '../user'; import UserModel from '../../../models/user'; export default (schema) => { const propertiesFields = {}; forEach(schema.properties, (property) => { if (TypesNativeGraphQL[property.type]) { const native = TypesNativeGraphQL[property.type]; propertiesFields[property.id] = Object.assign({}, native); } }); return new GraphQLObjectType({ name: `rlx_${schema.slug}`, fields: { _id: {type: new GraphQLNonNull(GraphQLID)}, title: {type: GraphQLString}, slug: {type: new GraphQLNonNull(GraphQLString)}, __v: {type: GraphQLInt}, state: {type: GraphQLString}, date: { type: GraphQLInt, resolve ({date}) { return date && date.getTime(); } }, updatedDate: { type: GraphQLInt, resolve ({updatedDate}) { return updatedDate && updatedDate.getTime(); } }, updatedBy: { type: userType, async resolve (schemaEntry) { return await UserModel.findById(schemaEntry.updatedBy).exec(); } }, createdBy: { type: userType, async resolve (schemaEntry) { return await UserModel.findById(schemaEntry.createdBy).exec(); } }, data: { type: GraphQLString, resolve (schemaEntry) { return JSON.stringify(schemaEntry.data); } }, ...propertiesFields } }); }; ================================================ FILE: lib/server/graphql/types/media-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLNonNull } from 'graphql'; const mediaInputType = new GraphQLInputObjectType({ name: 'MediaInput', fields: { file: { type: new GraphQLInputObjectType({ name: 'MediaInputFile', fields: { file: {type: new GraphQLNonNull(GraphQLString)}, filename: {type: new GraphQLNonNull(GraphQLString)} } }) } } }); export default mediaInputType; ================================================ FILE: lib/server/graphql/types/media.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLID } from 'graphql'; const mediaType = new GraphQLObjectType({ name: 'Media', fields: { _id: {type: new GraphQLNonNull(GraphQLID)}, name: {type: new GraphQLNonNull(GraphQLString)}, fileName: {type: new GraphQLNonNull(GraphQLString)}, type: {type: new GraphQLNonNull(GraphQLString)}, size: {type: new GraphQLNonNull(GraphQLString)}, filesize: {type: new GraphQLNonNull(GraphQLString)}, dimension: { type: new GraphQLObjectType({ name: 'MediaDimension', fields: { width: {type: GraphQLInt}, height: {type: GraphQLInt} } }) }, url: {type: new GraphQLNonNull(GraphQLString)}, absoluteUrl: {type: new GraphQLNonNull(GraphQLString)}, date: { type: GraphQLFloat, resolve: ({date}) => (date && date.getTime()) }, thumbnail: {type: GraphQLString}, variations: { type: GraphQLString, resolve (media) { return JSON.stringify(media.variations); } } } }); export default mediaType; ================================================ FILE: lib/server/graphql/types/menu-data.js ================================================ import getProjection from 'helpers/get-projection'; import { GraphQLObjectType, GraphQLString, GraphQLID, GraphQLList } from 'graphql'; import pageType from './page'; import PageModel from '../../models/page'; const menuDataType = new GraphQLObjectType({ name: 'MenuData', fields: () => ({ id: {type: GraphQLID}, type: {type: GraphQLString}, page: { type: pageType, resolve (menuData, params, options) { const projection = getProjection(options.fieldASTs[0]); return PageModel .findById(menuData.page) .select(projection) .exec(); } }, link: { type: new GraphQLObjectType({ name: 'MenuDataLink', fields: { url: {type: GraphQLString}, label: {type: GraphQLString} } }) }, children: { type: new GraphQLList(menuDataType) } }) }); export default menuDataType; ================================================ FILE: lib/server/graphql/types/menu-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLFloat, GraphQLID } from 'graphql'; const menuInputType = new GraphQLInputObjectType({ name: 'MenuInput', fields: { _id: {type: GraphQLID}, title: {type: GraphQLString}, date: { type: GraphQLFloat, resolve: () => Date.now() }, updatedDate: { type: GraphQLFloat, resolve: () => Date.now() }, updatedBy: {type: GraphQLString}, createdBy: {type: GraphQLString}, data: {type: GraphQLString} } }); export default menuInputType; ================================================ FILE: lib/server/graphql/types/menu.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLFloat, GraphQLID } from 'graphql'; import userType from './user'; import UserModel from '../../models/user'; const menuType = new GraphQLObjectType({ name: 'Menu', fields: { _id: {type: new GraphQLNonNull(GraphQLID)}, title: {type: GraphQLString}, date: { type: GraphQLFloat, resolve ({date}) { return date && date.getTime(); } }, updatedDate: { type: GraphQLFloat, resolve ({updatedDate}) { return updatedDate && updatedDate.getTime(); } }, updatedBy: { type: userType, resolve (menu) { return UserModel.findById(menu.updatedBy).exec(); } }, createdBy: { type: userType, resolve (menu) { return UserModel.findById(menu.createdBy).exec(); } }, data: { type: GraphQLString, resolve ({data}) { // TODO fetch needed data from nodes return JSON.stringify(data); } } } }); export default menuType; ================================================ FILE: lib/server/graphql/types/page-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLID } from 'graphql'; const pageInputType = new GraphQLInputObjectType({ name: 'PageInput', fields: { _id: {type: GraphQLID}, slug: {type: GraphQLString}, __v: {type: GraphQLInt}, state: {type: GraphQLString}, date: { type: GraphQLFloat, resolve: () => Date.now() }, updatedDate: { type: GraphQLFloat, resolve: () => Date.now() }, title: {type: GraphQLString}, data: {type: GraphQLString}, updatedBy: {type: GraphQLID}, createdBy: {type: GraphQLID} } }); export default pageInputType; ================================================ FILE: lib/server/graphql/types/page.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLID } from 'graphql'; import userType from './user'; import UserModel from '../../models/user'; const pageType = new GraphQLObjectType({ name: 'Page', fields: { _id: {type: new GraphQLNonNull(GraphQLID)}, slug: {type: new GraphQLNonNull(GraphQLString)}, __v: {type: GraphQLInt}, state: {type: GraphQLString}, date: { type: GraphQLFloat, resolve ({date}) { return date && date.getTime(); } }, updatedDate: { type: GraphQLFloat, resolve ({updatedDate}) { return updatedDate && updatedDate.getTime(); } }, title: {type: GraphQLString}, data: { type: GraphQLString, resolve (page) { return JSON.stringify(page.data); } }, updatedBy: { type: userType, async resolve (page) { return await UserModel.findById(page.updatedBy).exec(); } }, createdBy: { type: userType, async resolve (page) { return await UserModel.findById(page.createdBy).exec(); } } } }); export default pageType; ================================================ FILE: lib/server/graphql/types/revision.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLID } from 'graphql'; import userType from './user'; import UserModel from '../../models/user'; const revisionType = new GraphQLObjectType({ name: 'Revision', fields: { _id: { type: new GraphQLObjectType({ name: 'RevisionId', fields: { _id: {type: new GraphQLNonNull(GraphQLID)}, __v: {type: new GraphQLNonNull(GraphQLInt)} } }) }, date: { type: GraphQLFloat, resolve ({date}) { return date && date.getTime(); } }, doc: { type: new GraphQLNonNull(GraphQLString), resolve (revision) { return JSON.stringify(revision.doc); } }, user: { type: userType, async resolve (revision) { return await UserModel.findById(revision.user).exec(); } } } }); export default revisionType; ================================================ FILE: lib/server/graphql/types/schema-entry-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLID } from 'graphql'; export default new GraphQLInputObjectType({ name: 'SchemaEntryInput', fields: { _id: {type: GraphQLID}, title: {type: GraphQLString}, slug: {type: GraphQLString}, __v: {type: GraphQLInt}, state: {type: GraphQLString}, date: { type: GraphQLFloat, resolve: () => Date.now() }, updatedDate: { type: GraphQLFloat, resolve: () => Date.now() }, updatedBy: {type: GraphQLID}, createdBy: {type: GraphQLID}, data: {type: GraphQLString}, properties: {type: GraphQLString} } }); ================================================ FILE: lib/server/graphql/types/schema-entry.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLID } from 'graphql'; import userType from './user'; import UserModel from '../../models/user'; export default new GraphQLObjectType({ name: 'SchemaEntry', fields: { _id: {type: new GraphQLNonNull(GraphQLID)}, title: {type: GraphQLString}, slug: {type: new GraphQLNonNull(GraphQLString)}, __v: {type: GraphQLInt}, state: {type: GraphQLString}, date: { type: GraphQLFloat, resolve ({date}) { return date && date.getTime(); } }, publishedDate: { type: GraphQLFloat, resolve ({publishedDate}) { return publishedDate && publishedDate.getTime(); } }, updatedDate: { type: GraphQLFloat, resolve ({updatedDate}) { return updatedDate && updatedDate.getTime(); } }, updatedBy: { type: userType, async resolve (schemaEntry) { return await UserModel.findById(schemaEntry.updatedBy).exec(); } }, createdBy: { type: userType, async resolve (schemaEntry) { return await UserModel.findById(schemaEntry.createdBy).exec(); } }, data: { type: GraphQLString, resolve (schemaEntry) { return JSON.stringify(schemaEntry.data); } }, properties: { type: GraphQLString, resolve (schemaEntry) { return JSON.stringify(schemaEntry.properties); } } } }); ================================================ FILE: lib/server/graphql/types/schema-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLID } from 'graphql'; const schemaInputType = new GraphQLInputObjectType({ name: 'SchemaInput', fields: { _id: {type: GraphQLString}, __v: {type: GraphQLInt}, title: {type: GraphQLString}, slug: {type: GraphQLString}, type: {type: GraphQLString}, date: { type: GraphQLFloat, resolve: () => Date.now() }, updatedDate: { type: GraphQLFloat, resolve: () => Date.now() }, data: {type: GraphQLString}, schemaLinks: {type: GraphQLString}, updatedBy: {type: GraphQLID}, createdBy: {type: GraphQLID}, properties: {type: GraphQLString} } }); export default schemaInputType; ================================================ FILE: lib/server/graphql/types/schema.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLID } from 'graphql'; import userType from './user'; import UserModel from '../../models/user'; const schemaType = new GraphQLObjectType({ name: 'Schema', fields: { _id: { type: new GraphQLNonNull(GraphQLID) }, title: { type: GraphQLString }, slug: { type: new GraphQLNonNull(GraphQLString) }, type: { type: GraphQLString }, __v: { type: GraphQLInt }, date: { type: GraphQLFloat, resolve: ({date}) => (date && date.getTime()) }, updatedDate: { type: GraphQLFloat, resolve: ({updatedDate}) => (updatedDate && updatedDate.getTime()) }, data: { type: GraphQLString, resolve: (schema) => JSON.stringify(schema.data) }, schemaLinks: { type: GraphQLString, resolve: (schema) => JSON.stringify(schema.schemaLinks) }, updatedBy: { type: userType, resolve: (schema) => UserModel.findById(schema.updatedBy).exec() }, createdBy: { type: userType, resolve: (schema) => UserModel.findById(schema.createdBy).exec() }, properties: { type: GraphQLString, resolve: (schema) => JSON.stringify(schema.properties) } } }); export default schemaType; ================================================ FILE: lib/server/graphql/types/setting-input.js ================================================ import { GraphQLInputObjectType, GraphQLString } from 'graphql'; const settingInputType = new GraphQLInputObjectType({ name: 'SettingInput', fields: { _id: {type: GraphQLString}, value: {type: GraphQLString} } }); export default settingInputType; ================================================ FILE: lib/server/graphql/types/setting.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString } from 'graphql'; const settingType = new GraphQLObjectType({ name: 'Setting', fields: { _id: {type: new GraphQLNonNull(GraphQLString)}, value: {type: GraphQLString} } }); export default settingType; ================================================ FILE: lib/server/graphql/types/style-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLID } from 'graphql'; const styleInputType = new GraphQLInputObjectType({ name: 'StyleInput', fields: { _id: {type: GraphQLID}, title: {type: GraphQLString}, type: {type: GraphQLString}, options: {type: GraphQLString}, displayOptions: {type: GraphQLString} } }); export default styleInputType; ================================================ FILE: lib/server/graphql/types/style.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLID } from 'graphql'; const styleType = new GraphQLObjectType({ name: 'Style', fields: { _id: {type: new GraphQLNonNull(GraphQLID)}, type: {type: new GraphQLNonNull(GraphQLString)}, title: {type: GraphQLString}, options: { type: GraphQLString, resolve (style) { return JSON.stringify(style.options); } }, displayOptions: { type: GraphQLString, resolve (style) { return JSON.stringify(style.displayOptions); } } } }); export default styleType; ================================================ FILE: lib/server/graphql/types/symbol-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLID } from 'graphql'; const symbolInputType = new GraphQLInputObjectType({ name: 'SymbolInput', fields: { _id: {type: GraphQLID}, title: {type: GraphQLString}, data: {type: GraphQLString} } }); export default symbolInputType; ================================================ FILE: lib/server/graphql/types/symbol.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLID } from 'graphql'; const symbolType = new GraphQLObjectType({ name: 'Symbol', fields: { _id: {type: new GraphQLNonNull(GraphQLID)}, title: {type: GraphQLString}, data: { type: GraphQLString, resolve (symbol) { return JSON.stringify(symbol.data); } } } }); export default symbolType; ================================================ FILE: lib/server/graphql/types/tab-item.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString } from 'graphql'; export default new GraphQLObjectType({ name: 'TabItem', fields: { _id: { type: new GraphQLNonNull(GraphQLString) }, title: { type: GraphQLString } } }); ================================================ FILE: lib/server/graphql/types/tab.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLID, GraphQLString } from 'graphql'; import tabItemType from './tab-item'; import PageModel from '../../models/page'; export default new GraphQLObjectType({ name: 'Tab', fields: { _id: { type: new GraphQLNonNull(GraphQLID) }, _userId: { type: GraphQLID }, type: { type: new GraphQLNonNull(GraphQLString) }, item: { type: tabItemType, async resolve ({type, item}) { let result = null; if (type === 'page') { result = await PageModel.findById(item).exec(); } return result; } } } }); ================================================ FILE: lib/server/graphql/types/uploaded-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLInt } from 'graphql'; const uploadedInputType = new GraphQLInputObjectType({ name: 'UploadedFileInput', fields: { originalname: {type: GraphQLString}, mimetype: {type: GraphQLString}, destination: {type: GraphQLString}, filename: {type: GraphQLString}, path: {type: GraphQLString}, size: {type: GraphQLInt} } }); export default uploadedInputType; ================================================ FILE: lib/server/graphql/types/uploaded.js ================================================ import { GraphQLObjectType, GraphQLString, GraphQLInt } from 'graphql'; const uploadedType = new GraphQLObjectType({ name: 'UploadedFile', fields: { originalname: {type: GraphQLString}, mimetype: {type: GraphQLString}, destination: {type: GraphQLString}, filename: {type: GraphQLString}, path: {type: GraphQLString}, size: {type: GraphQLInt} } }); export default uploadedType; ================================================ FILE: lib/server/graphql/types/user-input.js ================================================ import { GraphQLInputObjectType, GraphQLString, GraphQLNonNull } from 'graphql'; const userInputType = new GraphQLInputObjectType({ name: 'UserInput', fields: { _id: {type: GraphQLString}, username: {type: new GraphQLNonNull(GraphQLString)}, name: {type: GraphQLString}, password: {type: GraphQLString}, email: {type: GraphQLString}, date: {type: GraphQLString} } }); export default userInputType; ================================================ FILE: lib/server/graphql/types/user.js ================================================ import { GraphQLObjectType, GraphQLNonNull, GraphQLString } from 'graphql'; const userType = new GraphQLObjectType({ name: 'User', fields: { _id: {type: new GraphQLNonNull(GraphQLString)}, username: {type: new GraphQLNonNull(GraphQLString)}, name: {type: GraphQLString}, email: {type: GraphQLString}, date: {type: GraphQLString} } }); export default userType; ================================================ FILE: lib/server/index.js ================================================ import bodyParser from 'body-parser'; import connectMongo from 'connect-mongo'; import express from 'express'; import graphqlHTTP from 'express-graphql'; import mongoose from 'mongoose'; import morgan from 'morgan'; import multer from 'multer'; import parseSettings from 'helpers/parse-settings'; import passport from 'passport'; import path from 'path'; import safeHtmlString from 'helpers/safe-html-string'; import session from 'express-session'; import config from '../../config'; import middleware from './middleware'; import routers from './routers'; import schema from './schema'; import SettingModel from './models/setting'; const app = express(); app.use(morgan('short')); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json({limit: 100000000})); // View engine app.set('views', path.join(__dirname, 'components')); // session const MongoStore = connectMongo(session); app.use(session({ secret: 'Is very secret', store: new MongoStore({mongooseConnection: mongoose.connection}) })); // Passport app.use(passport.initialize()); app.use(passport.session()); // Static files app.use(express.static('./public')); app.use(['favicon.ico', '/images*', '/media*', '/css*', '/fonts*', '/js*'], (req, res) => { res.status(404).end(); }); // Multer app.use('/graphql', multer({dest: './uploads/'}).single('file')); // GraphqQL server app.use('/graphql', graphqlHTTP(req => ({ schema: schema.getSchema(), rootValue: { isAuthenticated: req.isAuthenticated(), user: req.user, file: req.file }, graphiql: true }))); app.use(async (req, res, next) => { const settingsArr = await SettingModel .find({ _id: {$in: ['title', 'favicon']} }) .exec(); const settings = parseSettings(settingsArr); res.locals.header = [ { tag: 'title', content: settings.title && safeHtmlString(settings.title) || 'Relax CMS' } ]; if (process.env.NODE_ENV !== 'production') { res.baseScriptsURL = `http://localhost:${config.devPort}`; res.locals.header.push({ tag: 'script', props: { src: `${res.baseScriptsURL}/webpack-dev-server.js` } }); } else { res.baseScriptsURL = ''; } // footer res.locals.footer = [{ tag: 'script', props: { src: `${res.baseScriptsURL}/js/common.js` } }]; next(); }); app.use(middleware.fonts); app.use(middleware.googleAnalytics); app.use(routers.authRouter); app.use(routers.adminRouter); app.use(routers.publicRouter); app.use((req, res) => { res.status(404).end(); }); app.use((error, req, res) => { const statusCode = error.statusCode || 500; const err = { error: statusCode, message: error.message }; if (!res.headersSent) { res.status(statusCode).send(err); } }); export default app; ================================================ FILE: lib/server/logger.js ================================================ import winston from 'winston'; export default new winston.Logger({ transports: [ new winston.transports.Console({ level: 'debug', handleExceptions: true, json: false, colorize: true }) ], exitOnError: false }); ================================================ FILE: lib/server/middleware/fonts.js ================================================ import forEach from 'lodash.foreach'; import SettingModel from '../models/setting'; export default async (req, res, next) => { res.locals.header.push({ tag: 'script', props: { src: '//ajax.googleapis.com/ajax/libs/webfont/1.5.10/webfont.js' } }); try { const fontsSetting = await SettingModel.findOne({_id: 'fonts'}); if (fontsSetting && fontsSetting.value) { const fonts = JSON.parse(fontsSetting.value); if (fonts.customFonts) { let css = ''; forEach(fonts.customFonts, (customFont) => { const family = customFont.family; const map = customFont.files; const location = `/fonts/${customFont.id}/`; css += `@font-face { font-family: "${family}"; src: url("${location}${map.eot}"); src: `; if (map.woff2) { css += `url("${location}${map.woff2}"), `; } css += ` url("${location}${map.woff}"), url("${location}${map.ttf}"); } `; }); if (css !== '') { res.locals.header.push({ tag: 'style', props: { type: 'text/css' }, content: css }); } } if (fonts.webfontloader) { res.locals.header.push({ tag: 'script', content: `WebFont.load(${JSON.stringify(fonts.webfontloader)});` }); } } next(); } catch (err) { next(); } }; ================================================ FILE: lib/server/middleware/google-analytics.js ================================================ import utils from 'helpers/utils'; import SettingModel from '../models/setting'; export default async (req, res, next) => { res.locals.header.push({ tag: 'script', props: { src: '//ajax.googleapis.com/ajax/libs/webfont/1.5.10/webfont.js' } }); const googleAnalyticsSetting = await SettingModel .findById('googleAnalytics') .exec(); if (googleAnalyticsSetting && googleAnalyticsSetting.value && utils.validateGATrackingId(googleAnalyticsSetting.value)) { res.locals.header.push({ tag: 'script', content: ` (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', '${googleAnalyticsSetting.value}', 'auto'); ` }); next(); } else { next(); } }; ================================================ FILE: lib/server/middleware/index.js ================================================ import fonts from './fonts'; import googleAnalytics from './google-analytics'; export default { fonts, googleAnalytics }; ================================================ FILE: lib/server/migrate.js ================================================ import q from 'q'; import semver from 'semver'; import {readdirSync} from 'fs'; import {basename, extname, join} from 'path'; import logger from './logger'; import MigrationModel from './models/migration'; const migrationsPath = './migrations'; function saveMigration (path) { return new MigrationModel({_id: path}).save(); } function runMigration (path) { const migration = require(join(migrationsPath, path)); return migration() .then(() => saveMigration(path)) .then(() => logger.info(`migration ${path} was applied`)); } export default function migrate () { return q() .then(() => { let promise = q(); readdirSync(migrationsPath) .map((path) => (extname(path) === '.js' ? basename(path) : false)) .filter((path) => path && semver.valid(path.split('-')[0])) .sort((a, b) => semver.compare(a.split('-')[0], b.split('-')[0])) .forEach((path) => { promise = promise .then(() => MigrationModel.findOne({_id: path}).exec()) .then((migration) => !migration && runMigration(path)); }); return promise; }); } ================================================ FILE: lib/server/models/color.js ================================================ import mongoose from 'mongoose'; const colorSchema = new mongoose.Schema({ label: { type: String, required: true }, value: { type: String, required: true } }); export default mongoose.model('Color', colorSchema); ================================================ FILE: lib/server/models/draft.js ================================================ import mongoose from 'mongoose'; const draftSchema = new mongoose.Schema({ _id: { _id: { type: mongoose.Schema.Types.ObjectId }, _userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User' } }, data: { type: mongoose.Schema.Types.Mixed, default: {} }, actions: { type: Array, default: [] }, schemaLinks: { type: mongoose.Schema.Types.Mixed, default: {} } }); export default mongoose.model('Draft', draftSchema); ================================================ FILE: lib/server/models/index.js ================================================ import color from './color'; import draft from './draft'; import media from './media'; import menu from './menu'; import page from './page'; import revision from './revision'; import schema from './schema'; import setting from './setting'; import style from './style'; import tab from './tab'; import user from './user'; export default [ color, draft, media, menu, page, revision, schema, setting, style, tab, user ]; ================================================ FILE: lib/server/models/media.js ================================================ import mongoose from 'mongoose'; const mediaSchema = new mongoose.Schema({ name: { type: String, required: true }, fileName: { type: String, required: true }, type: { type: String, required: true }, size: { type: String, required: true }, filesize: { type: Number, required: true }, dimension: { width: { type: Number }, height: { type: Number } }, url: { type: String, required: true, unique: true }, absoluteUrl: { type: String, required: true, unique: true }, date: { type: Date, default: Date.now }, thumbnail: { type: String }, variations: { type: Array } }); export default mongoose.model('Media', mediaSchema); ================================================ FILE: lib/server/models/menu.js ================================================ import mongoose from 'mongoose'; const menuSchema = new mongoose.Schema({ title: { type: String, required: true }, date: { type: Date, default: Date.now }, updatedDate: { type: Date, default: Date.now }, createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, updatedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, data: {} }, {minimize: false}); export default mongoose.model('Menu', menuSchema); ================================================ FILE: lib/server/models/migration.js ================================================ import mongoose from 'mongoose'; const migrationSchema = new mongoose.Schema({ _id: { type: String }, when: { type: Date, default: Date.now } }); export default mongoose.model('Migration', migrationSchema); ================================================ FILE: lib/server/models/page.js ================================================ import mongoose from 'mongoose'; const pageSchema = new mongoose.Schema({ title: { type: String, required: true }, slug: { type: String, required: true, unique: true }, state: { type: String, default: 'draft' }, date: { type: Date, default: Date.now }, updatedDate: { type: Date, default: Date.now }, data: { type: mongoose.Schema.Types.Mixed, default: {} }, createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, updatedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' } }); export default mongoose.model('Page', pageSchema); ================================================ FILE: lib/server/models/revision.js ================================================ import mongoose from 'mongoose'; const schema = new mongoose.Schema({ _id: { _id: { type: mongoose.Schema.Types.ObjectId, required: true }, __v: { type: Number, required: true } }, date: { type: Date, default: Date.now }, user: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, doc: { type: mongoose.Schema.Types.Mixed, required: true } }); export default mongoose.model('Revision', schema); ================================================ FILE: lib/server/models/schema-entry.js ================================================ import forEach from 'lodash.foreach'; import mongoose from 'mongoose'; import {TypesNative} from 'helpers/data-types/native'; import SchemaModel from './schema'; // import tabsStore from '../stores/tabs'; // import revisionsStore from '../stores/revisions'; const models = {}; export default async (schemaId) => { if (models[schemaId]) { return models[schemaId]; } const schema = await SchemaModel.findById(schemaId).exec(); const properties = {}; forEach(schema.properties, (property) => { if (TypesNative[property.type]) { const native = TypesNative[property.type]; properties[property.id] = { type: native, required: property.required }; } }); const mongooseSchema = { title: { type: String, required: true }, slug: { type: String, required: true, unique: true }, state: { type: String, default: 'draft' }, date: { type: Date, default: Date.now }, publishedDate: { type: Date, default: Date.now }, updatedDate: { type: Date, default: Date.now }, data: { type: Array }, schemaLinks: { type: mongoose.Schema.Types.Mixed }, overlap: { type: Boolean, default: false }, createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, updatedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, properties }; const entrySchema = new mongoose.Schema(mongooseSchema, {collection: schema.slug}); // entrySchema.post('remove', (schemaEntry) => { // tabsStore.removeMultiple({ // '_id._id': schemaEntry._id // }); // revisionsStore.removeMultiple({ // '_id._id': schemaEntry._id // }); // }); const model = mongoose.model(schema.slug, entrySchema); models[schemaId] = model; return model; }; ================================================ FILE: lib/server/models/schema.js ================================================ import mongoose from 'mongoose'; // import tabsStore from '../stores/tabs'; // import revisionsStore from '../stores/revisions'; const schemaSchema = new mongoose.Schema({ title: { type: String, required: true }, slug: { type: String, required: true, unique: true }, type: { type: String, required: true }, data: { type: Array, default: [] }, schemaLinks: { type: mongoose.Schema.Types.Mixed, default: {} }, date: { type: Date, default: Date.now }, updatedDate: { type: Date, default: Date.now }, createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, updatedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, properties: [ { id: { type: String, required: true }, title: { type: String, required: true }, type: { type: String, required: true }, props: { type: mongoose.Schema.Types.Mixed, required: false }, default: {}, required: { type: Boolean, required: true, default: false }, dependencies: { type: Array, required: false } } ] }); // schemaSchema.post('remove', (schema) => { // tabsStore.removeMultiple({ // '_id._id': schema._id // }); // // revisionsStore.removeMultiple({ // '_id._id': schema._id // }); // }); export default mongoose.model('Schema', schemaSchema); ================================================ FILE: lib/server/models/setting.js ================================================ import mongoose from 'mongoose'; const settingSchema = new mongoose.Schema({ _id: { type: String }, value: { type: mongoose.Schema.Types.Mixed, required: true } }); export default mongoose.model('Setting', settingSchema); ================================================ FILE: lib/server/models/style.js ================================================ import mongoose from 'mongoose'; const styleSchema = new mongoose.Schema({ type: { type: String, required: true }, title: { type: String, required: true }, options: { type: mongoose.Schema.Types.Mixed, required: true }, displayOptions: { type: mongoose.Schema.Types.Mixed } }); export default mongoose.model('Style', styleSchema); ================================================ FILE: lib/server/models/symbol.js ================================================ import mongoose from 'mongoose'; const symbolSchema = new mongoose.Schema({ title: { type: String, required: true }, data: { type: mongoose.Schema.Types.Mixed, required: true } }); export default mongoose.model('Symbol', symbolSchema); ================================================ FILE: lib/server/models/tab.js ================================================ import mongoose from 'mongoose'; const tabSchema = new mongoose.Schema({ _userId: { type: mongoose.Schema.Types.ObjectId }, type: { type: String }, item: { type: mongoose.Schema.Types.ObjectId } }); export default mongoose.model('Tab', tabSchema); ================================================ FILE: lib/server/models/user.js ================================================ import mongoose from 'mongoose'; import passport from 'passport'; import passportLocalMongoose from 'passport-local-mongoose'; import {Strategy} from 'passport-local'; const userSchema = new mongoose.Schema({ username: { type: String, required: true, unique: true }, name: { type: String, required: true }, password: { type: String }, email: { type: String, unique: true, trim: true, required: true }, date: { type: Date, default: Date.now } }); userSchema.plugin(passportLocalMongoose); const UserModel = mongoose.model('User', userSchema); passport.use(new Strategy(UserModel.authenticate())); passport.serializeUser(UserModel.serializeUser()); passport.deserializeUser(UserModel.deserializeUser()); export default UserModel; ================================================ FILE: lib/server/routers/admin.js ================================================ import getDefaultFavicon from 'helpers/default-favicon'; import getMarkup from 'helpers/get-markup'; import routeHandler from 'helpers/route-handler'; import routes from 'routers/admin'; import {Router} from 'express'; const adminRouter = new Router(); // Restrict from here onwards adminRouter.get('/admin*', (req, res, next) => { if (req.isAuthenticated()) { res.locals.footer.push({ tag: 'link', props: { rel: 'stylesheet', type: 'text/css', href: 'https://fonts.googleapis.com/css?family=Open+Sans:400,600,700' } }); res.locals.header.push(getDefaultFavicon(res)); if (process.env.NODE_ENV === 'production') { res.locals.header.push({ tag: 'link', props: { rel: 'stylesheet', type: 'text/css', href: '/css/admin.css' } }); } res.locals.footer.push({ tag: 'script', props: { src: `${res.baseScriptsURL}/js/admin.js` } }); next(); } else { res.redirect('/admin/login'); } }); adminRouter.get('/admin*', (req, res, next) => { if (req.isAuthenticated()) { routeHandler(routes, req, res, next); } else { next(); } }); adminRouter.get('/admin*', async (req, res, next) => { if (req.isAuthenticated() && req.routerState) { // const AdminContainer = req.routerState.components[0]; // const PanelContainer = req.routerState.components[1]; // // const {panelSettings, defaultQuery} = PanelContainer; // const queryVariables = Object.assign({}, defaultQuery, req.query); // // const paginateQuery = getQueryVariables(queryVariables); // // const {query, variables} = AdminContainer.getQueryAndVariables( // { // params: req.routerState.params, // queryVariables: { // ...paginateQuery // } // }, // { // ...panelSettings // } // ); // const username = req.session.passport.user; // const user = await UserModel // .findOne({username}) // .select({ // _id: 1, // username: 1, // name: 1, // email: 1 // }) // .exec(); // const data = await graphql( // schema.getSchema(), // query, // { // isAuthenticated: true, // user // }, // variables // ); // await req.store.dispatch({ // type: graphqlActionType, // ...data // }); res.status(200).send(getMarkup(req.store, res)); } else { next(); } }); export default adminRouter; ================================================ FILE: lib/server/routers/auth.js ================================================ import getDefaultFavicon from 'helpers/default-favicon'; import getMarkup from 'helpers/get-markup'; import passport from 'passport'; import routeHandler from 'helpers/route-handler'; import routes from 'routers/auth'; import {Router} from 'express'; import UserModel from '../models/user'; const authRouter = new Router(); function injectScript (req, res, next) { res.locals.header.push({ tag: 'link', props: { rel: 'stylesheet', type: 'text/css', href: 'https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700' } }); if (process.env.NODE_ENV === 'production') { res.locals.header.push({ tag: 'link', props: { rel: 'stylesheet', type: 'text/css', href: '/css/auth.css' } }); } res.locals.header.push(getDefaultFavicon(res)); res.locals.footer.push({ tag: 'script', props: { src: `${res.baseScriptsURL}/js/auth.js` } }); next(); } authRouter.get(/^\/admin\/(login|init)$/, (req, res, next) => { if (req.isAuthenticated()) { res.redirect('/admin'); } else { routeHandler(routes, req, res, next); } }); // Logout authRouter.get('/admin/logout', (req, res) => { req.logout(); res.redirect('/admin/login'); }); // Register authRouter.get('/admin/init', injectScript, async (req, res, next) => { try { const count = await UserModel.count().exec(); if (count === 0) { res.status(200).send(getMarkup(req.store, res)); } else { next(); } } catch (error) { next(error); } }); // Login authRouter.get('/admin/login', injectScript, (req, res) => { if (req.isAuthenticated()) { res.redirect('/admin'); } else { res.status(200).send(getMarkup(req.store, res)); } }); authRouter.post('/admin/login', (req, res, next) => { passport.authenticate('local', (err, user) => { if (err) { res.status(500).send({ error: 500, message: err.message }); } else if (!user) { res.status(403).send({ error: 403, message: 'Invalid username and password combination' }); } else { req.logIn(user, (error) => { if (error) { res.status(500).send({ error: 500, message: error.message }); } else { res.status(200).end(); } }); } })(req, res, next); }); export default authRouter; ================================================ FILE: lib/server/routers/index.js ================================================ import adminRouter from './admin'; import authRouter from './auth'; import publicRouter from './public'; export default { adminRouter, authRouter, publicRouter }; ================================================ FILE: lib/server/routers/public.js ================================================ import find from 'lodash.find'; import forEach from 'lodash.foreach'; import getDefaultFavicon from 'helpers/default-favicon'; import getMarkup from 'helpers/get-markup'; import nodemailer from 'nodemailer'; import parseSettings from 'helpers/parse-settings'; import path from 'path'; import resizeImage from 'helpers/resize-image'; import routeHandler from 'helpers/route-handler'; import routes from 'routers/public'; import {graphql as graphqlActionType} from 'actions'; import {Router} from 'express'; import {graphql} from 'graphql'; import schema from '../schema'; import MediaModel from '../models/media'; import SettingModel from '../models/setting'; const publicRouter = new Router(); publicRouter.get('/api/media/resize/:mediaId/:width/:height', async (req, res, next) => { try { const {mediaId: id} = req.params; let {width, height} = req.params; width = parseInt(width, 10); height = parseInt(height, 10); const media = await MediaModel .findById(id) .select({ dimension: 1, variations: 1, fileName: 1, absoluteUrl: 1 }) .exec(); if (!media) { throw new Error('Media not found'); } if (!media.dimension) { throw new Error('Media file is not an image'); } const relativePath = path.join('media', id); const mediaPath = path.join('.', 'public', relativePath); const originalRatio = media.dimension.width / media.dimension.height; let resultWidth = Math.ceil(width / 100) * 100; let resultHeight = resultWidth / originalRatio; if (resultHeight < height) { resultHeight = Math.ceil(height / 100) * 100; resultWidth = resultHeight * originalRatio; } resultWidth = Math.round(resultWidth); resultHeight = Math.round(resultHeight); const filename = `${resultWidth}x${resultHeight}-${media.fileName}`; const filePath = path.join(mediaPath, filename); let variation; // Check if variation already exists forEach(media.variations, (_variation) => { const {dimension: {width: _width, height: _height}} = _variation; if (_width === resultWidth && _height === resultHeight) { variation = _variation; return false; } }); if (!variation) { await resizeImage(media.absoluteUrl, filePath, { width: resultWidth, height: resultHeight, quality: 100 }); variation = { url: path.join(relativePath, filename), absoluteUrl: path.join(mediaPath, filename), dimension: { width: resultWidth, height: resultHeight } }; media.variations.push(variation); await media.save(); } res.sendFile(variation.absoluteUrl, {root: '.'}); } catch (error) { next(error); } }); publicRouter.post('/send-email', async (req, res) => { const settingsIds = [ 'mailService', 'mailUser', 'mailPass', 'mailTo' ]; const settingsArr = await SettingModel .find({ _id: { $in: settingsIds } }) .exec(); const settings = parseSettings(settingsArr); const formData = req.body; let allSetup = true; forEach(settingsIds, (id) => { if (!settings[id]) { allSetup = false; return false; } }); if (allSetup) { const transporter = nodemailer.createTransport({ service: settings.mailService, auth: { user: settings.mailUser, pass: settings.mailPass } }); const mailOptions = { from: formData.from, to: settings.mailTo, subject: formData.subject, html: formData.message }; try { await transporter.sendMail(mailOptions); res.status(200).send(); } catch (err) { res.status(500).send('Error sending email'); } } else { res.status(500).send('Admin: setup not concluded'); } }); publicRouter.use('/', (req, res, next) => { res.locals.footer.push({ tag: 'script', props: { src: `${res.baseScriptsURL}/js/public.js` } }); res.locals.header.push({ tag: 'link', props: { rel: 'stylesheet', type: 'text/css', href: '/css/public.css' } }); routeHandler(routes, req, res, next); }); publicRouter.use('/', async (req, res, next) => { if (req.routerState) { const settingsArr = await SettingModel .find({ _id: {$in: ['favicon', 'webclip']} }) .exec(); const settings = parseSettings(settingsArr); let iconLink = getDefaultFavicon(res); if (settings.favicon) { const favicon = await MediaModel .findById(settings.favicon) .select('type url') .exec(); if (favicon) { iconLink = { tag: 'link', props: { rel: 'icon', type: favicon.type, href: `${res.baseScriptsURL}/${favicon.url}` } }; } } res.locals.header.push(iconLink); if (settings.webclip) { const webclip = await MediaModel .findById(settings.webclip) .select('url') .exec(); if (webclip) { res.locals.header.push({ tag: 'link', props: { rel: 'apple-touch-icon', href: `${res.baseScriptsURL}/${webclip.url}` } }); } } const PageContainer = req.routerState.components[0]; const {query, variables} = PageContainer.getQueryAndVariables( { params: req.routerState.params } ); const data = await graphql( schema.getSchema(), query, { isAuthenticated: false, user: null }, variables ); if (data && data.data && data.data.page && data.data.page.title) { const titleTag = find(res.locals.header, 'tag', 'title'); titleTag.content += ` - ${data.data.page.title}`; } await req.store.dispatch({ type: graphqlActionType, ...data }); res.status(200).send(getMarkup(req.store, res)); } else { next(); } }); export default publicRouter; ================================================ FILE: lib/server/schema.js ================================================ import clone from 'lodash.clone'; import forEach from 'lodash.foreach'; import { GraphQLObjectType, GraphQLSchema } from 'graphql'; import mutations from './graphql/mutations'; import queries from './graphql/queries'; import SchemaModel from './models/schema'; // import schemaEntryInputType from './graphql/types/generators/schema-entry-input'; // import schemaEntryType from './graphql/types/generators/schema-entry'; // import schemaListCountQuery from './graphql/queries/generators/schema-list-count'; // import schemaListQuery from './graphql/queries/generators/schema-list'; class SchemaManager { constructor () { this.init(); } async init () { this.queryFields = clone(queries); this.mutationFields = clone(mutations); const schemas = await SchemaModel.find().exec(); forEach(schemas, (schema) => { this.processSchema(schema); }); this.createRoot(); } processSchema (/* schema */) { // const type = schemaEntryType(schema); // const inputType = schemaEntryInputType(schema); // // const schemaQueries = { // ['rlx_' + schema.slug]: schemaListQuery(type, schema), // ['rlx_' + schema.slug + '_count']: schemaListCountQuery(type, schema) // }; // // // TODO create mutations // // Object.assign(this.queryFields, schemaQueries); } createRoot () { this.rootQuery = new GraphQLObjectType({ name: 'Query', fields: () => (this.queryFields) }); this.rootMutation = new GraphQLObjectType({ name: 'Mutation', fields: () => (this.mutationFields) }); } getSchema () { const schema = { query: this.rootQuery }; if (Object.keys(this.mutationFields).length) { schema.mutation = this.rootMutation; } return new GraphQLSchema(schema); } } export default new SchemaManager(); ================================================ FILE: lib/server/shared/components/html.jsx ================================================ import React, {PropTypes} from 'react'; export default class Html extends React.Component { static propTypes = { locals: PropTypes.object, props: PropTypes.any, body: PropTypes.any }; render () { return ( {this.renderHeader()}