Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebar content-get files #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/controller/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
'use strict';

var model = require('../models/sidebar');
var layer = require('../models/sidebar');

var sidebar = module.exports = {};

sidebar.getData = function () {
return model.get();
sidebar.get = function () {
var layers = layer.getLayers();
layer.get(layers[0]);

return layers;
};
18 changes: 12 additions & 6 deletions app/models/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';

var model = module.exports = {};
var layer = module.exports = {};
var fs = require('fs');

model.newData = [];
layer.layers = [];

// Logic to read an array of files inside a directory
model.get = function () {
// Logic to read folders inside a directory
layer.getLayers = function () {
var allData = fs.readdirSync('tests/all/scss');
var prosilverData = fs.readdirSync('tests/prosilver/scss');
var localData = model.newData;
var localData = layer.layers;
for (var i = 0; i < allData.length; i++) {
if (allData[i] === 'base' || allData[i] === 'settings' || allData[i] === 'objects' || allData[i] === 'components') {
localData.push(allData[i]);
Expand All @@ -28,6 +28,12 @@ model.get = function () {
var temp = localData[0];
localData[0] = localData[1];
localData[1] = temp;

return localData;
};

// Logic to read files inside the folders
layer.get = function (layer) {
var data = fs.readdirSync('tests/all/scss/' + layer);
console.log(data);
}
4 changes: 2 additions & 2 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var express = require('express');
var config = require('./controller/config');
var sidebar = require('./controller/sidebar');

var router = express.Router();
var router = new express.Router();

// Route to UPDATE the config
router.post('/settings/config', function (req, res) {
Expand All @@ -30,7 +30,7 @@ router.get('/editor', function (req, res) {

// Route to READ the file
router.get('/editor/sidebar', function (req, res) {
req.params.fetch = sidebar.getData();
req.params.fetch = sidebar.get();
res.send(req.params.fetch);
});

Expand Down