_plugins/alias_generator.rb
def generate_aliases(destination_url, aliases)
      alias_paths ||= Array.new
      alias_paths << aliases
      alias_paths.compact!

      alias_paths.flatten.each do |alias_path|
        alias_path = File.join('/', alias_path.to_s)

        alias_dir  = File.extname(alias_path).empty? ? alias_path : File.dirname(alias_path)
        alias_file = File.extname(alias_path).empty? ? "index.html" : File.basename(alias_path)

        fs_path_to_dir = File.join(@site.dest, alias_dir)
        alias_sections = alias_dir.split('/')[1..-1]

        FileUtils.mkdir_p(fs_path_to_dir)

        File.open(File.join(fs_path_to_dir, alias_file), 'w') do |file|
          file.write(alias_template(destination_url))
        end

        alias_sections.size.times do |sections|
          @site.static_files << Jekyll::AliasFile.new(@site, @site.dest, alias_sections[0, sections + 1].join('/'), '')
        end
        @site.static_files << Jekyll::AliasFile.new(@site, @site.dest, alias_dir, alias_file)
      end
    end
# Generates the alias files for a post / page. Takes two arguments:
#    - destination_url: the URL that the aliases should point to
#    - aliases: the list of alias files to generate
Generates the alias files for a post / page. Takes two arguments:
destination_url: the URL that the aliases should point to
aliases: the list of alias files to generate
Generates the alias files for a post / page . Takes two arguments : destination_url : the URL that the aliases should point to aliases : the list of alias files to generate
def generate_aliases(destination_url, aliases)
      alias_paths ||= Array.new
      alias_paths << aliases
      alias_paths.compact!
      alias_paths.flatten.each do |alias_path|
        alias_path = File.join('/', alias_path.to_s)
        alias_dir  = File.extname(alias_path).empty? ? alias_path : File.dirname(alias_path)
        alias_file = File.extname(alias_path).empty? ? "index.html" : File.basename(alias_path)
        fs_path_to_dir = File.join(@site.dest, alias_dir)
        alias_sections = alias_dir.split('/')[1..-1]
        FileUtils.mkdir_p(fs_path_to_dir)
        File.open(File.join(fs_path_to_dir, alias_file), 'w') do |file|
          file.write(alias_template(destination_url))
        end
        alias_sections.size.times do |sections|
          @site.static_files << Jekyll::AliasFile.new(@site, @site.dest, alias_sections[0, sections + 1].join('/'), '')
        end
        @site.static_files << Jekyll::AliasFile.new(@site, @site.dest, alias_dir, alias_file)
      end
    end
def generate_aliases ( destination_url , aliases ) alias_paths ||= Array . new alias_paths << aliases alias_paths . compact! alias_paths . flatten . each do | alias_path | alias_path = File . join ( '/' , alias_path . to_s ) alias_dir = File . extname ( alias_path ) . empty? ? alias_path : File . dirname ( alias_path ) alias_file = File . extname ( alias_path ) . empty? ? "index.html" : File . basename ( alias_path ) fs_path_to_dir = File . join ( @site . dest , alias_dir ) alias_sections = alias_dir . split ( '/' ) [ 1 .. - 1 ] FileUtils . mkdir_p ( fs_path_to_dir ) File . open ( File . join ( fs_path_to_dir , alias_file ) , 'w' ) do | file | file . write ( alias_template ( destination_url ) ) end alias_sections . size . times do | sections | @site . static_files << Jekyll :: AliasFile . new ( @site , @site . dest , alias_sections [ 0 , sections + 1 ] . join ( '/' ) , '' ) end @site . static_files << Jekyll :: AliasFile . new ( @site , @site . dest , alias_dir , alias_file ) end end
Generates the alias files for a post / page.
Generates the alias files for a post / page .
destination_url
aliases