> On Jun 19, 2020, at 4:50 PM, sebb <seb...@gmail.com> wrote: > > On Sat, 20 Jun 2020 at 00:44, Craig Russell <apache....@gmail.com> wrote: >> >> I'm getting an undefined local variable error [1] in this function at the >> ASF::SVN.svn_ line >> >> def get_template(url) >> Dir.mktmpdir do |tmpdir| >> tmpdir.untaint >> >> ASF::SVN.svn_('checkout', [url, tmpdir], _, >> {depth: 'empty', user: $USER, password: $PASSWORD}) >> >> # Dir.chdir tmpdir do >> # IO.binwrite(name, @file.read) >> # ASF::SVN.svn_('add', name, _) >> >> # ASF::SVN.svn_('commit', name, _, {user: $USER, password: $PASSWORD}) >> # end >> end >> 'This is a sample template with Name: __ Date: __ Metadata: __' >> end >> >> I'm sure it's just a big misunderstanding but where does the _ come from? >> I'm looking at proxy.cgi line 184. > > From the _html do block, see line 273 for example
So that means that any svn activity must be in the context of the _html block? I was hoping to write some functions that would be called from different places because it's a bit distracting looking at svn code in the middle of an _html section... > > I've committed a fix. What was broken and what did you fix? Thanks, Craig > >> [Fri Jun 19 16:39:14.214049 2020] [cgi:error] [pid 16948] [client >> 127.0.0.1:64416] AH01215: /srv/whimsy/www/officers/coi.cgi:16:in `block in >> get_template': undefined local variable or method `_' for main:Object >> (NameError): /srv/whimsy/www/officers/coi.cgi >> [Fri Jun 19 16:39:14.214500 2020] [cgi:error] [pid 16948] [client >> 127.0.0.1:64416] AH01215: \tfrom >> /usr/local/Cellar/ruby/2.7.1_2/lib/ruby/2.7.0/tmpdir.rb:89:in `mktmpdir': >> /srv/whimsy/www/officers/coi.cgi >> [Fri Jun 19 16:39:14.214584 2020] [cgi:error] [pid 16948] [client >> 127.0.0.1:64416] AH01215: \tfrom /srv/whimsy/www/officers/coi.cgi:13:in >> `get_template': /srv/whimsy/www/officers/coi.cgi >> >>> On Jun 19, 2020, at 2:38 PM, sebb <seb...@gmail.com> wrote: >>> >>> On Fri, 19 Jun 2020 at 19:50, Sam Ruby <ru...@intertwingly.net> wrote: >>>> >>>> On Fri, Jun 19, 2020 at 2:40 PM Craig Russell <apache....@gmail.com> wrote: >>>>> >>>>> Big picture: I will read current-year/template.txt, substitute the name >>>>> and date from the $USER information, and present that to the user in a >>>>> scroll window with a button (Sign) at the bottom. >>>>> >>>>> The server will then write that data to current-year/availid.txt and send >>>>> a message to avai...@apache.org, cc:secretary. >>>>> >>>>> Here's a start at reading the file, using repository.yml and document.rb: >>>>> coi_url = ASF::SVN.svnurl('conflict-of-interest-current-year') >>>>> current_timestamp = DateTime.now.strftime "%Y-%m-%d %H:%M:%S" >>>>> outputfile = File.join(coi_url, 'template.txt').untaint >>>>> template = File.read(outputfile) >>>>> affirmed = template.gsub("Name: __", "Name: _#{user.cn}_").gsub("Date: >>>>> __", "Date: _#{current_timestamp}_") >>>>> >>>>> Then, in the form method for POST, I need to write the data to the (new) >>>>> file current-year/availid.txt. I have not found any code or examples how >>>>> to do that. >>>> >>>> Here is a complete example: >>>> >>>> https://github.com/apache/whimsy/blob/master/www/treasurer/bill-upload.cgi#L82 >>>> >>>> Important points: >>>> >>>> 1) be sure to validate your inputs as this could be a security hole. >>>> 2) Create a temporary directory, do an empty svn checkout into it, >>>> write contents of the file, and do an svn add and svn commit. >>> >>> You should be able to use ASF::SVN.update() to do that. >>> >>>>> Thanks >>>>> Craig >>>>> >>>>> Craig L Russell >>>>> c...@apache.org >>>> >>>> - Sam Ruby >> >> Craig L Russell >> c...@apache.org >> Craig L Russell c...@apache.org