Skip to content

Commit e59a14c

Browse files
committed
Corrected SWAG license info added to imported snippets
1 parent 6c1d42f commit e59a14c

File tree

1 file changed

+55
-27
lines changed

1 file changed

+55
-27
lines changed

Src/SWAG.UImporter.pas

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -158,47 +158,75 @@ destructor TSWAGImporter.Destroy;
158158
end;
159159

160160
function TSWAGImporter.ExtraBoilerplate: IActiveText;
161-
resourcestring
162-
sStatementPrefix = 'This snippet was imported from a packet in the ';
163-
sStatementLinkText = 'SWAG Pascal Archive';
164-
sStatementPostfix = '. ';
165-
sLicense = 'The code packets in the archive pages are generally freeware or '
166-
+ 'public domain as defined by any accompanying comments and copyright '
167-
+ 'statements. Contact the author if in doubt.';
168-
// TODO: Check license wording against SWAG docs
169-
// URL of web page referenced from links in boilerplate
170-
SWAGDBURI = 'https://github.com/delphidabbler/swag';
171-
var
172-
// Active text attributes for link included in boilerplate
173-
SWAGDBURIAttr: IActiveTextAttrs;
174-
begin
175-
if not Assigned(fExtraBoilerplate) then
161+
162+
procedure AddText(const Text: string);
176163
begin
177-
SWAGDBURIAttr := TActiveTextFactory.CreateAttrs(
178-
TActiveTextAttr.Create('href', SWAGDBURI)
179-
);
180-
fExtraBoilerplate := TActiveTextFactory.CreateActiveText;
181164
fExtraBoilerplate.AddElem(
182-
TActiveTextFactory.CreateActionElem(ekPara, fsOpen)
165+
TActiveTextFactory.CreateTextElem(Text)
183166
);
184-
fExtraBoilerplate.AddElem(
185-
TActiveTextFactory.CreateTextElem(sStatementPrefix)
167+
end;
168+
169+
procedure AddLink(const Text, URI: string);
170+
var
171+
HRefAttr: IActiveTextAttrs;
172+
begin
173+
HRefAttr := TActiveTextFactory.CreateAttrs(
174+
TActiveTextAttr.Create('href', URI)
186175
);
187176
fExtraBoilerplate.AddElem(
188-
TActiveTextFactory.CreateActionElem(ekLink, SWAGDBURIAttr, fsOpen)
177+
TActiveTextFactory.CreateActionElem(ekLink, HRefAttr, fsOpen)
189178
);
179+
AddText(Text);
190180
fExtraBoilerplate.AddElem(
191-
TActiveTextFactory.CreateTextElem(sStatementLinkText)
181+
TActiveTextFactory.CreateActionElem(ekLink, HRefAttr, fsClose)
192182
);
183+
end;
184+
185+
resourcestring
186+
sStatementPrefix = 'This snippet was imported from a packet in the ';
187+
sStatementLinkText = 'SWAG Pascal Code Collection';
188+
sStatementPostfix = '. ';
189+
sLicense1 = 'Unless the snippet states otherwise it is deemed to be licensed '
190+
+ 'under either the ';
191+
sLGPLLinkText = 'GNU Lesser General Public License v2.1';
192+
sLicense2 = ' (source code) or the ';
193+
sFDLLinkText = 'GNU Free Documentation License v1.2';
194+
sLicense3 = ' (other documents), as appropriate. For further information '
195+
+ 'please see the ';
196+
sSWAGLicenseLinkText = 'SWAG License document';
197+
sLicense4 = '.';
198+
const
199+
// URLs of web pages referenced from links in boilerplate
200+
SWAGProjectURL = 'https://github.com/delphidabbler/swag';
201+
SWAGLicenseURL = SWAGProjectURL + '/blob/master/LICENSE.md';
202+
LGPLLicenseURL = 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html';
203+
FDPLicenseURL = 'https://www.gnu.org/licenses/old-licenses/fdl-1.2.html';
204+
205+
begin
206+
if not Assigned(fExtraBoilerplate) then
207+
begin
208+
fExtraBoilerplate := TActiveTextFactory.CreateActiveText;
209+
// Intro para
193210
fExtraBoilerplate.AddElem(
194-
TActiveTextFactory.CreateActionElem(ekLink, SWAGDBURIAttr, fsClose)
211+
TActiveTextFactory.CreateActionElem(ekPara, fsOpen)
195212
);
213+
AddText(sStatementPrefix);
214+
AddLink(sStatementLinkText, SWAGProjectURL);
215+
AddText(sStatementPostfix);
196216
fExtraBoilerplate.AddElem(
197-
TActiveTextFactory.CreateTextElem(sStatementPostfix)
217+
TActiveTextFactory.CreateActionElem(ekPara, fsClose)
198218
);
219+
// License para
199220
fExtraBoilerplate.AddElem(
200-
TActiveTextFactory.CreateTextElem(sLicense)
221+
TActiveTextFactory.CreateActionElem(ekPara, fsOpen)
201222
);
223+
AddText(sLicense1);
224+
AddLink(sLGPLLinkText, LGPLLicenseURL);
225+
AddText(sLicense2);
226+
AddLink(sFDLLinkText, FDPLicenseURL);
227+
AddText(sLicense3);
228+
AddLink(sSWAGLicenseLinkText, SWAGLicenseURL);
229+
AddText(sLicense4);
202230
fExtraBoilerplate.AddElem(
203231
TActiveTextFactory.CreateActionElem(ekPara, fsClose)
204232
);

0 commit comments

Comments
 (0)