Coder Social home page Coder Social logo

Comments (5)

michaeljoser avatar michaeljoser commented on July 30, 2024

I kinda found a solution that works for me.

Below i modified routes.js to check for a .html extension for the page i'm requesting. If its an html use sendfile (careful setting the correct path) otherwise render the .jade

// file: ./server/routes.js

var routes = [

    // Views
    {
        path: '/partials/*',
        httpMethod: 'GET',
        middleware: [function (req, res) {
            var requestedView;
            if (req.url.substr(-5) === '.html') {  
                // requesting a .html file
                requestedView = path.join(__dirname + '/../client/views/' , req.url);
                res.sendfile(requestedView);
            } else { 
                // its not html, render it as jade
                requestedView = path.join('./' , req.url);
                res.render(requestedView);
            } 
        }],
        accessLevel: accessLevels.public
    },
...
...

and in ./client/js/app.js i set the templateUrl to my custom html file

// file: ./client/js/app.js
...
...
    $routeProvider.when('/profile',
        {
            templateUrl:    '/partials/profile.html',
            controller:     'ProfileCtrl',
            access:         access.user
        });
...
...

With this i can use the default login.jade but serve my other pages as html ..

dunno if its a best practice though.

from angular-client-side-auth.

fnakstad avatar fnakstad commented on July 30, 2024

Hi Michael! I guess this depends on if you want to have parts of the application in Jade or have all your views be HTML... I think all you need to do for the latter is to change the "view engine" setting on line 10 in the server.js file to html instead of jade. If you can't get that working, you should be able to do a simple res.sendfile('path/to/view.html'). Let me know if you're still having problems with it!

from angular-client-side-auth.

michaeljoser avatar michaeljoser commented on July 30, 2024

Yes will try that as well. Thanks a lot.

Keep up the good work :)

from angular-client-side-auth.

m1ket avatar m1ket commented on July 30, 2024

I'm not a fan of Jade either. How easy do you think it would be to split this into two applications? 1. The Angular JS frontend that runs in Apache and 2. the Node.js server that acts as the API that runs the whole site?

from angular-client-side-auth.

fnakstad avatar fnakstad commented on July 30, 2024

It shouldn't be too hard I believe, but I don't see the point in using Apache if you also want to use Node.js for the API. If it's just jade that you don't want you can replace it with HTML by changing the view engine settings in Node.

from angular-client-side-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.