Skip to content

Commit

Permalink
api
Browse files Browse the repository at this point in the history
  • Loading branch information
starlying committed Dec 2, 2018
1 parent 75a595c commit 250d74a
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 91 deletions.
1 change: 1 addition & 0 deletions SiteServer.CMS/SiteServer.CMS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
<Compile Include="DataCache\Stl\StlSqlContentsCache.cs" />
<Compile Include="DataCache\Stl\StlTagCache.cs" />
<Compile Include="StlParser\FileSystemObjectAsync.cs" />
<Compile Include="StlParser\Model\ChannelIdContentId.cs" />
<Compile Include="StlParser\Model\ChannelItemInfo.cs" />
<Compile Include="StlParser\Model\ContentItemInfo.cs" />
<Compile Include="StlParser\Model\ContextInfo.cs" />
Expand Down
11 changes: 11 additions & 0 deletions SiteServer.CMS/StlParser/Model/ChannelIdContentId.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace SiteServer.CMS.StlParser.Model
{
public class MinContentInfo
{
public int Id { get; set; }

public int ChannelId { get; set; }
}
}
22 changes: 11 additions & 11 deletions SiteServer.CMS/StlParser/StlElement/StlFocusViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
using System.Web.UI.HtmlControls;
using SiteServer.Utils;
using SiteServer.CMS.Core;
using SiteServer.CMS.Model;
using SiteServer.CMS.Model.Attributes;
using SiteServer.CMS.StlParser.Model;
using SiteServer.CMS.StlParser.Parsers;
using SiteServer.CMS.StlParser.Utility;
using SiteServer.Utils.Enumerations;
using SiteServer.CMS.DataCache;

namespace SiteServer.CMS.StlParser.StlElement
{
Expand Down Expand Up @@ -213,9 +213,9 @@ private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, Html

var channelId = StlDataUtility.GetChannelIdByChannelIdOrChannelIndexOrChannelName(pageInfo.SiteId, contextInfo.ChannelId, channelIndex, channelName);

var dataSource = StlDataUtility.GetContentsDataSource(pageInfo.SiteInfo, channelId, 0, groupContent, groupContentNot, tags, true, true, false, false, false, false, false, startNum, totalNum, orderByString, isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot, isColorExists, isColor, where, scopeType, groupChannel, groupChannelNot, null);
var minContentInfoList = StlDataUtility.GetMinContentInfoList(pageInfo.SiteInfo, channelId, 0, groupContent, groupContentNot, tags, true, true, false, false, false, false, false, startNum, totalNum, orderByString, isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot, isColorExists, isColor, where, scopeType, groupChannel, groupChannelNot, null);

if (dataSource != null)
if (minContentInfoList != null)
{
if (StringUtils.EqualsIgnoreCase(theme, ThemeStyle2))
{
Expand All @@ -225,9 +225,9 @@ private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, Html
var navigationUrls = new StringCollection();
var titleCollection = new StringCollection();

foreach (var dataItem in dataSource.Tables[0].Rows)
foreach (var minContentInfo in minContentInfoList)
{
var contentInfo = new ContentInfo(dataItem);
var contentInfo = ContentManager.GetContentInfo(pageInfo.SiteInfo, minContentInfo.ChannelId, minContentInfo.Id);
var imageUrl = contentInfo.ImageUrl;

if (!string.IsNullOrEmpty(imageUrl))
Expand Down Expand Up @@ -312,9 +312,9 @@ private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, Html
var navigationUrls = new StringCollection();
var titleCollection = new StringCollection();

foreach (var dataItem in dataSource.Tables[0].Rows)
foreach (var minContentInfo in minContentInfoList)
{
var contentInfo = new ContentInfo(dataItem);
var contentInfo = ContentManager.GetContentInfo(pageInfo.SiteInfo, minContentInfo.ChannelId, minContentInfo.Id);
var imageUrl = contentInfo.GetString(BackgroundContentAttribute.ImageUrl);

if (!string.IsNullOrEmpty(imageUrl))
Expand Down Expand Up @@ -373,9 +373,9 @@ private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, Html
var imageUrls = new StringCollection();
var navigationUrls = new StringCollection();

foreach (var dataItem in dataSource.Tables[0].Rows)
foreach (var minContentInfo in minContentInfoList)
{
var contentInfo = new ContentInfo(dataItem);
var contentInfo = ContentManager.GetContentInfo(pageInfo.SiteInfo, minContentInfo.ChannelId, minContentInfo.Id);
var imageUrl = contentInfo.GetString(BackgroundContentAttribute.ImageUrl);

if (!string.IsNullOrEmpty(imageUrl))
Expand Down Expand Up @@ -492,9 +492,9 @@ function auto(){{
var navigationUrls = new StringCollection();
var titleCollection = new StringCollection();

foreach (var dataItem in dataSource.Tables[0].Rows)
foreach (var minContentInfo in minContentInfoList)
{
var contentInfo = new ContentInfo(dataItem);
var contentInfo = ContentManager.GetContentInfo(pageInfo.SiteInfo, minContentInfo.ChannelId, minContentInfo.Id);
var imageUrl = contentInfo.ImageUrl;

if (!string.IsNullOrEmpty(imageUrl))
Expand Down
40 changes: 20 additions & 20 deletions SiteServer.CMS/StlParser/StlElement/StlRss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,28 +204,28 @@ private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, stri
}
channel.Link = new Uri(PageUtils.AddProtocolToUrl(PageUtility.GetChannelUrl(pageInfo.SiteInfo, nodeInfo, pageInfo.IsLocal)));

var dataSource = StlDataUtility.GetContentsDataSource(pageInfo.SiteInfo, channelId, 0, groupContent, groupContentNot, tags, false, false, false, false, false, false, false, startNum, totalNum, orderByString, isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot, isColorExists, isColor, string.Empty, scopeType, groupChannel, groupChannelNot, null);
var minContentInfoList = StlDataUtility.GetMinContentInfoList(pageInfo.SiteInfo, channelId, 0, groupContent, groupContentNot, tags, false, false, false, false, false, false, false, startNum, totalNum, orderByString, isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot, isColorExists, isColor, string.Empty, scopeType, groupChannel, groupChannelNot, null);

if (dataSource != null)
if (minContentInfoList != null)
{
//foreach (var dataItem in dataSource)
//{
// var item = new RssItem();

// var contentInfo = new BackgroundContentInfo(dataItem);
// item.Title = StringUtils.Replace("&", contentInfo.Title, "&amp;");
// item.Description = contentInfo.Summary;
// if (string.IsNullOrEmpty(item.Description))
// {
// item.Description = StringUtils.StripTags(contentInfo.Content);
// item.Description = string.IsNullOrEmpty(item.Description) ? contentInfo.Title : StringUtils.MaxLengthText(item.Description, 200);
// }
// item.Description = StringUtils.Replace("&", item.Description, "&amp;");
// item.PubDate = contentInfo.AddDate;
// item.Link = new Uri(PageUtils.AddProtocolToUrl(PageUtility.GetContentUrl(pageInfo.SiteInfo, contentInfo)));

// channel.Items.Add(item);
//}
foreach (var minContentInfo in minContentInfoList)
{
var item = new RssItem();

var contentInfo = ContentManager.GetContentInfo(pageInfo.SiteInfo, minContentInfo.ChannelId, minContentInfo.Id);
item.Title = StringUtils.Replace("&", contentInfo.Title, "&amp;");
item.Description = contentInfo.Summary;
if (string.IsNullOrEmpty(item.Description))
{
item.Description = StringUtils.StripTags(contentInfo.Content);
item.Description = string.IsNullOrEmpty(item.Description) ? contentInfo.Title : StringUtils.MaxLengthText(item.Description, 200);
}
item.Description = StringUtils.Replace("&", item.Description, "&amp;");
item.PubDate = contentInfo.AddDate;
item.Link = new Uri(PageUtils.AddProtocolToUrl(PageUtility.GetContentUrl(pageInfo.SiteInfo, contentInfo, false)));

channel.Items.Add(item);
}
}

feed.Channels.Add(channel);
Expand Down
26 changes: 10 additions & 16 deletions SiteServer.CMS/StlParser/StlElement/StlSelect.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Data;
using System.Web.UI.HtmlControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using SiteServer.Utils;
using SiteServer.CMS.Core;
using SiteServer.CMS.DataCache;
using SiteServer.CMS.Model;
using SiteServer.CMS.StlParser.Model;
using SiteServer.CMS.StlParser.Parsers;
using SiteServer.CMS.StlParser.Utility;
Expand Down Expand Up @@ -298,24 +296,20 @@ private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, Html
}
else
{
var dataSource = StlDataUtility.GetContentsDataSource(pageInfo.SiteInfo, channelId, contextInfo.ContentId, groupContent, groupContentNot, tags, false, false, false, false, false, false, false, 1, totalNum, orderByString, isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot, isColorExists, isColor, where, scopeType, groupChannel, groupChannelNot, null);
var minContentInfoList = StlDataUtility.GetMinContentInfoList(pageInfo.SiteInfo, channelId, contextInfo.ContentId, groupContent, groupContentNot, tags, false, false, false, false, false, false, false, 1, totalNum, orderByString, isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot, isColorExists, isColor, where, scopeType, groupChannel, groupChannelNot, null);

if (dataSource != null)
if (minContentInfoList != null)
{
foreach (DataRow dataItem in dataSource.Tables[0].Rows)
foreach (var minContentInfo in minContentInfoList)
{
var contentInfo = new ContentInfo(dataItem);
if (contentInfo != null)
var contentInfo = ContentManager.GetContentInfo(pageInfo.SiteInfo, minContentInfo.ChannelId, minContentInfo.Id);
var title = StringUtils.MaxLengthText(contentInfo.Title, titleWordNum);
var url = PageUtility.GetContentUrl(pageInfo.SiteInfo, contentInfo, false);
if (!string.IsNullOrEmpty(queryString))
{
var title = StringUtils.MaxLengthText(contentInfo.Title, titleWordNum);
var url = PageUtility.GetContentUrl(pageInfo.SiteInfo, contentInfo, false);
if (!string.IsNullOrEmpty(queryString))
{
url = PageUtils.AddQueryString(url, queryString);
}
var listitem = new ListItem(title, url);
selectControl.Items.Add(listitem);
url = PageUtils.AddQueryString(url, queryString);
}
selectControl.Items.Add(new ListItem(title, url));
}
//foreach (var dataItem in dataSource)
//{
Expand Down
1 change: 0 additions & 1 deletion SiteServer.CMS/StlParser/Utility/RepeaterTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Specialized;
using System.Web.UI;
using System.Web.UI.WebControls;
using SiteServer.CMS.Model;
using SiteServer.CMS.Model.Attributes;
using SiteServer.CMS.StlParser.Model;
using SiteServer.Utils;
Expand Down
22 changes: 22 additions & 0 deletions SiteServer.CMS/StlParser/Utility/StlDataUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,28 @@ public static DataSet GetContentsDataSource(SiteInfo siteInfo, int channelId, in
return StlContentCache.GetStlDataSourceChecked(channelIdList, tableName, startNum, totalNum, orderByString, sqlWhereString, others);
}

public static List<MinContentInfo> GetMinContentInfoList(SiteInfo siteInfo, int channelId, int contentId, string groupContent, string groupContentNot, string tags, bool isImageExists, bool isImage, bool isVideoExists, bool isVideo, bool isFileExists, bool isFile, bool isRelatedContents, int startNum, int totalNum, string orderByString, bool isTopExists, bool isTop, bool isRecommendExists, bool isRecommend, bool isHotExists, bool isHot, bool isColorExists, bool isColor, string where, EScopeType scopeType, string groupChannel, string groupChannelNot, NameValueCollection others)
{
var dataSource = GetContentsDataSource(siteInfo, channelId, contentId, groupContent, groupContentNot, tags,
isImageExists, isImage, isVideoExists, isVideo, isFileExists, isFile, isRelatedContents, startNum,
totalNum, orderByString, isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot,
isColorExists, isColor, where, scopeType, groupChannel, groupChannelNot, others);

var list = new List<MinContentInfo>();

foreach (DataRow dataItem in dataSource.Tables[0].Rows)
{
var minContentInfo = new MinContentInfo
{
Id = (int) dataItem[ContentAttribute.Id],
ChannelId = (int) dataItem[ContentAttribute.ChannelId]
};
list.Add(minContentInfo);
}

return list;
}

public static DataSet GetChannelsDataSource(int siteId, int channelId, string group, string groupNot, bool isImageExists, bool isImage, int startNum, int totalNum, string orderByString, EScopeType scopeType, bool isTotal, string where)
{
DataSet ie;
Expand Down
6 changes: 3 additions & 3 deletions SiteServer.Web/SiteServer/Plugins/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ var methods = {
getPlugins: function () {
var $this = this;

$apiCloud.get('plugins', {
$apiCloud.get('updates', {
params: {
isNightly: $this.isNightly,
pluginVersion: $this.pluginVersion,
pluginIds: $this.pluginIds.join(",")
packageIds: $this.pluginIds.join(",")
}
}).then(function (response) {
var res = response.data;

for (var i = 0; i < res.value.length; i++) {
var releaseInfo = res.value[i].releaseInfo;
var releaseInfo = res.value[i];

for (var i = 0; i < releaseInfo.pluginReferences.length; i++) {
var reference = releaseInfo.pluginReferences[i];
Expand Down
12 changes: 6 additions & 6 deletions SiteServer.Web/SiteServer/Plugins/manage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -205,25 +205,25 @@
<tbody>
<tr v-for="package in updatePackages">
<td class="text-center text-nowrap">
<img :src="getIconUrl(package.updatePackage.pluginInfo.iconUrl)" width="48" height="48">
<img :src="package.metadata.iconUrl || '../assets/icons/favicon.png'" width="48" height="48">
</td>
<td class="text-nowrap">
<a :href="'view.cshtml?pluginId=' + package.updatePackage.pluginInfo.pluginId + '&returnUrl=' + encodeURIComponent(location.href)">{{ package.updatePackage.pluginInfo.pluginId }}</a>
<a :href="'view.cshtml?pluginId=' + package.updatePackage.pluginId + '&returnUrl=' + encodeURIComponent(location.href)">{{ package.updatePackage.pluginId }}</a>
</td>
<td class="text-nowrap">
{{ package.updatePackage.pluginInfo.title }}
{{ package.metadata.title }}
</td>
<td class="text-nowrap">
{{ package.metadata ? package.metadata.version : '' }}
</td>
<td class="text-nowrap">
{{ package.updatePackage.releaseInfo.version }}
{{ package.updatePackage.version }}
</td>
<td>
{{ package.updatePackage.releaseInfo.releaseNotes }}
{{ package.updatePackage.releaseNotes }}
</td>
<td class="text-center text-nowrap">
{{ package.updatePackage.releaseInfo.published }}
{{ package.updatePackage.published }}
</td>
<td class="text-center text-nowrap">
<a :href="'install.cshtml?isUpdate=true&pluginIds=' + package.id" class="btn btn-warning btn-md">插件升级</a>
Expand Down
12 changes: 6 additions & 6 deletions SiteServer.Web/SiteServer/Plugins/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@ var methods = {
}
}

$apiCloud.get('plugins', {
$apiCloud.get('updates', {
params: {
isNightly: $this.isNightly,
pluginVersion: $this.pluginVersion,
pluginIds: $this.packageIds
packageIds: $this.packageIds
}
}).then(function (response) {
var res = response.data;

for (var i = 0; i < res.value.length; i++) {
var pkg = res.value[i];
var releaseInfo = res.value[i];

var installedPackages = $.grep($this.allPackages, function (e) {
return e.id == pkg.pluginInfo.pluginId;
return e.id == releaseInfo.pluginId;
});
if (installedPackages.length == 1) {
var installedPackage = installedPackages[0];
installedPackage.updatePackage = pkg;
installedPackage.updatePackage = releaseInfo;

if (installedPackage.metadata && installedPackage.metadata.version) {
if (compareversion(installedPackage.metadata.version, pkg.releaseInfo.version) == -1) {
if (compareversion(installedPackage.metadata.version, releaseInfo.version) == -1) {
$this.updatePackages.push(installedPackage);
$this.updatePackageIds.push(installedPackage.id);
}
Expand Down
6 changes: 3 additions & 3 deletions SiteServer.Web/SiteServer/assets/js/utils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var $api = axios.create({
baseURL: apiUrl,
baseURL: window.apiUrl || '../api',
withCredentials: true
});

var $apiCloud = axios.create({
baseURL: 'https://api.siteserver.cn/v1.2',
// baseURL: 'http://api.siteserver-cms.com/v1.2',
// baseURL: 'https://api.siteserver.cn/v1.2',
baseURL: 'http://api.siteserver-cms.com/v1.2',
withCredentials: true
});

Expand Down
Loading

0 comments on commit 250d74a

Please sign in to comment.