Advertisement
Ruslan_Rayanov

falcon_yandexturbo

Mar 20th, 2022
2,971
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.05 KB | None | 0 0
  1. CREATE OR ALTER PROCEDURE [dbo].[falcon_yandexturbo]
  2.   @parameters DictionaryParameter READONLY,  -- as_domain - передача домена
  3.   @s nvarchar(max) output  
  4. AS
  5. BEGIN
  6.  
  7. declare @page int = (select try_cast(Value as int) from @parameters where  [key] = 'page')
  8. if(@page is null) set @page = 1
  9. declare @pageSize int = 40
  10.  
  11. declare @siteTitle nvarchar(max) = 'Falcon Space'
  12. declare @siteLink nvarchar(max) = 'https://falcon.web-automation.ru'
  13. declare @siteDesc nvarchar(max) = 'Веб-платформа для создания личных кабинетов на сайте'
  14. declare @siteLang nvarchar(max) = 'ru'
  15. declare @siteAuthor nvarchar(256) = 'Раянов Руслан'
  16.  
  17. declare @result table(link nvarchar(256) ,[date] date, topic nvarchar(max)  , author nvarchar(max), text nvarchar(max) )
  18. declare @pagedResult table(link nvarchar(256) ,[date] date, topic nvarchar(max)  , author nvarchar(max), text nvarchar(max) )
  19.  
  20.  
  21. declare @host nvarchar(256) = 'https://falcon.web-automation.ru'
  22.  
  23. insert into @result
  24. select
  25.     'http://falcon.web-automation.ru/blog/'+ code link,
  26.     updated date,
  27.     title topic,
  28.     @siteAuthor author,
  29.     text1 text
  30. from as_articles
  31.  
  32. insert into @pagedResult
  33. select * from @result
  34. order by date      
  35. OFFSET @PageSize * (@Page - 1) ROWS
  36. FETCH NEXT @PageSize ROWS ONLY;
  37.  
  38.  
  39. /*insert into @result
  40. select 'http://falcon.web-automation.ru/blog' link,
  41.     getdate() date,
  42.     'Некий заголовок страницы' topic,
  43.     'author1' author,
  44.     '<h1>Некий заголовок</h1>text1' text
  45. union
  46. select 'http://falcon.web-automation.ru' link,
  47.     getdate() date,
  48.     'А тут тоже заголовок' topic,
  49.     'author2' author,
  50.     '<h1>Некий заголовок</h1>text2' text
  51.     */
  52. set @s = '<?xml version="1.0" encoding="UTF-8"?>
  53. <rss xmlns:yandex="http://news.yandex.ru"
  54.     xmlns:media="http://search.yahoo.com/mrss/"
  55.     xmlns:turbo="http://turbo.yandex.ru"
  56.     version="2.0">' +char(10)
  57. set @s = @s + ' <channel>' +char(10)+'
  58.        <title>'+@siteTitle+'</title>' +char(10)+'
  59.        <link>'+@siteLink+'</link>' +char(10)+'
  60.        <description>'+@siteDesc+'</description>' +char(10)+'
  61.        <language>'+@siteLang+'</language>' +char(10)
  62.  
  63. declare @p ExtendedDictionaryParameter
  64. insert into @p(Value2)
  65. select '
  66.         <item turbo="true">
  67.            <turbo:extendedHtml>true</turbo:extendedHtml>
  68.            <link>'+isnull(link, '')+'</link>
  69.            <turbo:source></turbo:source>
  70.             <title>'+isnull(topic, '')+'</title>
  71.            <turbo:topic>'+isnull(topic, '')+'</turbo:topic>
  72.            <pubDate>'+cast([date] as nvarchar)+'</pubDate>
  73.            <author>'+isnull(author, '')+'</author>
  74.          
  75.            <yandex:related></yandex:related>
  76.            <turbo:content>
  77.                <![CDATA[
  78.                   '+isnull([text], '')+'
  79.                ]]>
  80.            </turbo:content>
  81.        </item>
  82. ' Value2
  83. from @pagedResult
  84.  
  85. set @s  = @s + isnull(dbo.as_agg(@p, ''), '')
  86.  
  87. set @s  = @s + '</channel>' + dbo.as_newLine(1)
  88.  
  89. set @s  = @s + '</rss>'+ dbo.as_newLine(1)
  90.  
  91. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement