Merge branch 'master' into es17.01

# Conflicts:
#	examples/demo/demo.ecf
#	modules/admin/admin-safe.ecf
This commit is contained in:
Jocelyn Fiat
2017-03-30 12:03:41 +02:00
27 changed files with 815 additions and 60 deletions

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<redirection xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-16-0 http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" uuid="1469E34C-98EE-4E39-BC13-24A0D93A7EC0" message="Obsolete: use embedded_video.ecf !" location="embedded_video.ecf">
</redirection>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-16-0 http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" name="embedded_video" uuid="1469E34C-98EE-4E39-BC13-24A0D93A7EC0" library_target="embedded_video">
<target name="embedded_video">
<root all_classes="true"/>
<option warning="true">
</option>
<capability>
<concurrency support="scoop" use="scoop"/>
<void_safety support="all"/>
</capability>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="cms" location="..\..\cms.ecf" readonly="false"/>
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
<cluster name="src" location="src\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,61 @@
note
description: "[
Module that allows you to embed videos from YouTube and Vimeo in a web page.
]"
date: "$Date: 2015-07-16 15:57:08 +0200 (jeu., 16 juil. 2015) $"
revision: "$Revision: 97722 $"
class
EMBEDDED_VIDEO_MODULE
inherit
CMS_MODULE
redefine
initialize
end
SHARED_EXECUTION_ENVIRONMENT
export
{NONE} all
end
REFACTORING_HELPER
create
make
feature {NONE} -- Initialization
make
-- Create current module
do
version := "1.0"
description := "Embedded video module"
package := "filters"
end
feature -- Access
name: STRING = "embedded_video"
-- <Precursor>
feature {CMS_API} -- Module Initialization
initialize (api: CMS_API)
-- <Precursor>
do
Precursor {CMS_MODULE} (api)
api.content_filters.extend (create {VIDEO_CONTENT_FILTER})
-- f := api.new_format ("video_html", "Video HTML content", <<{VIDEO_CONTENT_FILTER}.name>>)
-- api.formats.extend (f)
end
feature -- Router
setup_router (a_router: WSF_ROUTER; a_api: CMS_API)
-- Router configuration.
do
end
end

View File

@@ -0,0 +1,182 @@
note
description: "[
Quick syntax:
[video:url]
Full syntax:
[video:url width:X height:Y]
]"
date: "$Date: 2015-07-18 13:53:56 +0200 (sam., 18 juil. 2015) $"
revision: "$Revision: 97737 $"
class
VIDEO_CONTENT_FILTER
inherit
CONTENT_FILTER
redefine
help,
default_create
end
feature {NONE} -- Initialization
default_create
do
Precursor
width := 420
height := 315
end
feature -- Access
name: STRING_8 = "video"
title: STRING_8 = "Embedded video"
description: STRING_8 = "Embed any video using pattern [video:url width:X height:Y], width and height are optionals."
help: STRING = "Embed video using the following pattern: [video:url width:X height:Y], width and height are optionals."
feature -- Conversion
filter (a_text: STRING_8)
-- [video:url width:X height:Y]
local
l_new: detachable STRING
i,p,q,diff: INTEGER
do
from
i := 1
until
i > a_text.count
loop
p := a_text.substring_index ("[video:", i)
if p > 0 then
q := a_text.index_of (']', p + 1)
l_new := to_embedded_video_code (a_text, p, q)
if l_new /= Void then
diff := l_new.count - (q - p + 1)
i := i + diff
a_text.replace_substring (l_new, p, q)
else
i := q + 1
end
else
i := a_text.count
end
i := i + 1
end
end
to_embedded_video_code (a_text: STRING_8; a_lower, a_upper: INTEGER): detachable STRING
require
a_lower < a_upper
a_text.substring (a_lower, a_lower + 7).same_string ("[video:")
a_text.ends_with_general ("]")
local
i,j,n: INTEGER
s,k,v: STRING_8
l_url: STRING_8
l_width, l_height: detachable STRING
do
s := a_text.substring (a_lower + 1, a_upper - 1)
s.left_adjust
i := next_space_position (s, 1)
if i > 0 then
l_url := s.head (i - 1)
s.remove_head (i)
s.left_adjust
from
n := s.count
i := 1
until
i > n
loop
j := s.index_of (':', i)
if j > 0 then
k := s.head (j - 1)
s.remove_head (j)
s.left_adjust
i := 1
n := s.count
j := next_space_position (s, 1)
if j > 0 then
v := s.head (j - 1)
s.remove_head (j)
s.left_adjust
else
v := s.substring (i, n)
s.wipe_out
end
n := s.count
i := 1
if k.is_case_insensitive_equal ("width") then
l_width := v
elseif k.is_case_insensitive_equal ("height") then
l_height := v
else
check supported: False end
end
else
i := n + 1
end
end
else
s.remove_head (6)
l_url := s
end
if not l_url.is_whitespace then
create Result.make_from_string ("<iframe src=%"")
Result.append (l_url)
Result.append_character ('%"')
if l_width = Void then
if width > 0 then
l_width := width.out
end
end
if l_height = Void then
if height > 0 then
l_height := height.out
end
end
if l_width /= Void then
Result.append (" width=%"")
Result.append (l_width)
Result.append_character ('%"')
end
if l_height /= Void then
Result.append (" height=%"")
Result.append (l_height)
Result.append_character ('%"')
end
Result.append ("frameborder=%"0%" allowfullscreen></iframe>")
end
end
next_space_position (a_text: STRING; a_start_index: INTEGER): INTEGER
local
n: INTEGER
do
from
Result := a_start_index
n := a_text.count
until
a_text[Result].is_space or Result > n
loop
Result := Result + 1
end
if Result > n then
Result := 0
end
end
feature {NONE} -- Implementation
width: INTEGER;
-- Specifies the width of an <iframe> in pixels.
height: INTEGER
-- Specifies the height of an <iframe> in pixels.
end

View File

@@ -0,0 +1,34 @@
note
description: "Summary description for {VIDEO_HTML_CONTENT_FORMAT}."
author: ""
date: "$Date: 2015-07-10 13:38:10 +0200 (ven., 10 juil. 2015) $"
revision: "$Revision: 97687 $"
class
VIDEO_HTML_CONTENT_FORMAT
inherit
CONTENT_FORMAT
redefine
default_create
end
feature {NONE} -- Initialization
default_create
do
Precursor
create filters.make (0)
filters.force (create {VIDEO_CONTENT_FILTER})
end
feature -- Access
name: STRING = "video_html"
title: STRING_8 = "Video HTML content"
filters: ARRAYED_LIST [CONTENT_FILTER]
end

View File

@@ -0,0 +1,183 @@
note
description: "[
Eiffel tests that can be executed by testing tool.
]"
author: "EiffelStudio test wizard"
date: "$Date: 2015-07-10 13:38:10 +0200 (ven., 10 juil. 2015) $"
revision: "$Revision: 97687 $"
testing: "type/manual"
class
TEST_CONTENT_FILTER_SET
inherit
EQA_TEST_SET
feature -- Test routines
test_video_filter
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[video:https://www.youtube.com/embed/jBMOSSnCMCk]"
expected_text := "<iframe width=%"420%" height=%"315%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
test_video_filter_2
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[ video : https://www.youtube.com/embed/jBMOSSnCMCk ]"
expected_text := "<iframe width=%"420%" height=%"315%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
test_video_filter_3
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[ video :https://www.youtube.com/embed/jBMOSSnCMCk ]"
expected_text := "<iframe width=%"420%" height=%"315%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
test_video_filter_4
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[ video :https://www.youtube.com/embed/jBMOSSnCMCk height:425]"
expected_text := "<iframe width=%"420%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
test_video_filter_5
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[ video :https://www.youtube.com/embed/jBMOSSnCMCk height : 425]"
expected_text := "<iframe width=%"420%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
test_video_filter_6
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[ video :https://www.youtube.com/embed/jBMOSSnCMCk height : 425 width: 425]"
expected_text := "<iframe width=%"425%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
test_video_filter_7
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[video:https://www.youtube.com/embed/jBMOSSnCMCk height:425 width:425]"
expected_text := "<iframe width=%"425%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
test_video_filter_8
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[height:425 width:425 video:https://www.youtube.com/embed/jBMOSSnCMCk ]"
expected_text := "<iframe width=%"425%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
test_video_filter_9
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[ width:425 video:https://www.youtube.com/embed/jBMOSSnCMCk height:425]"
expected_text := "<iframe width=%"425%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
test_video_filter_10
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[ wrong:425 video:https://www.youtube.com/embed/jBMOSSnCMCk height:425]"
expected_text := "<iframe width=%"420%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
test_video_filter_11
-- New test routine
local
f: VIDEO_CONTENT_FILTER
text: STRING
expected_text: STRING
do
text := "[wrong hello:1020 ]"
expected_text := "[wrong hello:1020 ]"
create f
f.filter (text)
assert ("expected iframe with video", text.same_string (expected_text))
end
end

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<redirection xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-16-0 http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" uuid="BD491995-C14C-4413-B09A-C1B4EDDA3116" message="Obsolete: use testing.ecf !" location="testing.ecf">
</redirection>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-16-0 http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" name="embedded_video_testing" uuid="BD491995-C14C-4413-B09A-C1B4EDDA3116">
<target name="embedded_video_testing">
<root class="ANY" feature="default_create"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/.svn$</exclude>
<exclude>/EIFGENs$</exclude>
</file_rule>
<option warning="true">
</option>
<capability>
<concurrency use="none"/>
</capability>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="embeded_module" location="..\video.ecf"/>
<library name="testing" location="$ISE_LIBRARY\library\testing\testing.ecf"/>
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
<tests name="src" location=".\"/>
</target>
</system>