summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/inline.pm
blob: 551c38a65157c64aef2fd6d8629eb9c18eeb2ee6 (plain)
  1. #!/usr/bin/perl
  2. # Page inlining and blogging.
  3. package IkiWiki::Plugin::inline;
  4. use warnings;
  5. use strict;
  6. use Encode;
  7. use IkiWiki 3.00;
  8. use URI;
  9. my %knownfeeds;
  10. my %page_numfeeds;
  11. my @inline;
  12. my $nested=0;
  13. sub import {
  14. hook(type => "getopt", id => "inline", call => \&getopt);
  15. hook(type => "getsetup", id => "inline", call => \&getsetup);
  16. hook(type => "checkconfig", id => "inline", call => \&checkconfig);
  17. hook(type => "sessioncgi", id => "inline", call => \&sessioncgi);
  18. hook(type => "preprocess", id => "inline",
  19. call => \&IkiWiki::preprocess_inline);
  20. hook(type => "pagetemplate", id => "inline",
  21. call => \&IkiWiki::pagetemplate_inline);
  22. hook(type => "format", id => "inline", call => \&format, first => 1);
  23. # Hook to change to do pinging since it's called late.
  24. # This ensures each page only pings once and prevents slow
  25. # pings interrupting page builds.
  26. hook(type => "change", id => "inline", call => \&IkiWiki::pingurl);
  27. }
  28. sub getopt () {
  29. eval q{use Getopt::Long};
  30. error($@) if $@;
  31. Getopt::Long::Configure('pass_through');
  32. GetOptions(
  33. "rss!" => \$config{rss},
  34. "atom!" => \$config{atom},
  35. "allowrss!" => \$config{allowrss},
  36. "allowatom!" => \$config{allowatom},
  37. "pingurl=s" => sub {
  38. push @{$config{pingurl}}, $_[1];
  39. },
  40. );
  41. }
  42. sub getsetup () {
  43. return
  44. plugin => {
  45. safe => 1,
  46. rebuild => undef,
  47. },
  48. rss => {
  49. type => "boolean",
  50. example => 0,
  51. description => "enable rss feeds by default?",
  52. safe => 1,
  53. rebuild => 1,
  54. },
  55. atom => {
  56. type => "boolean",
  57. example => 0,
  58. description => "enable atom feeds by default?",
  59. safe => 1,
  60. rebuild => 1,
  61. },
  62. allowrss => {
  63. type => "boolean",
  64. example => 0,
  65. description => "allow rss feeds to be used?",
  66. safe => 1,
  67. rebuild => 1,
  68. },
  69. allowatom => {
  70. type => "boolean",
  71. example => 0,
  72. description => "allow atom feeds to be used?",
  73. safe => 1,
  74. rebuild => 1,
  75. },
  76. pingurl => {
  77. type => "string",
  78. example => "http://rpc.technorati.com/rpc/ping",
  79. description => "urls to ping (using XML-RPC) on feed update",
  80. safe => 1,
  81. rebuild => 0,
  82. },
  83. }
  84. sub checkconfig () {
  85. if (($config{rss} || $config{atom}) && ! length $config{url}) {
  86. error(gettext("Must specify url to wiki with --url when using --rss or --atom"));
  87. }
  88. if ($config{rss}) {
  89. push @{$config{wiki_file_prune_regexps}}, qr/\.rss$/;
  90. }
  91. if ($config{atom}) {
  92. push @{$config{wiki_file_prune_regexps}}, qr/\.atom$/;
  93. }
  94. if (! exists $config{pingurl}) {
  95. $config{pingurl}=[];
  96. }
  97. }
  98. sub format (@) {
  99. my %params=@_;
  100. # Fill in the inline content generated earlier. This is actually an
  101. # optimisation.
  102. $params{content}=~s{<div class="inline" id="([^"]+)"></div>}{
  103. delete @inline[$1,]
  104. }eg;
  105. return $params{content};
  106. }
  107. sub sessioncgi ($$) {
  108. my $q=shift;
  109. my $session=shift;
  110. if ($q->param('do') eq 'blog') {
  111. my $page=titlepage(decode_utf8($q->param('title')));
  112. $page=~s/(\/)/"__".ord($1)."__"/eg; # don't create subdirs
  113. # if the page already exists, munge it to be unique
  114. my $from=$q->param('from');
  115. my $add="";
  116. while (exists $IkiWiki::pagecase{lc($from."/".$page.$add)}) {
  117. $add=1 unless length $add;
  118. $add++;
  119. }
  120. $q->param('page', $page.$add);
  121. # now go create the page
  122. $q->param('do', 'create');
  123. # make sure the editpage plugin in loaded
  124. if (IkiWiki->can("cgi_editpage")) {
  125. IkiWiki::cgi_editpage($q, $session);
  126. }
  127. else {
  128. error(gettext("page editing not allowed"));
  129. }
  130. exit;
  131. }
  132. }
  133. # Back to ikiwiki namespace for the rest, this code is very much
  134. # internal to ikiwiki even though it's separated into a plugin.
  135. package IkiWiki;
  136. my %toping;
  137. my %feedlinks;
  138. sub preprocess_inline (@) {
  139. my %params=@_;
  140. if (! exists $params{pages}) {
  141. error gettext("missing pages parameter");
  142. }
  143. my $raw=yesno($params{raw});
  144. my $archive=yesno($params{archive});
  145. my $rss=(($config{rss} || $config{allowrss}) && exists $params{rss}) ? yesno($params{rss}) : $config{rss};
  146. my $atom=(($config{atom} || $config{allowatom}) && exists $params{atom}) ? yesno($params{atom}) : $config{atom};
  147. my $quick=exists $params{quick} ? yesno($params{quick}) : 0;
  148. my $feeds=exists $params{feeds} ? yesno($params{feeds}) : !$quick;
  149. my $emptyfeeds=exists $params{emptyfeeds} ? yesno($params{emptyfeeds}) : 1;
  150. my $feedonly=yesno($params{feedonly});
  151. if (! exists $params{show} && ! $archive) {
  152. $params{show}=10;
  153. }
  154. if (! exists $params{feedshow} && exists $params{show}) {
  155. $params{feedshow}=$params{show};
  156. }
  157. my $desc;
  158. if (exists $params{description}) {
  159. $desc = $params{description}
  160. }
  161. else {
  162. $desc = $config{wikiname};
  163. }
  164. my $actions=yesno($params{actions});
  165. if (exists $params{template}) {
  166. $params{template}=~s/[^-_a-zA-Z0-9]+//g;
  167. }
  168. else {
  169. $params{template} = $archive ? "archivepage" : "inlinepage";
  170. }
  171. my @list;
  172. my $lastmatch;
  173. foreach my $page (keys %pagesources) {
  174. next if $page eq $params{page};
  175. $lastmatch=pagespec_match($page, $params{pages}, location => $params{page});
  176. if ($lastmatch) {
  177. push @list, $page;
  178. }
  179. }
  180. if (! @list && defined $lastmatch &&
  181. $lastmatch->isa("IkiWiki::ErrorReason")) {
  182. error(sprintf(gettext("cannot match pages: %s"), $lastmatch));
  183. }
  184. if (exists $params{sort} && $params{sort} eq 'title') {
  185. @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
  186. }
  187. elsif (exists $params{sort} && $params{sort} eq 'title_natural') {
  188. eval q{use Sort::Naturally};
  189. if ($@) {
  190. error(gettext("Sort::Naturally needed for title_natural sort"));
  191. }
  192. @list=sort { Sort::Naturally::ncmp(pagetitle(basename($a)), pagetitle(basename($b))) } @list;
  193. }
  194. elsif (exists $params{sort} && $params{sort} eq 'mtime') {
  195. @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
  196. }
  197. elsif (! exists $params{sort} || $params{sort} eq 'age') {
  198. @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
  199. }
  200. else {
  201. error sprintf(gettext("unknown sort type %s"), $params{sort});
  202. }
  203. if (yesno($params{reverse})) {
  204. @list=reverse(@list);
  205. }
  206. if (exists $params{skip}) {
  207. @list=@list[$params{skip} .. scalar @list - 1];
  208. }
  209. my @feedlist;
  210. if ($feeds) {
  211. if (exists $params{feedshow} &&
  212. $params{feedshow} && @list > $params{feedshow}) {
  213. @feedlist=@list[0..$params{feedshow} - 1];
  214. }
  215. else {
  216. @feedlist=@list;
  217. }
  218. }
  219. if ($params{show} && @list > $params{show}) {
  220. @list=@list[0..$params{show} - 1];
  221. }
  222. add_depends($params{page}, $params{pages});
  223. # Explicitly add all currently displayed pages as dependencies, so
  224. # that if they are removed or otherwise changed, the inline will be
  225. # sure to be updated.
  226. add_depends($params{page}, join(" or ", $#list >= $#feedlist ? @list : @feedlist));
  227. if ($feeds && exists $params{feedpages}) {
  228. @feedlist=grep { pagespec_match($_, $params{feedpages}, location => $params{page}) } @feedlist;
  229. }
  230. my ($feedbase, $feednum);
  231. if ($feeds) {
  232. # Ensure that multiple feeds on a page go to unique files.
  233. # Feedfile can lead to conflicts if usedirs is not enabled,
  234. # so avoid supporting it in that case.
  235. delete $params{feedfile} if ! $config{usedirs};
  236. # Tight limits on legal feedfiles, to avoid security issues
  237. # and conflicts.
  238. if (defined $params{feedfile}) {
  239. if ($params{feedfile} =~ /\// ||
  240. $params{feedfile} !~ /$config{wiki_file_regexp}/) {
  241. error("illegal feedfile");
  242. }
  243. $params{feedfile}=possibly_foolish_untaint($params{feedfile});
  244. }
  245. $feedbase=targetpage($params{destpage}, "", $params{feedfile});
  246. my $feedid=join("\0", $feedbase, map { $_."\0".$params{$_} } sort keys %params);
  247. if (exists $knownfeeds{$feedid}) {
  248. $feednum=$knownfeeds{$feedid};
  249. }
  250. else {
  251. if (exists $page_numfeeds{$params{destpage}}{$feedbase}) {
  252. if ($feeds) {
  253. $feednum=$knownfeeds{$feedid}=++$page_numfeeds{$params{destpage}}{$feedbase};
  254. }
  255. }
  256. else {
  257. $feednum=$knownfeeds{$feedid}="";
  258. if ($feeds) {
  259. $page_numfeeds{$params{destpage}}{$feedbase}=1;
  260. }
  261. }
  262. }
  263. }
  264. my $rssurl=abs2rel($feedbase."rss".$feednum, dirname(htmlpage($params{destpage}))) if $feeds && $rss;
  265. my $atomurl=abs2rel($feedbase."atom".$feednum, dirname(htmlpage($params{destpage}))) if $feeds && $atom;
  266. my $ret="";
  267. if (length $config{cgiurl} && ! $params{preview} && (exists $params{rootpage} ||
  268. (exists $params{postform} && yesno($params{postform}))) &&
  269. IkiWiki->can("cgi_editpage")) {
  270. # Add a blog post form, with feed buttons.
  271. my $formtemplate=template("blogpost.tmpl", blind_cache => 1);
  272. $formtemplate->param(cgiurl => $config{cgiurl});
  273. my $rootpage;
  274. if (exists $params{rootpage}) {
  275. $rootpage=bestlink($params{page}, $params{rootpage});
  276. if (!length $rootpage) {
  277. $rootpage=$params{rootpage};
  278. }
  279. }
  280. else {
  281. $rootpage=$params{page};
  282. }
  283. $formtemplate->param(rootpage => $rootpage);
  284. $formtemplate->param(rssurl => $rssurl) if $feeds && $rss;
  285. $formtemplate->param(atomurl => $atomurl) if $feeds && $atom;
  286. if (exists $params{postformtext}) {
  287. $formtemplate->param(postformtext =>
  288. $params{postformtext});
  289. }
  290. else {
  291. $formtemplate->param(postformtext =>
  292. gettext("Add a new post titled:"));
  293. }
  294. $ret.=$formtemplate->output;
  295. # The post form includes the feed buttons, so
  296. # emptyfeeds cannot be hidden.
  297. $emptyfeeds=1;
  298. }
  299. elsif ($feeds && !$params{preview} && ($emptyfeeds || @feedlist)) {
  300. # Add feed buttons.
  301. my $linktemplate=template("feedlink.tmpl", blind_cache => 1);
  302. $linktemplate->param(rssurl => $rssurl) if $rss;
  303. $linktemplate->param(atomurl => $atomurl) if $atom;
  304. $ret.=$linktemplate->output;
  305. }
  306. if (! $feedonly) {
  307. require HTML::Template;
  308. my @params=IkiWiki::template_params($params{template}.".tmpl", blind_cache => 1);
  309. if (! @params) {
  310. error sprintf(gettext("nonexistant template %s"), $params{template});
  311. }
  312. my $template=HTML::Template->new(@params) unless $raw;
  313. foreach my $page (@list) {
  314. my $file = $pagesources{$page};
  315. my $type = pagetype($file);
  316. if (! $raw || ($raw && ! defined $type)) {
  317. unless ($archive && $quick) {
  318. # Get the content before populating the
  319. # template, since getting the content uses
  320. # the same template if inlines are nested.
  321. my $content=get_inline_content($page, $params{destpage});
  322. $template->param(content => $content);
  323. }
  324. $template->param(pageurl => urlto(bestlink($params{page}, $page), $params{destpage}));
  325. $template->param(inlinepage => $page);
  326. $template->param(title => pagetitle(basename($page)));
  327. $template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}));
  328. $template->param(mtime => displaytime($pagemtime{$page}, $params{timeformat}));
  329. $template->param(first => 1) if $page eq $list[0];
  330. $template->param(last => 1) if $page eq $list[$#list];
  331. if ($actions) {
  332. my $file = $pagesources{$page};
  333. my $type = pagetype($file);
  334. if ($config{discussion}) {
  335. my $discussionlink=gettext("discussion");
  336. if ($page !~ /.*\/\Q$discussionlink\E$/ &&
  337. (length $config{cgiurl} ||
  338. exists $links{$page."/".$discussionlink})) {
  339. $template->param(have_actions => 1);
  340. $template->param(discussionlink =>
  341. htmllink($page,
  342. $params{destpage},
  343. gettext("Discussion"),
  344. noimageinline => 1,
  345. forcesubpage => 1));
  346. }
  347. }
  348. if (length $config{cgiurl} && defined $type) {
  349. $template->param(have_actions => 1);
  350. $template->param(editurl => cgiurl(do => "edit", page => $page));
  351. }
  352. }
  353. run_hooks(pagetemplate => sub {
  354. shift->(page => $page, destpage => $params{destpage},
  355. template => $template,);
  356. });
  357. $ret.=$template->output;
  358. $template->clear_params;
  359. }
  360. else {
  361. if (defined $type) {
  362. $ret.="\n".
  363. linkify($page, $params{destpage},
  364. preprocess($page, $params{destpage},
  365. filter($page, $params{destpage},
  366. readfile(srcfile($file)))));
  367. }
  368. }
  369. }
  370. }
  371. if ($feeds && ($emptyfeeds || @feedlist)) {
  372. if ($rss) {
  373. my $rssp=$feedbase."rss".$feednum;
  374. will_render($params{destpage}, $rssp);
  375. if (! $params{preview}) {
  376. writefile($rssp, $config{destdir},
  377. genfeed("rss",
  378. $config{url}."/".$rssp, $desc, $params{guid}, $params{destpage}, @feedlist));
  379. $toping{$params{destpage}}=1 unless $config{rebuild};
  380. $feedlinks{$params{destpage}}.=qq{<link rel="alternate" type="application/rss+xml" title="$desc (RSS)" href="$rssurl" />};
  381. }
  382. }
  383. if ($atom) {
  384. my $atomp=$feedbase."atom".$feednum;
  385. will_render($params{destpage}, $atomp);
  386. if (! $params{preview}) {
  387. writefile($atomp, $config{destdir},
  388. genfeed("atom", $config{url}."/".$atomp, $desc, $params{guid}, $params{destpage}, @feedlist));
  389. $toping{$params{destpage}}=1 unless $config{rebuild};
  390. $feedlinks{$params{destpage}}.=qq{<link rel="alternate" type="application/atom+xml" title="$desc (Atom)" href="$atomurl" />};
  391. }
  392. }
  393. }
  394. return $ret if $raw || $nested;
  395. push @inline, $ret;
  396. return "<div class=\"inline\" id=\"$#inline\"></div>\n\n";
  397. }
  398. sub pagetemplate_inline (@) {
  399. my %params=@_;
  400. my $page=$params{page};
  401. my $template=$params{template};
  402. $template->param(feedlinks => $feedlinks{$page})
  403. if exists $feedlinks{$page} && $template->query(name => "feedlinks");
  404. }
  405. sub get_inline_content ($$) {
  406. my $page=shift;
  407. my $destpage=shift;
  408. my $file=$pagesources{$page};
  409. my $type=pagetype($file);
  410. if (defined $type) {
  411. $nested++;
  412. my $ret=htmlize($page, $destpage, $type,
  413. linkify($page, $destpage,
  414. preprocess($page, $destpage,
  415. filter($page, $destpage,
  416. readfile(srcfile($file))))));
  417. $nested--;
  418. return $ret;
  419. }
  420. else {
  421. return "";
  422. }
  423. }
  424. sub date_822 ($) {
  425. my $time=shift;
  426. my $lc_time=POSIX::setlocale(&POSIX::LC_TIME);
  427. POSIX::setlocale(&POSIX::LC_TIME, "C");
  428. my $ret=POSIX::strftime("%a, %d %b %Y %H:%M:%S %z", localtime($time));
  429. POSIX::setlocale(&POSIX::LC_TIME, $lc_time);
  430. return $ret;
  431. }
  432. sub date_3339 ($) {
  433. my $time=shift;
  434. my $lc_time=POSIX::setlocale(&POSIX::LC_TIME);
  435. POSIX::setlocale(&POSIX::LC_TIME, "C");
  436. my $ret=POSIX::strftime("%Y-%m-%dT%H:%M:%SZ", gmtime($time));
  437. POSIX::setlocale(&POSIX::LC_TIME, $lc_time);
  438. return $ret;
  439. }
  440. sub absolute_urls ($$) {
  441. # sucky sub because rss sucks
  442. my $content=shift;
  443. my $baseurl=shift;
  444. my $url=$baseurl;
  445. $url=~s/[^\/]+$//;
  446. # what is the non path part of the url?
  447. my $top_uri = URI->new($url);
  448. $top_uri->path_query(""); # reset the path
  449. my $urltop = $top_uri->as_string;
  450. $content=~s/(<a(?:\s+(?:class|id)\s*="?\w+"?)?)\s+href=\s*"(#[^"]+)"/$1 href="$baseurl$2"/mig;
  451. # relative to another wiki page
  452. $content=~s/(<a(?:\s+(?:class|id)\s*="?\w+"?)?)\s+href=\s*"(?!\w+:)([^\/][^"]*)"/$1 href="$url$2"/mig;
  453. $content=~s/(<img(?:\s+(?:class|id|width|height)\s*="?\w+"?)*)\s+src=\s*"(?!\w+:)([^\/][^"]*)"/$1 src="$url$2"/mig;
  454. # relative to the top of the site
  455. $content=~s/(<a(?:\s+(?:class|id)\s*="?\w+"?)?)\s+href=\s*"(?!\w+:)(\/[^"]*)"/$1 href="$urltop$2"/mig;
  456. $content=~s/(<img(?:\s+(?:class|id|width|height)\s*="?\w+"?)*)\s+src=\s*"(?!\w+:)(\/[^"]*)"/$1 src="$urltop$2"/mig;
  457. return $content;
  458. }
  459. sub genfeed ($$$$$@) {
  460. my $feedtype=shift;
  461. my $feedurl=shift;
  462. my $feeddesc=shift;
  463. my $guid=shift;
  464. my $page=shift;
  465. my @pages=@_;
  466. my $url=URI->new(encode_utf8(urlto($page,"",1)));
  467. my $itemtemplate=template($feedtype."item.tmpl", blind_cache => 1);
  468. my $content="";
  469. my $lasttime = 0;
  470. foreach my $p (@pages) {
  471. my $u=URI->new(encode_utf8(urlto($p, "", 1)));
  472. my $pcontent = absolute_urls(get_inline_content($p, $page), $url);
  473. $itemtemplate->param(
  474. title => pagetitle(basename($p)),
  475. url => $u,
  476. permalink => $u,
  477. cdate_822 => date_822($pagectime{$p}),
  478. mdate_822 => date_822($pagemtime{$p}),
  479. cdate_3339 => date_3339($pagectime{$p}),
  480. mdate_3339 => date_3339($pagemtime{$p}),
  481. );
  482. if (exists $pagestate{$p}) {
  483. if (exists $pagestate{$p}{meta}{guid}) {
  484. $itemtemplate->param(guid => $pagestate{$p}{meta}{guid});
  485. }
  486. if (exists $pagestate{$p}{meta}{updated}) {
  487. $itemtemplate->param(mdate_822 => date_822($pagestate{$p}{meta}{updated}));
  488. $itemtemplate->param(mdate_3339 => date_3339($pagestate{$p}{meta}{updated}));
  489. }
  490. }
  491. if ($itemtemplate->query(name => "enclosure")) {
  492. my $file=$pagesources{$p};
  493. my $type=pagetype($file);
  494. if (defined $type) {
  495. $itemtemplate->param(content => $pcontent);
  496. }
  497. else {
  498. my $size=(srcfile_stat($file))[8];
  499. my $mime="unknown";
  500. eval q{use File::MimeInfo};
  501. if (! $@) {
  502. $mime = mimetype($file);
  503. }
  504. $itemtemplate->param(
  505. enclosure => $u,
  506. type => $mime,
  507. length => $size,
  508. );
  509. }
  510. }
  511. else {
  512. $itemtemplate->param(content => $pcontent);
  513. }
  514. run_hooks(pagetemplate => sub {
  515. shift->(page => $p, destpage => $page,
  516. template => $itemtemplate);
  517. });
  518. $content.=$itemtemplate->output;
  519. $itemtemplate->clear_params;
  520. $lasttime = $pagemtime{$p} if $pagemtime{$p} > $lasttime;
  521. }
  522. my $template=template($feedtype."page.tmpl", blind_cache => 1);
  523. $template->param(
  524. title => $page ne "index" ? pagetitle($page) : $config{wikiname},
  525. wikiname => $config{wikiname},
  526. pageurl => $url,
  527. content => $content,
  528. feeddesc => $feeddesc,
  529. guid => $guid,
  530. feeddate => date_3339($lasttime),
  531. feedurl => $feedurl,
  532. version => $IkiWiki::version,
  533. );
  534. run_hooks(pagetemplate => sub {
  535. shift->(page => $page, destpage => $page,
  536. template => $template);
  537. });
  538. return $template->output;
  539. }
  540. sub pingurl (@) {
  541. return unless @{$config{pingurl}} && %toping;
  542. eval q{require RPC::XML::Client};
  543. if ($@) {
  544. debug(gettext("RPC::XML::Client not found, not pinging"));
  545. return;
  546. }
  547. # daemonize here so slow pings don't slow down wiki updates
  548. defined(my $pid = fork) or error("Can't fork: $!");
  549. return if $pid;
  550. chdir '/';
  551. POSIX::setsid() or error("Can't start a new session: $!");
  552. open STDIN, '/dev/null';
  553. open STDOUT, '>/dev/null';
  554. open STDERR, '>&STDOUT' or error("Can't dup stdout: $!");
  555. # Don't need to keep a lock on the wiki as a daemon.
  556. IkiWiki::unlockwiki();
  557. foreach my $page (keys %toping) {
  558. my $title=pagetitle(basename($page), 0);
  559. my $url=urlto($page, "", 1);
  560. foreach my $pingurl (@{$config{pingurl}}) {
  561. debug("Pinging $pingurl for $page");
  562. eval {
  563. my $client = RPC::XML::Client->new($pingurl);
  564. my $req = RPC::XML::request->new('weblogUpdates.ping',
  565. $title, $url);
  566. my $res = $client->send_request($req);
  567. if (! ref $res) {
  568. error("Did not receive response to ping");
  569. }
  570. my $r=$res->value;
  571. if (! exists $r->{flerror} || $r->{flerror}) {
  572. error("Ping rejected: ".(exists $r->{message} ? $r->{message} : "[unknown reason]"));
  573. }
  574. };
  575. if ($@) {
  576. error "Ping failed: $@";
  577. }
  578. }
  579. }
  580. exit 0; # daemon done
  581. }
  582. 1