Skip to content
Snippets Groups Projects
Commit fab9dbb3 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg Committed by Alfredo Sumaran
Browse files

First import of gitignores


Add .gitignore dropdown when creating a new .gitignore file

Signed-off-by: default avatarAlfredo Sumaran <alfredo@gitlab.com>
parent e166a802
No related branches found
No related tags found
1 merge request!425CE upstream
Showing
with 311 additions and 5 deletions
......@@ -6,6 +6,7 @@
projects_path: "/api/:version/projects.json"
labels_path: "/api/:version/projects/:id/labels"
license_path: "/api/:version/licenses/:key"
gitignoretext_path: "/api/:version/gitignores/:key"
group: (group_id, callback) ->
url = Api.buildUrl(Api.group_path)
......@@ -103,6 +104,12 @@
).done (license) ->
callback(license)
gitIgnoreText: (key, callback) ->
url = Api.buildUrl(Api.gitignoretext_path).replace(':key', key)
$.get url, (gitignore) ->
callback(gitignore)
buildUrl: (url) ->
url = gon.relative_url_root + url if gon.relative_url_root?
return url.replace(':version', gon.api_version)
class @BlobGitIgnoreSelector
constructor: (opts) ->
{
@dropdown
@editor
@wrapper = @dropdown.parents('.gitignore-selector')
@fileNameInput = $('#file_name')
@data = @dropdown.data('filenames')
} = opts
@dropdown.glDropdown(
data: @data,
filterable: true,
selectable: true,
search:
fields: ['text']
clicked: @onClick.bind(@)
)
@toggleGitIgnoreSelector()
@bindEvents()
bindEvents: ->
@fileNameInput
.on 'keyup blur', (e) =>
@toggleGitIgnoreSelector()
toggleGitIgnoreSelector: ->
filename = @fileNameInput.val() or $('.editor-file-name').text().trim()
@wrapper.toggleClass 'hidden', filename isnt '.gitignore'
onClick: (item) ->
@requestIgnoreFile(item.text)
requestIgnoreFile: (name) ->
Api.gitIgnoreText name, @requestIgnoreFileSuccess.bind(@)
requestIgnoreFileSuccess: (gitignore) ->
@editor.setValue(gitignore.content, -1)
# Move cursor position to end of file
row = @editor.session.getLength() - 1
column = @editor.session.getLine(row).length
@editor.gotoLine(row + 1, column)
@editor.focus()
class @BlobGitIgnoreSelectors
constructor: (opts) ->
_this = @
{
@dropdowns = $('.js-gitignore-selector')
@editor
} = opts
@dropdowns.each ->
$dropdown = $(@)
new BlobGitIgnoreSelector(
dropdown: $dropdown,
editor: _this.editor
)
......@@ -13,6 +13,7 @@ class @EditBlob
@initModePanesAndLinks()
new BlobLicenseSelector(@editor)
new BlobGitIgnoreSelectors(editor: @editor)
initModePanesAndLinks: ->
@$editModePanes = $(".js-edit-mode-pane")
......
......@@ -23,7 +23,7 @@
.file-title {
@extend .monospace;
line-height: 42px;
line-height: 35px;
padding-top: 7px;
padding-bottom: 7px;
......@@ -43,7 +43,7 @@
.editor-file-name {
@extend .monospace;
float: left;
margin-right: 10px;
}
......@@ -59,7 +59,22 @@
}
.encoding-selector,
.license-selector {
.license-selector,
.gitignore-selector {
display: inline-block;
vertical-align: top;
font-family: $regular_font;
}
.gitignore-selector {
.dropdown {
line-height: 21px;
}
.dropdown-menu-toggle{
vertical-align: top;
width: 220px;
}
}
}
......@@ -16,8 +16,10 @@
.license-selector.js-license-selector.hide
= select_tag :license_type, grouped_options_for_select(licenses_for_select, @project.repository.license_key), include_blank: true, class: 'select2 license-select', data: {placeholder: 'Choose a license template', project: @project.name, fullname: @project.namespace.human_name}
.gitignore-selector.js-gitignore-selector.hide
= select_tag :gitignore_template, options_for_select(Gitlab::Gitignore.all), include_blank: true, class: 'select2 gitignore-select', data: {placeholder: 'Choose a .gitignore template'}
.gitignore-selector.hidden
= dropdown_tag("Choose a .gitignore template", options: { toggle_class: 'js-gitignore-selector', title: "Choose a template", filter: true, placeholder: "Filter projects", data: { filenames: Gitlab::Gitignore.all.map.with_index{ |v| {text: v.name} } } } )
-# = select_tag :gitignore_template, options_for_select(Gitlab::Gitignore.all.map(&:name)), include_blank: true, class: 'select2 gitignore-select', data: {placeholder: 'Choose a .gitignore template'}
.encoding-selector
= select_tag :encoding, options_for_select([ "base64", "text" ], "text"), class: 'select2'
......
# Build and Release Folders
bin/
bin-debug/
bin-release/
[Oo]bj/ # FlashDevelop obj
[Bb]in/ # FlashDevelop bin
# Other files and folders
.settings/
# Executables
*.swf
*.air
*.ipa
*.apk
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
# should NOT be excluded as they contain compiler settings and other important
# information for Eclipse / Flash Builder.
# Object file
*.o
# Ada Library Information
*.ali
*.agdai
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# Intellij
*.iml
# Keystore files
*.jks
# Google App Engine generated folder
appengine-generated/
# Build folder and log file
build/
build.log
*.tar
*.tar.*
*.jar
*.exe
*.msi
*.zip
*.tgz
*.log
*.log.*
*.sig
pkg/
src/
# http://www.gnu.org/software/automake
Makefile.in
# http://www.gnu.org/software/autoconf
/autom4te.cache
/autoscan.log
/autoscan-*.log
/aclocal.m4
/compile
/config.h.in
/configure
/configure.scan
/depcomp
/install-sh
/missing
/stamp-h1
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# Object files
*.o
*.ko
*.obj
*.elf
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
# unpacked plugin folders
plugins/**/*
# files directory where uploads go
files
# DBMigrate plugin: generated SQL
db/sql
# AssetBundler plugin: generated bundles
javascripts/bundles
stylesheets/bundles
CMakeCache.txt
CMakeFiles
CMakeScripts
Makefile
cmake_install.cmake
install_manifest.txt
*.i
*.ii
*.gpu
*.ptx
*.cubin
*.fatbin
# CakePHP 3
/vendor/*
/config/app.php
/tmp/cache/models/*
!/tmp/cache/models/empty
/tmp/cache/persistent/*
!/tmp/cache/persistent/empty
/tmp/cache/views/*
!/tmp/cache/views/empty
/tmp/sessions/*
!/tmp/sessions/empty
/tmp/tests/*
!/tmp/tests/empty
/logs/*
!/logs/empty
# CakePHP 2
/app/tmp/*
/app/Config/core.php
/app/Config/database.php
/vendors/*
.vagrant
/cookbooks
# Bundler
bin/*
.bundle/*
.kitchen/
.kitchen.local.yml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment