Current section

36 Versions

Jump to

Compare versions

5 files changed
+97 additions
-67 deletions
  @@ -135,7 +135,7 @@ Current Features or To-Do
135 135
136 136 - [x] [Supports: generate kind of some sitemaps](#supports-generate-kind-of-some-sitemaps)
137 137 - [x] [News Sitemaps](#news-sitemaps)
138 - - [x] Video Sitemaps
138 + - [x] [Video Sitemaps](#video-sitemaps)
139 139 - [x] Image Sitemaps
140 140 - [x] Geo Sitemaps
141 141 - [x] Mobile Sitemaps
  @@ -181,20 +181,20 @@ end
181 181
182 182 ```xml
183 183 <url>
184 - <loc>http://www.example.com/index.html</loc>
185 - <lastmod>2016-05-30T13:13:12Z</lastmod>
186 - <news:news>
187 - <news:publication>
188 - <news:name>Example</news:name>
189 - <news:language>en</news:language>
190 - </news:publication>
191 - <news:title>My Article</news:title>
192 - <news:access>Subscription</news:access>
193 - <news:genres>PressRelease</news:genres>
194 - <news:keywords>my article, articles about myself</news:keywords>
195 - <news:stock_tickers>SAO:PETR3</news:stock_tickers>
196 - <news:publication_date>2011-08-22</news:publication_date>
197 - </news:news>
184 + <loc>http://www.example.com/index.html</loc>
185 + <lastmod>2016-05-30T13:13:12Z</lastmod>
186 + <news:news>
187 + <news:publication>
188 + <news:name>Example</news:name>
189 + <news:language>en</news:language>
190 + </news:publication>
191 + <news:title>My Article</news:title>
192 + <news:access>Subscription</news:access>
193 + <news:genres>PressRelease</news:genres>
194 + <news:keywords>my article, articles about myself</news:keywords>
195 + <news:stock_tickers>SAO:PETR3</news:stock_tickers>
196 + <news:publication_date>2011-08-22</news:publication_date>
197 + </news:news>
198 198 </url>
199 199 ```
200 200
  @@ -208,13 +208,34 @@ defmodule Sitemaps do
208 208
209 209 create do
210 210 add "index.html", videos: [
211 - thumbnail_loc: "Example",
212 - publication_language: "http://www.example.com/video1_thumbnail.png",
213 - title: "My Video",
214 - description: "my video, videos about itself",
215 - content_loc: "http://www.example.com/cool_video.mpg",
216 - tags: ~w(and then nothing),
217 - category: "Category"
211 + thumbnail_loc: "http://www.example.com/thumbs/123.jpg",
212 + title: "Grilling steaks for summer",
213 + description: "Alkis shows you how to get perfectly done steaks every time",
214 + content_loc: "http://www.example.com/video123.flv",
215 + player_loc: "http://www.example.com/videoplayer.swf?video=123",
216 + allow_embed: true,
217 + autoplay: true,
218 + duration: 600,
219 + expiration_date: "2009-11-05T19:20:30+08:00",
220 + publication_date: "2007-11-05T19:20:30+08:00",
221 + rating: 0.5,
222 + view_count: 1000,
223 + tags: ~w(tag1 tag2 tag3),
224 + tag: "tag4",
225 + category: "Category",
226 + family_friendly: true,
227 + restriction: "IE GB US CA",
228 + relationship: true,
229 + gallery_loc: "http://cooking.example.com",
230 + gallery_title: "Cooking Videos",
231 + price: "1.99",
232 + price_currency: "EUR",
233 + price_type: "own",
234 + price_resolution: "HD",
235 + uploader: "GrillyMcGrillerson",
236 + uploader_info: "http://www.example.com/users/grillymcgrillerson",
237 + live: true,
238 + requires_subscription: false
218 239 ]
219 240 end
220 241 end
  @@ -225,24 +246,33 @@ end
225 246
226 247 ```xml
227 248 <url>
228 - <loc>http://www.example.com/video.html</loc>
229 - <lastmod>2016-05-30T14:53:00Z</lastmod>
230 - <video:video>
231 - <video:title>Grilling steaks for summer</video:title>
232 - <video:description>Alkis shows you how to get perfectly done steaks every time</video:description>
233 - <video:rating>0.5</video:rating>
234 - <video:duration>600</video:duration>
235 - <video:view_count>1000</video:view_count>
236 - <video:expiration_date>2009-11-05T19:20:30+08:00</video:expiration_date>
237 - <video:publication_date>2007-11-05T19:20:30+08:00</video:publication_date>
238 - <video:tag>tag1</video:tag>
239 - <video:tag>tag2</video:tag>
240 - <video:tag>tag3</video:tag>
241 - <video:tag>tag4</video:tag>
242 - <video:category>Category</video:category>
243 - <video:family_friendly>yes</video:family_friendly>
244 - </video:video>
249 + <loc>http://www.example.com/video.html</loc>
250 + <lastmod>2016-05-31T12:51:47Z</lastmod>
251 + <video:video>
252 + <video:title>Grilling steaks for summer</video:title>
253 + <video:description>Alkis shows you how to get perfectly done steaks every time</video:description>
254 + <video:player_loc allow_embed="yes" autoplay="ap=1">http://www.example.com/videoplayer.swf?video=123</video:player_loc>
255 + <video:content_loc>http://www.example.com/video123.flv</video:content_loc>
256 + <video:thumbnail_loc>http://www.example.com/thumbs/123.jpg</video:thumbnail_loc>
257 + <video:duration>600</video:duration>
258 + <video:gallery_loc title="Cooking Videos">http://cooking.example.com</video:gallery_loc>
259 + <video:rating>0.5</video:rating>
260 + <video:view_count>1000</video:view_count>
261 + <video:expiration_date>2009-11-05T19:20:30+08:00</video:expiration_date>
262 + <video:publication_date>2007-11-05T19:20:30+08:00</video:publication_date>
263 + <video:tag>tag1</video:tag>
264 + <video:tag>tag2</video:tag>
265 + <video:tag>tag3</video:tag>
266 + <video:tag>tag4</video:tag>
267 + <video:category>Category</video:category>
268 + <video:family_friendly>yes</video:family_friendly>
269 + <video:restriction relationship="allow">IE GB US CA</video:restriction>
270 + <video:uploader info="http://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson</video:uploader>
271 + <video:price currency="EUR" resolution="HD" type="own">1.99</video:price>
272 + <video:live>yes</video:live>
273 + <video:requires_subscription>no</video:requires_subscription>
274 + </video:video>
245 275 </url>
246 276 ```
247 277
248 - Look at [Video sitemaps](https://support.google.com/webmasters/answer/80471) as required.
278 + Look at [Video sitemaps](https://developers.google.com/webmasters/videosearch/sitemaps#adding-video-content-to-a-sitemap) as required.
  @@ -23,4 +23,4 @@
23 23 [{<<"app">>,<<"xml_builder">>},
24 24 {<<"optional">>,false},
25 25 {<<"requirement">>,<<">= 0.0.0">>}]}]}.
26 - {<<"version">>,<<"0.6.1">>}.
26 + {<<"version">>,<<"0.6.2">>}.
  @@ -69,40 +69,36 @@ defmodule Sitemap.Builders.Url do
69 69 element(:"video:video", Funcs.eraser([
70 70 element(:"video:title", data[:title]),
71 71 element(:"video:description", data[:description]),
72 -
73 72 (if data[:player_loc] do
74 73 attrs = %{allow_embed: Funcs.yes_no(data[:allow_embed])}
75 74 if data[:autoplay], do: attrs = Map.put(attrs, :autoplay, Funcs.autoplay(data[:autoplay]))
76 75 element(:"video:player_loc", attrs, data[:player_loc])
77 76 end),
78 - # element(:"video:content_loc", data[:content_loc]),
79 - # element(:"video:thumbnail_loc", data[:thumbnail_loc]),
80 - # element(:"video:gallery_loc", %{title: data[:gallery_title]}, data[:gallery_loc]),
81 -
82 - # element(:"video:price", video_price_attrs(data), data[:price]),
83 - element(:"video:rating", data[:rating]),
77 + element(:"video:content_loc", data[:content_loc]),
78 + element(:"video:thumbnail_loc", data[:thumbnail_loc]),
84 79 element(:"video:duration", data[:duration]),
85 - element(:"video:view_count", data[:view_count]),
86 80
87 - element(:"video:expiration_date", data[:expiration_date]), # TODO: gonna be convinient
88 - element(:"video:publication_date",data[:publication_date]), # TODO: gonna be convinient
89 -
90 - Enum.map(data[:tags] || [], &(element(:"video:tag", &1))),
91 - element(:"video:tag", data[:tag]),
92 - element(:"video:category", data[:category]),
93 -
94 - (if Keyword.has_key?(data, :family_friendly) do
95 - element(:"video:family_friendly", Funcs.yes_no(data[:family_friendly]))
81 + (unless is_nil(data[:gallery_loc]), do: element(:"video:gallery_loc", %{title: data[:gallery_title]}, data[:gallery_loc])),
82 + (unless is_nil(data[:rating]), do: element(:"video:rating", data[:rating])),
83 + (unless is_nil(data[:view_count]), do: element(:"video:view_count", data[:view_count])),
84 + (unless is_nil(data[:expiration_date]), do: element(:"video:expiration_date", data[:expiration_date])), # TODO: gonna be convinient
85 + (unless is_nil(data[:publication_date]), do: element(:"video:publication_date", data[:publication_date])), # TODO: gonna be convinient
86 + (unless is_nil(data[:tags]), do: Enum.map(data[:tags] || [], &(element(:"video:tag", &1)))),
87 + (unless is_nil(data[:tag]), do: element(:"video:tag", data[:tag])),
88 + (unless is_nil(data[:category]), do: element(:"video:category", data[:category])),
89 + (unless is_nil(data[:family_friendly]), do: element(:"video:family_friendly", Funcs.yes_no(data[:family_friendly]))),
90 + (unless is_nil(data[:restriction]) do
91 + attrs = %{relationship: Funcs.allow_deny(data[:relationship])}
92 + element(:"video:restriction", attrs, data[:restriction])
96 93 end),
97 -
98 - (if data[:uploader] do
94 + (unless is_nil(data[:uploader]) do
99 95 attrs = %{}
100 96 if data[:uploader_info], do: attrs = %{info: data[:uploader_info]}
101 97 element(:"video:uploader", attrs, data[:uploader])
102 98 end),
103 -
104 - element(:"video:live", data[:live]),
105 - element(:"video:requires_subscription", data[:requires_subscription]),
99 + (unless is_nil(data[:price]), do: element(:"video:price", video_price_attrs(data), data[:price])),
100 + (unless is_nil(data[:live]), do: element(:"video:live", Funcs.yes_no(data[:live]))),
101 + (unless is_nil(data[:requires_subscription]), do: element(:"video:requires_subscription", Funcs.yes_no(data[:requires_subscription]))),
106 102 ]))
107 103
108 104 videos(tail, elements ++ [elm])
  @@ -110,9 +106,9 @@ defmodule Sitemap.Builders.Url do
110 106
111 107 defp video_price_attrs(data) do
112 108 attrs = %{}
113 - attrs = Map.put attrs, :currency, data[:price_currency]
114 - attrs = Map.put attrs, :type, data[:price_type]
115 - attrs = Map.put attrs, :resolution, data[:price_resolution]
109 + attrs = Map.put attrs, :currency, data[:price_currency]
110 + if data[:price_type], do: attrs = Map.put attrs, :type, data[:price_type]
111 + if data[:price_type], do: attrs = Map.put attrs, :resolution, data[:price_resolution]
116 112 attrs
117 113 end
  @@ -23,6 +23,10 @@ defmodule Sitemap.Funcs do
23 23 if bool == false, do: "no", else: "yes"
24 24 end
25 25
26 + def allow_deny(bool) do
27 + if bool == false, do: "deny", else: "allow"
28 + end
29 +
26 30 def autoplay(bool) do
27 31 if bool, do: "ap=1", else: "ap=0"
28 32 end
  @@ -9,7 +9,7 @@ defmodule Sitemap.Mixfile do
9 9 [
10 10 app: :sitemap,
11 11 name: "Sitemap",
12 - version: "0.6.1",
12 + version: "0.6.2",
13 13 elixir: ">= 1.0.0",
14 14 description: @description,
15 15 build_embedded: Mix.env == :prod,