Skip to content
Snippets Groups Projects
Select Git revision
  • bfd8e0b4a82302f640c1a602fcce0de0a2c2f8a7
  • main default protected
  • dev/grabowski
  • origin/main
  • hsh_1.22.4
  • 1.22.4
  • 1.22.3
  • 1.22.2
  • 1.22.1
  • 1.22
  • 1.21
  • 1.20.2
  • 1.20.1
  • 1.20.0
  • 1.19.1
  • 1.19
  • 1.18
  • 1.17.2
  • 1.17.1
  • 1.17
  • 1.16
  • 1.15
  • 1.14
  • 1.13
24 results

458-fix-for-embedded-video-resizing-problem.patch

Blame
    • Dennis Grabowski's avatar
      bfd8e0b4
      feat(patches): add first community patches · bfd8e0b4
      Dennis Grabowski authored
      Because the H5P plugin team seems to be very slow, we should adopt a few
      fixes/changes the community has implemented (and ideally even battle-
      tested).
      
      I devised the following concept based on a workflow I have seen in other
      repositories (e.g. ´https://github.com/Frogging-Family/linux-tkg´).
      
      We add pull requests or other fixes/changes as a single-patch file to a
      folder (here: ´./patches´). This way, we can track what each changes
      each fix needs, and are able to revert them easily, in case the official
      H5P repo contains a fix in the future for one of the issues.
      Because we could pull these changes from many different places, I would
      suggest we use the following scheme for persistence:
      
      ´
      ./patches/gitProviderURL/gitUserOrOrganisationName/gitRepoName/pullRequestID-description.patch
      ´
      
      So, for example, if we want to merge a patch from GitHub, from the user
      ´catalyst´ and the repo name ´moodle-mod_hvp´, it would look like this:
      
      ´
      ./patches/github.com/catalyst/moodle-mod_hvp/001-example-filename.patch
      ´
      
      This way, we can easily track where we got the patches from without the
      need to keep a list around.
      This allows us also to check the pull requests in future for
      discussions, i.e. are they still needed? did another
      user find a better way to fix it? is the pull request merged or did the
      H5P team reject it for some reason?
      
      Our own patches should go either into the base ´./patches´ folder, or if
      wished for, we create a ´HsH´ subfolder.
      
      This commit contains two of these patches:
      * Pull request #425: A fix for allowing H5P content in the mobile app
        without the need to allow frame embeddings globally
      * Pull request #458: A fix for an ongoing resizing issue with embedded
        videos. This one seems to only fix embedded videos, sadly, as we are
        still plagued from other resizing issues.
      
      Both fixes are pretty important IMHO to increase the h5p adoption of
      both user groups (students, teachers).
      bfd8e0b4
      History
      feat(patches): add first community patches
      Dennis Grabowski authored
      Because the H5P plugin team seems to be very slow, we should adopt a few
      fixes/changes the community has implemented (and ideally even battle-
      tested).
      
      I devised the following concept based on a workflow I have seen in other
      repositories (e.g. ´https://github.com/Frogging-Family/linux-tkg´).
      
      We add pull requests or other fixes/changes as a single-patch file to a
      folder (here: ´./patches´). This way, we can track what each changes
      each fix needs, and are able to revert them easily, in case the official
      H5P repo contains a fix in the future for one of the issues.
      Because we could pull these changes from many different places, I would
      suggest we use the following scheme for persistence:
      
      ´
      ./patches/gitProviderURL/gitUserOrOrganisationName/gitRepoName/pullRequestID-description.patch
      ´
      
      So, for example, if we want to merge a patch from GitHub, from the user
      ´catalyst´ and the repo name ´moodle-mod_hvp´, it would look like this:
      
      ´
      ./patches/github.com/catalyst/moodle-mod_hvp/001-example-filename.patch
      ´
      
      This way, we can easily track where we got the patches from without the
      need to keep a list around.
      This allows us also to check the pull requests in future for
      discussions, i.e. are they still needed? did another
      user find a better way to fix it? is the pull request merged or did the
      H5P team reject it for some reason?
      
      Our own patches should go either into the base ´./patches´ folder, or if
      wished for, we create a ´HsH´ subfolder.
      
      This commit contains two of these patches:
      * Pull request #425: A fix for allowing H5P content in the mobile app
        without the need to allow frame embeddings globally
      * Pull request #458: A fix for an ongoing resizing issue with embedded
        videos. This one seems to only fix embedded videos, sadly, as we are
        still plagued from other resizing issues.
      
      Both fixes are pretty important IMHO to increase the h5p adoption of
      both user groups (students, teachers).
    milter-template.py 4.87 KiB
    ## To roll your own milter, create a class that extends Milter.  
    #  See the pymilter project at http://bmsi.com/python/milter.html
    #  based on Sendmail's milter API 
    #  This code is open-source on the same terms as Python.
    
    ## Milter calls methods of your class at milter events.
    ## Return REJECT,TEMPFAIL,ACCEPT to short circuit processing for a message.
    ## You can also add/del recipients, replacebody, add/del headers, etc.
    
    from __future__ import print_function
    import Milter
    try:
      from StringIO import StringIO
    except:
      from io import StringIO
    import time
    import email
    import sys
    from socket import AF_INET, AF_INET6
    from Milter.utils import parse_addr
    if True:
      from multiprocessing import Process as Thread, Queue
    else:
      from threading import Thread
      from Queue import Queue
    
    logq = Queue(maxsize=4)
    
    class myMilter(Milter.Base):
    
      def __init__(self):  # A new instance with each new connection.
        self.id = Milter.uniqueID()  # Integer incremented with each call.
    
      # each connection runs in its own thread and has its own myMilter
      # instance.  Python code must be thread safe.  This is trivial if only stuff
      # in myMilter instances is referenced.
      @Milter.noreply
      def connect(self, IPname, family, hostaddr):
        # (self, 'ip068.subnet71.example.com', AF_INET, ('215.183.71.68', 4720) )
        # (self, 'ip6.mxout.example.com', AF_INET6,
        #	('3ffe:80e8:d8::1', 4720, 1, 0) )
        self.IP = hostaddr[0]
        self.port = hostaddr[1]
        if family == AF_INET6:
          self.flow = hostaddr[2]
          self.scope = hostaddr[3]
        else:
          self.flow = None
          self.scope = None
        self.IPname = IPname  # Name from a reverse IP lookup
        self.H = None
        self.fp = None
        self.receiver = self.getsymval('j')
        self.log("connect from %s at %s" % (IPname, hostaddr) )
        
        return Milter.CONTINUE
    
    
      ##  def hello(self,hostname):
      def hello(self, heloname):
        # (self, 'mailout17.dallas.texas.example.com')
        self.H = heloname
        self.log("HELO %s" % heloname)
        if heloname.find('.') < 0:	# illegal helo name
          # NOTE: example only - too many real braindead clients to reject on this
          self.setreply('550','5.7.1','Sheesh people!  Use a proper helo name!')
          return Milter.REJECT
          
        return Milter.CONTINUE
    
      ##  def envfrom(self,f,*str):
      def envfrom(self, mailfrom, *str):
        self.F = mailfrom
        self.R = []  # list of recipients
        self.fromparms = Milter.dictfromlist(str)	# ESMTP parms
        self.user = self.getsymval('{auth_authen}')	# authenticated user
        self.log("mail from:", mailfrom, *str)
        # NOTE: self.fp is only an *internal* copy of message data.  You
        # must use addheader, chgheader, replacebody to change the message
        # on the MTA.
        self.fp = StringIO()
        self.canon_from = '@'.join(parse_addr(mailfrom))
        self.fp.write('From %s %s\n' % (self.canon_from,time.ctime()))
        return Milter.CONTINUE
    
    
      ##  def envrcpt(self, to, *str):
      @Milter.noreply
      def envrcpt(self, to, *str):
        rcptinfo = to,Milter.dictfromlist(str)
        self.R.append(rcptinfo)
        
        return Milter.CONTINUE
    
    
      @Milter.noreply
      def header(self, name, hval):
        self.fp.write("%s: %s\n" % (name,hval))	# add header to buffer
        return Milter.CONTINUE
    
      @Milter.noreply
      def eoh(self):
        self.fp.write("\n")				# terminate headers
        return Milter.CONTINUE
    
      @Milter.noreply
      def body(self, chunk):
        self.fp.write(chunk)
        return Milter.CONTINUE
    
      def eom(self):
        self.fp.seek(0)
        msg = email.message_from_file(self.fp)
        # many milter functions can only be called from eom()
        # example of adding a Bcc:
        self.addrcpt('<%s>' % 'spy@example.com')
        return Milter.ACCEPT
    
      def close(self):
        # always called, even when abort is called.  Clean up
        # any external resources here.
        return Milter.CONTINUE
    
      def abort(self):
        # client disconnected prematurely
        return Milter.CONTINUE
    
      ## === Support Functions ===
    
      def log(self,*msg):
        logq.put((msg,self.id,time.time()))
    
    def background():
      while True:
        t = logq.get()
        if not t: break
        msg,id,ts = t
        print("%s [%d]" % (time.strftime('%Y%b%d %H:%M:%S',time.localtime(ts)),id),
            end=None)
        # 2005Oct13 02:34:11 [1] msg1 msg2 msg3 ...
        for i in msg: print(i,end=None)
        print()
        sys.stdout.flush()
    
    ## ===
        
    def main():
      bt = Thread(target=background)
      bt.start()
      socketname = "/home/stuart/pythonsock"
      timeout = 600
      # Register to have the Milter factory create instances of your class:
      Milter.factory = myMilter
      flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
      flags += Milter.ADDRCPT
      flags += Milter.DELRCPT
      Milter.set_flags(flags)       # tell Sendmail which features we use
      print("%s milter startup" % time.strftime('%Y%b%d %H:%M:%S'))
      sys.stdout.flush()
      Milter.runmilter("pythonfilter",socketname,timeout)
      logq.put(None)
      bt.join()
      print("%s bms milter shutdown" % time.strftime('%Y%b%d %H:%M:%S'))
    
    if __name__ == "__main__":
      main()