Adding support to detect the difference between a Grails gsp and a Gosu gsp.

This commit is contained in:
Jeff Beck
2011-08-29 11:27:40 -05:00
parent 5b9b46116b
commit 3dd06de711
6 changed files with 64 additions and 0 deletions

View File

@@ -433,6 +433,19 @@ module Linguist
end
end
# Internal: Guess language of .gsp files.
#
# Returns a Language.
def guess_gsp_language
if lines.grep(/<%|<%@|${|<%|<g:|<meta name="layout"|<r:/).any?
Language['Groovy Server Pages']
else
Language['Gosu']
end
end
# Internal: Guess language from the first line.
#
# Look for leading "<?php"

View File

@@ -379,6 +379,16 @@ Groovy:
- .gradle
- .groovy
Groovy Server Pages:
group: Groovy
lexer: Java Server Page
overrides:
- .gsp
aliases:
- gsp
extensions:
- .gsp
HTML:
type: markup
primary_extension: .html

10
test/fixtures/bar.gsp vendored Normal file
View File

@@ -0,0 +1,10 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Testing with SiteMesh and Resources</title>
<meta name="layout" content="blankMain"/>
<r:require module="style"/>
</head>
<body>
</body>
</html>

16
test/fixtures/hello-pagedirective.gsp vendored Normal file
View File

@@ -0,0 +1,16 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>Using page directive tag</title>
</head>
<body>
<div class="center">
<a href="#" alt="Download" id="downloadButton">Download</a>
</div>
<div class="center">
<a href="#" alt="Print" id="printButton">Print</a>
</div>
</body>
</html>

9
test/fixtures/hello-resources.gsp vendored Normal file
View File

@@ -0,0 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Testing with Resources</title>
<r:require module="style"/>
</head>
<body>
</body>
</html>

View File

@@ -332,6 +332,12 @@ class TestBlob < Test::Unit::TestCase
assert_equal Language['Gosu'], blob("hello.gsp").language
assert_equal Language['Gosu'], blob("Hello.gst").language
assert_equal Language['Gosu'], blob("hello.vark").language
#Groovy Server Pages
assert_equal Language['Groovy Server Pages'], blob("bar.gsp").language
assert_equal Language['Groovy Server Pages'], blob("hello-resources.gsp").language
assert_equal Language['Groovy Server Pages'], blob("hello-pagedirective.gsp").language
end
def test_lexer