1d3815f89b
Started implementation for the first iteration of gitlab-org/gitlab-ce#32420. This will allow users to select a template to start with, instead of an empty repository in the project just created. Internally this is basically a small extension of the ImportExport GitLab projects we already support. We just import a certain import tar archive. This commits includes the first one: Ruby on Rails. In the future more will be added.
39 lines
697 B
Ruby
39 lines
697 B
Ruby
module Gitlab
|
|
class ProjectTemplate
|
|
attr_reader :title, :name
|
|
|
|
def initialize(name, title)
|
|
@name, @title = name, title
|
|
end
|
|
|
|
def logo_path
|
|
"project_templates/#{name}.png"
|
|
end
|
|
|
|
def file
|
|
template_archive.open
|
|
end
|
|
|
|
def template_archive
|
|
Rails.root.join("vendor/project_templates/#{name}.tar.gz")
|
|
end
|
|
|
|
def ==(other)
|
|
name == other.name && title == other.title
|
|
end
|
|
|
|
TemplatesTable = [
|
|
ProjectTemplate.new('rails', 'Ruby on Rails')
|
|
].freeze
|
|
|
|
class << self
|
|
def all
|
|
TemplatesTable
|
|
end
|
|
|
|
def find(name)
|
|
all.find { |template| template.name == name.to_s }
|
|
end
|
|
end
|
|
end
|
|
end
|