QuickLinks implemented

main
Inga 🏳‍🌈 15 years ago
parent ca233b582b
commit 5c61ba138c
  1. 2
      Builder/IISMainHandler/build.txt
  2. 2
      Builder/IISUploadHandler/build.txt
  3. 1
      Common/Common.csproj
  4. 75
      Common/dataobjects/QuickLink.cs
  5. 1
      IISMainHandler/IISMainHandler.csproj
  6. 17
      IISMainHandler/handlers/response/QuickLinkHandler.cs

@ -87,6 +87,7 @@
<Compile Include="dataobjects\PMMessage.cs" /> <Compile Include="dataobjects\PMMessage.cs" />
<Compile Include="dataobjects\Post.cs" /> <Compile Include="dataobjects\Post.cs" />
<Compile Include="dataobjects\PostLayer.cs" /> <Compile Include="dataobjects\PostLayer.cs" />
<Compile Include="dataobjects\QuickLink.cs" />
<Compile Include="dataobjects\Session.cs" /> <Compile Include="dataobjects\Session.cs" />
<Compile Include="dataobjects\Skin.cs" /> <Compile Include="dataobjects\Skin.cs" />
<Compile Include="dataobjects\Thread.cs" /> <Compile Include="dataobjects\Thread.cs" />

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FLocal.Core;
using FLocal.Core.DB;
using FLocal.Core.DB.conditions;
namespace FLocal.Common.dataobjects {
public class QuickLink : SqlObject<QuickLink> {
public class TableSpec : ISqlObjectTableSpec {
public const string TABLE = "QuickLinks";
public const string FIELD_ID = "Id";
public const string FIELD_NAME = "Name";
public const string FIELD_URL = "Url";
public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; } }
public string idName { get { return FIELD_ID; } }
public void refreshSqlObject(int id) { Refresh(id); }
}
protected override ISqlObjectTableSpec table { get { return TableSpec.instance; } }
private string _name;
public string name {
get {
this.LoadIfNotLoaded();
return this._name;
}
}
private string _url;
public string url {
get {
this.LoadIfNotLoaded();
return this._url;
}
}
private static Dictionary<string, int> name2id = new Dictionary<string,int>();
public static QuickLink LoadByName(string name) {
if(!name2id.ContainsKey(name)) {
lock(name2id) {
if(!name2id.ContainsKey(name)) {
List<string> ids = Config.instance.mainConnection.LoadIdsByConditions(
TableSpec.instance,
new ComparisonCondition(
TableSpec.instance.getColumnSpec(TableSpec.FIELD_NAME),
ComparisonType.EQUAL,
name
),
Diapasone.unlimited
);
if(ids.Count > 1) {
throw new CriticalException("not unique");
} else if(ids.Count == 1) {
name2id[name] = int.Parse(ids[0]);
} else {
throw new NotFoundInDBException();
}
}
}
}
return QuickLink.LoadById(name2id[name]);
}
protected override void doFromHash(Dictionary<string, string> data) {
this._name = data[TableSpec.FIELD_NAME];
this._url = data[TableSpec.FIELD_URL];
}
}
}

@ -81,6 +81,7 @@
<Compile Include="handlers\response\PMReplyHandler.cs" /> <Compile Include="handlers\response\PMReplyHandler.cs" />
<Compile Include="handlers\response\PMReplyToPostHandler.cs" /> <Compile Include="handlers\response\PMReplyToPostHandler.cs" />
<Compile Include="handlers\response\PMSendHandler.cs" /> <Compile Include="handlers\response\PMSendHandler.cs" />
<Compile Include="handlers\response\QuickLinkHandler.cs" />
<Compile Include="handlers\response\RedirectGetHandler.cs" /> <Compile Include="handlers\response\RedirectGetHandler.cs" />
<Compile Include="handlers\response\ReplyHandler.cs" /> <Compile Include="handlers\response\ReplyHandler.cs" />
<Compile Include="handlers\response\SettingsHandler.cs" /> <Compile Include="handlers\response\SettingsHandler.cs" />

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FLocal.Core;
using FLocal.Common;
using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.response {
class QuickLinkHandler : RedirectGetHandler {
protected override string getRedirectUrl(WebContext context) {
return QuickLink.LoadByName(context.requestParts[1]).url;
}
}
}
Loading…
Cancel
Save