mirror of
https://github.com/moparisthebest/Simba
synced 2025-02-25 16:01:48 -05:00
Extensions: Updated paster.sex
All time sexyness by Dgby714!
This commit is contained in:
parent
cf06819618
commit
12c9bb5862
@ -1,33 +1,49 @@
|
|||||||
program Paster;
|
program Paster;
|
||||||
|
|
||||||
var
|
var
|
||||||
Simba_Menu: TMenuItem;
|
Paster_Menu, Private_MenuItem, Paster_MenuItem, Divider_MenuItem, AltHost_Menu: TMenuItem;
|
||||||
HOST: string;
|
AltHost_Menus: array[1..5] of TMenuItem;
|
||||||
|
AltHost_MenuItems: array[1..5] of array[1..2] of TMenuItem;
|
||||||
|
|
||||||
type
|
type
|
||||||
TJSON = record
|
TJSON = record
|
||||||
name: string;
|
name: string;
|
||||||
value: string;
|
value_type: string;
|
||||||
|
value_string: string;
|
||||||
|
value_bool: boolean;
|
||||||
end;
|
end;
|
||||||
TJSONArray = array of TJSON;
|
TJSONArray = array of TJSON;
|
||||||
|
|
||||||
function Encode(str: string): string;
|
function EncodeString(Data: string): string;
|
||||||
var
|
var
|
||||||
Pattern, Replacement: TStringArray;
|
Pattern, Replacement: TStringArray;
|
||||||
I: integer;
|
I: integer;
|
||||||
begin
|
begin
|
||||||
Pattern := ['\', #8, #9, #10, #11, #12, #13, '"', {#39,} '/'];
|
Pattern := ['\', #8, #9, #10, #11, #12, #13, '"', {#39,} '/'];
|
||||||
Replacement := ['\\', '\b', '\t', '\n', '\v', '\f', '\r', '\"', {'\'#39,} '\/'];
|
Replacement := ['\\', '\b', '\t', '\n', '\v', '\f', '\r', '\"', {'\'#39,} '\/'];
|
||||||
Result := str;
|
Result := Data;
|
||||||
if (Length(Pattern) = Length(Replacement)) then
|
if (Length(Pattern) = Length(Replacement)) then
|
||||||
for I := 0 to High(Pattern) do
|
for I := Low(Pattern) to High(Pattern) do
|
||||||
Result := Replace(Result, Pattern[I], Replacement[I], [rfIgnoreCase, rfReplaceAll]);
|
Result := Replace(Result, Pattern[I], Replacement[I], [rfIgnoreCase, rfReplaceAll]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CJSON(name, value: string): TJSON;
|
function CreateJSON(Name: string; Value: variant): TJSON;
|
||||||
begin
|
begin
|
||||||
Result.name := Encode(name);
|
Result.name := Name;
|
||||||
Result.value := Encode(value);
|
case VarType(Value) of //Made it a case incase we add more =)
|
||||||
|
varString: begin
|
||||||
|
Result.value_type := 'string';
|
||||||
|
Result.value_string := EncodeString(Value);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
varBoolean: begin
|
||||||
|
Result.value_type := 'boolean';
|
||||||
|
Result.value_bool := Value;
|
||||||
|
end;
|
||||||
|
varNull: begin
|
||||||
|
Result.value_type := 'null';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function DecodeJSON(JSON: string): TJSONArray;
|
function DecodeJSON(JSON: string): TJSONArray;
|
||||||
@ -43,7 +59,7 @@ begin
|
|||||||
AStringArray[I] := Explode('": ', StringArray[I]);
|
AStringArray[I] := Explode('": ', StringArray[I]);
|
||||||
SetArrayLength(Result, Length(AStringArray));
|
SetArrayLength(Result, Length(AStringArray));
|
||||||
for I := 0 to High(AStringArray) do
|
for I := 0 to High(AStringArray) do
|
||||||
Result[I] := CJSON(Between('"', '"', AStringArray[I][0] + '"'), Between('"', '"', AStringArray[I][1]));
|
Result[I] := CreateJSON(Between('"', '"', AStringArray[I][0] + '"'), Between('"', '"', AStringArray[I][1]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function EncodeJSON(JSON: TJSONArray): string;
|
function EncodeJSON(JSON: TJSONArray): string;
|
||||||
@ -53,48 +69,17 @@ begin
|
|||||||
Result := '{';
|
Result := '{';
|
||||||
for I := 0 to High(JSON) do
|
for I := 0 to High(JSON) do
|
||||||
begin
|
begin
|
||||||
Result := Result + '"' + JSON[I].name + '": "' + JSON[I].value + '"';
|
Result := Result + '"' + JSON[I].name + '": ';
|
||||||
|
case JSON[I].value_type of
|
||||||
|
'string': Result := Result + '"' + JSON[I].value_string + '"';
|
||||||
|
'boolean': Result := Result + Lowercase(BoolToStr(JSON[I].value_bool));
|
||||||
|
end;
|
||||||
if (I < High(JSON)) then
|
if (I < High(JSON)) then
|
||||||
Result := Result + ', ';
|
Result := Result + ', ';
|
||||||
end;
|
end;
|
||||||
Result := Result + '}';
|
Result := Result + '}';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PasteIt(out Data: string): boolean;
|
|
||||||
var
|
|
||||||
JSONArray: TJSONArray;
|
|
||||||
begin
|
|
||||||
HOST := Settings.getKeyValueDef('Host', 'paste.sheeva.villavu.com');
|
|
||||||
if (MessageDlg('Paster Plugin', 'Upload this script to ' + HOST + '?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
|
|
||||||
begin
|
|
||||||
Data := EncodeJSON([CJSON('language', 'delphi'), CJSON('code', ScriptText), CJSON('private', 'True')]);
|
|
||||||
WriteLn(Data);
|
|
||||||
Data := GetPageEx('http://' + HOST + '/json/?method=pastes.newPaste', Data, 'application/json');
|
|
||||||
JSONArray := DecodeJSON(Data); //Should be 0 = id and 1 = error
|
|
||||||
if (JSONArray[0].value = '') then
|
|
||||||
begin
|
|
||||||
Data := '[Paster]Error: ' + JSONArray[1].value
|
|
||||||
Result := False;
|
|
||||||
end else
|
|
||||||
begin
|
|
||||||
Data := 'http://' + HOST + '/show/' + JSONArray[0].value + '/';
|
|
||||||
Result := True;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure OnClick(sender : TObject);
|
|
||||||
var
|
|
||||||
Data: string;
|
|
||||||
begin;
|
|
||||||
if PasteIt(Data) then
|
|
||||||
begin
|
|
||||||
WriteLn('Opening pasted script at "' + Data + '"!');
|
|
||||||
OpenWebPage(Data);
|
|
||||||
end else
|
|
||||||
WriteLn(Data);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function GetName: string;
|
function GetName: string;
|
||||||
begin;
|
begin;
|
||||||
Result := 'Paster';
|
Result := 'Paster';
|
||||||
@ -105,14 +90,141 @@ begin;
|
|||||||
Result := '0.1a';
|
Result := '0.1a';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Init;
|
function PasteIt(out Data: string; HOST: string): boolean;
|
||||||
|
var
|
||||||
|
JSONArray: TJSONArray;
|
||||||
|
begin
|
||||||
|
if (HOST = '') then
|
||||||
|
HOST := 'paste.sheeva.villavu.com';
|
||||||
|
if (MessageDlg(GetName + ' ' + GetVersion + ' Extension', 'Upload this script to ' + HOST + '?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
|
||||||
|
begin
|
||||||
|
Data := EncodeJSON([CreateJSON('language', 'delphi'), CreateJSON('code', ScriptText), CreateJSON('private', (Lowercase(Settings.getKeyValueDef('Private', 'true')) = 'true'))])
|
||||||
|
WriteLn(Data);
|
||||||
|
Data := GetPageEx('http://' + HOST + '/json/?method=pastes.newPaste', Data, 'application/json');
|
||||||
|
JSONArray := DecodeJSON(Data); //Should be 0 = id and 1 = error
|
||||||
|
if (JSONArray[0].value_string = '') then
|
||||||
|
begin
|
||||||
|
Data := '[Paster]Error: ' + JSONArray[1].value_string
|
||||||
|
Result := False;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Data := 'http://' + HOST + '/show/' + JSONArray[0].value_string + '/';
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Paste(Host: string);
|
||||||
|
var
|
||||||
|
Data: string;
|
||||||
|
begin
|
||||||
|
if PasteIt(Data, Host) then
|
||||||
|
begin
|
||||||
|
WriteLn('Opening pasted script at "' + Data + '"!');
|
||||||
|
OpenWebPage(Data);
|
||||||
|
end else
|
||||||
|
WriteLn(Data);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure UpdateHost(I: integer);
|
||||||
|
var
|
||||||
|
Data: string;
|
||||||
|
begin
|
||||||
|
if InputQuery(GetName + ' ' + GetVersion + ' Extension', 'Please input the LodgeIt Host! (Ex: paste.pocoo.org)', Data) then
|
||||||
|
begin
|
||||||
|
AltHost_Menus[I].Caption := Data;
|
||||||
|
AltHost_MenuItems[I][1].Enabled := True;
|
||||||
|
Settings.setKeyValue('Host' + IntToStr(I), Data);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure OnClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
I: integer;
|
||||||
|
begin;
|
||||||
|
case Sender of
|
||||||
|
Paster_MenuItem: Paste('');
|
||||||
|
AltHost_MenuItems[1][1]: Paste(Settings.getKeyValue('Host1'));
|
||||||
|
AltHost_MenuItems[2][1]: Paste(Settings.getKeyValue('Host2'));
|
||||||
|
AltHost_MenuItems[3][1]: Paste(Settings.getKeyValue('Host3'));
|
||||||
|
AltHost_MenuItems[4][1]: Paste(Settings.getKeyValue('Host4'));
|
||||||
|
AltHost_MenuItems[5][1]: Paste(Settings.getKeyValue('Host5'));
|
||||||
|
AltHost_MenuItems[1][2]: UpdateHost(1);
|
||||||
|
AltHost_MenuItems[2][2]: UpdateHost(2);
|
||||||
|
AltHost_MenuItems[3][2]: UpdateHost(3);
|
||||||
|
AltHost_MenuItems[4][2]: UpdateHost(4);
|
||||||
|
AltHost_MenuItems[5][2]: UpdateHost(5);
|
||||||
|
Private_MenuItem: begin
|
||||||
|
Private_MenuItem.Checked := (not (Private_MenuItem.Checked));
|
||||||
|
Settings.SetKeyValue('Private', Lowercase(BoolToStr(Private_MenuItem.Checked)));
|
||||||
|
WriteLn('Private = ' + Lowercase(BoolToStr(Private_MenuItem.Checked)));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Attach;
|
||||||
begin;
|
begin;
|
||||||
Simba_Menu := TMenuItem.Create(Simba_MainMenu);
|
|
||||||
Simba_Menu.Caption := 'Paste It!';
|
|
||||||
Simba_Menu.OnClick := @OnClick;
|
|
||||||
Simba_MainMenu.Items.Add(Simba_Menu);
|
|
||||||
Settings.getKeyValueDef('Host', 'paste.sheeva.villavu.com');
|
|
||||||
WriteLn(GetName + ' ' + GetVersion + ' Plugin Loaded!');
|
WriteLn(GetName + ' ' + GetVersion + ' Plugin Loaded!');
|
||||||
|
Paster_Menu.Visible := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure Detach;
|
||||||
|
begin
|
||||||
|
Paster_Menu.Visible := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Init;
|
||||||
|
var
|
||||||
|
I, K: integer;
|
||||||
|
begin;
|
||||||
|
Paster_Menu := TMenuItem.Create(Simba_MainMenu);
|
||||||
|
Paster_Menu.Caption := GetName;
|
||||||
|
Simba_MainMenu.Items.Add(Paster_Menu);
|
||||||
|
|
||||||
|
Paster_MenuItem := TMenuItem.Create(Paster_Menu);
|
||||||
|
with Paster_MenuItem do
|
||||||
|
begin
|
||||||
|
Caption := 'Paste It!';
|
||||||
|
OnClick := @OnClick;
|
||||||
|
end;
|
||||||
|
Paster_Menu.Add(Paster_MenuItem);
|
||||||
|
|
||||||
|
Private_MenuItem := TMenuItem.Create(Paster_Menu);
|
||||||
|
with Private_MenuItem do
|
||||||
|
begin
|
||||||
|
Caption := 'Private';
|
||||||
|
OnClick := @OnClick;
|
||||||
|
Checked := (Lowercase(Settings.getKeyValueDef('Private', 'true')) = 'true');
|
||||||
|
end;
|
||||||
|
Paster_Menu.Add(Private_MenuItem);
|
||||||
|
|
||||||
|
Divider_MenuItem := TMenuItem.Create(Paster_Menu);
|
||||||
|
Divider_MenuItem.Caption := '-';
|
||||||
|
Paster_Menu.Add(Divider_MenuItem);
|
||||||
|
|
||||||
|
AltHost_Menu := TMenuItem.Create(Paster_Menu);
|
||||||
|
AltHost_Menu.Caption := 'Alternate Hosts';
|
||||||
|
Paster_Menu.Add(AltHost_Menu);
|
||||||
|
|
||||||
|
for I := 1 to 5 do
|
||||||
|
begin
|
||||||
|
AltHost_Menus[I] := TMenuItem.Create(AltHost_Menu);
|
||||||
|
AltHost_Menus[I].Caption := Settings.getKeyValueDef('Host' + IntToStr(I), 'Host ' + IntToStr(I));
|
||||||
|
AltHost_Menu.Add(AltHost_Menus[I]);
|
||||||
|
|
||||||
|
for K := 1 to 2 do
|
||||||
|
begin
|
||||||
|
AltHost_MenuItems[I][K] := TMenuItem.Create(AltHost_Menus[I]);
|
||||||
|
case K of
|
||||||
|
1: AltHost_MenuItems[I][1].Caption := 'Paste It!';
|
||||||
|
2: AltHost_MenuItems[I][2].Caption := 'Update Host';
|
||||||
|
end;
|
||||||
|
AltHost_MenuItems[I][K].OnClick := @OnClick;
|
||||||
|
if ((K = 1) and (AltHost_Menus[I].Caption = 'Host ' + IntToStr(I))) then
|
||||||
|
AltHost_MenuItems[I][1].Enabled := False;
|
||||||
|
AltHost_Menus[I].Add(AltHost_MenuItems[I][K]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user