fixed sourcepath bug
This commit is contained in:
		
							parent
							
								
									db954333dc
								
							
						
					
					
						commit
						c736df077a
					
				@ -12,6 +12,7 @@ angular.module('myApp.post', ['ngRoute'])
 | 
				
			|||||||
  , ['$scope', '$location', '$timeout', 'Desirae'
 | 
					  , ['$scope', '$location', '$timeout', 'Desirae'
 | 
				
			||||||
  , function ($scope, $location, $timeout, DesiraeService) {
 | 
					  , function ($scope, $location, $timeout, DesiraeService) {
 | 
				
			||||||
  var scope = this
 | 
					  var scope = this
 | 
				
			||||||
 | 
					    , path = window.path
 | 
				
			||||||
    ;
 | 
					    ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function init() {
 | 
					  function init() {
 | 
				
			||||||
@ -48,6 +49,7 @@ angular.module('myApp.post', ['ngRoute'])
 | 
				
			|||||||
    , uuid: window.uuid.v4()
 | 
					    , uuid: window.uuid.v4()
 | 
				
			||||||
    , abspath: scope.blogdir
 | 
					    , abspath: scope.blogdir
 | 
				
			||||||
    , sourcepath: ''
 | 
					    , sourcepath: ''
 | 
				
			||||||
 | 
					    , fileepath: ''
 | 
				
			||||||
    , post: { 
 | 
					    , post: { 
 | 
				
			||||||
        yml: {
 | 
					        yml: {
 | 
				
			||||||
          title: ""
 | 
					          title: ""
 | 
				
			||||||
@ -91,7 +93,7 @@ angular.module('myApp.post', ['ngRoute'])
 | 
				
			|||||||
      post.yml.permalink = selected.permalink;
 | 
					      post.yml.permalink = selected.permalink;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /*
 | 
					    /*
 | 
				
			||||||
    if (window.path.extname(post.yml.permalink) !== '.' + selected.format) {
 | 
					    if (path.extname(post.yml.permalink) !== '.' + selected.format) {
 | 
				
			||||||
     post.yml.permalink = post.yml.permalink.replace(/\.\w+$/, '.' + selected.format);
 | 
					     post.yml.permalink = post.yml.permalink.replace(/\.\w+$/, '.' + selected.format);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    */
 | 
					    */
 | 
				
			||||||
@ -99,19 +101,20 @@ angular.module('myApp.post', ['ngRoute'])
 | 
				
			|||||||
    post.frontmatter = window.jsyaml.dump(post.yml).trim();
 | 
					    post.frontmatter = window.jsyaml.dump(post.yml).trim();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // TODO use some sort of filepath pattern in config.yml
 | 
					    // TODO use some sort of filepath pattern in config.yml
 | 
				
			||||||
    selected.path = window.path.join((scope.env.compiled_path || 'compiled'), post.yml.permalink);
 | 
					    selected.path = path.join((scope.env.compiled_path || 'compiled'), post.yml.permalink);
 | 
				
			||||||
    if (!/\.html?$/.test(selected.path)) {
 | 
					    if (!/\.html?$/.test(selected.path)) {
 | 
				
			||||||
      selected.path = window.path.join(selected.path, 'index.html');
 | 
					      selected.path = path.join(selected.path, 'index.html');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    selected.url = window.path.join(scope.site.base_url + window.path.join(scope.site.base_path, post.yml.permalink));
 | 
					    selected.url = path.join(scope.site.base_url + path.join(scope.site.base_path, post.yml.permalink));
 | 
				
			||||||
    if (scope.env.explicitIndexes && /\/$/.test(selected.url)) {
 | 
					    if (scope.env.explicitIndexes && /\/$/.test(selected.url)) {
 | 
				
			||||||
      selected.url += 'index.html';
 | 
					      selected.url += 'index.html';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    selected.markdown   = '[' + selected.title + '](' + selected.url + ')';
 | 
					    selected.markdown   = '[' + selected.title + '](' + selected.url + ')';
 | 
				
			||||||
    selected.ahref      = '<a href="' + selected.url + '">' + selected.title + '</a>';
 | 
					    selected.ahref      = '<a href="' + selected.url + '">' + selected.title + '</a>';
 | 
				
			||||||
    selected.abspath    = window.path.join(scope.blogdir, selected.path);
 | 
					    selected.abspath    = path.join(scope.blogdir, selected.path);
 | 
				
			||||||
    selected.sourcepath = window.path.join(scope.blogdir, (selected.collection || 'posts'), scope.slug + '.' + selected.format);
 | 
					    selected.filepath   = path.join((selected.collection || 'posts'), scope.slug + '.' + selected.format);
 | 
				
			||||||
 | 
					    selected.sourcepath = path.join(scope.blogdir, (selected.collection || 'posts'), scope.slug + '.' + selected.format);
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
  scope.onFrontmatterChange = function () {
 | 
					  scope.onFrontmatterChange = function () {
 | 
				
			||||||
    var data
 | 
					    var data
 | 
				
			||||||
@ -131,17 +134,18 @@ angular.module('myApp.post', ['ngRoute'])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      post = scope.selected.post;
 | 
					      post = scope.selected.post;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      scope.selected.path = window.path.join((scope.env.compiled_path || 'compiled'), post.yml.permalink);
 | 
					      scope.selected.path = path.join((scope.env.compiled_path || 'compiled'), post.yml.permalink);
 | 
				
			||||||
      if (!/\.html?$/.test(window.path.basename(post.yml.permalink))) {
 | 
					      if (!/\.html?$/.test(path.basename(post.yml.permalink))) {
 | 
				
			||||||
        scope.selected.path = window.path.join(scope.selected.path.replace(/\.w+$/, ''), 'index.html');
 | 
					        scope.selected.path = path.join(scope.selected.path.replace(/\.w+$/, ''), 'index.html');
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      scope.selected.url = window.path.join(scope.site.base_url + window.path.join(scope.site.base_path, post.yml.permalink));
 | 
					      scope.selected.url = path.join(scope.site.base_url + path.join(scope.site.base_path, post.yml.permalink));
 | 
				
			||||||
      if (scope.env.explicitIndexes && /\/$/.test(scope.selected.url)) {
 | 
					      if (scope.env.explicitIndexes && /\/$/.test(scope.selected.url)) {
 | 
				
			||||||
        scope.selected.url += 'index.html';
 | 
					        scope.selected.url += 'index.html';
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      scope.selected.abspath = window.path.join(scope.blogdir, scope.selected.path);
 | 
					      scope.selected.abspath = path.join(scope.blogdir, scope.selected.path);
 | 
				
			||||||
      scope.selected.sourcepath = window.path.join((scope.selected.collection || 'posts'), scope.slug + '.' + scope.selected.format);
 | 
					      scope.selected.sourcepath = path.join(scope.blogdir, (scope.selected.collection || 'posts'), scope.slug + '.' + scope.selected.format);
 | 
				
			||||||
 | 
					      scope.selected.filepath   = path.join((scope.selected.collection || 'posts'), scope.slug + '.' + scope.selected.format);
 | 
				
			||||||
    } catch(e) {
 | 
					    } catch(e) {
 | 
				
			||||||
      console.error(e);
 | 
					      console.error(e);
 | 
				
			||||||
      console.error('ignoring update that created parse error');
 | 
					      console.error('ignoring update that created parse error');
 | 
				
			||||||
@ -178,7 +182,7 @@ angular.module('myApp.post', ['ngRoute'])
 | 
				
			|||||||
      ;
 | 
					      ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    files.push({
 | 
					    files.push({
 | 
				
			||||||
      path: scope.selected.sourcepath
 | 
					      path: scope.selected.filepath
 | 
				
			||||||
    , contents: 
 | 
					    , contents: 
 | 
				
			||||||
          '---\n'
 | 
					          '---\n'
 | 
				
			||||||
        + scope.selected.post.frontmatter.trim()
 | 
					        + scope.selected.post.frontmatter.trim()
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user