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

Understanding angular-seo #18

Open
gerbsen opened this issue Apr 3, 2014 · 2 comments
Open

Understanding angular-seo #18

gerbsen opened this issue Apr 3, 2014 · 2 comments

Comments

@gerbsen
Copy link

gerbsen commented Apr 3, 2014

Hi,
Thanks for this really useful plugin. Helps me a lot.
I've a question on how this actually works in practice. Say, I have an angular website running at http://example.com and the phantomjs-angular-seo server running at http://example.com:8888. How does a crawler know on which port it the generated HTML is served? I mean, if i run curl 'http://example.com:8888/?_escaped_fragment_=/view/515/52.5199-13.4386' I get the generated HTML, but how does Google, FB or Bing know where to look for it? Is 8888 the default port for that?

Would be great, if someone could shed some light on my misunderstanding.
Thanks again,
Daniel

@yagobski
Copy link

You need to configure your reverse proxy. You can use nginx for exemple

@360disrupt
Copy link

I have a bunch of questions for understanding this module:

#1)
PhantomJS is run on server side?

#2)
why is in the README example (at the end) 'angular-seo' required as dependency. I thought the dependency is seo?

#3)
What does this code exactly do, and when do I need it/can I just use the htmlready in the controller. And why is there an error variable declared which does not seem to be used? Also isn't there missing the $locationProvider in the app args?

var $http,
            interceptor = ['$q', '$injector', function ($q, $injector) {
                var error;
                function success(response) {
                    $http = $http || $injector.get('$http');
                    var $timeout = $injector.get('$timeout');
                    var $rootScope = $injector.get('$rootScope');
                    if($http.pendingRequests.length < 1) {
                        $timeout(function(){
                            if($http.pendingRequests.length < 1){
                                $rootScope.htmlReady();
                            }
                        }, 700);//an 0.7 seconds safety interval, if there are no requests for 0.7 seconds, it means that the app is through rendering
                    }
                    return response;
                }

                function error(response) {
                    $http = $http || $injector.get('$http');

                    return $q.reject(response);
                }

                return function (promise) {
                    return promise.then(success, error);
                }
            }];

        $httpProvider.responseInterceptors.push(interceptor);

#4
If I tranlsate this into coffee & use it within my app I get an error:

    $http = undefined
    interceptor = [
      '$q'
      '$injector'
      ($q, $injector) ->

        success = (response) ->
          $http = $http or $injector.get('$http')
          $timeout = $injector.get('$timeout')
          $rootScope = $injector.get('$rootScope')
          if $http.pendingRequests.length < 1
            $timeout (->
              if $http.pendingRequests.length < 1
                $rootScope.htmlReady()
              return
            ), 700
            #an 0.7 seconds safety interval, if there are no requests for 0.7 seconds, it means that the app is through rendering
          response

        error = (response) ->
          $http = $http or $injector.get('$http')
          $q.reject response

        (promise) ->
          promise.then success, error
    ]
    $httpProvider.responseInterceptors.push interceptor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants