-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into licensee-6
- Loading branch information
Showing
35 changed files
with
1,389 additions
and
553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require 'linguist/blob_helper' | ||
|
||
module Linguist | ||
# A Blob is a wrapper around the content of a file to make it quack | ||
# like a Grit::Blob. It provides the basic interface: `name`, | ||
# `data`, `path` and `size`. | ||
class Blob | ||
include BlobHelper | ||
|
||
# Public: Initialize a new Blob. | ||
# | ||
# path - A path String (does not necessarily exists on the file system). | ||
# content - Content of the file. | ||
# | ||
# Returns a FileBlob. | ||
def initialize(path, content) | ||
@path = path | ||
@content = content | ||
end | ||
|
||
# Public: Filename | ||
# | ||
# Examples | ||
# | ||
# Blob.new("/path/to/linguist/lib/linguist.rb", "").path | ||
# # => "/path/to/linguist/lib/linguist.rb" | ||
# | ||
# Returns a String | ||
attr_reader :path | ||
|
||
# Public: File name | ||
# | ||
# Returns a String | ||
def name | ||
File.basename(@path) | ||
end | ||
|
||
# Public: File contents. | ||
# | ||
# Returns a String. | ||
def data | ||
@content | ||
end | ||
|
||
# Public: Get byte size | ||
# | ||
# Returns an Integer. | ||
def size | ||
@content.bytesize | ||
end | ||
|
||
# Public: Get file extension. | ||
# | ||
# Returns a String. | ||
def extension | ||
extensions.last || "" | ||
end | ||
|
||
# Public: Return an array of the file extensions | ||
# | ||
# >> Linguist::FileBlob.new("app/views/things/index.html.erb").extensions | ||
# => [".html.erb", ".erb"] | ||
# | ||
# Returns an Array | ||
def extensions | ||
basename, *segments = name.downcase.split(".") | ||
|
||
segments.map.with_index do |segment, index| | ||
"." + segments[index..-1].join(".") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<#import "layout.ftl" as layout> | ||
|
||
<#assign results = [ | ||
{ | ||
"title": "Example Result", | ||
"description": "Lorem ipsum dolor sit amet, pede id pellentesque, sollicitudin turpis sed in sed sed, libero dictum." | ||
} | ||
] /> | ||
|
||
<@layout.page title="FreeMarker Example"> | ||
<#if results?size == 0> | ||
There were no results. | ||
<#else> | ||
<ul> | ||
<#list results as result> | ||
<li> | ||
<strong>${result.title}</strong> | ||
<p>${result.description}</p> | ||
</li> | ||
</#list> | ||
</ul> | ||
</#if> | ||
|
||
<#-- This is a FreeMarker comment --> | ||
<@currentTime /> | ||
</@layout.page> | ||
|
||
|
||
<#macro currentTime> | ||
${.now?string.full} | ||
</#macro> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<#ftl strip_text=true /> | ||
|
||
<#macro page title> | ||
<!doctype html> | ||
<html lang="${.lang}"> | ||
<head> | ||
<title>${title}</title> | ||
<@metaTags /> | ||
</head> | ||
<body> | ||
<#nested /> | ||
<@footer /> | ||
</body> | ||
</html> | ||
</#macro> | ||
|
||
|
||
<#--- | ||
Default meta tags | ||
--> | ||
<#macro metaTags> | ||
<#compress> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<meta name="format-detection" content="telephone=no"> | ||
</#compress> | ||
</#macro> | ||
|
||
<#macro footer> | ||
<p>This page is using FreeMarker v${.version}</p> | ||
</#macro> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<h1>Listing Books</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Title</th> | ||
<th>Summary</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<%= for book <- @books do %> | ||
<tr> | ||
<%# comment %> | ||
<td><%= book.title %></td> | ||
<td><%= book.content %></td> | ||
<td><%= link "Show", to: book_path(@conn, :show, book) %></td> | ||
<td><%= link "Edit", to: book_path(@conn, :edit, book) %></td> | ||
<td><%= link "Delete", to: book_path(@conn, :delete, book), method: :delete, data: [confirm: "Are you sure?"] %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link "New book", to: book_path(@conn, :new) %> |
Oops, something went wrong.