Exemplo n.º 1
0
	.then(function(links){
		var menuItemsCompiled = links.toString().split(",").join("");
		//inject our menu using our special interpolation @{key} in jade
		var markup = saphireTemplate.inject(templateMarkup, {
			"navItems":menuItemsCompiled
		});

		var block = new blocksModel({
			machineName:"admin_menu",
			name:"Admin Menu",
			description:"Foxie admin menu block, menu items generated for cores package.json file.",
			title:"Admin menu",
			content:markup,
			enabled:true,
			origin:"core"
		});

		saphireApi.queryGate(blocksModel,function(){
			block.save(function (err) {
				if (err) return console.log("error:", err.message)
			})
		});
	});
Exemplo n.º 2
0
var express = require('express'),
		app = express(),
		path = require('path'),
		saphire = require('saphire').functions;

var conf = {
	port:3000,
	root:path.normalize(__dirname +"/public/")
}

app.listen(conf.port);
app.set('views', __dirname + '/public/views/');

saphire.start(app);
Exemplo n.º 3
0
var util = require('./utils.js'),
	saphireApi = require("saphire").functions,
	saphireData = require("saphire").data,
	saphireModels = saphireData.models;
	//saphireModels = saphireData.models[0]

var saphire = require("saphire"),
	saphireExpose = {
		cores: saphire.cores
	}

var mongoose = saphireApi.db.mongoose

//require the registered model and then grab its export (menu parent)

var menuModelParent = saphireApi.useData("menu",saphireModels);
adminMenuModel = new saphireApi.local("make")

var saphireAdmin = {

	entry: function (admin, puroseData) {


		//get all data for the admin, this could be pretty much anything
		this.admin = admin;
		this.purposeData = puroseData;
		return this.saphireCores();
	},
	saphireCores: function () {
		var cores = saphireExpose.cores;
		for (core in cores) {
Exemplo n.º 4
0
	saphireCores: function () {
		var cores = saphireExpose.cores;
		for (core in cores) {
			//delete main module info as not needed here
			if (cores[core]["name"] == "saphire") {
				delete cores[core];
			}
		}
		//clean up delete
		var cores = cores.filter(Boolean),
			templateData = []
			//loop clean array
		for (core in cores) {
			var friendlyName = cores[core]["name"].replace(/-/g, " ");
			var machineName = cores[core]["name"].replace(/-/g, "_");
			var title = cores[core]["name"].split("-")[1];
			var version = cores[core]["version"];
			var description = cores[core]["description"];
			var routerInfo = cores[core]["saphire"]["admin"]["page"];
			//overide this with if query db TO DO
			var menuEnabled = cores[core]["saphire"]["admin"]["menu"]["enabled"];
			var menuIndex = cores[core]["saphire"]["admin"]["menu"]["index"];
			//end overide
			var menu = cores[core]["saphire"]["admin"]["menu"];
			//Build
			templateData[machineName] = {}
			templateData[machineName]["meta"] = {
				version: version,
				description: description
			}
			templateData[machineName]["template"] = {
				title: title
			}
			templateData[machineName]["system"] = {
				machineName: machineName
			}

			//per purpose pass data to template based on machine name
			var machineName = templateData[machineName]["system"]["machineName"],
				purposeData = this.purposeData[machineName]
			templateData[machineName]["purpose"] = {
				data: purposeData
			};

			//get the modules page definitions from the package.json
			templateData[machineName]["routes"] = routerInfo;

			//make admin menu
			saphireApi.extend("adminMenu", machineName, menu)

			//all routes admin common data like menu and such
			templateData[machineName]["common"] = {}
			templateData[machineName]["common"]["menu"] = saphire.data.adminMenu;
			//console.log(saphire.data.adminMenu)

			//use api to build a local array and return it to be saved in db
			adminMenuModel.extend({
				machineName: machineName,
				friendlyName: title,
				enabled: menuEnabled,
				index: menuIndex
			})
		}
		//Out of for loop
		//console.log(this.purposeData)

		//save the adminMenuModel to the schema
		var adminMenu = new menuModelParent({
			adminMenu: adminMenuModel.make
		});

		//query db if no record run function to save
		saphireApi.queryGate(menuModelParent, function () {
			adminMenu.save(function (err) {
				if (err) return console.log("error:", err.message)
			})
		});

		this.templateData = templateData;
		return templateData;
	}
Exemplo n.º 5
0
//Async

var saphireApi = require("saphire").functions,
		saphireData = require("saphire").data,
		Q = require("q"),
		fs = require("fs"),
		gulp = require("gulp"),
		concat = require('gulp-concat'),
		uglify = require('gulp-uglify'),
		path = require("path");

	var themePath = saphireApi.useData("temp",saphireData.publicPath),
			systemLibPath = path.resolve(__dirname,"../../../saphire-themes/system/libraries");

var settings = {
	compress:true,
}

function afterDir(path){ //[3]
	//must exec inside async, sadly
	var lib = require('bower-files')({
			dir:themePath+"libraries/bower/",
			cwd:themePath+"libraries/"
	});

	gulp.task("default",function(){ //Make gulp pipe the libraries files into the actual system rendered templates dir (saphire_themes)
		//console.log(lib.ext('js').files)
		gulp.src(lib.ext('js').files)
			.pipe(concat('lib.min.js'))
			.pipe(uglify())
			.pipe(gulp.dest(systemLibPath));